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

!7442 test:Add flex_justifyContent_Center xts_acts test

Merge pull request !7442 from 王倩/flex_Center
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddAlign {
@State DadAddAlign: number = Alignment.TopStart
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_NoSpace onPageShow')
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'DadAddAlign') {
this.DadAddAlign = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_AddAlign_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddAlign_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddAlign_013")
}
.key("Center_AddAlign_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
.align(this.DadAddAlign)
}
.width("100%")
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddAllSpace {
@State DadAllSpace: number = 10
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddAllSpace onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'DadAllSpace') {
this.DadAllSpace = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_AddAllSpace_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddAllSpace_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddAllSpace_013")
}
.key("Center_AddAllSpace_01")
.width(500)
.height(200)
.padding(this.DadAllSpace)
.margin(10)
.backgroundColor(0xAFEEEE)
}
.key("Center_AddAllSpace_01_Box")
.width("100%")
.alignItems(HorizontalAlign.Start)
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddLayoutWeight {
@State OneLayoutWeight1: number = 1;
@State OneLayoutWeight2: number = 1;
@State OneLayoutWeight3: number = 1;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddLayoutWeight onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'OneLayoutWeight1') {
this.OneLayoutWeight1 = message.value;
}
if (message.name == 'OneLayoutWeight2') {
this.OneLayoutWeight2 = message.value;
}
if (message.name == 'OneLayoutWeight3') {
this.OneLayoutWeight3 = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1')
.width(150)
.height(50)
.backgroundColor(0xF5DEB3)
.key("Center_AddLayoutWeight_011")
.layoutWeight(this.OneLayoutWeight1)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddLayoutWeight_012")
.layoutWeight(this.OneLayoutWeight2)
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddLayoutWeight_013")
.layoutWeight(this.OneLayoutWeight3)
}
.key("Center_AddLayoutWeight_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
}
.width("100%")
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddMargin {
@State DadMargin: number = 10
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddMargin onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'DadMargin') {
this.DadMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_AddMargin_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddMargin_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddMargin_013")
}
.key("Center_AddMargin_01")
.width(500)
.height(200)
.margin(this.DadMargin)
.backgroundColor(0xAFEEEE)
}
.key("Center_AddMargin_01_Box")
.width("100%")
.alignItems(HorizontalAlign.Start)
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOffset {
@State OneOffset: any = { x: 0, y: 0 }
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOffset onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'OneOffset') {
this.OneOffset = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_AddOffset_011")
.offset(this.OneOffset)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddOffset_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddOffset_013")
}
.key("Center_AddOffset_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
}
.width("100%")
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOneMargin {
@State OneMargin: number = 10
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOneMargin onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'OneMargin') {
this.OneMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1')
.width(150)
.height(50)
.backgroundColor(0xF5DEB3)
.key("Center_AddOneMargin_011")
.margin(this.OneMargin)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddOneMargin_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddOneMargin_013")
}
.key("Center_AddOneMargin_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
}
.width("100%")
.alignItems(HorizontalAlign.Start)
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOneWidth {
@State OneWidth: number = 100
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOneWidth onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'OneWidth') {
this.OneWidth = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(this.OneWidth).height(50).backgroundColor(0xF5DEB3).key("Center_AddOneWidth_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddOneWidth_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddOneWidth_013")
}
.key("Center_AddOneWidth_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
}
.width("100%")
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddPadding {
@State DadPadding: number = 10
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddPadding onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'DadPadding') {
this.DadPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction:FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_AddPadding_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddPadding_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddPadding_013")
}.key("Center_AddPadding_01")
.width(500)
.height(200)
.padding(this.DadPadding)
.backgroundColor(0xAFEEEE)
}
.width('100%')
.height('100%')
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddVisibility {
@State OneVisibility: number = Visibility.Visible;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddVisibility onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'OneVisibility') {
this.OneVisibility = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1')
.width(150)
.height(50)
.backgroundColor(0xF5DEB3)
.key("Center_AddVisibility_011")
.visibility(this.OneVisibility)
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_AddVisibility_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_AddVisibility_013")
}
.key("Center_AddVisibility_01")
.width(500)
.height(200)
.backgroundColor(0xAFEEEE)
}
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_NoSpace {
@State DadWidth: number = 200
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_NoSpace onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'DadWidth') {
this.DadWidth = message.value;
}
}
this.messageManager.registerCallback(callback);
}
@State justifyContent: FlexAlign = FlexAlign.Center
build() {
Column() {
Text('justifyContent:FlexAlign.Center').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: this.justifyContent, direction: FlexDirection.Row }) {
Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key("Center_NoSpace_011")
Text('2').width(150).height(100).backgroundColor(0xD2B48C).key("Center_NoSpace_012")
Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key("Center_NoSpace_013")
}
.key("Center_NoSpace_01")
.width(this.DadWidth)
.height(200)
.backgroundColor(0xAFEEEE)
}
}
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddAlign() {
describe('AlignCenter_AddAlign', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddAlign'
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddAlign state success " + JSON.stringify(pages));
if (!("AlignCenter_AddAlign" == pages.name)) {
console.info("get AlignCenter_AddAlign state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddAlign page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddAlign page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddAlign after each called")
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0800
* @tc.name Align_Center_Row_AddAlign
* @tc.desc Setting generic properties does not take effect, and owned properties take precedence
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0800', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0800] START');
globalThis.value.message.notify({name:'DadAlign', value:Alignment.BottomEnd})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddAlign_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddAlign_011 = CommonFunc.getComponentRect('Center_AddAlign_011')
let Center_AddAlign_012 = CommonFunc.getComponentRect('Center_AddAlign_012')
let Center_AddAlign_013 = CommonFunc.getComponentRect('Center_AddAlign_013')
let Center_AddAlign_01 = CommonFunc.getComponentRect('Center_AddAlign_01')
expect(Center_AddAlign_011.top).assertEqual(Center_AddAlign_012.top);
expect(Center_AddAlign_012.top).assertEqual(Center_AddAlign_013.top);
expect(Center_AddAlign_011.top).assertEqual(Center_AddAlign_01.top);
expect(Center_AddAlign_012.left).assertEqual(Center_AddAlign_011.right);
expect(Center_AddAlign_013.left).assertEqual(Center_AddAlign_012.right);
expect(Center_AddAlign_011.left - Center_AddAlign_01.left).assertEqual(vp2px(25));
expect(Center_AddAlign_01.right - Center_AddAlign_013.right).assertEqual(vp2px(25));
expect(Center_AddAlign_011.right - Center_AddAlign_011.left).assertEqual(vp2px(150));
expect(Center_AddAlign_012.right - Center_AddAlign_012.left).assertEqual(vp2px(150));
expect(Center_AddAlign_013.right - Center_AddAlign_013.left).assertEqual(vp2px(150));
expect(Center_AddAlign_011.bottom - Center_AddAlign_011.top).assertEqual(vp2px(50));
expect(Center_AddAlign_012.bottom - Center_AddAlign_012.top).assertEqual(vp2px(100));
expect(Center_AddAlign_013.bottom - Center_AddAlign_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0800] END');
done()
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddAllSpace() {
describe('AlignCenter_AddAllSpace', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddAllSpace'
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddAllSpace state success " + JSON.stringify(pages));
if (!("AlignCenter_AddAllSpace" == pages.name)) {
console.info("get AlignCenter_AddAllSpace state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddAllSpace page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignAlignCenter_AddAllSpace page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignAlignCenter_AddAllSpace after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0600
* @tc.name Align_Center_Row_AddAllSpace
* @tc.desc After setting margin, after subtracting the padding from the layout space of the parent component,
* the interface display of the spindle layout that does not meet the sub-component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0600', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0600] START');
globalThis.value.message.notify({name:'DadAllSpace', value:30})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddAllSpace_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddAllSpace_011 = CommonFunc.getComponentRect('Center_AddAllSpace_011');
let Center_AddAllSpace_012 = CommonFunc.getComponentRect('Center_AddAllSpace_012');
let Center_AddAllSpace_013 = CommonFunc.getComponentRect('Center_AddAllSpace_013');
let Center_AddAllSpace_01 = CommonFunc.getComponentRect('Center_AddAllSpace_01');
let Center_AddAllSpace_01_Box = CommonFunc.getComponentRect('Center_AddAllSpace_01_Box');
expect(Center_AddAllSpace_011.top).assertEqual(Center_AddAllSpace_012.top);
expect(Center_AddAllSpace_012.top).assertEqual(Center_AddAllSpace_013.top);
expect(Center_AddAllSpace_012.left).assertEqual(Center_AddAllSpace_011.right);
expect(Center_AddAllSpace_013.left).assertEqual(Center_AddAllSpace_012.right);
expect(Center_AddAllSpace_011.top - Center_AddAllSpace_01.top).assertEqual(vp2px(30));
expect(Center_AddAllSpace_011.left - Center_AddAllSpace_01.left).assertEqual(vp2px(30));
expect(Center_AddAllSpace_01.right - Center_AddAllSpace_013.right).assertEqual(vp2px(30));
expect(Center_AddAllSpace_01.top - Center_AddAllSpace_01_Box.top).assertEqual(vp2px(10));
expect(Center_AddAllSpace_01.left - Center_AddAllSpace_01_Box.left).assertEqual(vp2px(10));
expect(Center_AddAllSpace_011.bottom - Center_AddAllSpace_011.top).assertEqual(vp2px(50));
expect(Center_AddAllSpace_012.bottom - Center_AddAllSpace_012.top).assertEqual(vp2px(100));
expect(Center_AddAllSpace_013.bottom - Center_AddAllSpace_013.top).assertEqual(vp2px(150));
expect(Center_AddAllSpace_011.right - Center_AddAllSpace_011.left).assertEqual(vp2px(440/3));
expect(Center_AddAllSpace_012.right - Center_AddAllSpace_012.left).assertEqual(vp2px(440/3));
expect(Center_AddAllSpace_013.right - Center_AddAllSpace_013.left).assertEqual(vp2px(440/3));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0600] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0700
* @tc.name Align_Center_Row_AddAllSpace
* @tc.desc After setting margin, the interface that satisfies the spindle layout of the child component is
* displayed after subtracting the padding from the layout space of the parent component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0700', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0700] START');
globalThis.value.message.notify({name:'DadAllSpace', value:20});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddAllSpace_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddAllSpace_011 = CommonFunc.getComponentRect('Center_AddAllSpace_011');
let Center_AddAllSpace_012 = CommonFunc.getComponentRect('Center_AddAllSpace_012');
let Center_AddAllSpace_013 = CommonFunc.getComponentRect('Center_AddAllSpace_013');
let Center_AddAllSpace_01 = CommonFunc.getComponentRect('Center_AddAllSpace_01');
let Center_AddAllSpace_01_Box = CommonFunc.getComponentRect('Center_AddAllSpace_01_Box');
expect(Center_AddAllSpace_011.top).assertEqual(Center_AddAllSpace_012.top);
expect(Center_AddAllSpace_012.top).assertEqual(Center_AddAllSpace_013.top);
expect(Center_AddAllSpace_012.left).assertEqual(Center_AddAllSpace_011.right);
expect(Center_AddAllSpace_013.left).assertEqual(Center_AddAllSpace_012.right);
expect(Center_AddAllSpace_011.top - Center_AddAllSpace_01.top).assertEqual(vp2px(20));
expect(Center_AddAllSpace_011.left - Center_AddAllSpace_01.left).assertEqual(vp2px(25));
expect(Center_AddAllSpace_01.right - Center_AddAllSpace_013.right).assertEqual(vp2px(25));
expect(Center_AddAllSpace_01.top - Center_AddAllSpace_01_Box.top).assertEqual(vp2px(10));
expect(Center_AddAllSpace_01.left - Center_AddAllSpace_01_Box.left).assertEqual(vp2px(10));
expect(Center_AddAllSpace_011.bottom - Center_AddAllSpace_011.top).assertEqual(vp2px(50));
expect(Center_AddAllSpace_012.bottom - Center_AddAllSpace_012.top).assertEqual(vp2px(100));
expect(Center_AddAllSpace_013.bottom - Center_AddAllSpace_013.top).assertEqual(vp2px(150));
expect(Center_AddAllSpace_011.right - Center_AddAllSpace_011.left).assertEqual(vp2px(150));
expect(Center_AddAllSpace_012.right - Center_AddAllSpace_012.left).assertEqual(vp2px(150));
expect(Center_AddAllSpace_013.right - Center_AddAllSpace_013.left).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0700] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddLayoutWeight() {
describe('AlignCenter_AddLayoutWeight', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddLayoutWeight'
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddLayoutWeight state success " + JSON.stringify(pages));
if (!("AlignCenter_AddLayoutWeight" == pages.name)) {
console.info("get AlignCenter_AddLayoutWeight state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddLayoutWeight page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddLayoutWeight page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddLayoutWeight after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1200
* @tc.name Align_Center_Row_AddLayoutWeight
* @tc.desc The interface displays all subcomponents that set different layoutWeight properties
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1200', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1200] START');
globalThis.value.message.notify({name:'OneLayoutWeight1', value:1});
globalThis.value.message.notify({name:'OneLayoutWeight2', value:2});
globalThis.value.message.notify({name:'OneLayoutWeight3', value:2});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddLayoutWeight_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddLayoutWeight_011 = CommonFunc.getComponentRect('Center_AddLayoutWeight_011');
let Center_AddLayoutWeight_012 = CommonFunc.getComponentRect('Center_AddLayoutWeight_012');
let Center_AddLayoutWeight_013 = CommonFunc.getComponentRect('Center_AddLayoutWeight_013');
let Center_AddLayoutWeight_01 = CommonFunc.getComponentRect('Center_AddLayoutWeight_01');
expect(Center_AddLayoutWeight_011.top).assertEqual(Center_AddLayoutWeight_012.top);
expect(Center_AddLayoutWeight_013.top).assertEqual(Center_AddLayoutWeight_012.top);
expect(Center_AddLayoutWeight_011.top).assertEqual(Center_AddLayoutWeight_01.top);
expect(Center_AddLayoutWeight_011.right).assertEqual(Center_AddLayoutWeight_012.left);
expect(Center_AddLayoutWeight_012.right).assertEqual(Center_AddLayoutWeight_013.left);
expect(Center_AddLayoutWeight_011.left).assertEqual(Center_AddLayoutWeight_01.left);
expect(Center_AddLayoutWeight_013.right).assertEqual(Center_AddLayoutWeight_01.right);
expect(Center_AddLayoutWeight_011.right - Center_AddLayoutWeight_011.left).assertEqual(vp2px(100));
expect(Center_AddLayoutWeight_012.right - Center_AddLayoutWeight_012.left).assertEqual(vp2px(200));
expect(Center_AddLayoutWeight_013.right - Center_AddLayoutWeight_013.left).assertEqual(vp2px(200));
expect(Center_AddLayoutWeight_011.bottom - Center_AddLayoutWeight_011.top).assertEqual(vp2px(50));
expect(Center_AddLayoutWeight_012.bottom - Center_AddLayoutWeight_012.top).assertEqual(vp2px(100));
expect(Center_AddLayoutWeight_013.bottom - Center_AddLayoutWeight_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1200] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1600
* @tc.name Align_Center_Row_AddLayoutWeight
* @tc.desc Some subcomponents are displayed with different layoutWeight properties
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1600', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1600] START');
globalThis.value.message.notify({name:'OneLayoutWeight1', value:1});
globalThis.value.message.notify({name:'OneLayoutWeight2', value:2});
globalThis.value.message.notify({name:'OneLayoutWeight3', value:0});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddLayoutWeight_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddLayoutWeight_011 = CommonFunc.getComponentRect('Center_AddLayoutWeight_011');
let Center_AddLayoutWeight_012 = CommonFunc.getComponentRect('Center_AddLayoutWeight_012');
let Center_AddLayoutWeight_013 = CommonFunc.getComponentRect('Center_AddLayoutWeight_013');
let Center_AddLayoutWeight_01 = CommonFunc.getComponentRect('Center_AddLayoutWeight_01');
expect(Center_AddLayoutWeight_011.top).assertEqual(Center_AddLayoutWeight_012.top);
expect(Center_AddLayoutWeight_013.top).assertEqual(Center_AddLayoutWeight_012.top);
expect(Center_AddLayoutWeight_011.top).assertEqual(Center_AddLayoutWeight_01.top);
expect(Center_AddLayoutWeight_011.right).assertEqual(Center_AddLayoutWeight_012.left);
expect(Center_AddLayoutWeight_012.right).assertEqual(Center_AddLayoutWeight_013.left);
expect(Center_AddLayoutWeight_011.left).assertEqual(Center_AddLayoutWeight_01.left);
expect(Center_AddLayoutWeight_013.right).assertEqual(Center_AddLayoutWeight_01.right);
let oneWidth = Center_AddLayoutWeight_011.right - Center_AddLayoutWeight_011.left;
let twoWidth = Center_AddLayoutWeight_012.right - Center_AddLayoutWeight_012.left;
expect(twoWidth / oneWidth).assertEqual(2);
expect(twoWidth + oneWidth).assertEqual(vp2px(350));
expect(Center_AddLayoutWeight_013.right - Center_AddLayoutWeight_013.left).assertEqual(vp2px(150));
expect(Center_AddLayoutWeight_011.bottom - Center_AddLayoutWeight_011.top).assertEqual(vp2px(50));
expect(Center_AddLayoutWeight_012.bottom - Center_AddLayoutWeight_012.top).assertEqual(vp2px(100));
expect(Center_AddLayoutWeight_013.bottom - Center_AddLayoutWeight_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1600] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddMargin() {
describe('AlignCenter_AddMargin', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddMargin',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddMargin state success " + JSON.stringify(pages));
if (!("AlignCenter_AddMargin" == pages.name)) {
console.info("get AlignCenter_AddMargin state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddMargin page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddMargin page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddMargin after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0500
* @tc.name Align_Center_Row_AddMargin
* @tc.desc The interface display where the child component is offset by the margin setting of the parent
* component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0500', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0500] START');
globalThis.value.message.notify({name:'DadMargin', value:20});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddMargin_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddMargin_011 = CommonFunc.getComponentRect('Center_AddMargin_011');
let Center_AddMargin_012 = CommonFunc.getComponentRect('Center_AddMargin_012');
let Center_AddMargin_013 = CommonFunc.getComponentRect('Center_AddMargin_013');
let Center_AddMargin_01 = CommonFunc.getComponentRect('Center_AddMargin_01');
let Center_AddMargin_01_Box = CommonFunc.getComponentRect('Center_AddMargin_01_Box');
expect(Center_AddMargin_011.top).assertEqual(Center_AddMargin_012.top);
expect(Center_AddMargin_011.top).assertEqual(Center_AddMargin_01.top);
expect(Center_AddMargin_013.top).assertEqual(Center_AddMargin_012.top);
expect(Center_AddMargin_012.left).assertEqual(Center_AddMargin_011.right);
expect(Center_AddMargin_013.left).assertEqual(Center_AddMargin_012.right);
expect(Center_AddMargin_01.left - Center_AddMargin_01_Box.left).assertEqual(vp2px(20));
expect(Center_AddMargin_01.top - Center_AddMargin_01_Box.top).assertEqual(vp2px(20));
expect(Center_AddMargin_011.left - Center_AddMargin_01.left).assertEqual(vp2px(25));
expect(Center_AddMargin_01.right - Center_AddMargin_013.right).assertEqual(vp2px(25));
expect(Center_AddMargin_011.bottom - Center_AddMargin_011.top).assertEqual(vp2px(50));
expect(Center_AddMargin_012.bottom - Center_AddMargin_012.top).assertEqual(vp2px(100));
expect(Center_AddMargin_013.bottom - Center_AddMargin_013.top).assertEqual(vp2px(150));
expect(Center_AddMargin_011.right - Center_AddMargin_011.left).assertEqual(vp2px(150));
expect(Center_AddMargin_012.right - Center_AddMargin_012.left).assertEqual(vp2px(150));
expect(Center_AddMargin_013.right - Center_AddMargin_013.left).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0500] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOffset() {
describe('AlignCenter_AddOffset', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddOffset'
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddOffset state success " + JSON.stringify(pages));
if (!("AlignCenter_AddOffset" == pages.name)) {
console.info("get AlignCenter_AddOffset state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddOffset page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddOffset page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddOffset after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0900
* @tc.name Align_Center_Row_AddOffset
* @tc.desc The interface display of the component that sets the offset position when drawing
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0900', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0900] START');
globalThis.value.message.notify({name:'OneOffset', value:{ x: 10, y: 15 }});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddAlign_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddOffset_011 = CommonFunc.getComponentRect('Center_AddOffset_011');
let Center_AddOffset_012 = CommonFunc.getComponentRect('Center_AddOffset_012');
let Center_AddOffset_013 = CommonFunc.getComponentRect('Center_AddOffset_013');
let Center_AddOffset_01 = CommonFunc.getComponentRect('Center_AddOffset_01');
expect(Center_AddOffset_011.top - Center_AddOffset_01.top).assertEqual(vp2px(15));
expect(Center_AddOffset_011.left - Center_AddOffset_01.left).assertEqual(vp2px(35));
expect(Center_AddOffset_01.right - Center_AddOffset_013.right).assertEqual(vp2px(25));
expect(Center_AddOffset_012.top).assertEqual(Center_AddOffset_013.top);
expect(Center_AddOffset_012.top).assertEqual(Center_AddOffset_01.top);
expect(Center_AddOffset_013.left).assertEqual(Center_AddOffset_012.right);
expect(Center_AddOffset_011.right - Center_AddOffset_011.left).assertEqual(vp2px(150));
expect(Center_AddOffset_012.right - Center_AddOffset_012.left).assertEqual(vp2px(150));
expect(Center_AddOffset_013.right - Center_AddOffset_013.left).assertEqual(vp2px(150));
expect(Center_AddOffset_011.bottom - Center_AddOffset_011.top).assertEqual(vp2px(50));
expect(Center_AddOffset_012.bottom - Center_AddOffset_012.top).assertEqual(vp2px(100));
expect(Center_AddOffset_013.bottom - Center_AddOffset_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0900] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOneMargin() {
describe('AlignCenter_AddOneMargin', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddOneMargin',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddOneMargin state success " + JSON.stringify(pages));
if (!("AlignCenter_AddOneMargin" == pages.name)) {
console.info("get AlignCenter_AddOneMargin state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddOneMargin page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddOneMargin page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddOneMargin after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1400
* @tc.name Align_Center_Row_AddOneMargin
* @tc.desc After setting margin for the first subcomponent, the layout of the parent component's spindle
* meets the interface display of the subcomponent's layout
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1400', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1400] START');
globalThis.value.message.notify({name:'OneMargin', value:20});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddOneMargin_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddOneMargin_011 = CommonFunc.getComponentRect('Center_AddOneMargin_011');
let Center_AddOneMargin_012 = CommonFunc.getComponentRect('Center_AddOneMargin_012');
let Center_AddOneMargin_013 = CommonFunc.getComponentRect('Center_AddOneMargin_013');
let Center_AddOneMargin_01 = CommonFunc.getComponentRect('Center_AddOneMargin_01');
expect(Center_AddOneMargin_012.top).assertEqual(Center_AddOneMargin_01.top);
expect(Center_AddOneMargin_013.top).assertEqual(Center_AddOneMargin_012.top);
expect(Center_AddOneMargin_013.left).assertEqual(Center_AddOneMargin_012.right);
expect(Center_AddOneMargin_011.left - Center_AddOneMargin_01.left).assertEqual(vp2px(25));
expect(Center_AddOneMargin_011.top - Center_AddOneMargin_01.top).assertEqual(vp2px(20));
expect(Center_AddOneMargin_012.left - Center_AddOneMargin_011.right).assertEqual(vp2px(20));
expect(Center_AddOneMargin_01.right - Center_AddOneMargin_013.right).assertEqual(vp2px(5));
expect(Center_AddOneMargin_011.bottom - Center_AddOneMargin_011.top).assertEqual(vp2px(50));
expect(Center_AddOneMargin_012.bottom - Center_AddOneMargin_012.top).assertEqual(vp2px(100));
expect(Center_AddOneMargin_013.bottom - Center_AddOneMargin_013.top).assertEqual(vp2px(150));
expect(Center_AddOneMargin_011.right - Center_AddOneMargin_011.left).assertEqual(vp2px(150));
expect(Center_AddOneMargin_012.right - Center_AddOneMargin_012.left).assertEqual(vp2px(150));
expect(Center_AddOneMargin_013.right - Center_AddOneMargin_013.left).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1400] END');
done();
})
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1500
* @tc.name Align_Center_Row_AddOneMargin
* @tc.desc After setting margin for the first subcomponent, the layout of the parent component's spindle does
* not meet the interface display of the subcomponent's layout
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1500', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1500] START');
globalThis.value.message.notify({name:'OneMargin', value:30});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddOneMargin_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddOneMargin_011 = CommonFunc.getComponentRect('Center_AddOneMargin_011');
let Center_AddOneMargin_012 = CommonFunc.getComponentRect('Center_AddOneMargin_012');
let Center_AddOneMargin_013 = CommonFunc.getComponentRect('Center_AddOneMargin_013');
let Center_AddOneMargin_01 = CommonFunc.getComponentRect('Center_AddOneMargin_01');
expect(Center_AddOneMargin_01.top).assertEqual(Center_AddOneMargin_012.top);
expect(Center_AddOneMargin_013.top).assertEqual(Center_AddOneMargin_012.top);
expect(Center_AddOneMargin_011.left - Center_AddOneMargin_01.left).assertEqual(vp2px(500/17));
expect(Center_AddOneMargin_011.top - Center_AddOneMargin_01.top).assertEqual(vp2px(30));
expect(Center_AddOneMargin_012.left - Center_AddOneMargin_011.right).assertEqual(vp2px(500/17));
expect(Center_AddOneMargin_012.right).assertEqual(Center_AddOneMargin_013.left);
expect(Center_AddOneMargin_011.bottom - Center_AddOneMargin_011.top).assertEqual(vp2px(50));
expect(Center_AddOneMargin_012.bottom - Center_AddOneMargin_012.top).assertEqual(vp2px(100));
expect(Center_AddOneMargin_013.bottom - Center_AddOneMargin_013.top).assertEqual(vp2px(150));
expect(Center_AddOneMargin_011.right - Center_AddOneMargin_011.left).assertEqual(vp2px(2500/17));
expect(Center_AddOneMargin_012.right - Center_AddOneMargin_012.left).assertEqual(vp2px(2500/17));
expect(Center_AddOneMargin_013.right - Center_AddOneMargin_013.left).assertEqual(vp2px(2500/17));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1500] END');
done();
})
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddOneWidth() {
describe('AlignCenter_AddOneWidth', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddOneWidth',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddOneWidth state success " + JSON.stringify(pages));
if (!("AlignCenter_AddOneWidth" == pages.name)) {
console.info("get AlignCenter_AddOneWidth state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddOneWidth page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddOneWidth page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_ChangeOneWidth after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1300
* @tc.name Align_Center_Row_ChangeOneWidth
* @tc.desc The interface is displayed when you change the spindle length (width) of the first subassembly
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1300', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1300] START');
globalThis.value.message.notify({name:'OneWidth', value:160})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddOneWidth_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddOneWidth_011 = CommonFunc.getComponentRect('Center_AddOneWidth_011');
let Center_AddOneWidth_012 = CommonFunc.getComponentRect('Center_AddOneWidth_012');
let Center_AddOneWidth_013 = CommonFunc.getComponentRect('Center_AddOneWidth_013');
let Center_AddOneWidth_01 = CommonFunc.getComponentRect('Center_AddOneWidth_01');
expect(Center_AddOneWidth_011.top).assertEqual(Center_AddOneWidth_012.top);
expect(Center_AddOneWidth_013.top).assertEqual(Center_AddOneWidth_012.top);
expect(Center_AddOneWidth_011.top).assertEqual(Center_AddOneWidth_01.top);
expect(Center_AddOneWidth_011.right).assertEqual(Center_AddOneWidth_012.left);
expect(Center_AddOneWidth_012.right).assertEqual(Center_AddOneWidth_013.left);
expect(Center_AddOneWidth_011.left - Center_AddOneWidth_01.left).assertEqual(vp2px(20));
expect(Center_AddOneWidth_01.right - Center_AddOneWidth_013.right).assertEqual(vp2px(20));
expect(Center_AddOneWidth_011.right - Center_AddOneWidth_011.left).assertEqual(vp2px(160));
expect(Center_AddOneWidth_012.right - Center_AddOneWidth_012.left).assertEqual(vp2px(150));
expect(Center_AddOneWidth_013.right - Center_AddOneWidth_013.left).assertEqual(vp2px(150));
expect(Center_AddOneWidth_011.bottom - Center_AddOneWidth_011.top).assertEqual(vp2px(50));
expect(Center_AddOneWidth_012.bottom - Center_AddOneWidth_012.top).assertEqual(vp2px(100));
expect(Center_AddOneWidth_013.bottom - Center_AddOneWidth_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1300] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddPadding() {
describe('AlignCenter_AddPadding', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddPadding',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddPadding state success " + JSON.stringify(pages));
if (!("AlignCenter_AddPadding" == pages.name)) {
console.info("get AlignCenter_AddPadding state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddPadding page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddPadding page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddPadding after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0300
* @tc.name Align_Center_Row_AddPadding
* @tc.desc After subtracting the padding from the parent component layout space, the interface
* display that does not meet the spindle layout of the child component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0300', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0300] START');
globalThis.value.message.notify({name:'DadPadding', value:30});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddPadding_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddPadding_011 = CommonFunc.getComponentRect('Center_AddPadding_011');
let Center_AddPadding_012 = CommonFunc.getComponentRect('Center_AddPadding_012');
let Center_AddPadding_013 = CommonFunc.getComponentRect('Center_AddPadding_013');
let Center_AddPadding_01 = CommonFunc.getComponentRect('Center_AddPadding_01');
expect(Center_AddPadding_011.top).assertEqual(Center_AddPadding_012.top);
expect(Center_AddPadding_012.top).assertEqual(Center_AddPadding_013.top);
expect(Center_AddPadding_012.left).assertEqual(Center_AddPadding_011.right);
expect(Center_AddPadding_013.left).assertEqual(Center_AddPadding_012.right);
expect(Center_AddPadding_011.left - Center_AddPadding_01.left).assertEqual(vp2px(30));
expect(Center_AddPadding_01.right - Center_AddPadding_013.right).assertEqual(vp2px(30));
expect(Center_AddPadding_011.top - Center_AddPadding_01.top).assertEqual(vp2px(30));
expect(Center_AddPadding_011.bottom - Center_AddPadding_011.top).assertEqual(vp2px(50));
expect(Center_AddPadding_012.bottom - Center_AddPadding_012.top).assertEqual(vp2px(100));
expect(Center_AddPadding_013.bottom - Center_AddPadding_013.top).assertEqual(vp2px(150));
expect(Center_AddPadding_011.right - Center_AddPadding_011.left).assertEqual(vp2px(440/3));
expect(Center_AddPadding_012.right - Center_AddPadding_012.left).assertEqual(vp2px(440/3));
expect(Center_AddPadding_013.right - Center_AddPadding_013.left).assertEqual(vp2px(440/3));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0300] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0400
* @tc.name Align_Center_Row_AddPadding
* @tc.desc After subtracting the padding from the parent component layout space, the interface that
* satisfies the spindle layout of the child component is displayed
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0400', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0400] START');
globalThis.value.message.notify({name:'DadPadding', value:20});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddPadding_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_AddPadding_011 = CommonFunc.getComponentRect('Center_AddPadding_011');
let Center_AddPadding_012 = CommonFunc.getComponentRect('Center_AddPadding_012');
let Center_AddPadding_013 = CommonFunc.getComponentRect('Center_AddPadding_013');
let Center_AddPadding_01 = CommonFunc.getComponentRect('Center_AddPadding_01');
expect(Center_AddPadding_011.top).assertEqual(Center_AddPadding_012.top);
expect(Center_AddPadding_012.top).assertEqual(Center_AddPadding_013.top);
expect(Center_AddPadding_012.left) .assertEqual(Center_AddPadding_011.right);
expect(Center_AddPadding_013.left) .assertEqual(Center_AddPadding_012.right);
expect(Center_AddPadding_011.top - Center_AddPadding_01.top).assertEqual(vp2px(20));
expect(Center_AddPadding_011.left - Center_AddPadding_01.left).assertEqual(vp2px(25));
expect(Center_AddPadding_01.right - Center_AddPadding_013.right).assertEqual(vp2px(25));
expect(Center_AddPadding_011.right - Center_AddPadding_011.left).assertEqual(vp2px(150));
expect(Center_AddPadding_012.right - Center_AddPadding_012.left).assertEqual(vp2px(150));
expect(Center_AddPadding_013.right - Center_AddPadding_013.left).assertEqual(vp2px(150));
expect(Center_AddPadding_011.bottom - Center_AddPadding_011.top).assertEqual(vp2px(50));
expect(Center_AddPadding_012.bottom - Center_AddPadding_012.top).assertEqual(vp2px(100));
expect(Center_AddPadding_013.bottom - Center_AddPadding_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0400] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_AddVisibility() {
describe('AlignCenter_AddVisibility', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_AddVisibility',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_AddVisibility state success " + JSON.stringify(pages));
if (!("AlignCenter_AddVisibility" == pages.name)) {
console.info("get AlignCenter_AddVisibility state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_AddVisibility page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_AddVisibility page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_AddVisibility after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1000
* @tc.name Align_Center_Row_AddVisibility
* @tc.desc The subcomponent sets the visibility. None, the child components are hidden in the interface display
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1000', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1000] START');
globalThis.value.message.notify({name:'OneVisibility',value:Visibility.None});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddVisibility_01');
let obj = JSON.parse(strJson);
let strJson2 = getInspectorByKey('Center_AddVisibility_011');
let obj2 = JSON.parse(strJson2)
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
expect(obj2.$attrs.visibility).assertEqual("Visibility.None");
let Center_AddVisibility_012 = CommonFunc.getComponentRect('Center_AddVisibility_012');
let Center_AddVisibility_013 = CommonFunc.getComponentRect('Center_AddVisibility_013');
let Center_AddVisibility_01 = CommonFunc.getComponentRect('Center_AddVisibility_01');
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_013.top);
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_01.top);
expect(Center_AddVisibility_012.right).assertEqual(Center_AddVisibility_013.left);
expect(Center_AddVisibility_012.left - Center_AddVisibility_01.left).assertEqual(vp2px(100));
expect(Center_AddVisibility_01.right - Center_AddVisibility_013.right).assertEqual(vp2px(100));
expect(Center_AddVisibility_012.right - Center_AddVisibility_012.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_013.right - Center_AddVisibility_013.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_012.bottom - Center_AddVisibility_012.top).assertEqual(vp2px(100));
expect(Center_AddVisibility_013.bottom - Center_AddVisibility_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1000] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1100
* @tc.name Align_Center_Row_AddVisibility
* @tc.desc When the subcomponent sets visibility.hidden, the interface of the subcomponent does not occupy the
* position
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1100', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1100] START');
globalThis.value.message.notify({name:'OneVisibility', value:Visibility.Hidden});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddVisibility_01');
let obj = JSON.parse(strJson);
let strJson2 = getInspectorByKey('Center_AddVisibility_011');
let obj2 = JSON.parse(strJson2)
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
expect(obj2.$attrs.visibility).assertEqual("Visibility.Hidden");
let Center_AddVisibility_011 = CommonFunc.getComponentRect('Center_AddVisibility_011');
let Center_AddVisibility_012 = CommonFunc.getComponentRect('Center_AddVisibility_012');
let Center_AddVisibility_013 = CommonFunc.getComponentRect('Center_AddVisibility_013');
let Center_AddVisibility_01 = CommonFunc.getComponentRect('Center_AddVisibility_01');
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_013.top);
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_011.top);
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_01.top);
expect(Center_AddVisibility_011.right).assertEqual(Center_AddVisibility_012.left);
expect(Center_AddVisibility_012.right).assertEqual(Center_AddVisibility_013.left);
expect(Center_AddVisibility_011.left - Center_AddVisibility_01.left).assertEqual(vp2px(25));
expect(Center_AddVisibility_01.right - Center_AddVisibility_013.right).assertEqual(vp2px(25));
expect(Center_AddVisibility_011.right - Center_AddVisibility_011.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_012.right - Center_AddVisibility_012.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_013.right - Center_AddVisibility_013.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_011.bottom - Center_AddVisibility_011.top).assertEqual(vp2px(50));
expect(Center_AddVisibility_012.bottom - Center_AddVisibility_012.top).assertEqual(vp2px(100));
expect(Center_AddVisibility_013.bottom - Center_AddVisibility_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1100] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1700
* @tc.name Align_Center_Row_AddVisibility
* @tc.desc The subcomponent sets the visibility. Visible, the subcomponent does not occupy a position in the
* interface display
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1700', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1700] START');
globalThis.value.message.notify({name:'OneVisibility', value:Visibility.Visible});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_AddVisibility_01');
let obj = JSON.parse(strJson);
let strJson2 = getInspectorByKey('Center_AddVisibility_011');
let obj2 = JSON.parse(strJson2)
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
expect(obj2.$attrs.visibility).assertEqual("Visibility.Visible");
let Center_AddVisibility_011 = CommonFunc.getComponentRect('Center_AddVisibility_011');
let Center_AddVisibility_012 = CommonFunc.getComponentRect('Center_AddVisibility_012');
let Center_AddVisibility_013 = CommonFunc.getComponentRect('Center_AddVisibility_013');
let Center_AddVisibility_01 = CommonFunc.getComponentRect('Center_AddVisibility_01');
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_013.top);
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_011.top);
expect(Center_AddVisibility_012.top).assertEqual(Center_AddVisibility_01.top);
expect(Center_AddVisibility_011.right).assertEqual(Center_AddVisibility_012.left);
expect(Center_AddVisibility_012.right).assertEqual(Center_AddVisibility_013.left);
expect(Center_AddVisibility_011.left - Center_AddVisibility_01.left).assertEqual(vp2px(25));
expect(Center_AddVisibility_01.right - Center_AddVisibility_013.right).assertEqual(vp2px(25));
expect(Center_AddVisibility_011.right - Center_AddVisibility_011.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_012.right - Center_AddVisibility_012.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_013.right - Center_AddVisibility_013.left).assertEqual(vp2px(150));
expect(Center_AddVisibility_011.bottom - Center_AddVisibility_011.top).assertEqual(vp2px(50));
expect(Center_AddVisibility_012.bottom - Center_AddVisibility_012.top).assertEqual(vp2px(100));
expect(Center_AddVisibility_013.bottom - Center_AddVisibility_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_1700] END');
done();
});
})
}
/*
* Copyright (c) 2023-2030 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 AlignCenter_NoSpace() {
describe('AlignCenter_NoSpace', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Flex/justifyContent/Center/AlignCenter_NoSpace'
}
try {
router.clear();
let pages = router.getState();
console.info("get AlignCenter_NoSpace state success " + JSON.stringify(pages));
if (!("AlignCenter_NoSpace" == pages.name)) {
console.info("get AlignCenter_NoSpace state pages.name " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlignCenter_NoSpace page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlignCenter_NoSpace page error " + JSON.stringify(err));
expect().assertFail();
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("AlignCenter_NoSpace after each called");
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0100
* @tc.name Align_Center_Row_ChangeWidth
* @tc.desc The parent component layout space does not meet the interface display of the spindle layout of
* the child component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0100', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0100] START');
globalThis.value.message.notify({name:'DadWidth', value:400});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_NoSpace_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_NoSpace_011 = CommonFunc.getComponentRect('Center_NoSpace_011');
let Center_NoSpace_012 = CommonFunc.getComponentRect('Center_NoSpace_012');
let Center_NoSpace_013 = CommonFunc.getComponentRect('Center_NoSpace_013');
let Center_NoSpace_01 = CommonFunc.getComponentRect('Center_NoSpace_01');
expect(Center_NoSpace_011.top).assertEqual(Center_NoSpace_012.top);
expect(Center_NoSpace_012.top).assertEqual(Center_NoSpace_013.top);
expect(Center_NoSpace_011.top).assertEqual(Center_NoSpace_01.top);
expect(Center_NoSpace_012.left).assertEqual(Center_NoSpace_011.right);
expect(Center_NoSpace_013.left).assertEqual(Center_NoSpace_012.right);
expect(Center_NoSpace_011.left).assertEqual(Center_NoSpace_01.left);
expect(Center_NoSpace_013.right).assertEqual(Center_NoSpace_01.right);
expect(Center_NoSpace_011.bottom - Center_NoSpace_011.top).assertEqual(vp2px(50));
expect(Center_NoSpace_012.bottom - Center_NoSpace_012.top).assertEqual(vp2px(100));
expect(Center_NoSpace_013.bottom - Center_NoSpace_013.top).assertEqual(vp2px(150));
expect(Center_NoSpace_011.right - Center_NoSpace_011.left).assertEqual(vp2px(400/3));
expect(Center_NoSpace_012.right - Center_NoSpace_012.left).assertEqual(vp2px(400/3));
expect(Center_NoSpace_013.right - Center_NoSpace_013.left).assertEqual(vp2px(400/3));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0100] END');
done();
});
/**
* @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0200
* @tc.name Align_Center_Row_ChangeWidth
* @tc.desc The interface display where the parent component layout space satisfies the spindle layout of
* the child component
*/
it('SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0200', 0, async function (done) {
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0200] START');
globalThis.value.message.notify({name:'DadWidth', value:500});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Center_NoSpace_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Flex');
expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row');
expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.Center');
let Center_NoSpace_011 = CommonFunc.getComponentRect('Center_NoSpace_011');
let Center_NoSpace_012 = CommonFunc.getComponentRect('Center_NoSpace_012');
let Center_NoSpace_013 = CommonFunc.getComponentRect('Center_NoSpace_013');
let Center_NoSpace_01 = CommonFunc.getComponentRect('Center_NoSpace_01');
expect(Center_NoSpace_011.top).assertEqual(Center_NoSpace_012.top);
expect(Center_NoSpace_012.top).assertEqual(Center_NoSpace_013.top);
expect(Center_NoSpace_011.top).assertEqual(Center_NoSpace_01.top);
expect(Center_NoSpace_011.right).assertEqual(Center_NoSpace_012.left);
expect(Center_NoSpace_013.left).assertEqual(Center_NoSpace_012.right);
expect(Center_NoSpace_011.left - Center_NoSpace_01.left)
.assertEqual(Center_NoSpace_01.right - Center_NoSpace_013.right);
expect(Center_NoSpace_011.left - Center_NoSpace_01.left).assertEqual(vp2px(25));
expect(Center_NoSpace_011.right - Center_NoSpace_011.left).assertEqual(vp2px(150));
expect(Center_NoSpace_012.right - Center_NoSpace_012.left).assertEqual(vp2px(150));
expect(Center_NoSpace_013.right - Center_NoSpace_013.left).assertEqual(vp2px(150));
expect(Center_NoSpace_011.bottom - Center_NoSpace_011.top).assertEqual(vp2px(50));
expect(Center_NoSpace_012.bottom - Center_NoSpace_012.top).assertEqual(vp2px(100));
expect(Center_NoSpace_013.bottom - Center_NoSpace_013.top).assertEqual(vp2px(150));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_CENTER_TEST_0200] END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册