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

!7470 test:add flex_alignContent_Center xts_act testcase

Merge pull request !7470 from zmshij/flexCenter
/*
* 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 AlignContentFlex_Center {
@State flexHeight: number = 300;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'height') {
this.flexHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('AlignContentFlex_Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexCenter_flex001_1')
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexCenter_flex001_2')
Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexCenter_flex001_3')
Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexCenter_flex001_4')
}
.key('AlignContentFlexCenter_flex001')
.width(400)
.height(this.flexHeight)
.backgroundColor(0xAFEEEE)
}.width('100%')
}
}
/*
* 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 AlignContent_Center_FlexP_Fixed_Margin {
@State textMargin: number = 5;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'margin') {
this.textMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Margin_1')
.margin(this.textMargin)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Margin_2')
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Margin_3')
Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Margin_4')
}
.key('AlignContent_Center_FlexP_Fixed_Margin_flex001')
.width(500)
.height(400)
.backgroundColor(0xAFEEEE)
}
.width('100%')
.alignItems(HorizontalAlign.Start)
}
}
/*
* 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.
*/
@Entry
@Component
struct AlignContent_Center_FlexP_Fixed_Offset {
alignContent: number
build() {
Column() {
Text('AlignContent_Center_FlexP_Fixed_Offset').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Offset_1')
.offset({ x: 15, y: 30 })
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Offset_2')
Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Offset_3')
Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Offset_4')
}
.key('AlignContent_Center_FlexP_Fixed_Offset_flex001')
.width(500)
.height(400)
.backgroundColor(0xAFEEEE)
}.width('100%')
}
}
/*
* 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 AlignContent_Center_FlexP_Fixed_Visibility {
@State textVisibility : number = Visibility.Visible;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'visibility') {
this.textVisibility = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('AlignContent_Center_FlexP_Fixed_Visibility').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Visibility_1')
.visibility(this.textVisibility)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Visibility_2')
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContent_Center_FlexP_Fixed_Visibility_3')
Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContent_Center_FlexP_Fixed_Visibility_4')
}
.key('AlignContent_Center_FlexP_Fixed_Visibility_flex001')
.width(500)
.height(400)
.backgroundColor(0xAFEEEE)
}.width('100%')
}
}
/*
* 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 AlignContent_Center_FlexP_fixed {
@State textHeight: number = 50;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'height') {
this.textHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('AlignContent_Center_FlexP_fixed').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(this.textHeight).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterP_fixed_1')
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexCenterP_fixed_2')
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterP_fixed_3')
Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContentFlexCenterP_fixed_4')
}
.key('AlignContentFlexCenterP_fixed_flex001')
.width(500)
.height(400)
.backgroundColor(0xAFEEEE)
}.width('100%')
}
}
/*
* 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.
*/
@Entry
@Component
struct AlignContent_FlexAlign_Center_Margin {
build() {
Column() {
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterMargin_flex_1')
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexCenterMargin_flex_2')
Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexCenterMargin_flex_3')
Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterMargin_flex_4')
}
.key('AlignContentFlexCenterMargin_flex')
.width(400)
.height(360)
.backgroundColor(0xAFEEEE)
.margin(15)
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.key('AlignContentFlexCenterMargin_Column')
}
}
/*
* 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 AlignContent_FlexAlign_Center_Margin_padding {
@State flexPadding: number = 10;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'padding') {
this.flexPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Column(){
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3)
.key('AlignContentFlexCenterMargin&padding_flex001_1')
Text('2').width(150).height(100).backgroundColor(0xD2B48C)
.key('AlignContentFlexCenterMargin&padding_flex001_2')
Text('3').width(150).height(150).backgroundColor(0xD2B48C)
.key('AlignContentFlexCenterMargin&padding_flex001_3')
Text('4').width(150).height(200).backgroundColor(0xF5DEB3)
.key('AlignContentFlexCenterMargin&padding_flex001_4')
}
.key('AlignContentFlexCenterMargin&padding_flex001')
.width(400)
.height(360)
.backgroundColor(0xAFEEEE)
.margin(10)
.padding(this.flexPadding)
}.key('AlignContentFlexCenterMargin&padding_Column_1')
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.key('AlignContentFlexCenterMargin&padding_Column')
}
}
/*
* 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 AlignContent_FlexAlign_Center_padding {
@State flexPadding: number = 10;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignContentFlex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'padding') {
this.flexPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('AlignContent_FlexAlign_Center_padding').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({
direction: FlexDirection.Row,
wrap: FlexWrap.Wrap,
alignContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterPadding_flex001_1')
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexCenterPadding_flex001_2')
Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexCenterPadding_flex001_3')
Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexCenterPadding_flex001_4')
}
.key('AlignContentFlexCenterPadding_flex001')
.width(400)
.height(360)
.backgroundColor(0xAFEEEE)
.padding(this.flexPadding)
}.width('100%')
}
}
/*
* 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContentFlex_Center() {
describe('AlignContentFlex_CenterTest', function () {
beforeEach(async function (done) {
console.info("AlignContentFlex_CenterTest beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContentFlex_Center',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContentFlex_Center state success " + JSON.stringify(pages));
if (!("AlignContentFlex_Center" == pages.name)) {
console.info("get AlignContentFlex_Center state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContentFlex_Center page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContentFlex_Center page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContentFlex_CenterTest beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContentFlex_Center after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0100
* @tc.name testAlignContentCenterFlexHeightSatisfy
* @tc.desc The Flex component alignContent property is set to FlexAlign.Center, and the height of the Flex
* component meets the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexHeightSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexHeightSatisfy START');
globalThis.value.message.notify({ name:'height', value:360 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenter_flex001');
let obj = JSON.parse(strJson);
console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj));
console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor));
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_4');
console.log('AlignContentFlexCenter_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex001.top);
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
console.info('testAlignContentCenterFlexHeightSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_Center_0200
* @tc.name testAlignContentCenterFlexHeightNoSatisfy
* @tc.desc The AlignContent property of the Flex component is set to FlexAlign.Center, and the height of the
* Flex component does not meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexHeightNoSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexHeightNoSatisfy START');
globalThis.value.message.notify({ name:'height', value:250 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenter_flex001');
let obj = JSON.parse(strJson);
let AlignContentFlexCenter_flex002 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenter_flex001_4');
console.log('AlignContentFlexCenter_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex002))
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_1.top).assertEqual(AlignContentFlexCenter_flex002.top);
expect(AlignContentFlexCenter_4.bottom).assertLarger(AlignContentFlexCenter_flex002.bottom);
expect(AlignContentFlexCenter_2.bottom).assertEqual(AlignContentFlexCenter_4.top);
console.info('testAlignContentCenterFlexHeightNoSatisfy 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContent_Center_FlexP_Fixed_Margin() {
describe('AlignContent_Center_FlexP_Fixed_Margin', function () {
beforeEach(async function (done) {
console.info("AlignContent_Center_FlexP_Fixed_Margin beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_Center_FlexP_Fixed_Margin',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_Center_FlexP_Fixed_Margin state success " + JSON.stringify(pages));
if (!("AlignContent_Center_FlexP_Fixed_Margin" == pages.name)) {
console.info("get AlignContent_Center_FlexP_Fixed_Margin state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_Center_FlexP_Fixed_Margin page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_Center_FlexP_Fixed_Margin page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_Center_FlexP_Fixed_Margin beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_Center_FlexP_Fixed_Margin after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_1100
* @tc.name testAlignContentCenterFlexfixedMarginSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, and set the margin for
* the subcomponents to meet the height requirements of the flex container
*/
it('testAlignContentCenterFlexfixedMarginSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedMarginSatisfy START');
globalThis.value.message.notify({ name:'margin', value:10 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Margin_flex001');
let obj = JSON.parse(strJson);
console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj));
console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor));
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_4');
console.log('AlignContent_Center_FlexP_Fixed_Margin_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_2.top - AlignContentFlexCenter_flex001.top);
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_2.top)).assertEqual(vp2px(10));
expect(Math.round(AlignContentFlexCenter_2.left - AlignContentFlexCenter_1.right)).assertEqual(vp2px(10));
expect(Math.round((AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)*10)/10).assertEqual(vp2px(25));
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_3.bottom);
console.info('testAlignContentCenterFlexfixedMarginSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_1200
* @tc.name testAlignContentCenterFlexfixedMarginNoSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, and set the margin for
* the subcomponents to prevent the flex container from meeting the height requirements.
*/
it('testAlignContentCenterFlexfixedMarginNoSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedMarginNoSatisfy START');
globalThis.value.message.notify({ name:'margin', value:100 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Margin_flex001');
let obj = JSON.parse(strJson);
let AlignContentFlexCenter_flex002 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Margin_4');
console.log('AlignContent_Center_FlexP_Fixed_Margin_flex002 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex002))
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex002.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_1.left - AlignContentFlexCenter_flex002.left)).assertEqual(vp2px(100));
expect(AlignContentFlexCenter_4.bottom).assertLarger(AlignContentFlexCenter_flex002.bottom);
expect(Math.round(AlignContentFlexCenter_3.top - AlignContentFlexCenter_1.bottom)).assertEqual(vp2px(100));
console.info('testAlignContentCenterFlexfixedMarginNoSatisfy 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
export default function AlignContent_Center_FlexP_Fixed_Offset() {
describe('AlignContent_Center_FlexP_Fixed_Offset', function () {
beforeEach(async function (done) {
console.info("AlignContent_Center_FlexP_Fixed_Offset beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_Center_FlexP_Fixed_Offset',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_Center_FlexP_Fixed_Offset state success " + JSON.stringify(pages));
if (!("AlignContent_Center_FlexP_Fixed_Offset" == pages.name)) {
console.info("get AlignContent_Center_FlexP_Fixed_Offset state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_Center_FlexP_Fixed_Offset page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_Center_FlexP_Fixed_Offset page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_Center_FlexP_Fixed_Offset beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_Center_FlexP_Fixed_Offset after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_1000
* @tc.name testAlignContentCenterFlexPfixedOffset
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center and set the offsize for
* the subcomponent
*/
it('testAlignContentCenterFlexPfixedOffset', 0, async function (done) {
console.info('testAlignContentCenterFlexPfixedOffset START');
let strJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Offset_flex001');
let obj = JSON.parse(strJson);
console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj));
console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor));
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Offset_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Offset_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Offset_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Offset_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Offset_4');
console.log('AlignContent_Center_FlexP_Fixed_Offset_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round(AlignContentFlexCenter_2.left - AlignContentFlexCenter_flex001.left)).assertEqual(vp2px(150));
expect(Math.round((AlignContentFlexCenter_4.top - AlignContentFlexCenter_flex001.top)*10)/10).assertEqual(vp2px(175));
expect(Math.round((AlignContentFlexCenter_1.right - AlignContentFlexCenter_2.left)*10)/10).assertEqual(vp2px(15));
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_2.top)).assertEqual(vp2px(30));
expect(AlignContentFlexCenter_2.top - AlignContentFlexCenter_flex001.top)
.assertEqual(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom);
expect(Math.round((AlignContentFlexCenter_2.top - AlignContentFlexCenter_flex001.top)*10)/10)
.assertEqual(vp2px(25));
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_3.bottom)
console.info('testAlignContentCenterFlexPfixedOffset 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContent_Center_FlexP_Fixed_Visibility() {
describe('AlignContent_Center_FlexP_Fixed_Visibility', function () {
beforeEach(async function (done) {
console.info("AlignContent_Center_FlexP_Fixed_Visibility beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_Center_FlexP_Fixed_Visibility',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_Center_FlexP_Fixed_Visibility state success " + JSON.stringify(pages));
if (!("AlignContent_Center_FlexP_Fixed_Visibility" == pages.name)) {
console.info("get AlignContent_Center_FlexP_Fixed_Visibility state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_Center_FlexP_Fixed_Visibility page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_Center_FlexP_Fixed_Visibility page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_Center_FlexP_Fixed_Visibility beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_Center_FlexP_Fixed_Visibility after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_1300
* @tc.name testAlignContentCenterFlexfixedVisibilityHidden
* @tc.desc The AlignContent property of the Flex component is set to FlexAlign. Center, and the visibility
* property of the sub component is set to Visibility.Hidden.
*/
it('testAlignContentCenterFlexfixedVisibilityHidden', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedVisibilityHidden START');
globalThis.value.message.notify({ name:'visibility', value:Visibility.Hidden })
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Visibility_flex001');
let obj = JSON.parse(strJson);
let textStrJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Visibility_1');
let textObj = JSON.parse(textStrJson);
console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj));
console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor));
console.info('Text1 textObj.$attrs is:' + JSON.stringify(textObj.$attrs));
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_flex001');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_4');
console.log('AlignContent_Center_FlexP_Fixed_Visibility_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(textObj.$attrs.visibility).assertEqual("Visibility.Hidden");
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_3.top - AlignContentFlexCenter_flex001.top);
expect(Math.round((AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)*10)/10).assertEqual(vp2px(25));
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_3.bottom);
expect(Math.round(AlignContentFlexCenter_2.left - AlignContentFlexCenter_flex001.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.top - AlignContentFlexCenter_2.top)).assertEqual(vp2px(150));
console.info('testAlignContentCenterFlexfixedVisibilityHidden END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_1400
* @tc.name testAlignContentCenterFlexfixedVisibilityNone
* @tc.desc The AlignContent property of the Flex component is set to FlexAlign. Center, and the visibility
* property of the sub component is set to Visibility.None
*/
it('testAlignContentCenterFlexfixedVisibilityNone', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedVisibilityNone START');
globalThis.value.message.notify({ name:'visibility', value:Visibility.None })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Visibility_flex001');
let obj = JSON.parse(strJson);
let textStrJson = getInspectorByKey('AlignContent_Center_FlexP_Fixed_Visibility_1');
let textObj = JSON.parse(textStrJson);
let AlignContentFlexCenter_flex002 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_flex001');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContent_Center_FlexP_Fixed_Visibility_4');
console.log('AlignContent_Center_FlexP_Fixed_Visibility_flex002 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex002))
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(textObj.$attrs.visibility).assertEqual("Visibility.None");
expect(AlignContentFlexCenter_flex002.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_3.top - AlignContentFlexCenter_flex002.top);
expect(Math.round(AlignContentFlexCenter_2.top - AlignContentFlexCenter_flex002.top))
.assertEqual(vp2px(100));
expect(AlignContentFlexCenter_2.top).assertEqual(AlignContentFlexCenter_3.top);
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_3.top);
expect(AlignContentFlexCenter_2.left).assertEqual(AlignContentFlexCenter_flex002.left);
console.info('testAlignContentCenterFlexfixedVisibilityNone 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContent_Center_FlexP_fixed() {
describe('AlignContent_Center_FlexP_fixed', function () {
beforeEach(async function (done) {
console.info("AlignContent_Center_FlexP_fixed beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_Center_FlexP_fixed',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_Center_FlexP_fixed state success " + JSON.stringify(pages));
if (!("AlignContent_Center_FlexP_fixed" == pages.name)) {
console.info("get AlignContent_Center_FlexP_fixed state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_Center_FlexP_fixed page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_Center_FlexP_fixed page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_Center_FlexP_fixed beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_Center_FlexP_fixed after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0800
* @tc.name testAlignContentCenterFlexfixedSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center to change the height of
* the subcomponent so that the flex container meets the height of the subcomponent.
*/
it('testAlignContentCenterFlexfixedSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedSatisfy START');
globalThis.value.message.notify({ name:'height', value:80 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterP_fixed_flex001');
let obj = JSON.parse(strJson);
console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj));
console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor));
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_4');
console.log('AlignContentFlexCenter_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(80));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex001.top);
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_3.bottom);
console.info('testAlignContentCenterFlexfixedSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0900
* @tc.name testAlignContentCenterFlexfixedNoSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, change the height of the
* subcomponent to make the flex container less than the height of the subcomponent.
*/
it('testAlignContentCenterFlexfixedNoSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexfixedNoSatisfy START');
globalThis.value.message.notify({ name:'height', value:300 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterP_fixed_flex001');
let obj = JSON.parse(strJson);
let AlignContentFlexCenter_flex002 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterP_fixed_4');
console.log('AlignContentFlexCenterP_fixed_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex002))
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(300));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_1.top).assertEqual(AlignContentFlexCenter_flex002.top);
expect(AlignContentFlexCenter_4.bottom).assertLarger(AlignContentFlexCenter_flex002.bottom);
expect(AlignContentFlexCenter_1.bottom).assertEqual(AlignContentFlexCenter_4.top);
console.info('testAlignContentCenterFlexfixedNoSatisfy 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
export default function AlignContent_FlexAlign_Center_Margin() {
describe('AlignContent_FlexAlign_Center_Margin', function () {
beforeEach(async function (done) {
console.info("AlignContent_FlexAlign_Center_Margin beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_FlexAlign_Center_Margin',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_FlexAlign_Center_Margin state success " + JSON.stringify(pages));
if (!("AlignContent_FlexAlign_Center_Margin" == pages.name)) {
console.info("get AlignContent_FlexAlign_Center_Margin state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_FlexAlign_Center_Margin page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_FlexAlign_Center_Margin page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_FlexAlign_Center_Margin beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_FlexAlign_Center_Margin after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0500
* @tc.name testAlignContentCenterFlexMarginSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, and set the margin for
* the flex component to meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexMarginSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexMarginSatisfy START');
let strJson = getInspectorByKey('AlignContentFlexCenterMargin_flex');
let obj = JSON.parse(strJson);
let Center_Margin_Column = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_Column');
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_flex');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_flex_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_flex_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_flex_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin_flex_4');
console.log('AlignContentFlexCenterMargin_flex rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenterMargin_flex_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenterMargin_flex_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenterMargin_flex_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenterMargin_flex_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round((AlignContentFlexCenter_flex001.top - Center_Margin_Column.top)*10)/10)
.assertEqual(vp2px(15))
expect(Math.round((AlignContentFlexCenter_1.top - Center_Margin_Column.top)*10)/10)
.assertEqual(vp2px(45))
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex001.top);
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex001.top))
.assertEqual(vp2px(30));
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
console.info('testAlignContentCenterFlexMarginSatisfy 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContent_FlexAlign_Center_Margin_padding() {
describe('AlignContent_FlexAlign_Center_Margin_padding', function () {
beforeEach(async function (done) {
console.info("AlignContent_FlexAlign_Center_Margin_padding beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_FlexAlign_Center_Margin_padding',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_FlexAlign_Center_Margin_padding state success " + JSON.stringify(pages));
if (!("AlignContent_FlexAlign_Center_Margin_padding" == pages.name)) {
console.info("get AlignContent_FlexAlign_Center_Margin_padding state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_FlexAlign_Center_Margin_padding page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_FlexAlign_Center_Margin_padding page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_FlexAlign_Center_Margin_padding beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_FlexAlign_Center_Margin_padding after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0600
* @tc.name testAlignContentCenterFlexMargin&PaddingNOSatisfy
* @tc.desc The AlignContent property of the Flex component is set to FlexAlign.Center, while the margin and
* padding settings of the flex component do not meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexMargin&PaddingNOSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexMargin&PaddingNOSatisfy START');
globalThis.value.message.notify({ name:'padding', value:40 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterMargin&padding_flex001');
let obj = JSON.parse(strJson);
let Center_Margin_Column_1 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_Column_1');
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_4');
console.log('AlignContentFlexCenterMargin&padding_flex001 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenterMargin&padding_flex001_1 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenterMargin&padding_flex001_2 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenterMargin&padding_flex001_3 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenterMargin&padding_flex001_4 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round(AlignContentFlexCenter_flex001.top - Center_Margin_Column_1.top)).assertEqual(vp2px(10))
expect(Math.round(AlignContentFlexCenter_1.top - Center_Margin_Column_1.top)).assertEqual(vp2px(50))
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom).assertLess(vp2px(40));
console.info('testAlignContentCenterFlexMargin&PaddingNOSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0700
* @tc.name testAlignContentCenterFlexMargin&PaddingSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, and set the margin and
* padding for the flex component to meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexMargin&PaddingSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexMargin&PaddingSatisfy START');
globalThis.value.message.notify({ name:'padding', value:15 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterMargin&padding_flex001');
let obj = JSON.parse(strJson);
let Center_Margin_Column_2 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_Column_1');
let AlignContentFlexCenter_flex002 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_flex001');
let AlignContentFlexCenter_1 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc
.getComponentRect('AlignContentFlexCenterMargin&padding_flex001_4');
console.log('AlignContentFlexCenterMargin&padding_flex001 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_flex002));
console.log('AlignContentFlexCenterMargin&padding_flex001_1 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenterMargin&padding_flex001_2 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenterMargin&padding_flex001_3 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenterMargin&padding_flex001_4 rect_value is:' +
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round(AlignContentFlexCenter_flex002.top - Center_Margin_Column_2.top))
.assertEqual(vp2px(10))
expect(Math.round(AlignContentFlexCenter_1.top - Center_Margin_Column_2.top))
.assertEqual(vp2px(40))
expect(AlignContentFlexCenter_flex002.bottom - AlignContentFlexCenter_4.bottom)
.assertEqual(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex002.top);
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex002.top))
.assertEqual(vp2px(30));
console.info('testAlignContentCenterFlexMargin&PaddingSatisfy 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 '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common'
import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager';
export default function AlignContent_FlexAlign_Center_padding() {
describe('AlignContent_FlexAlign_Center_padding', function () {
beforeEach(async function (done) {
console.info("AlignContent_FlexAlign_Center_padding beforeEach start")
let options = {
uri: 'MainAbility/pages/Flex/alignContent/Center/AlignContent_FlexAlign_Center_padding',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get AlignContent_FlexAlign_Center_padding state success " + JSON.stringify(pages));
if (!("AlignContent_FlexAlign_Center_padding" == pages.name)) {
console.info("get AlignContent_FlexAlign_Center_padding state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push AlignContent_FlexAlign_Center_padding page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignContent_FlexAlign_Center_padding page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("AlignContent_FlexAlign_Center_padding beforeEach end")
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("AlignContent_FlexAlign_Center_padding after each called");
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0300
* @tc.name testAlignContentCenterFlexPaddingNoSatisfy
* @tc.desc The AlignContent property of the Flex component is set to FlexAlign.Center, and the padding
* setting of the Flex component does not meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexPaddingNoSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexPaddingNoSatisfy START');
globalThis.value.message.notify({ name:'padding', value:40 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterPadding_flex001');
let obj = JSON.parse(strJson);
let AlignContentFlexCenter_flex001 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_4');
console.log('AlignContentFlexCenterPadding_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_flex001));
console.log('AlignContentFlexCenterPadding_flex001_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenterPadding_flex001_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenterPadding_flex001_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenterPadding_flex001_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenter_flex001.top)).assertEqual(vp2px(40));
expect(AlignContentFlexCenter_flex001.bottom - AlignContentFlexCenter_4.bottom).assertLess(vp2px(40));
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
console.info('testAlignContentCenterFlexPaddingNoSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_FLEXALIGNCONTENT_CENTER_0400
* @tc.name testAlignContentCenterFlexPaddingSatisfy
* @tc.desc Set the AlignContent property of the Flex component to FlexAlign.Center, and set the padding for
* the Flex component to meet the size requirements of the subcomponent.
*/
it('testAlignContentCenterFlexPaddingSatisfy', 0, async function (done) {
console.info('testAlignContentCenterFlexPaddingSatisfy START');
globalThis.value.message.notify({ name:'padding', value:15 })
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('AlignContentFlexCenterPadding_flex001');
let obj = JSON.parse(strJson);
let AlignContentFlexCenterPadding_flex002 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001');
let AlignContentFlexCenter_1 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_1');
let AlignContentFlexCenter_2 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_2');
let AlignContentFlexCenter_3 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_3');
let AlignContentFlexCenter_4 = CommonFunc.getComponentRect('AlignContentFlexCenterPadding_flex001_4');
console.log('AlignContentFlexCenterPadding_flex001 rect_value is:'+
JSON.stringify(AlignContentFlexCenterPadding_flex002))
console.log('AlignContentFlexCenter_1 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_1));
console.log('AlignContentFlexCenter_2 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_2));
console.log('AlignContentFlexCenter_3 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_3));
console.log('AlignContentFlexCenter_4 rect_value is:'+
JSON.stringify(AlignContentFlexCenter_4));
expect(Math.round(AlignContentFlexCenter_1.bottom - AlignContentFlexCenter_1.top)).assertEqual(vp2px(50));
expect(Math.round(AlignContentFlexCenter_2.bottom - AlignContentFlexCenter_2.top)).assertEqual(vp2px(100));
expect(Math.round(AlignContentFlexCenter_3.bottom - AlignContentFlexCenter_3.top)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.bottom - AlignContentFlexCenter_4.top)).assertEqual(vp2px(200));
expect(Math.round(AlignContentFlexCenter_1.right - AlignContentFlexCenter_1.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_2.right - AlignContentFlexCenter_2.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_3.right - AlignContentFlexCenter_3.left)).assertEqual(vp2px(150));
expect(Math.round(AlignContentFlexCenter_4.right - AlignContentFlexCenter_4.left)).assertEqual(vp2px(150));
expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row");
expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.Center");
expect(AlignContentFlexCenter_4.top).assertEqual(AlignContentFlexCenter_2.bottom);
expect(Math.round(AlignContentFlexCenter_1.top - AlignContentFlexCenterPadding_flex002.top)).assertEqual(vp2px(30));
expect(Math.round(AlignContentFlexCenterPadding_flex002.bottom - AlignContentFlexCenter_4.bottom)).assertEqual(vp2px(30));
console.info('testAlignContentCenterFlexPaddingSatisfy END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册