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

!7447 test:add flex_Wrap_Wrap xts_acts testcase part1

Merge pull request !7447 from 李伟明/flex_wrap
/**
* 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_Wrap_DisplayPriorityTest() {
describe('Flex_Wrap_DisplayPriorityTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_DisplayPriority beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_DisplayPriority',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_DisplayPriority state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_DisplayPriority" == pages.name)) {
console.info("get Flex_Wrap_DisplayPriority state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_DisplayPriority page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_DisplayPriority page error:" + err);
}
console.info("Flex_Wrap_DisplayPriority beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_DisplayPriority after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0100
* @tc.name testWrapWrapTextDisplayPriority
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components,and displaypriority of the child components set different values
*/
it('testWrapWrapTextDisplayPriority', 0, async function (done) {
console.info('[testWrapWrapTextDisplayPriority] START');
globalThis.value.message.notify({name:'firstTextPriority', value:3});
globalThis.value.message.notify({name:'secondTextPriority', value:2});
globalThis.value.message.notify({name:'thirdTextPriority', value:1});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_DisplayPriority01');
let secondText = CommonFunc.getComponentRect('Wrap_DisplayPriority02');
let thirdText = CommonFunc.getComponentRect('Wrap_DisplayPriority03');
let flexContainer = CommonFunc.getComponentRect('FlexWrap_DisplayPriority_Container01');
let flexContainerStrJson = getInspectorByKey('FlexWrap_DisplayPriority_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.right).assertEqual(secondText.left);
expect(firstText.top).assertEqual(secondText.top);
expect(firstText.top).assertEqual(flexContainer.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(secondText.right - secondText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(300));
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(200));
expect(thirdText.left).assertEqual(flexContainer.left);
expect(thirdText.top).assertEqual(secondText.bottom);
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(50));
console.info('[testWrapWrapTextDisplayPriority] END');
done();
});
})
}
/**
* 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_Wrap_FlexMarPad_TextMarPadTest() {
describe('Flex_Wrap_FlexMarPad_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_FlexMarPad_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_FlexMarPad_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_FlexMarPad_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_FlexMarPad_TextMarPad" == pages.name)) {
console.info("get Flex_Wrap_FlexMarPad_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_FlexMarPad_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_FlexMarPad_TextMarPad page error:" + err);
}
console.info("Flex_Wrap_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_Wrap_FlexMarPad_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0500
* @tc.name testWrapWrapFlexMarPadTextPad
* @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('testWrapWrapFlexMarPadTextPad', 0, async function (done) {
console.info('[testWrapWrapFlexMarPadTextPad] 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('Wrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMarPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10)); // flex_margin= 10
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30)); // flex_padding= 30
expect(secondText.left).assertEqual(firstText.right);
expect(firstText.top).assertEqual(secondText.top);
expect(thirdText.top).assertEqual(secondText.bottom);
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(170));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
console.info('[testWrapWrapFlexMarPadTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0600
* @tc.name testWrapWrapFlexMarPadTextMar
* @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('testWrapWrapFlexMarPadTextMar', 0, async function (done) {
console.info('[testWrapWrapFlexMarPadTextMar] 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('Wrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMarPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30)); // flex_padding= 20,text_margin =10
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(firstText.top).assertEqual(secondText.top);
expect(Math.round(thirdText.top -secondText.bottom)).assertEqual(vp2px(20));
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(150));
expect(flexContainer.bottom).assertEqual(thirdText.bottom);
console.info('[testWrapWrapFlexMarPadTextMar] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0700
* @tc.name testWrapWrapFlexMarPadTextMarPad
* @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('testWrapWrapFlexMarPadTextMarPad', 0, async function (done) {
console.info('[testWrapWrapFlexMarPadTextMarPad] 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('Wrap_FlexMarPad_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMarPad_TextPad3');
let flexContainer = CommonFunc.getComponentRect('FlexWrap_FlexMarPad_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMarPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('FlexWrap_FlexMarPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(20)); // flex_margin= 20
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40)); // flex_padding= 30 text_margin= 10
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(firstText.top).assertEqual(secondText.top);
expect(Math.round(thirdText.top -secondText.bottom)).assertEqual(vp2px(20));
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(140));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(10));
console.info('[testWrapWrapFlexMarPadTextMarPad] 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_Wrap_FlexMar_TextMarPadTest() {
describe('Flex_Wrap_FlexMar_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_FlexMar_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_FlexMar_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_FlexMar_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_FlexMar_TextMarPad" == pages.name)) {
console.info("get Flex_Wrap_FlexMar_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_FlexMar_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_FlexMar_TextMarPad page error:" + err);
}
console.info("Flex_Wrap_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_Wrap_FlexMar_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0200
* @tc.name testWrapWrapFlexMarTextPad
* @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('testWrapWrapFlexMarTextPad', 0, async function (done) {
console.info('[testWrapWrapFlexMarTextPad] 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('Wrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexMar_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMar_TextMarPad_Container');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));//flex_margin=10
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
console.info('[testWrapWrapFlexMarTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0300
* @tc.name testWrapWrapFlexMarTextMar
* @tc.desc The size of the parent component in the main axis direction is not enough for
* the child components when the parent components set margin,and the child components set margin
*/
it('testWrapWrapFlexMarTextMar', 0, async function (done) {
console.info('[testWrapWrapFlexMarTextMar] START');
globalThis.value.message.notify({name:'firstTextMargin', value:30});
globalThis.value.message.notify({name:'flexMargin', value:10});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexMar_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMar_TextMarPad_Container');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
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(30));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30));
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(30));
expect(secondText.top).assertEqual(flexContainer.top);
expect(Math.round(thirdText.top - firstText.bottom)).assertEqual(vp2px(30));
expect(thirdText.left).assertEqual(flexContainer.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
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(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(140));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(40));
console.info('[testWrapWrapFlexMarTextMar] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0400
* @tc.name testWrapWrapFlexMarTextMarPad
* @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('testWrapWrapFlexMarTextMarPad', 0, async function (done) {
console.info('[testWrapWrapFlexMarTextMarPad] 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('Wrap_FlexMar_TextPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexMar_TextPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexMar_TextMarPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexMar_TextMarPad_Container');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexMar_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.left - columnContainer.left)).assertEqual(vp2px(10));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(10)); //margin = 10
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(10));
expect(firstText.top).assertEqual(secondText.top);
expect(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(thirdText.top - secondText.bottom)).assertEqual(vp2px(20));
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(170));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
console.info('[testWrapWrapFlexMarTextMarPad] 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_Wrap_FlexPad_TextMarPadTest() {
describe('Flex_Wrap_FlexPad_TextMarPadTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_FlexPad_TextMarPadTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_FlexPad_TextMarPad',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_FlexPad_TextMarPad state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_FlexPad_TextMarPad" == pages.name)) {
console.info("get Flex_Wrap_FlexPad_TextMarPad pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_FlexPad_TextMarPad page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_FlexPad_TextMarPad page error:" + err);
}
console.info("Flex_Wrap_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_Wrap_FlexPad_TextMarPadText after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0800
* @tc.name testWrapWrapFlexPadTextPad
* @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('testWrapWrapFlexPadTextPad', 0, async function (done) {
console.info('[testWrapWrapFlexPadTextPad] 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('Wrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.right).assertEqual(secondText.left);
expect(firstText.top).assertEqual(secondText.top);
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(30)); //padding=30
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30));
expect(thirdText.top).assertEqual(secondText.bottom);
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(170));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
console.info('[testWrapWrapFlexPadTextPad] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_0900
* @tc.name testWrapWrapFlexPadTextMargin
* @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('testWrapWrapFlexPadTextMargin', 0, async function (done) {
console.info('[testWrapWrapFlexPadTextMargin] 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('Wrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40)); //flex_pad+text_margin = 40
expect(secondText.bottom).assertEqual(thirdText.top);
expect(Math.round(firstText.left - thirdText.left)).assertEqual(vp2px(20));
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(140));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(30));
console.info('[testWrapWrapFlexPadTextMargin] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1000
* @tc.name testWrapWrapFlexPadTextMarPad
* @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
* and padding
*/
it('testWrapWrapFlexPadTextMarPad', 0, async function (done) {
console.info('[testWrapWrapFlexPadTextMarPad] 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('Wrap_FlexPad_TextMarPad1');
let secondText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad2');
let thirdText = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexPad_TextMarPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.top).assertEqual(secondText.top);
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40));
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(40)); //flex_pad+text_margin = 40
expect(Math.round(thirdText.top - secondText.bottom)).assertEqual(vp2px(20));
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(secondText.left - firstText.right)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(140));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(10));
console.info('[testWrapWrapFlexPadTextMarPad] 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_Wrap_FlexSizeTest() {
describe('flex_Wrap_FlexSizeTest', function () {
beforeEach(async function (done) {
console.info("flex_Wrap_FlexSizeTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_FlexSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get flex_Wrap_FlexSize state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_FlexSize" == pages.name)) {
console.info("get flex_Wrap_FlexSize state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push flex_Wrap_FlexSize page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push flex_Wrap_FlexSize page error:" + err);
}
console.info("flex_Wrap_FlexSizeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("flex_Wrap_FlexSizeTest after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1100
* @tc.name wrap_Wrap_FlexSize
* @tc.desc The size of the parent component in the main axis direction
* meets the layout of the child components
*/
it('SUB_ACE_FLEXWRAP_WRAP_1100', 0, async function (done) {
console.info('[SUB_ACE_FLEXWRAP_WRAP_1100] START');
globalThis.value.message.notify({name:'width', value:500})
globalThis.value.message.notify({name:'height', value:200})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('Wrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('Wrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
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(firstText.top).assertEqual(flexContainer.top);
expect(firstText.left).assertEqual(flexContainer.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(50));
console.info('[SUB_ACE_FLEXWRAP_WRAP_1100] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1200
* @tc.name wrap_Wrap_FlexSize
* @tc.desc The size of the parent component in the main axis direction
* is not enough for the layout of the child components,and the cross axis meets
*/
it('SUB_ACE_FLEXWRAP_WRAP_1200', 0, async function (done) {
console.info('[SUB_ACE_FLEXWRAP_WRAP_1200] START');
globalThis.value.message.notify({name:'width', value:400})
globalThis.value.message.notify({name:'height', value:260})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('Wrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('Wrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(firstText.top).assertEqual(flexContainer.top);
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.right).assertEqual(secondText.left);
expect(firstText.top).assertEqual(secondText.top);
expect(thirdText.left).assertEqual(firstText.left);
expect(thirdText.top).assertEqual(secondText.bottom);
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(100));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(10));
console.info('[SUB_ACE_FLEXWRAP_WRAP_1200] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1300
* @tc.name wrap_Wrap_FlexSize
* @tc.desc The size of the parent component in the main axis direction
* is not enough for the layout of the child componentsand,and the cross axis as well
*/
it('SUB_ACE_FLEXWRAP_WRAP_1300', 0, async function (done) {
console.info('[SUB_ACE_FLEXWRAP_WRAP_1300] START');
globalThis.value.message.notify({name:'width', value:350})
globalThis.value.message.notify({name:'height', value:150})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('Wrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('Wrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('Wrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('Wrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
expect(firstText.top).assertEqual(secondText.top);
expect(firstText.right).assertEqual(secondText.left);
expect(thirdText.left).assertEqual(firstText.left);
expect(thirdText.top).assertEqual(secondText.bottom);
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(50));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(100));
console.info('[SUB_ACE_FLEXWRAP_WRAP_1300] END');
done();
});
})
}
/**
* 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_Wrap_LayoutWeightTest() {
describe('Flex_Wrap_LayoutWeightTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_LayoutWeightTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_LayoutWeight',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_LayoutWeight state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_LayoutWeight" == pages.name)) {
console.info("get Flex_Wrap_LayoutWeight state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(1000);
console.info("push Flex_Wrap_LayoutWeight page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_LayoutWeight page error:" + err);
}
console.info("Flex_Wrap_LayoutWeightTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_LayoutWeight after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1400
* @tc.name testWrapWrapTextLayoutWeight
* @tc.desc The size of the parent component in the main axis direction meets the layout of
* the child components,and LayoutWeight of the child components set different values
*/
it('testWrapWrapTextLayoutWeight', 0, async function (done) {
console.info('[testWrapWrapTextLayoutWeight] START');
globalThis.value.message.notify({name:'firstTextLayoutWeight', value:2})
globalThis.value.message.notify({name:'secondTextLayoutWeight', value:1})
globalThis.value.message.notify({name:'thirdTextLayoutWeight', value:1})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_LayoutWeight01');
let secondText = CommonFunc.getComponentRect('Wrap_LayoutWeight02');
let thirdText = CommonFunc.getComponentRect('Wrap_LayoutWeight03');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_layoutWeight_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_layoutWeight_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(secondText.right - secondText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(firstText.right - firstText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
console.info('[testWrapWrapTextLayoutWeight] END');
done();
});
})
}
/**
* 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_Wrap_PaddingTest() {
describe('Flex_Wrap_PaddingTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_PaddingTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_Padding',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_Padding state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_Padding" == pages.name)) {
console.info("get Flex_Wrap_Padding state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_Padding page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_Padding page error:" + err);
}
console.info("Flex_Wrap_PaddingTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'flexMargin', value:0});
globalThis.value.message.notify({name:'flexPadding', value:0});
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_Padding after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1500
* @tc.name testWrapWrapFlexPaddingMeet
* @tc.desc The size of the parent component in the main axis direction
* meets the layout of the child components when the parent component set padding
*/
it('testWrapWrapFlexPaddingMeet', 0, async function (done) {
console.info('[testWrapWrapFlexPaddingMeet] START');
globalThis.value.message.notify({name:'flexPadding', value:10})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Pad_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Pad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(10)); //Flex_padding = 10
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(10));
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(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(40));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(140));
console.info('[testWrapWrapFlexPaddingMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1600
* @tc.name testWrapWrapFlexPaddingOverflow
* @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
*/
it('testWrapWrapFlexPaddingOverflow', 0, async function (done) {
console.info('[testWrapWrapFlexPaddingOverflow] START');
globalThis.value.message.notify({name:'flexPadding', value:30})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Pad_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Pad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30)); // Flex_padding = 30
expect(Math.round(firstText.left- flexContainer.left)).assertEqual(vp2px(30));
expect(firstText.top).assertEqual(secondText.top);
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.bottom).assertEqual(thirdText.top);
expect(secondText.left).assertEqual(thirdText.right);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(170));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
console.info('[testWrapWrapFlexPaddingOverflow] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1700
* @tc.name testWrapWrapFlexMargin
* @tc.desc The size of the parent component in the main axis direction
* meets the layout of the child components when the parent component set margin
*/
it('testWrapWrapFlexMargin', 0, async function (done) {
console.info('[testWrapWrapFlexMargin] START');
globalThis.value.message.notify({name:'flexMargin', value:10})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Pad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexPad_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Pad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10)); // margin =10
expect(Math.round(flexContainer.top - columnContainer.top))
.assertEqual(Math.round(firstText.top - columnContainer.top));
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(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
console.info('[testWrapWrapFlexMargin] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1800
* @tc.name testWrapWrapFlexMarPad
* @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 margin and padding
*/
it('testWrapWrapFlexMarPad', 0, async function (done) {
console.info('[testWrapWrapFlexMarPad] START');
globalThis.value.message.notify({name:'flexMargin', value:10});
globalThis.value.message.notify({name:'flexPadding', value:30});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Pad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_Wrap_FlexPad_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Pad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(flexContainer.top - columnContainer.top)).assertEqual(vp2px(10)); // margin=10
expect(Math.round(firstText.top - columnContainer.top)).assertEqual(vp2px(40)); //Flex_padding+margin = 40
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(30));
expect(firstText.top).assertEqual(secondText.top);
expect(firstText.right).assertEqual(secondText.left);
expect(thirdText.top).assertEqual(secondText.bottom);
expect(thirdText.left).assertEqual(firstText.left);
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(170));
console.info('[testWrapWrapFlexMarPad] END');
done();
});
})
}
/**
* 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_Wrap_PositionTest() {
describe('Flex_Wrap_PositionTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_PositionTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_Position',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_Position state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_Position" == pages.name)) {
console.info("get Flex_Wrap_Position state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_Position page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_Position page error:" + err);
}
console.info("Flex_Wrap_PositionTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_Position after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_1900
* @tc.name testWrapWrapTextPosition
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components when the first child components change position
*/
it('testWrapWrapTextPosition', 0, async function (done) {
console.info('[testWrapWrapTextPosition] START');
globalThis.value.message.notify({name:'position', value: {x:20, y:40}})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_Position01');
let secondText = CommonFunc.getComponentRect('Wrap_Position02');
let thirdText = CommonFunc.getComponentRect('Wrap_Position03');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Position_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Position_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(200));
expect(Math.round(firstText.top - flexContainer.top)).assertEqual(vp2px(40));
expect(Math.round(firstText.left-flexContainer.left)).assertEqual(vp2px(20)); //position({x:20,y:40})
expect(secondText.top).assertEqual(flexContainer.top)
expect(secondText.left).assertEqual(flexContainer.left);
expect(secondText.top).assertEqual(thirdText.top);
expect(secondText.right).assertEqual(thirdText.left);
console.info('[testWrapWrapTextPosition] END');
done();
});
})
}
/**
* 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 "deccjsunit/index";
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_Wrap_TextSizeTest() {
describe('Flex_Wrap_TextSizeTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_TextSizeTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_TextSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_TextSize state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_TextSize" == pages.name)) {
console.info("get Flex_Wrap_TextSize state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_TextSize page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_TextSize page error:" + err);
}
console.info("Flex_Wrap_TextSizeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_TextSizeTest after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_2000
* @tc.name testWrapWrapTextSizeMeet
* @tc.desc The size of the parent component in the main axis direction
* meets the layout of the child components when the child component change size
*/
it('testWrapWrapTextSizeMeet', 0, async function (done) {
console.info('[testWrapWrapTextSizeMeet] START');
globalThis.value.message.notify({name:'width', value:150})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_TextSize1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_TextSize2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_TextSize3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_TextSize_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_TextSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
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(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(150));
console.info('[testWrapWrapTextSizeMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_2100
* @tc.name testWrapWrapTextSizeOverflow
* @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 child component change size
*/
it('testWrapWrapTextSizeOverflow', 0, async function (done) {
console.info('[testWrapWrapTextSizeOverflow] START');
globalThis.value.message.notify({name:'width', value:200})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('Wrap_flex_TextSize1');
let secondText = CommonFunc.getComponentRect('Wrap_flex_TextSize2');
let thirdText = CommonFunc.getComponentRect('Wrap_flex_TextSize3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_TextSize_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_TextSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(Math.round(firstText.bottom - firstText.top)).assertEqual(vp2px(50));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(100));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(150));
expect(Math.round(firstText.right - firstText.left)).assertEqual(vp2px(200));
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(firstText.top).assertEqual(secondText.top);
expect(firstText.right).assertEqual(secondText.left);
expect(firstText.top).assertEqual(flexContainer.top);
expect(firstText.left).assertEqual(flexContainer.left);
expect(secondText.left).assertEqual(thirdText.right);
expect(secondText.bottom).assertEqual(thirdText.top);
expect(Math.round(flexContainer.right - secondText.right)).assertEqual(vp2px(100));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(50));
console.info('[testWrapWrapTextSizeOverflow] END');
done();
});
})
}
/**
* 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_Wrap_VisibilityTest() {
describe('Flex_Wrap_VisibilityTest', function () {
beforeEach(async function (done) {
console.info("Flex_Wrap_VisibilityTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/Wrap/Flex_Wrap_Visibility',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_Wrap_Visibility state pages:" + JSON.stringify(pages));
if (!("Flex_Wrap_Visibility" == pages.name)) {
console.info("get Flex_Wrap_Visibility state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_Wrap_Visibility page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_Wrap_Visibility page error:" + err);
}
console.info("Flex_Wrap_VisibilityTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_Wrap_Visibility after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_2200
* @tc.name testWrapWrapTextVisibilityNoneOverflow
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when one of the child components set "Visibility.NOne"
*/
it('testWrapWrapTextVisibilityNoneOverflow', 0, async function (done) {
console.info('[testWrapWrapTextVisibilityNoneOverflow] START');
globalThis.value.message.notify({name:'firstTextWidth', value:250});
globalThis.value.message.notify({name:'secondTextWidth', value:350});
globalThis.value.message.notify({name:'thirdTextWidth', value:350});
globalThis.value.message.notify({name:'visibility', value:Visibility.None})
await CommonFunc.sleep(3000);
let secondText = CommonFunc.getComponentRect('Wrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('Wrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(secondText.top).assertEqual(flexContainer.top);
expect(secondText.left).assertEqual(flexContainer.left);
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(350));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(thirdText.top).assertEqual(secondText.bottom);
expect(thirdText.left).assertEqual(secondText.left);
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(150));
console.info('[testWrapWrapTextVisibilityNoneOverflow] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_2300
* @tc.name testWrapWrapTextVisibilityNoneMeet
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components when one of the child components set "Visibility.NOne"
*/
it('testWrapWrapTextVisibilityNoneMeet', 0, async function (done) {
console.info('[testWrapWrapTextVisibilityNoneMeet] START');
globalThis.value.message.notify({name:'firstTextWidth', value:250});
globalThis.value.message.notify({name:'secondTextWidth', value:150});
globalThis.value.message.notify({name:'thirdTextWidth', value:150});
globalThis.value.message.notify({name:'visibility', value:Visibility.None})
await CommonFunc.sleep(3000);
let secondText = CommonFunc.getComponentRect('Wrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('Wrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(secondText.right).assertEqual(thirdText.left);
expect(secondText.top).assertEqual(thirdText.top);
expect(flexContainer.top).assertEqual(thirdText.top);
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(200));
expect(flexContainer.left).assertEqual(secondText.left);
console.info('[testWrapWrapTextVisibilityNoneMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_WRAP_2400
* @tc.name testWrapWrapTextVisibilityHidden
* @tc.desc The size of the parent component in the main axis direction meets the layout
* of the child components when one of the child components set "Visibility.Hidden"
*/
it('testWrapWrapTextVisibilityHidden', 0, async function (done) {
console.info('[testWrapWrapTextVisibilityHidden] START');
globalThis.value.message.notify({name:'firstTextWidth', value:150});
globalThis.value.message.notify({name:'secondTextWidth', value:150});
globalThis.value.message.notify({name:'thirdTextWidth', value:150});
globalThis.value.message.notify({name:'visibility', value:Visibility.Hidden})
await CommonFunc.sleep(3000);
let secondText = CommonFunc.getComponentRect('Wrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('Wrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_Wrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_Wrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.Wrap');
expect(secondText.right).assertEqual(thirdText.left)
expect(secondText.top).assertEqual(thirdText.top);
expect(flexContainer.top).assertEqual(thirdText.top);
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(Math.round(secondText.left - flexContainer.left)).assertEqual(vp2px(150));
console.info('[testWrapWrapTextVisibilityHidden] END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册