未验证 提交 9392fd2d 编写于 作者: O openharmony_ci 提交者: Gitee

!7461 test:add flex_Wrap_NoWrap xts_acts testcase part2

Merge pull request !7461 from 李伟明/flex_nowrap_1
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_FlexMarPad_TextMarPad{
@State firstTextPadding: number = 0;
@State secondTextPadding: number = 0;
@State thirdTextPadding: number = 0;
@State firstTextMargin: number = 0;
@State secondTextMargin: number = 0;
@State thirdTextMargin: number = 0;
@State flexMargin: number = 0;
@State flexPadding: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_FlexMarPad_TextMarPad onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'firstTextPadding') {
this.firstTextPadding = message.value;
}
if (message.name == 'secondTextPadding') {
this.secondTextPadding = message.value;
}
if (message.name == 'thirdTextPadding') {
this.thirdTextPadding = message.value;
}
if (message.name == 'firstTextMargin') {
this.firstTextMargin = message.value;
}
if (message.name == 'secondTextMargin') {
this.secondTextMargin = message.value;
}
if (message.name == 'thirdTextMargin') {
this.thirdTextMargin = message.value;
}
if (message.name == 'flexMargin') {
this.flexMargin = message.value;
}
if (message.name == 'flexPadding') {
this.flexPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Flex({wrap:FlexWrap.NoWrap}){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3).margin(this.firstTextMargin)
.padding(this.firstTextPadding).key('NoWrap_FlexMarPad_TextPad1');
Text('2').width(150).height(150).backgroundColor(0xD2B48C).margin(this.secondTextMargin)
.padding(this.secondTextPadding).key('NoWrap_FlexMarPad_TextPad2');
Text('3').width(150).height(200).backgroundColor(0xF5DEB3).margin(this.thirdTextMargin)
.padding(this.thirdTextPadding).key('NoWrap_FlexMarPad_TextPad3');
}
.width(500)
.height(200)
.margin(this.flexMargin)
.padding(this.flexPadding)
.backgroundColor(0xAFEEEE)
.key('FlexNoWrap_FlexMarPad_TextMarPad_Container01')
}
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('100%')
.key('Column_Container01')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_FlexMar_TextMarPad{
@State firstTextPadding: number = 0;
@State secondTextPadding: number = 0;
@State thirdTextPadding: number = 0;
@State firstTextMargin: number = 0;
@State secondTextMargin: number = 0;
@State thirdTextMargin: number = 0;
@State flexMargin: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('FlexAlignContent_SpaceAround_01 onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'firstTextPadding') {
this.firstTextPadding = message.value;
}
if (message.name == 'secondTextPadding') {
this.secondTextPadding = message.value;
}
if (message.name == 'thirdTextPadding') {
this.thirdTextPadding = message.value;
}
if (message.name == 'firstTextMargin') {
this.firstTextMargin = message.value;
}
if (message.name == 'secondTextMargin') {
this.secondTextMargin = message.value;
}
if (message.name == 'thirdTextMargin') {
this.thirdTextMargin = message.value;
}
if (message.name == 'flexMargin') {
this.flexMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Flex({wrap:FlexWrap.NoWrap}){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3).margin(this.firstTextMargin)
.padding(this.firstTextPadding).key('NoWrap_FlexMar_TextPad1');
Text('2').width(150).height(150).backgroundColor(0xD2B48C).margin(this.secondTextMargin)
.padding(this.secondTextPadding).key('NoWrap_FlexMar_TextPad2');
Text('3').width(150).height(200).backgroundColor(0xF5DEB3).margin(this.thirdTextMargin)
.padding(this.thirdTextPadding).key('NoWrap_FlexMar_TextPad3');
}
.width(500)
.height(200)
.margin(this.flexMargin)
.backgroundColor(0xAFEEEE)
.key('FlexMar_TextMarPad_Container01')
}
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('100%')
.key('Column_FlexMar_TextMarPad_Container01')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_FlexPad_TextMarPad{
@State firstTextPadding: number = 0;
@State secondTextPadding: number = 0;
@State thirdTextPadding: number = 0;
@State firstTextMargin: number = 0;
@State secondTextMargin: number = 0;
@State thirdTextMargin: number = 0;
@State flexPadding: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_FlexPad_TextMarPad onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'firstTextPadding') {
this.firstTextPadding = message.value;
}
if (message.name == 'secondTextPadding') {
this.secondTextPadding = message.value;
}
if (message.name == 'thirdTextPadding') {
this.thirdTextPadding = message.value;
}
if (message.name == 'firstTextMargin') {
this.firstTextMargin = message.value;
}
if (message.name == 'secondTextMargin') {
this.secondTextMargin = message.value;
}
if (message.name == 'thirdTextMargin') {
this.thirdTextMargin = message.value;
}
if (message.name == 'flexPadding') {
this.flexPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Flex({wrap:FlexWrap.NoWrap}){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3).margin(this.firstTextMargin)
.padding(this.firstTextPadding).key('NoWrap_FlexPad_TextMarPad1');
Text('2').width(150).height(150).backgroundColor(0xD2B48C).margin(this.secondTextMargin)
.padding(this.secondTextPadding).key('NoWrap_FlexPad_TextMarPad2');
Text('3').width(150).height(200).backgroundColor(0xF5DEB3).margin(this.thirdTextMargin)
.padding(this.thirdTextPadding).key('NoWrap_FlexPad_TextMarPad3');
}
.width(500)
.height(200)
.padding(this.flexPadding)
.backgroundColor(0xAFEEEE)
.key('FlexNoWrap_FlexPad_TextMarPad_Container01')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import router from '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function flex_NoWrap_FlexMarPad_TextMarPadTest() {
describe('Flex_NoWrap_FlexMarPad_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_FlexMarPad_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_FlexMarPad_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_FlexMarPad_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_FlexMarPad_TextMarPad" == pages.name)) {
console.info("get Flex_NoWrap_FlexMarPad_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_FlexMarPad_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_FlexMarPad_TextMarPad page error:" + err);
}
console.info("Flex_NoWrap_FlexMarPad_TextMarPadTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'firstTextMargin', value:0});
globalThis.value.message.notify({name:'secondTextMargin', value:0});
globalThis.value.message.notify({name:'thirdTextMargin', value:0});
globalThis.value.message.notify({name:'firstTextPadding', value:0});
globalThis.value.message.notify({name:'secondTextPadding', value:0});
globalThis.value.message.notify({name:'thirdTextPadding', value:0});
globalThis.value.message.notify({name:'flexMargin', value:0});
globalThis.value.message.notify({name:'flexPadding', value:0});
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_FlexMarPad_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0500
* @tc.name testWrapNoWrapFlexMarPadTextPad
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when the parent components set padding and margin,and the child components set padding
*/
it('testWrapNoWrapFlexMarPadTextPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarPadTextPad] START');
globalThis.value.message.notify({name:'firstTextPadding', value:10});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:30});
globalThis.value.message.notify({name:'flexMargin', value:10});
globalThis.value.message.notify({name:'flexPadding', value:30});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10)); //margin = 10
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30)); //padding=30
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(vp2px(440) / 3));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(30));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(30));
console.info('[testWrapNoWrapFlexMarPadTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0600
* @tc.name testWrapNoWrapFlexMarPadTextMar
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when the parent components set padding and margin,and the child components set margin
*/
it('testWrapNoWrapFlexMarPadTextMar', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarPadTextMar] START');
globalThis.value.message.notify({name:'firstTextMargin', value:10});
globalThis.value.message.notify({name:'secondTextMargin', value:10});
globalThis.value.message.notify({name:'thirdTextMargin', value:10});
globalThis.value.message.notify({name:'flexMargin', value:10});
globalThis.value.message.notify({name:'flexPadding', value:20});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10)); //margin = 10
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10)); //margin = 10
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30)); //padding+margin=30
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(vp2px(400) / 3));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(30));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(30));
console.info('[testWrapNoWrapFlexMarPadTextMar] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0700
* @tc.name testWrapNoWrapFlexMarPadTextMarPad
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when all of components set padding and margin
*/
it('testWrapNoWrapFlexMarPadTextMarPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarPadTextMarPad] START');
globalThis.value.message.notify({name:'firstTextMargin', value:10});
globalThis.value.message.notify({name:'secondTextMargin', value:10});
globalThis.value.message.notify({name:'thirdTextMargin', value:10});
globalThis.value.message.notify({name:'firstTextPadding', value:10});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:30});
globalThis.value.message.notify({name:'flexMargin', value:20});
globalThis.value.message.notify({name:'flexPadding', value:30});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(20)); //margin = 20
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40)); //flex_padding + margin=40
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(vp2px(380) / 3));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(thirdText.left - secondText.right)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(40));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(40));
console.info('[testWrapNoWrapFlexMarPadTextMarPad] END');
done();
});
})
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import router from '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function flex_NoWrap_FlexMar_TextMarPadTest() {
describe('Flex_NoWrap_FlexMar_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_FlexMar_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_FlexMar_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_FlexMar_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_FlexMar_TextMarPad" == pages.name)) {
console.info("get Flex_NoWrap_FlexMar_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_FlexMar_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_FlexMar_TextMarPad page error:" + err);
}
console.info("Flex_NoWrap_FlexMar_TextMarPadTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'firstTextMargin', value:0});
globalThis.value.message.notify({name:'secondTextMargin', value:0});
globalThis.value.message.notify({name:'thirdTextMargin', value:0});
globalThis.value.message.notify({name:'firstTextPadding', value:0});
globalThis.value.message.notify({name:'secondTextPadding', value:0});
globalThis.value.message.notify({name:'thirdTextPadding', value:0});
globalThis.value.message.notify({name:'flexMargin', value:0});
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_FlexMar_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0200
* @tc.name testWrapNoWrapFlexMarTextPad
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components when the parent components set margin,and the child components set padding
*/
it('testWrapNoWrapFlexMarTextPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarTextPad] START');
globalThis.value.message.notify({name:'firstTextPadding', value:10});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:30});
globalThis.value.message.notify({name:'flexMargin', value:10});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexMar_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_FlexMar_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10)); //margin =10
expect(Math.round(flexContainer.top - columnContainer.top))
.assertEqual(Math.round(firstText.top - columnContainer.top));
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right - firstText.left)).assertEqual(vp2px(150))
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(flexContainer.bottom).assertEqual(thirdText.bottom);
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
console.info('[testWrapNoWrapFlexMarTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0300
* @tc.name testWrapNoWrapFlexMarTextMar
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components when the parent components set margin,and the child components set margin
*/
it('testWrapNoWrapFlexMarTextMar', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarTextMar] START');
globalThis.value.message.notify({name:'firstTextMargin', value:10});
globalThis.value.message.notify({name:'flexMargin', value:10});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad3');
let columnContainer = CommonFunc.getComponentRect('Column_FlexMar_TextMarPad_Container01');
let flexContainer = CommonFunc.getComponentRect('FlexMar_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10)); //flex_margin =10
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(10));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(10));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(Math.round(secondText.left - firstText.right));
expect(secondText.top).assertEqual(thirdText.top);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right- firstText.left)).assertEqual(vp2px(150));
expect(Math.round(firstText.right- firstText.left)).assertEqual(Math.round(secondText.right- secondText.left));
expect(Math.round(secondText.right- secondText.left)).assertEqual(Math.round(thirdText.right- thirdText.left));
expect(flexContainer.bottom).assertEqual(thirdText.bottom);
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(30));
console.info('[testWrapNoWrapFlexMarTextMar] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0400
* @tc.name testWrapNoWrapFlexMarTextMarPad
* @tc.desc The size of the parent component in the main axis direction is not enough the layout
* of the child components when the parent components set margin,and the child components set margin and padding
*/
it('testWrapNoWrapFlexMarTextMarPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarTextMarPad] START');
globalThis.value.message.notify({name:'firstTextMargin', value:10});
globalThis.value.message.notify({name:'secondTextMargin', value:10});
globalThis.value.message.notify({name:'thirdTextMargin', value:10});
globalThis.value.message.notify({name:'firstTextPadding', value:20});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:20});
globalThis.value.message.notify({name:'flexMargin', value:10});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexMar_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexMar_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_FlexMar_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(10));
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(10));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(thirdText.left - secondText.right)).assertEqual(vp2px(20));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(vp2px(440) / 3));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(10));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(10));
console.info('[testWrapNoWrapFlexMarTextMarPad] END');
done();
});
})
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import events_emitter from '@ohos.events.emitter';
import router from '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function flex_NoWrap_FlexPad_TextMarPadTest() {
describe('Flex_NoWrap_FlexPad_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_FlexPad_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_FlexPad_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_FlexPad_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_FlexPad_TextMarPad" == pages.name)) {
console.info("get Flex_NoWrap_FlexPad_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_FlexPad_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_FlexPad_TextMarPad page error:" + err);
}
console.info("Flex_NoWrap_FlexPad_TextMarPadTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'firstTextMargin', value:0});
globalThis.value.message.notify({name:'secondTextMargin', value:0});
globalThis.value.message.notify({name:'thirdTextMargin', value:0});
globalThis.value.message.notify({name:'firstTextPadding', value:0});
globalThis.value.message.notify({name:'secondTextPadding', value:0});
globalThis.value.message.notify({name:'thirdTextPadding', value:0});
globalThis.value.message.notify({name:'flexPadding', value:0});
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_FlexPad_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0800
* @tc.name testWrapNoWrapFlexPadTextPad
* @tc.desc The size of the parent component in the main axis direction is not enough for
* the layout of the child components when all of the components set padding
*/
it('testWrapNoWrapFlexPadTextPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexPadTextPad] START');
globalThis.value.message.notify({name:'firstTextPadding', value:10});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:30});
globalThis.value.message.notify({name:'flexPadding', value:30});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.top - flexContainer.top).assertEqual(vp2px(30)); //padding =30
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right- firstText.left)).assertEqual(Math.round(vp2px(440) / 3));
expect(Math.round(firstText.right- firstText.left)).assertEqual(Math.round(secondText.right- secondText.left));
expect(Math.round(secondText.right- secondText.left)).assertEqual(Math.round(thirdText.right- thirdText.left));
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(30));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(30));
console.info('[testWrapNoWrapFlexPadTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0900
* @tc.name testWrapNoWrapFlexPadTextMargin
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when the parent component set padding and the child components set margin
*/
it('testWrapNoWrapFlexPadTextMargin', 0, async function (done) {
console.info('[testWrapNoWrapFlexPadTextMargin] START');
globalThis.value.message.notify({name:'firstTextMargin', value:20});
globalThis.value.message.notify({name:'flexPadding', value:20});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40));
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(firstText.right - firstText.left)).assertEqual(vp2px(140)); // 420/3
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(20));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(20));
console.info('[testWrapNoWrapFlexPadTextMargin] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1000
* @tc.name testWrapNoWrapFlexPadTextMarPad
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when all of components set padding and margin
*/
it('testWrapNoWrapFlexPadTextMarPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexPadTextMarPad] START');
globalThis.value.message.notify({name:'firstTextMargin', value:10});
globalThis.value.message.notify({name:'secondTextMargin', value:10});
globalThis.value.message.notify({name:'thirdTextMargin', value:10});
globalThis.value.message.notify({name:'firstTextPadding', value:10});
globalThis.value.message.notify({name:'secondTextPadding', value:20});
globalThis.value.message.notify({name:'thirdTextPadding', value:30});
globalThis.value.message.notify({name:'flexPadding', value:30});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexNoWrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40));
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(thirdText.left - secondText.right)).assertEqual(vp2px(20));
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(100));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(vp2px(380) / 3));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(40));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(40));
console.info('[testWrapNoWrapFlexPadTextMarPad] END');
done();
});
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册