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

!7473 test:add row_parentComponentChanged xts_act testcase

Merge pull request !7473 from zmshij/row
/*
* 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 Row_FlexAlign {
@State rowjustifyContent: number = FlexAlign.Start;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_FlexAlign onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'justifyContent') {
this.rowjustifyContent = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('Row_FlexAlign').fontSize(9).fontColor(0xCCCCCC).width('90%')
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Text3')
}
.key('Row_ParentComponentChanged_Row')
.justifyContent(this.rowjustifyContent)
.width(350)
.height(200)
.backgroundColor(0xB05F77)
}
.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 Row_Margin {
@State rowPadding: number = 0;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_Margin 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.rowPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Row_Margin_Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Row_Margin_Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Row_Margin_Text3')
}
.key('Row_Margin_Row')
.width(350)
.height(200)
.margin(this.rowPadding)
.backgroundColor(0xB05F77)
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.key('Column_Row_Margin')
}
}
/*
* 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 Row_MarginPadding {
@State rowPadding: number = 10;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_MarginPadding 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.rowPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Row_MarginPadding_Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Row_MarginPadding_Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Row_MarginPadding_Text3')
}
.key('Row_MarginPadding')
.width(350)
.height(200)
.margin(5)
.padding(this.rowPadding)
.backgroundColor(0xB05F77)
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.key('Column_Row_MarginPadding')
}
}
/*
* 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 Row_Padding {
@State rowPadding: number = 10;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_Padding 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.rowPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('Row_Padding').fontSize(9).fontColor(0xCCCCCC).width('90%')
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Row_Padding_Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Row_Padding_Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Row_Padding_Text3')
}
.key('Row_Padding_Row')
.width(350)
.height(200)
.padding(this.rowPadding)
.backgroundColor(0xB05F77)
}
.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 Row_Size {
@State rowWidth: number = 400;
@State rowHeight: number = 300;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_Size onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'width') {
this.rowWidth = message.value;
}
if (message.name == 'height') {
this.rowHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('Row_Size').fontSize(9).fontColor(0xCCCCCC).width('90%')
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Row_Size_Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Row_Size_Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Row_Size_Text3')
}
.key('Row_Size_Row')
.width(this.rowWidth)
.height(this.rowHeight)
.backgroundColor(0xB05F77)
}
.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 Row_VerticalAlign {
@State rowAlignItems: number = VerticalAlign.Center;
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Row_VerticalAlign onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'alignItems') {
this.rowAlignItems = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column() {
Text('Row_VerticalAlign').fontSize(9).fontColor(0xCCCCCC).width('90%')
Row({ space:10 }) {
Text('1').width(100).height(50).backgroundColor(0xAFEEEE).key('Row_VerticalAlign_Text1')
Text('2').width(100).height(100).backgroundColor(0x00FFFF).key('Row_VerticalAlign_Text2')
Text('3').width(100).height(150).backgroundColor(0xAFEEEE).key('Row_VerticalAlign_Text3')
}
.key('Row_VerticalAlign_Row')
.alignItems(this.rowAlignItems)
.width(350)
.height(200)
.backgroundColor(0xB05F77)
}
.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 Row_FlexAlign() {
describe('Row_FlexAlign', function () {
beforeEach(async function (done) {
console.info("Row_FlexAlign beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_FlexAlign',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get Row_FlexAlign state success " + JSON.stringify(pages));
if (!("Row_FlexAlign" == pages.name)) {
console.info("get Row_FlexAlign state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Row_FlexAlign page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_FlexAlign page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("Row_FlexAlign beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_FlexAlign after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1100
* @tc.name testRowJustifyContentFlexAlignStart
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.Start
*/
it('testRowJustifyContentFlexAlignStart', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignStart START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.Start });
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.Start");
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Row.right).assertLarger(Text3.right);
console.info('testRowJustifyContentFlexAlignStart END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1200
* @tc.name testRowJustifyContentFlexAlignCenter
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.Center
*/
it('testRowJustifyContentFlexAlignCenter', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignCenter START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.Center });
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.Center");
expect(Text1.left - Row.left).assertEqual(Row.right - Text3.right);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
console.info('testRowJustifyContentFlexAlignCenter END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1300
* @tc.name testRowJustifyContentFlexAlignEnd
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.End
*/
it('testRowJustifyContentFlexAlignEnd', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignEnd START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.End });
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.End");
expect(Text3.right).assertEqual(Row.right);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Text1.left).assertLarger(Row.left);
console.info('testRowJustifyContentFlexAlignEnd END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1400
* @tc.name testRowJustifyContentFlexAlignSpaceBetween
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.SpaceBetween
*/
it('testRowJustifyContentFlexAlignSpaceBetween', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignSpaceBetween START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.SpaceBetween });
await CommonFunc.sleep(3000)
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.SpaceBetween");
expect(Text1.left).assertEqual(Row.left);
expect(Text3.right).assertEqual(Row.right);
expect(Math.round((Text2.left - Text1.right)*10)/10).assertEqual(vp2px(25));
expect(Math.round((Text3.left - Text2.right)*10)/10).assertEqual(vp2px(25));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
console.info('testRowJustifyContentFlexAlignSpaceBetween END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1500
* @tc.name testRowJustifyContentFlexAlignSpaceAround
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.SpaceAround
*/
it('testRowJustifyContentFlexAlignSpaceAround', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignSpaceAround START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.SpaceAround });
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.SpaceAround");
expect(Text1.left - Row.left).assertEqual(Row.right - Text3.right);
expect(Math.round((Text1.left - Row.left)*10)/10).assertEqual(Math.round(vp2px(50/6)*10)/10);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(50/3));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(50/3));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
console.info('testRowJustifyContentFlexAlignSpaceAround END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1600
* @tc.name testRowJustifyContentFlexAlignSpaceEvenly
* @tc.desc The JustifyContent property of the ROW component is set to FlexAlign.SpaceEvenly
*/
it('testRowJustifyContentFlexAlignSpaceEvenly', 0, async function (done) {
console.info('testRowJustifyContentFlexAlignSpaceEvenly START');
globalThis.value.message.notify({ name:'justifyContent', value:FlexAlign.SpaceEvenly });
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Row_ParentComponentChanged_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_ParentComponentChanged_Row');
let Text1 = CommonFunc.getComponentRect('Text1');
let Text2 = CommonFunc.getComponentRect('Text2');
let Text3 = CommonFunc.getComponentRect('Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.justifyContent).assertEqual("FlexAlign.SpaceEvenly");
expect(Text1.left - Row.left).assertEqual(Row.right - Text3.right);
expect(Math.round((Text1.left - Row.left)*100)/100).assertEqual(Math.round(vp2px(50/4)*100)/100);
expect(Math.round((Text2.left - Text1.right)*100)/100).assertEqual(Math.round(vp2px(50/4)*100)/100);
expect(Math.round((Text3.left - Text2.right)*100)/100).assertEqual(Math.round(vp2px(50/4)*100)/100);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
console.info('testRowJustifyContentFlexAlignSpaceEvenly 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 Row_Margin() {
describe('Row_Margin', function () {
beforeEach(async function (done) {
console.info("Row_Margin beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_Margin',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get Row_Margin state success " + JSON.stringify(pages));
if (!("Row_Margin" == pages.name)) {
console.info("get Row_Margin state success " + JSON.stringify(pages.name));
let result = await router.push(options)
await CommonFunc.sleep(2000);
console.info("push Row_Margin page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_Margin page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("Row_Margin beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_Margin after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0600
* @tc.name testParentComponentChangedRowMargin
* @tc.desc Setting the Margin for the Row component
*/
it('testParentComponentChangedRowMargin', 0, async function (done) {
console.info('testParentComponentChangedRowMargin START');
globalThis.value.message.notify({ name:'margin', value:5 });
await CommonFunc.sleep(3000);
let Column = CommonFunc.getComponentRect('Column_Row_Margin');
let Row = CommonFunc.getComponentRect('Row_Margin_Row');
let Text1 = CommonFunc.getComponentRect('Row_Margin_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Margin_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Margin_Text3');
console.log('Column rect_value is:'+ JSON.stringify(Column));
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Math.round((Row.left - Column.left)*10)/10).assertEqual(vp2px(5));
expect(Math.round((Row.top - Column.top)*10)/10).assertEqual(vp2px(5));
expect(Math.round((Text1.left - Column.left)*10)/10).assertEqual(vp2px(5));
expect(Math.round(Text1.top - Column.top)).assertEqual(vp2px(80));
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Row.right).assertLarger(Text3.right);
console.info('testParentComponentChangedRowMargin 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 Row_MarginPadding() {
describe('Row_MarginPadding', function () {
beforeEach(async function (done) {
console.info("Row_MarginPadding beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_MarginPadding',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get Row_MarginPadding state success " + JSON.stringify(pages));
if (!("Row_MarginPadding" == pages.name)) {
console.info("get Row_MarginPadding state success " + JSON.stringify(pages.name));
let result = await router.push(options)
await CommonFunc.sleep(2000);
console.info("push Row_MarginPadding page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_MarginPadding page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("Row_MarginPadding beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_MarginPadding after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0700
* @tc.name testRowMarginPaddingSatisfy
* @tc.desc When margin and padding are set for the Row component, the width of the Row component meets the
* requirements
*/
it('testRowMarginPaddingSatisfy', 0, async function (done) {
console.info('testRowMarginPaddingSatisfy START');
globalThis.value.message.notify({ name:'padding', value:15 });
await CommonFunc.sleep(3000);
let Column = CommonFunc.getComponentRect('Column_Row_MarginPadding');
let Row = CommonFunc.getComponentRect('Row_MarginPadding');
let Text1 = CommonFunc.getComponentRect('Row_MarginPadding_Text1');
let Text2 = CommonFunc.getComponentRect('Row_MarginPadding_Text2');
let Text3 = CommonFunc.getComponentRect('Row_MarginPadding_Text3');
console.log('Column rect_value is:'+ JSON.stringify(Column));
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Math.round((Row.left - Column.left)*10)/10).assertEqual(vp2px(5));
expect(Math.round((Row.top - Column.top)*10)/10).assertEqual(vp2px(5));
expect(Math.round(Text1.left - Column.left)).assertEqual(vp2px(20));
expect(Math.round(Text1.top - Column.top)).assertEqual(vp2px(80));
expect(Math.round((Text1.left - Row.left)*10)/10).assertEqual(vp2px(15));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Math.round((Row.right - Text3.right)*10)/10).assertEqual(vp2px(15));
console.info('testRowMarginPaddingSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0800
* @tc.name testRowMarginPaddingNoSatisfy
* @tc.desc The width of the Row component does not meet the requirements when margin and padding are set for
* the Row component
*/
it('testRowMarginPaddingNoSatisfy', 0, async function (done) {
console.info('testRowMarginPaddingNoSatisfy START');
globalThis.value.message.notify({ name:'padding', value:40 });
await CommonFunc.sleep(3000)
let Column = CommonFunc.getComponentRect('Column_Row_MarginPadding');
let Row = CommonFunc.getComponentRect('Row_MarginPadding');
let Text1 = CommonFunc.getComponentRect('Row_MarginPadding_Text1');
let Text2 = CommonFunc.getComponentRect('Row_MarginPadding_Text2');
let Text3 = CommonFunc.getComponentRect('Row_MarginPadding_Text3');
console.log('Column rect_value is:'+ JSON.stringify(Column));
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Math.round((Row.left - Column.left)*10)/10).assertEqual(vp2px(5));
expect(Math.round((Row.top - Column.top)*10)/10).assertEqual(vp2px(5));
expect(Math.round((Text1.left - Column.left)*10)/10).assertEqual(vp2px(45));
expect(Math.round((Text1.top - Column.top)*10)/10).assertEqual(vp2px(80));
expect(Math.round(Text1.left - Row.left)).assertEqual(vp2px(40));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Text3.right).assertLarger(Row.right);
expect(Text3.top - Row.top).assertLess(vp2px(40));
console.info('testRowMarginPaddingNoSatisfy 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 Row_Padding() {
describe('Row_Padding', function () {
beforeEach(async function (done) {
console.info("Row_Padding beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_Padding',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get Row_Padding state success " + JSON.stringify(pages));
if (!("Row_Padding" == pages.name)) {
console.info("get Row_Padding state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Row_Padding page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_Padding page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("Row_Padding beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_Padding after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0400
* @tc.name testRowPaddingSatisfy
* @tc.desc Set padding for the row component. The width of the row component meets the requirements
*/
it('testRowPaddingSatisfy', 0, async function (done) {
console.info('testRowPaddingSatisfy START');
globalThis.value.message.notify({ name:'padding', value:15 });
await CommonFunc.sleep(3000);
let Row = CommonFunc.getComponentRect('Row_Padding_Row');
let Text1 = CommonFunc.getComponentRect('Row_Padding_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Padding_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Padding_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Math.round((Text1.left - Row.left)*10)/10).assertEqual(vp2px(15));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Math.round((Row.right - Text3.right)*10)/10).assertEqual(vp2px(15));
console.info('testRowPaddingSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0500
* @tc.name testRowPaddingNOSatisfy
* @tc.desc Padding is configured for the row component. The width of the row component does not meet the
* requirements
*/
it('testRowPaddingNOSatisfy', 0, async function (done) {
console.info('testRowPaddingNOSatisfy START');
globalThis.value.message.notify({ name:'padding', value:40 });
await CommonFunc.sleep(3000)
let Row = CommonFunc.getComponentRect('Row_Padding_Row');
let Text1 = CommonFunc.getComponentRect('Row_Padding_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Padding_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Padding_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Math.round(Text1.left - Row.left)).assertEqual(vp2px(40));
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Text3.right).assertLarger(Row.right);
expect(Text3.top - Row.top).assertLess(vp2px(40));
console.info('testRowPaddingNOSatisfy 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 Row_Size() {
describe('Row_Size', function () {
beforeEach(async function (done) {
console.info("Row_Size beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_Size',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get Row_Size state success " + JSON.stringify(pages));
if (!("Row_Size" == pages.name)) {
console.info("get Row_Size state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Row_Size page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_Size page error " + JSON.stringify(err));
}
await CommonFunc.sleep(1000)
console.info("Row_Size beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_Size after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0100
* @tc.name testRowSizeBothSatisfy
* @tc.desc The height and width of the row component meet the requirements of the subcomponent
*/
it('testRowSizeBothSatisfy', 0, async function (done) {
console.info('testRowSizeBothSatisfy START');
globalThis.value.message.notify({ name:'width', value:350 });
globalThis.value.message.notify({ name:'height', value:200 });
await CommonFunc.sleep(3000);
let Row = CommonFunc.getComponentRect('Row_Size_Row');
let Text1 = CommonFunc.getComponentRect('Row_Size_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Size_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Size_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Row.right).assertLarger(Text3.right);
console.info('testRowSizeBothSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0200
* @tc.name testRowSizeWidthNOSatisfy
* @tc.desc Set the height and width of the row component. The width of the row component does not meet the
* requirements of the subcomponent
*/
it('testRowSizeWidthNOSatisfy', 0, async function (done) {
console.info('testRowSizeWidthNOSatisfy START');
globalThis.value.message.notify({ name:'width', value:200 });
globalThis.value.message.notify({ name:'height', value:200 });
await CommonFunc.sleep(3000)
let Row = CommonFunc.getComponentRect('Row_Size_Row');
let Text1 = CommonFunc.getComponentRect('Row_Size_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Size_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Size_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Text3.right).assertLarger(Row.right);
console.info('testRowSizeWidthNOSatisfy END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0300
* @tc.name testRowSizeHeightNOSatisfy
* @tc.desc Set the height and width of the row component. The height of the row component does not meet the
* requirements of the subcomponent
*/
it('testRowSizeHeightNOSatisfy', 0, async function (done) {
console.info('testRowSizeHeightNOSatisfy START');
globalThis.value.message.notify({ name:'width', value:350 });
globalThis.value.message.notify({ name:'height', value:100 });
await CommonFunc.sleep(3000)
let Row = CommonFunc.getComponentRect('Row_Size_Row');
let Text1 = CommonFunc.getComponentRect('Row_Size_Text1');
let Text2 = CommonFunc.getComponentRect('Row_Size_Text2');
let Text3 = CommonFunc.getComponentRect('Row_Size_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top - Row.top).assertEqual(Row.bottom - Text1.bottom);
expect(Text2.top - Row.top).assertEqual(Row.bottom - Text2.bottom);
expect(Text3.top - Row.top).assertEqual(Row.bottom - Text3.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Text3.bottom).assertLarger(Row.bottom);
expect(Row.top).assertLarger(Text3.top);
console.info('testRowSizeHeightNOSatisfy 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 Row_VerticalAlign() {
describe('Row_VerticalAlign', function () {
beforeEach(async function (done) {
console.info("Row_VerticalAlign beforeEach start");
let options = {
uri: 'MainAbility/pages/Row/parentComponentChanged/Row_VerticalAlign',
}
try {
router.clear();
let pages = router.getState();
console.info("get Row_VerticalAlign state success " + JSON.stringify(pages));
if (!("Row_VerticalAlign" == pages.name)) {
console.info("get Row_VerticalAlign state success " + JSON.stringify(pages.name));
let result = await router.push(options)
await CommonFunc.sleep(2000);
console.info("push Row_VerticalAlign page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push Row_VerticalAlign page error " + JSON.stringify(err));
}
console.info("Row_VerticalAlign beforeEach end");
done()
});
afterEach(async function () {
await CommonFunc.sleep(2000)
console.info("Row_VerticalAlign after each called");
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_0900
* @tc.name testRowAlignItemsVerticalAlignTop
* @tc.desc Set the AlignItems property of the Row component to VerticalAlign.Top
*/
it('testRowAlignItemsVerticalAlignTop', 0, async function (done) {
console.info('testRowAlignItemsVerticalAlignTop START');
globalThis.value.message.notify({ name:'alignItems', value:VerticalAlign.Top });
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Row_VerticalAlign_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_VerticalAlign_Row');
let Text1 = CommonFunc.getComponentRect('Row_VerticalAlign_Text1');
let Text2 = CommonFunc.getComponentRect('Row_VerticalAlign_Text2');
let Text3 = CommonFunc.getComponentRect('Row_VerticalAlign_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.alignItems).assertEqual("VerticalAlign.Top");
expect(Text1.left).assertEqual(Row.left);
expect(Text1.top).assertEqual(Row.top);
expect(Text2.top).assertEqual(Row.top);
expect(Text3.top).assertEqual(Row.top);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Row.right).assertLarger(Text3.right);
console.info('testRowAlignItemsVerticalAlignTop END');
done();
});
/**
* @tc.number SUB_ACE_ROW_PARENTCOMPONENTCHANGED_1000
* @tc.name testRowAlignItemsVerticalAlignBottom
* @tc.desc Set the AlignItems property of the Row component to VerticalAlign.Bottom
*/
it('testRowAlignItemsVerticalAlignBottom', 0, async function (done) {
console.info('testRowAlignItemsVerticalAlignBottom START');
globalThis.value.message.notify({ name:'alignItems', value:VerticalAlign.Bottom });
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Row_VerticalAlign_Row');
let obj = JSON.parse(strJson);
console.info('Row obj.$attrs is:' + JSON.stringify(obj.$attrs));
let Row = CommonFunc.getComponentRect('Row_VerticalAlign_Row');
let Text1 = CommonFunc.getComponentRect('Row_VerticalAlign_Text1');
let Text2 = CommonFunc.getComponentRect('Row_VerticalAlign_Text2');
let Text3 = CommonFunc.getComponentRect('Row_VerticalAlign_Text3');
console.log('Row rect_value is:'+ JSON.stringify(Row));
console.log('Text1 rect_value is:'+ JSON.stringify(Text1));
console.log('Text2 rect_value is:'+ JSON.stringify(Text2));
console.log('Text3 rect_value is:'+ JSON.stringify(Text3));
expect(Math.round(Text1.bottom - Text1.top)).assertEqual(vp2px(50));
expect(Math.round(Text2.bottom - Text2.top)).assertEqual(vp2px(100));
expect(Math.round(Text3.bottom - Text3.top)).assertEqual(vp2px(150));
expect(Math.round(Text1.right - Text1.left)).assertEqual(vp2px(100));
expect(Math.round(Text2.right - Text2.left)).assertEqual(vp2px(100));
expect(Math.round(Text3.right - Text3.left)).assertEqual(vp2px(100));
expect(obj.$attrs.alignItems).assertEqual("VerticalAlign.Bottom");
expect(Text1.left).assertEqual(Row.left);
expect(Text1.bottom).assertEqual(Row.bottom);
expect(Text2.bottom).assertEqual(Row.bottom);
expect(Text3.bottom).assertEqual(Row.bottom);
expect(Math.round(Text2.left - Text1.right)).assertEqual(vp2px(10));
expect(Math.round(Text3.left - Text2.right)).assertEqual(vp2px(10));
expect(Row.right).assertLarger(Text3.right);
console.info('testRowAlignItemsVerticalAlignBottom END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册