提交 38e9aa36 编写于 作者: W wmlih

test:add flex_Wrap_NoWrap xts_acts testcase part1

Signed-off-by: Nwmlih <wmlih@isoftstone.com>
上级 00bec899
/**
* 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_DisplayPriority{
@State firstTextPriority: number = 1;
@State secondTextPriority: number = 1;
@State thirdTextPriority: number = 1;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_DisplayPriority onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'firstTextPriority') {
this.firstTextPriority = message.value;
}
if (message.name == 'secondTextPriority') {
this.secondTextPriority = message.value;
}
if (message.name == 'thirdTextPriority') {
this.thirdTextPriority = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Flex({wrap:FlexWrap.NoWrap}){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3)
.displayPriority(this.firstTextPriority).key('NoWrap_DisplayPriority01');
Text('2').width(150).height(150).backgroundColor(0xD2B48C)
.displayPriority(this.secondTextPriority).key('NoWrap_DisplayPriority02');
Text('3').width(250).height(200).backgroundColor(0xF5DEB3)
.displayPriority(this.thirdTextPriority).key('NoWrap_DisplayPriority03');
}
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.key('Flex_DisplayPriority_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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_FlexSize{
@State testWidth: number = 400;
@State testHeight: number = 100;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_FlexSize onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'width') {
this.testWidth = message.value;
}
if (message.name == 'height') {
this.testHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:10}){
Flex({wrap:FlexWrap.NoWrap, direction: FlexDirection.Row}){
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('NoWrap_flexSize_Text1');
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('NoWrap_flexSize_Text2');
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('NoWrap_flexSize_Text3');
}
.width(this.testWidth)
.height(this.testHeight)
.backgroundColor(0xAFEEEE)
.key('NoWrap_FlexSize_Container01')
}
.width('100%')
.height('100%')
.key('Column_Container')
}
}
\ 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_layoutWeight{
@State firstTextLayoutWeight: number = 1;
@State secondTextLayoutWeight: number = 1;
@State thirdTextLayoutWeight: number = 1;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_layoutWeight onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'firstTextLayoutWeight') {
this.firstTextLayoutWeight = message.value;
}
if (message.name == 'secondTextLayoutWeight') {
this.secondTextLayoutWeight = message.value;
}
if (message.name == 'thirdTextLayoutWeight') {
this.thirdTextLayoutWeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Flex({wrap:FlexWrap.NoWrap}){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3)
.layoutWeight(this.firstTextLayoutWeight).key('NoWrap_LayoutWeight01');
Text('2').width(150).height(150).backgroundColor(0xD2B48C)
.layoutWeight(this.secondTextLayoutWeight).key('NoWrap_LayoutWeight02');
Text('3').width(150).height(200).backgroundColor(0xF5DEB3)
.layoutWeight(this.thirdTextLayoutWeight).key('NoWrap_LayoutWeight03');
}
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.key('Flex_NoWrap_layoutWeight_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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_Padding{
@State flexMargin: number = 0;
@State flexPadding: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_Padding onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + 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, direction: FlexDirection.Row }){
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('NoWrap_flex_pad1');
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('NoWrap_flex_pad2');
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('NoWrap_flex_pad3');
}
.width(500)
.height(200)
.padding(this.flexPadding)
.margin(this.flexMargin)
.backgroundColor(0xAFEEEE)
.key('NoWrap_FlexPad_Container01')
}
.width('100%')
.height('100%')
.key('Column_NoWrap_FlexPad_Container')
}
}
\ 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_Position{
@State testPosition: object = { x:0, y:0 };
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_Position onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'position') {
this.testPosition = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({ space:30 }){
Flex({ wrap:FlexWrap.NoWrap }){
Text('1').width(150).height(100).backgroundColor(0xF5DEB3).key('NoWrap_Position01').position(this.testPosition);
Text('2').width(150).height(150).backgroundColor(0xD2B48C).key('NoWrap_Position02');
Text('3').width(150).height(200).backgroundColor(0xF5DEB3).key('NoWrap_Position03');
}
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.key('Flex_NoWrap_Position_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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_TextSize{
@State testWidth: number = 100;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_TextSize onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'width') {
this.testWidth = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({ space:10 }){
Flex({ wrap:FlexWrap.NoWrap, direction: FlexDirection.Row }){
Text('1').width(this.testWidth).height(100).backgroundColor(0xF5DEB3).key('NoWrap_flex_TextSize1');
Text('2').width(this.testWidth).height(150).backgroundColor(0xD2B48C).key('NoWrap_flex_TextSize2');
Text('3').width(this.testWidth).height(200).backgroundColor(0xF5DEB3).key('NoWrap_flex_TextSize3');
}
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.key('Flex_NoWrap_TextSize_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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct Flex_NoWrap_Visibility{
@State testVisibility: number = Visibility.Visible;
@State firstTextWidth: number = 150;
@State secondTextWidth: number = 150;
@State thirdTextWidth: number = 150;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Flex_NoWrap_Visibility onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'visibility') {
this.testVisibility = message.value;
}
if (message.name == 'firstTextWidth') {
this.firstTextWidth = message.value;
}
if (message.name == 'secondTextWidth') {
this.secondTextWidth = message.value;
}
if (message.name == 'secondTextWidth') {
this.thirdTextWidth = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({ space:30 }){
Flex({ wrap:FlexWrap.NoWrap }){
Text('1').width(this.firstTextWidth).height(100).backgroundColor(0xF5DEB3)
.visibility(this.testVisibility).key('NoWrap_Text_Visibility1');
Text('2').width(this.secondTextWidth).height(150).backgroundColor(0xD2B48C).key('NoWrap_Text_Visibility2');
Text('3').width(this.thirdTextWidth).height(200).backgroundColor(0xF5DEB3).key('NoWrap_Text_Visibility3');
}
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.key('Flex_NoWrap_Visibility_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_DisplayPriorityTest() {
describe('Flex_NoWrap_DisplayPriorityTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_DisplayPriority beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_DisplayPriority',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_DisplayPriority state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_DisplayPriority" == pages.name)) {
console.info("get Flex_NoWrap_DisplayPriority state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_DisplayPriority page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_DisplayPriority page error:" + err);
}
console.info("Flex_NoWrap_DisplayPriority beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_DisplayPriority after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_0100
* @tc.name testWrapNoWrapTextDisplayPriority
* @tc.desc The size of the parent component in the main axis direction is not enough for the layout
* of the child components when display_priority of the child components set different values
*/
it('testWrapNoWrapTextDisplayPriority', 0, async function (done) {
console.info('[testWrapNoWrapTextDisplayPriority] START');
globalThis.value.message.notify({name:'firstTextPriority', value:1});
globalThis.value.message.notify({name:'secondTextPriority', value:2});
globalThis.value.message.notify({name:'thirdTextPriority', value:3});
await CommonFunc.sleep(3000);
let secondText = CommonFunc.getComponentRect('NoWrap_DisplayPriority02');
let thirdText = CommonFunc.getComponentRect('NoWrap_DisplayPriority03');
let flexContainer = CommonFunc.getComponentRect('Flex_DisplayPriority_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_DisplayPriority_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(secondText.top).assertEqual(thirdText.top);
expect(secondText.left).assertEqual(flexContainer.left);
expect(secondText.top).assertEqual(flexContainer.top);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(secondText.right - secondText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(250));
expect(Math.round(secondText.bottom - secondText.top)).assertEqual(vp2px(150));
expect(Math.round(thirdText.bottom - thirdText.top)).assertEqual(vp2px(200));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(100));
expect(flexContainer.bottom).assertEqual(thirdText.bottom);
console.info('[testWrapNoWrapTextDisplayPriority] 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_NoWrap_FlexSizeTest() {
describe('flex_NoWrap_FlexSizeTest', function () {
beforeEach(async function (done) {
console.info("flex_NoWrap_FlexSizeTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_FlexSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get flex_NoWrap_FlexSize state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_FlexSize" == pages.name)) {
console.info("get flex_NoWrap_FlexSize state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push flex_NoWrap_FlexSize page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push flex_NoWrap_FlexSize page error:" + err);
}
console.info("flex_NoWrap_FlexSizeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("flex_NoWrap_FlexSizeTest after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1100
* @tc.name testWrapNoWrapFlexSizeMeet
* @tc.desc The size of the parent component in the main axis direction
* meets the layout of the child components
*/
it('testWrapNoWrapFlexSizeMeet', 0, async function (done) {
console.info('[testWrapNoWrapFlexSizeMeet] 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('NoWrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('NoWrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(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('[testWrapNoWrapFlexSizeMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1200
* @tc.name testWrapNoWrapFlexSizeMainAxisOverflow
* @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('testWrapNoWrapFlexSizeMainAxisOverflow', 0, async function (done) {
console.info('[testWrapNoWrapFlexSizeMainAxisOverflow] START');
globalThis.value.message.notify({name:'width', value:400})
globalThis.value.message.notify({name:'height', value:100})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('NoWrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(Math.round(vp2px(400) / 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(thirdText.right).assertEqual(flexContainer.right);
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(50));
console.info('[testWrapNoWrapFlexSizeMainAxisOverflow] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1300
* @tc.name testWrapNoWrapFlexSizeAllAxisOverflow
* @tc.desc The size of the parent component in the main axis directionmeets the layout of
* the child components,and the cross axis is not enough for the layout of the child components
*/
it('testWrapNoWrapFlexSizeAllAxisOverflow', 0, async function (done) {
console.info('[testWrapNoWrapFlexSizeAllAxisOverflow] START');
globalThis.value.message.notify({name:'width', value:500});
globalThis.value.message.notify({name:'height', value:100});
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flexSize_Text1');
let secondText = CommonFunc.getComponentRect('NoWrap_flexSize_Text2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flexSize_Text3');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexSize_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(secondText.right- secondText.left)).assertEqual(Math.round(thirdText.right- thirdText.left));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(50));
console.info('[testWrapNoWrapFlexSizeAllAxisOverflow] 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_NoWrap_LayoutWeightTest() {
describe('Flex_NoWrap_LayoutWeightTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_LayoutWeightTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_LayoutWeight',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_LayoutWeight state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_LayoutWeight" == pages.name)) {
console.info("get Flex_NoWrap_LayoutWeight state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(1000);
console.info("push Flex_NoWrap_LayoutWeight page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_LayoutWeight page error:" + err);
}
console.info("Flex_NoWrap_LayoutWeightTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_LayoutWeight after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1400
* @tc.name testWrapNoWrapTextLayoutWeight
* @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('testWrapNoWrapTextLayoutWeight', 0, async function (done) {
console.info('[testWrapNoWrapTextLayoutWeight] START');
globalThis.value.message.notify({name:'firstTextLayoutWeight', value:1})
globalThis.value.message.notify({name:'secondTextLayoutWeight', value:2})
globalThis.value.message.notify({name:'thirdTextLayoutWeight', value:3})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_LayoutWeight01');
let secondText = CommonFunc.getComponentRect('NoWrap_LayoutWeight02');
let thirdText = CommonFunc.getComponentRect('NoWrap_LayoutWeight03');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_layoutWeight_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_layoutWeight_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.top).assertEqual(flexContainer.top);
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(thirdText.bottom).assertEqual(flexContainer.bottom);
expect(firstText.left).assertEqual(flexContainer.left);
expect(thirdText.right).assertEqual(flexContainer.right);
expect(Math.round(2 * (firstText.right - firstText.left)))
.assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round((1.5 * (secondText.right - secondText.left))*10)/10)
.assertEqual(Math.round((thirdText.right - thirdText.left)*10)/10);
console.info('[testWrapNoWrapTextLayoutWeight] 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 events_emitter from '@ohos.events.emitter';
import router from '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function flex_NoWrap_PaddingTest() {
describe('Flex_NoWrap_PaddingTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_PaddingTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_Padding',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_Padding state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_Padding" == pages.name)) {
console.info("get Flex_NoWrap_Padding state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_Padding page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_Padding page error:" + err);
}
console.info("Flex_NoWrap_PaddingTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'flexPadding', value:0});
globalThis.value.message.notify({name:'flexMargin', value:0})
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_Padding after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1500
* @tc.name testWrapNoWrapFlexPaddingOverflow
* @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('testWrapNoWrapFlexPaddingOverflow', 0, async function (done) {
console.info('[testWrapNoWrapFlexPaddingOverflow] START');
globalThis.value.message.notify({name:'flexPadding', value:60})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexPad_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(60));
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(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(60)); //Flex_padding = 60
expect(Math.round(thirdText.bottom - flexContainer.bottom)).assertEqual(vp2px(10));
console.info('[testWrapNoWrapFlexPaddingOverflow] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1600
* @tc.name testWrapNoWrapFlexPaddingMeet
* @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('testWrapNoWrapFlexPaddingMeet', 0, async function (done) {
console.info('[testWrapNoWrapFlexPaddingMeet] START');
globalThis.value.message.notify({name:'flexPadding', value:10})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_pad3');
let columnContainer = CommonFunc.getComponentRect('Column_NoWrap_FlexPad_Container');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexPad_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(Math.round(firstText.left - flexContainer.left)).assertEqual(vp2px(10)); // Flex_padding = 10
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(450) / 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(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(40));
console.info('[testWrapNoWrapFlexPaddingMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1700
* @tc.name testWrapNoWrapFlexMargin
* @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('testWrapNoWrapFlexMargin', 0, async function (done) {
console.info('[testWrapNoWrapFlexMargin] START');
globalThis.value.message.notify({name:'flexMargin', value:10})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_pad3');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexPad_Container01');
let columnContainer = CommonFunc.getComponentRect('Column_NoWrap_FlexPad_Container');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.right).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(450) / 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(50));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(50));
console.info('[testWrapNoWrapFlexMargin] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1800
* @tc.name testWrapNoWrapFlexMarPad
* @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 and padding
*/
it('testWrapNoWrapFlexMarPad', 0, async function (done) {
console.info('[testWrapNoWrapFlexMarPad] 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('NoWrap_flex_pad1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_pad2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_pad3');
let columnContainer = CommonFunc.getComponentRect('Column_NoWrap_FlexPad_Container');
let flexContainer = CommonFunc.getComponentRect('NoWrap_FlexPad_Container01');
let flexContainerStrJson = getInspectorByKey('NoWrap_FlexPad_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
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(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.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(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(30));
expect(Math.round(flexContainer.bottom - thirdText.bottom)).assertEqual(vp2px(20));
console.info('[testWrapNoWrapFlexMarPad] 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_NoWrap_PositionTest() {
describe('Flex_NoWrap_PositionTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_PositionTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_Position',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_Position state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_Position" == pages.name)) {
console.info("get Flex_NoWrap_Position state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_Position page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_Position page error:" + err);
}
console.info("Flex_NoWrap_PositionTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_Position after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_1900
* @tc.name testWrapNoWrapTextPosition
* @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('testWrapNoWrapTextPosition', 0, async function (done) {
console.info('[testWrapNoWrapTextPosition] START');
globalThis.value.message.notify({name:'position', value: {x:20, y:40}})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_Position01');
let secondText = CommonFunc.getComponentRect('NoWrap_Position02');
let thirdText = CommonFunc.getComponentRect('NoWrap_Position03');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_Position_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_Position_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
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(secondText.top).assertEqual(flexContainer.top);
expect(secondText.left).assertEqual(flexContainer.left);
expect(secondText.top).assertEqual(thirdText.top);
expect(secondText.right).assertEqual(thirdText.left);
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(200));
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
expect(Math.round(firstText.top-flexContainer.top)).assertEqual(vp2px(40));
expect(Math.round(firstText.left-flexContainer.left)).assertEqual(vp2px(20));
console.info('[testWrapNoWrapTextPosition] 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';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
export default function flex_NoWrap_TextSizeTest() {
describe('Flex_NoWrap_TextSizeTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_TextSizeTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_TextSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_TextSize state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_TextSize" == pages.name)) {
console.info("get Flex_NoWrap_TextSize pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_TextSize page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_TextSize page error:" + err);
}
console.info("Flex_NoWrap_TextSizeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_TextSizeTest after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_2000
* @tc.name testWrapNoWrapTextSizeMeet
* @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('testWrapNoWrapTextSizeMeet', 0, async function (done) {
console.info('[testWrapNoWrapTextSizeMeet] START');
globalThis.value.message.notify({name:'width', value:150})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flex_TextSize1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_TextSize2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_TextSize3');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_TextSize_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_TextSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.left).assertEqual(flexContainer.left);
expect(firstText.top).assertEqual(flexContainer.top);
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(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(thirdText.bottom).assertEqual(flexContainer.bottom);
console.info('[testWrapNoWrapTextSizeMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_2100
* @tc.name testWrapNoWrapTextSizeOverflow
* @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('testWrapNoWrapTextSizeOverflow', 0, async function (done) {
console.info('[testWrapNoWrapTextSizeOverflow] START');
globalThis.value.message.notify({name:'width', value:200})
await CommonFunc.sleep(3000);
let firstText = CommonFunc.getComponentRect('NoWrap_flex_TextSize1');
let secondText = CommonFunc.getComponentRect('NoWrap_flex_TextSize2');
let thirdText = CommonFunc.getComponentRect('NoWrap_flex_TextSize3');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_TextSize_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_TextSize_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(firstText.top).assertEqual(secondText.top);
expect(secondText.top).assertEqual(thirdText.top);
expect(flexContainer.top).assertEqual(firstText.top);
expect(flexContainer.left).assertEqual(firstText.left);
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(500) / 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(thirdText.right).assertEqual(flexContainer.right);
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
console.info('[testWrapNoWrapTextSizeOverflow] 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_NoWrap_VisibilityTest() {
describe('Flex_NoWrap_VisibilityTest', function () {
beforeEach(async function (done) {
console.info("Flex_NoWrap_VisibilityTest beforeEach start");
let options = {
url: 'MainAbility/pages/Flex/Wrap/NoWrap/Flex_NoWrap_Visibility',
}
try {
router.clear();
let pages = router.getState();
console.info("get Flex_NoWrap_Visibility state pages:" + JSON.stringify(pages));
if (!("Flex_NoWrap_Visibility" == pages.name)) {
console.info("get Flex_NoWrap_Visibility state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Flex_NoWrap_Visibility page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Flex_NoWrap_Visibility page error:" + err);
}
console.info("Flex_NoWrap_VisibilityTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Flex_NoWrap_Visibility after each called");
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_2200
* @tc.name testWrapNoWrapTextVisibilityNoneOverflow
* @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('testWrapNoWrapTextVisibilityNoneOverflow', 0, async function (done) {
console.info('[testWrapNoWrapTextVisibilityNoneOverflow] START');
try {
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 firstText = CommonFunc.getComponentRect('NoWrap_Text_Visibility1');
let secondText = CommonFunc.getComponentRect('NoWrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('NoWrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(secondText.top).assertEqual(flexContainer.top);
expect(secondText.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(secondText.right - secondText.left)).assertEqual(Math.round(thirdText.right - thirdText.left));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(250));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(Math.round(secondText.right - secondText.left));
expect(secondText.left).assertEqual(flexContainer.left);
expect(thirdText.right).assertEqual(flexContainer.right);
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
} catch (err) {
console.error('[testWrapNoWrapTextVisibilityNoneOverflow] failed');
expect().assertFail();
}
console.info('[testWrapNoWrapTextVisibilityNoneOverflow] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_2300
* @tc.name testWrapNoWrapTextVisibilityNoneMeet
* @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('testWrapNoWrapTextVisibilityNoneMeet', 0, async function (done) {
console.info('[testWrapNoWrapTextVisibilityNoneMeet] START');
try {
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 firstText = CommonFunc.getComponentRect('NoWrap_Text_Visibility1');
let secondText = CommonFunc.getComponentRect('NoWrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('NoWrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
expect(flexContainer.left).assertEqual(secondText.left);
expect(secondText.right).assertEqual(thirdText.left);
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(secondText.right - secondText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(150));
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(200));
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
} catch (err) {
console.error('[testWrapNoWrapTextVisibilityNoneMeet] failed');
expect().assertFail();
}
console.info('[testWrapNoWrapTextVisibilityNoneMeet] END');
done();
});
/**
* @tc.number SUB_ACE_FLEXWRAP_NOWRAP_2400
* @tc.name testWrapNoWrapTextVisibilityHidden
* @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('testWrapNoWrapTextVisibilityHidden', 0, async function (done) {
console.info('[testWrapNoWrapTextVisibilityHidden] START');
try {
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 firstText = CommonFunc.getComponentRect('NoWrap_Text_Visibility1');
let secondText = CommonFunc.getComponentRect('NoWrap_Text_Visibility2');
let thirdText = CommonFunc.getComponentRect('NoWrap_Text_Visibility3');
let flexContainer = CommonFunc.getComponentRect('Flex_NoWrap_Visibility_Container01');
let flexContainerStrJson = getInspectorByKey('Flex_NoWrap_Visibility_Container01');
let flexContainerObj = JSON.parse(flexContainerStrJson);
expect(flexContainerObj.$type).assertEqual('Flex');
expect(flexContainerObj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap');
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(secondText.right - secondText.left)).assertEqual(vp2px(150));
expect(Math.round(thirdText.right - thirdText.left)).assertEqual(vp2px(150));
expect(thirdText.bottom).assertEqual(flexContainer.bottom);
expect(Math.round(flexContainer.right - thirdText.right)).assertEqual(vp2px(50));
expect(Math.round(secondText.left - flexContainer.left)).assertEqual(vp2px(150));
} catch (err) {
console.error('[testWrapNoWrapTextVisibilityHidden] failed');
expect().assertFail();
}
console.info('[testWrapNoWrapTextVisibilityHidden] END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册