Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f15c2aab
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f15c2aab
编写于
4月 12, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 12, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7804 test:Add Stack_One xts_acts test
Merge pull request !7804 from 王倩/stack
上级
7d1ebb6f
f93e658d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
1623 addition
and
0 deletion
+1623
-0
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_offset_change.ets
...lity/pages/Stack/StackItem_change/stack_offset_change.ets
+48
-0
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_position_change.ets
...ty/pages/Stack/StackItem_change/stack_position_change.ets
+48
-0
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_zIndex.ets
...MainAbility/pages/Stack/StackItem_change/stack_zIndex.ets
+48
-0
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/Stack_alignContent/stack_alignContent.ets
...ity/pages/Stack/Stack_alignContent/stack_alignContent.ets
+56
-0
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_offset_change.test.ets
.../test/Stack/StackItem_change/stack_offset_change.test.ets
+306
-0
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_position_change.test.ets
...est/Stack/StackItem_change/stack_position_change.test.ets
+306
-0
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_zIndex.test.ets
...ain/ets/test/Stack/StackItem_change/stack_zIndex.test.ets
+419
-0
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/Stack_alignContent/stack_alignContent.test.ets
...test/Stack/Stack_alignContent/stack_alignContent.test.ets
+392
-0
未找到文件。
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_offset_change.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* 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 Stack_Offset_Change{
@State addOffset: object = { x: 20, y: 20 };
@State addAlignContent: number = Alignment.TopStart;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Stack_Offset_Change onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'addOffset') {
this.addOffset = message.value;
}
if (message.name == 'addAlignContent') {
this.addAlignContent = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Stack({ alignContent:this.addAlignContent }) {
Text('1').width(200).height(200).backgroundColor(0xF5DEB3).key('Stack_Offset_Change_011').offset(this.addOffset);
Text('2').width(100).height(100).backgroundColor(0xD2B48C).key('Stack_Offset_Change_012');
}
.width(300)
.height(300)
.backgroundColor(0xAFEEEE)
.key('Stack_Offset_Change_01')
}
}
\ No newline at end of file
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_position_change.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* 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 Stack_Position_Change{
@State addPosition: object = { x: 20, y: 20 };
@State addAlignContent: number = Alignment.TopStart;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Stack_Position_Change onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'addPosition') {
this.addPosition = message.value;
}
if (message.name == 'addAlignContent') {
this.addAlignContent = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Stack({ alignContent:this.addAlignContent }) {
Text('1').width(200).height(200).backgroundColor(0xF5DEB3).key('Stack_Position_Change_011').position(this.addPosition);
Text('2').width(100).height(100).backgroundColor(0xD2B48C).key('Stack_Position_Change_012');
}
.width(300)
.height(300)
.backgroundColor(0xAFEEEE)
.key('Stack_Position_Change_01')
}
}
\ No newline at end of file
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/StackItem_change/stack_zIndex.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* 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 Stack_ZIndex{
@State addZIndex: number = 1;
@State addAlignContent: number = Alignment.TopStart;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Stack_ZIndex onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'addZIndex') {
this.addZIndex = message.value;
}
if (message.name == 'addAlignContent') {
this.addAlignContent = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Stack({ alignContent:this.addAlignContent }) {
Text().width(200).height(200).backgroundColor(Color.Red).key('Stack_ZIndex_011').zIndex(this.addZIndex);
Text().width(100).height(100).backgroundColor(Color.Blue).key('Stack_ZIndex_012');
}
.width(350)
.height(350)
.backgroundColor(Color.White)
.key('Stack_ZIndex_01')
}
}
\ No newline at end of file
arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Stack/Stack_alignContent/stack_alignContent.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* 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 Stack_AlignContent{
@State addAlignContent: number = Alignment.TopStart;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Stack_AlignContent onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'addAlignContent') {
this.addAlignContent = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column() {
Stack() {
Text('1').width(300).height(300).backgroundColor(0xF5DEB3).key('Stack_AlignContent_011');
Text('2').width(200).height(200).backgroundColor(0xD2B48C).key('Stack_AlignContent_012');
Text('3').width(100).height(100).backgroundColor(0xF5DEB3).key('Stack_AlignContent_013');
}
.width(350)
.height(350)
.backgroundColor(0xAFEEEE)
.key('Stack_AlignContent_01')
Stack({ alignContent:this.addAlignContent }) {
Text('1').width(300).height(300).backgroundColor(0xF5DEB3).key('Stack_AlignContent_021');
Text('2').width(200).height(200).backgroundColor(0xD2B48C).key('Stack_AlignContent_022');
Text('3').width(100).height(100).backgroundColor(0xF5DEB3).key('Stack_AlignContent_023');
}
.width(350)
.height(350)
.backgroundColor(0xAFEEEE)
.key('Stack_AlignContent_02')
}
}
}
\ No newline at end of file
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_offset_change.test.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import router from '@ohos.router';
import CommonFunc from '../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../MainAbility/common/MessageManager';
export default function Stack_Offset_Change() {
describe('Stack_Offset_ChangeTest', function () {
beforeEach(async function (done) {
console.info("Stack_Offset_ChangeTest beforeEach start");
let options = {
url: "MainAbility/pages/Stack/StackItem_change/stack_offset_change",
}
try {
router.clear();
let pages = router.getState();
console.info("get Stack_Offset_Change state pages:" + JSON.stringify(pages));
if (!("stack_offset_change" == pages.name)) {
console.info("get Stack_Offset_Change pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Stack_Offset_Change page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Stack_Offset_Change page error " + JSON.stringify(err));
expect().assertFail();
}
console.info("Stack_Offset_ChangeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("Stack_Offset_Change after each called")
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0100
* @tc.name testStackOffsetChangeWithAlignmentTopStart
* @tc.desc The stack component sets alignContent to Alignment.TopStart and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentTopStart', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentTopStart] START');
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopStart');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.left).assertEqual(Stack_Offset_Change_01.left);
expect(Stack_Offset_Change_012.top).assertEqual(Stack_Offset_Change_01.top);
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentTopStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0200
* @tc.name testStackOffsetChangeWithAlignmentTop
* @tc.desc The stack component sets alignContent to Alignment.Top and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentTop', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentTop] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Top});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Top');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.top).assertEqual(Stack_Offset_Change_01.top);
expect(Math.round(Stack_Offset_Change_012.left - Stack_Offset_Change_01.left))
.assertEqual(Math.round(Stack_Offset_Change_01.right - Stack_Offset_Change_012.right));
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentTop] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0300
* @tc.name testStackOffsetChangeWithAlignmentTopEnd
* @tc.desc The stack component sets alignContent to Alignment.TopEnd and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentTopEnd', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentTopEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.TopEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopEnd');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.right).assertEqual(Stack_Offset_Change_01.right);
expect(Stack_Offset_Change_012.top).assertEqual(Stack_Offset_Change_01.top);
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_01.right)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentTopEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0400
* @tc.name testStackOffsetChangeWithAlignmentStart
* @tc.desc The stack component sets alignContent to Alignment.Start and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentStart', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Start});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Start');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.left).assertEqual(Stack_Offset_Change_01.left);
expect(Math.round(Stack_Offset_Change_012.top - Stack_Offset_Change_01.top))
.assertEqual(Math.round(Stack_Offset_Change_01.bottom - Stack_Offset_Change_012.bottom));
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0500
* @tc.name testStackOffsetChangeWithAlignmentCenter
* @tc.desc The stack component sets alignContent to Alignment.Center and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentCenter', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentCenter] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Center});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Center');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Math.round(Stack_Offset_Change_012.left - Stack_Offset_Change_01.left))
.assertEqual(Math.round(Stack_Offset_Change_01.right - Stack_Offset_Change_012.right));
expect(Math.round(Stack_Offset_Change_012.top - Stack_Offset_Change_01.top))
.assertEqual(Math.round(Stack_Offset_Change_01.bottom - Stack_Offset_Change_012.bottom));
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentCenter] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0600
* @tc.name testStackOffsetChangeWithAlignmentEnd
* @tc.desc The stack component sets alignContent to Alignment.End and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentEnd', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.End});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.End');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.right).assertEqual(Stack_Offset_Change_01.right);
expect(Math.round(Stack_Offset_Change_012.top - Stack_Offset_Change_01.top))
.assertEqual(Math.round(Stack_Offset_Change_01.bottom - Stack_Offset_Change_012.bottom));
expect(Math.round(Stack_Offset_Change_011.top - Stack_Offset_Change_01.top)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_01.right)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0700
* @tc.name testStackOffsetChangeWithAlignmentBottomStart
* @tc.desc The stack component sets alignContent to Alignment.BottomStart and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentBottomStart', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentBottomStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomStart});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomStart');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.left).assertEqual(Stack_Offset_Change_01.left);
expect(Stack_Offset_Change_012.bottom).assertEqual(Stack_Offset_Change_01.bottom);
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_01.bottom)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentBottomStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0800
* @tc.name testStackOffsetChangeWithAlignmentBottom
* @tc.desc The stack component sets alignContent to Alignment.Bottom and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentBottom', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentBottom] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Bottom});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Bottom');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.bottom).assertEqual(Stack_Offset_Change_01.bottom);
expect(Math.round(Stack_Offset_Change_012.left - Stack_Offset_Change_01.left))
.assertEqual(Math.round(Stack_Offset_Change_01.right - Stack_Offset_Change_012.right));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_01.bottom)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.left - Stack_Offset_Change_01.left)).assertEqual(vp2px(70));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentBottom] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_OFFSET_CHANGE_TEST_0900
* @tc.name testStackOffsetChangeWithAlignmentBottomEnd
* @tc.desc The stack component sets alignContent to Alignment.BottomEnd and sets the offset of
* the first subcomponent
*/
it('testStackOffsetChangeWithAlignmentBottomEnd', 0, async function (done) {
console.info('[testStackOffsetChangeWithAlignmentBottomEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Offset_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomEnd');
let Stack_Offset_Change_011 = CommonFunc.getComponentRect('Stack_Offset_Change_011');
let Stack_Offset_Change_012 = CommonFunc.getComponentRect('Stack_Offset_Change_012');
let Stack_Offset_Change_01 = CommonFunc.getComponentRect('Stack_Offset_Change_01');
expect(Stack_Offset_Change_012.bottom).assertEqual(Stack_Offset_Change_01.bottom);
expect(Stack_Offset_Change_012.right).assertEqual(Stack_Offset_Change_01.right);
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_01.bottom)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_01.right)).assertEqual(vp2px(20));
expect(Math.round(Stack_Offset_Change_011.bottom - Stack_Offset_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.bottom - Stack_Offset_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Offset_Change_011.right - Stack_Offset_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Offset_Change_012.right - Stack_Offset_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackOffsetChangeWithAlignmentBottomEnd] END');
done();
});
})
}
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_position_change.test.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import router from '@ohos.router';
import CommonFunc from '../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../MainAbility/common/MessageManager';
export default function Stack_Position_Change() {
describe('Stack_Position_ChangeTest', function () {
beforeEach(async function (done) {
console.info("Stack_Position_ChangeTest beforeEach start");
let options = {
url: "MainAbility/pages/Stack/StackItem_change/stack_position_change",
}
try {
router.clear();
let pages = router.getState();
console.info("get Stack_Position_Change state pages:" + JSON.stringify(pages));
if (!("stack_position_change" == pages.name)) {
console.info("get Stack_Position_Change pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Stack_Position_Change page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Stack_Position_Change page error " + JSON.stringify(err));
expect().assertFail();
}
console.info("Stack_Position_ChangeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("Stack_Position_Change after each called")
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0100
* @tc.name testStackPositionChangeWithAlignmentTopStart
* @tc.desc The stack component sets alignContent to Alignment.TopStart and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentTopStart', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentTopStart] START');
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopStart');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.left).assertEqual(Stack_Position_Change_01.left);
expect(Stack_Position_Change_012.top).assertEqual(Stack_Position_Change_01.top);
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentTopStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0200
* @tc.name testStackPositionChangeWithAlignmentTop
* @tc.desc The stack component sets alignContent to Alignment.Top and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentTop', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentTop] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Top});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Top');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.top).assertEqual(Stack_Position_Change_01.top);
expect(Math.round(Stack_Position_Change_012.left - Stack_Position_Change_01.left))
.assertEqual(Math.round(Stack_Position_Change_01.right - Stack_Position_Change_012.right));
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentTop] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0300
* @tc.name testStackPositionChangeWithAlignmentTopEnd
* @tc.desc The stack component sets alignContent to Alignment.TopEnd and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentTopEnd', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentTopEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.TopEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopEnd');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.right).assertEqual(Stack_Position_Change_01.right);
expect(Stack_Position_Change_012.top).assertEqual(Stack_Position_Change_01.top);
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentTopEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0400
* @tc.name testStackPositionChangeWithAlignmentStart
* @tc.desc The stack component sets alignContent to Alignment.Start and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentStart', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Start});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Start');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.left).assertEqual(Stack_Position_Change_01.left);
expect(Math.round(Stack_Position_Change_012.top - Stack_Position_Change_01.top))
.assertEqual(Math.round(Stack_Position_Change_01.bottom - Stack_Position_Change_012.bottom));
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0500
* @tc.name testStackPositionChangeWithAlignmentCenter
* @tc.desc The stack component sets alignContent to Alignment.Center and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentCenter', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentCenter] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Center});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Center');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Math.round(Stack_Position_Change_012.left - Stack_Position_Change_01.left))
.assertEqual(Math.round(Stack_Position_Change_01.right - Stack_Position_Change_012.right));
expect(Math.round(Stack_Position_Change_012.top - Stack_Position_Change_01.top))
.assertEqual(Math.round(Stack_Position_Change_01.bottom - Stack_Position_Change_012.bottom));
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentCenter] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0600
* @tc.name testStackPositionChangeWithAlignmentEnd
* @tc.desc The stack component sets alignContent to Alignment.End and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentEnd', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.End});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.End');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.right).assertEqual(Stack_Position_Change_01.right);
expect(Math.round(Stack_Position_Change_012.top - Stack_Position_Change_01.top))
.assertEqual(Math.round(Stack_Position_Change_01.bottom - Stack_Position_Change_012.bottom));
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0700
* @tc.name testStackPositionChangeWithAlignmentBottomStart
* @tc.desc The stack component sets alignContent to Alignment.BottomStart and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentBottomStart', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentBottomStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomStart});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomStart');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.left).assertEqual(Stack_Position_Change_01.left);
expect(Stack_Position_Change_012.bottom).assertEqual(Stack_Position_Change_01.bottom);
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentBottomStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0800
* @tc.name testStackPositionChangeWithAlignmentBottom
* @tc.desc The stack component sets alignContent to Alignment.Bottom and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentBottom', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentBottom] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Bottom});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Bottom');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.bottom).assertEqual(Stack_Position_Change_01.bottom);
expect(Math.round(Stack_Position_Change_012.left - Stack_Position_Change_01.left))
.assertEqual(Math.round(Stack_Position_Change_01.right - Stack_Position_Change_012.right));
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentBottom] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_POSITION_CHANGE_TEST_0900
* @tc.name testStackPositionChangeWithAlignmentBottomEnd
* @tc.desc The stack component sets alignContent to Alignment.BottomEnd and sets the position of
* the first subcomponent
*/
it('testStackPositionChangeWithAlignmentBottomEnd', 0, async function (done) {
console.info('[testStackPositionChangeWithAlignmentBottomEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_Position_Change_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomEnd');
let Stack_Position_Change_011 = CommonFunc.getComponentRect('Stack_Position_Change_011');
let Stack_Position_Change_012 = CommonFunc.getComponentRect('Stack_Position_Change_012');
let Stack_Position_Change_01 = CommonFunc.getComponentRect('Stack_Position_Change_01');
expect(Stack_Position_Change_012.bottom).assertEqual(Stack_Position_Change_01.bottom);
expect(Stack_Position_Change_012.right).assertEqual(Stack_Position_Change_01.right);
expect(Math.round(Stack_Position_Change_011.top - Stack_Position_Change_01.top)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.left - Stack_Position_Change_01.left)).assertEqual(vp2px(20));
expect(Math.round(Stack_Position_Change_011.bottom - Stack_Position_Change_011.top)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.bottom - Stack_Position_Change_012.top)).assertEqual(vp2px(100));
expect(Math.round(Stack_Position_Change_011.right - Stack_Position_Change_011.left)).assertEqual(vp2px(200));
expect(Math.round(Stack_Position_Change_012.right - Stack_Position_Change_012.left)).assertEqual(vp2px(100));
console.info('[testStackPositionChangeWithAlignmentBottomEnd] END');
done();
});
})
}
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/StackItem_change/stack_zIndex.test.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'@ohos/hypium'
;
import
router
from
'@ohos.router'
;
import
CommonFunc
from
'../../../MainAbility/common/Common'
;
import
{
MessageManager
,
Callback
}
from
'../../../MainAbility/common/MessageManager'
;
import
screenshot
from
'@ohos.screenshot'
;
import
image
from
'@ohos.multimedia.image'
;
import
window
from
'@ohos.window'
;
export
default
function
Stack_ZIndex
()
{
describe
(
'Stack_ZIndex_Test'
,
function
()
{
async
function
imageComparisonAssert
(
left
,
top
){
let
windowClass
=
null
;
let
theWinTop
=
0
;
let
isTrue
=
true
try
{
let
winTop
=
window
.
getLastWindow
(
globalThis
.
abilityContext
);
winTop
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'Succeeded in obtaining the top window. Data: '
+
JSON
.
stringify
(
data
));
let
properties
=
windowClass
.
getWindowProperties
();
console
.
info
(
'Succeeded in obtaining the window properties. Data: '
+
properties
.
windowRect
.
top
);
theWinTop
=
properties
.
windowRect
.
top
+
top
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to obtain the top window. Cause: '
+
err
);
});
}
catch
(
exception
)
{
console
.
error
(
'Failed to obtain the top window. Cause: '
+
JSON
.
stringify
(
exception
));
}
await
CommonFunc
.
sleep
(
3000
);
let
screenshotOptions
=
{
"screenRect"
:
{
"left"
:
left
,
"top"
:
theWinTop
,
"width"
:
150
,
"height"
:
150
},
"imageSize"
:
{
"width"
:
150
,
"height"
:
150
},
"rotation"
:
0
,
"displayId"
:
0
};
try
{
await
screenshot
.
save
(
screenshotOptions
,
(
err
,
pixelMap
)
=>
{
if
(
err
)
{
console
.
log
(
'Failed to save screenshot. Code: '
+
JSON
.
stringify
(
err
));
isTrue
=
false
;
}
console
.
log
(
'Succeeded in saving sreenshot. Pixel bytes number: '
+
pixelMap
.
getPixelBytesNumber
());
let
PixelBytesNumber
=
pixelMap
.
getPixelBytesNumber
();
const
color
=
new
ArrayBuffer
(
PixelBytesNumber
);
pixelMap
.
readPixelsToBuffer
(
color
,
(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
'Failed to read image pixel data.'
+
err
);
isTrue
=
false
;
}
else
{
var
bufferArr
=
new
Uint8Array
(
color
)
for
(
var
i
=
0
;
i
<
bufferArr
.
length
;
i
+=
40
)
{
if
(
bufferArr
[
i
]
!=
255
||
bufferArr
[
i
+
1
]
!=
0
||
bufferArr
[
i
+
2
]
!=
0
){
isTrue
=
false
;
return
}
}
}
})
pixelMap
.
release
();
});
}
catch
(
exception
)
{
console
.
error
(
'Failed to save screenshot. Code: '
+
JSON
.
stringify
(
exception
));
isTrue
=
false
;
};
await
CommonFunc
.
sleep
(
5000
);
return
isTrue
}
beforeEach
(
async
function
(
done
)
{
console
.
info
(
"Stack_ZIndex beforeEach start"
);
let
options
=
{
url
:
"MainAbility/pages/Stack/StackItem_change/stack_zIndex"
,
}
try
{
router
.
clear
();
let
pages
=
router
.
getState
();
console
.
info
(
"get Stack_ZIndex state pages:"
+
JSON
.
stringify
(
pages
));
if
(
!
(
"stack_zIndex"
==
pages
.
name
))
{
console
.
info
(
"get Stack_ZIndex pages.name:"
+
JSON
.
stringify
(
pages
.
name
));
let
result
=
await
router
.
push
(
options
);
await
CommonFunc
.
sleep
(
2000
);
console
.
info
(
"push Stack_ZIndex page result:"
+
JSON
.
stringify
(
result
));
}
}
catch
(
err
)
{
console
.
error
(
"push Stack_ZIndex page error "
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
}
console
.
info
(
"Stack_ZIndex beforeEach end"
);
done
();
});
afterEach
(
async
function
()
{
await
CommonFunc
.
sleep
(
2000
);
console
.
info
(
"Stack_ZIndex after each called"
);
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0100
* @tc.name testStackZIndexWithAlignmentTopStart
* @tc.desc The stack component sets alignContent to Alignment.TopStart and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentTopStart'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentTopStart] START'
);
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.TopStart'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
num
=
await
imageComparisonAssert
(
0
,
0
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_011
.
top
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_012
.
top
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_011
.
left
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_012
.
left
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentTopStart] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0200
* @tc.name testStackZIndexWithAlignmentTop
* @tc.desc The stack component sets alignContent to Alignment.Top and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentTop'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentTop] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
Top
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.Top'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
0
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_011
.
top
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_012
.
top
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_011
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_012
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentTop] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0300
* @tc.name testStackZIndexWithAlignmentTopEnd
* @tc.desc The stack component sets alignContent to Alignment.TopEnd and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentTopEnd'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentTopEnd] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
TopEnd
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.TopEnd'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
0
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_011
.
top
);
expect
(
Stack_ZIndex_01
.
top
)
.
assertEqual
(
Stack_ZIndex_012
.
top
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_011
.
right
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_012
.
right
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentTopEnd] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0400
* @tc.name testStackZIndexWithAlignmentStart
* @tc.desc The stack component sets alignContent to Alignment.Start and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentStart'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentStart] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
Start
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.Start'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
num
=
await
imageComparisonAssert
(
0
,
theTop
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_011
.
left
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_012
.
left
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_011
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_012
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentStart] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0500
* @tc.name testStackZIndexWithAlignmentCenter
* @tc.desc The stack component sets alignContent to Alignment.Center and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentCenter'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentCenter] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
Center
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.Center'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
theTop
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_011
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_012
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_011
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_012
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentCenter] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0600
* @tc.name testStackZIndexWithAlignmentEnd
* @tc.desc The stack component sets alignContent to Alignment.End and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentEnd'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentEnd] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
End
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.End'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
theTop
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_011
.
right
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_012
.
right
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_011
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
top
-
Stack_ZIndex_01
.
top
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
bottom
-
Stack_ZIndex_012
.
bottom
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentEnd] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0700
* @tc.name testStackZIndexWithAlignmentBottomStart
* @tc.desc The stack component sets alignContent to Alignment.BottomStart and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentBottomStart'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentBottomStart] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
BottomStart
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.BottomStart'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
num
=
await
imageComparisonAssert
(
0
,
theTop
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_011
.
left
);
expect
(
Stack_ZIndex_01
.
left
)
.
assertEqual
(
Stack_ZIndex_012
.
left
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_011
.
bottom
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_012
.
bottom
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentBottomStart] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0800
* @tc.name testStackZIndexWithAlignmentBottom
* @tc.desc The stack component sets alignContent to Alignment.Bottom and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentBottom'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentBottom] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
Bottom
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.Bottom'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
theTop
);
await
CommonFunc
.
sleep
(
1000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_011
.
bottom
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_012
.
bottom
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_011
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
left
-
Stack_ZIndex_01
.
left
))
.
assertEqual
(
Math
.
round
(
Stack_ZIndex_01
.
right
-
Stack_ZIndex_012
.
right
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentBottom] END'
);
done
();
});
/**
* @tc.number SUB_ACE_STACK_ZINDEX_TEST_0900
* @tc.name testStackZIndexWithAlignmentBottomEnd
* @tc.desc The stack component sets alignContent to Alignment.BottomEnd and sets the zIndex of
* the first subcomponent
*/
it
(
'testStackZIndexWithAlignmentBottomEnd'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[testStackZIndexWithAlignmentBottomEnd] START'
);
globalThis
.
value
.
message
.
notify
({
name
:
'addAlignContent'
,
value
:
Alignment
.
BottomEnd
});
await
CommonFunc
.
sleep
(
1000
);
let
strJson
=
getInspectorByKey
(
'Stack_ZIndex_01'
);
let
obj
=
JSON
.
parse
(
strJson
);
expect
(
obj
.
$type
)
.
assertEqual
(
'Stack'
);
expect
(
obj
.
$attrs
.
alignContent
)
.
assertEqual
(
'Alignment.BottomEnd'
);
let
Stack_ZIndex_011
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_011'
);
let
Stack_ZIndex_012
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_012'
);
let
Stack_ZIndex_01
=
CommonFunc
.
getComponentRect
(
'Stack_ZIndex_01'
);
let
theTop
=
Stack_ZIndex_012
.
top
;
let
theLeft
=
Stack_ZIndex_012
.
left
;
let
num
=
await
imageComparisonAssert
(
theLeft
,
theTop
);
await
CommonFunc
.
sleep
(
3000
);
expect
(
num
)
.
assertEqual
(
true
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_011
.
bottom
);
expect
(
Stack_ZIndex_01
.
bottom
)
.
assertEqual
(
Stack_ZIndex_012
.
bottom
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_011
.
right
);
expect
(
Stack_ZIndex_01
.
right
)
.
assertEqual
(
Stack_ZIndex_012
.
right
);
expect
(
Math
.
round
(
Stack_ZIndex_011
.
bottom
-
Stack_ZIndex_011
.
top
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
bottom
-
Stack_ZIndex_012
.
top
))
.
assertEqual
(
vp2px
(
100
));
expect
(
Math
.
round
(
Stack_ZIndex_011
.
right
-
Stack_ZIndex_011
.
left
))
.
assertEqual
(
vp2px
(
200
));
expect
(
Math
.
round
(
Stack_ZIndex_012
.
right
-
Stack_ZIndex_012
.
left
))
.
assertEqual
(
vp2px
(
100
));
console
.
info
(
'[testStackZIndexWithAlignmentBottomEnd] END'
);
done
();
});
})
}
arkui/ace_ets_layout_test/entry/src/main/ets/test/Stack/Stack_alignContent/stack_alignContent.test.ets
0 → 100644
浏览文件 @
f15c2aab
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import router from '@ohos.router';
import CommonFunc from '../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../MainAbility/common/MessageManager';
export default function Stack_AlignContent() {
describe('Stack_AlignContent_Test', function () {
beforeEach(async function (done) {
console.info("Stack_AlignContent_Test beforeEach start");
let options = {
url: "MainAbility/pages/Stack/Stack_alignContent/stack_alignContent",
}
try {
router.clear();
let pages = router.getState();
console.info("get Stack_AlignContent state pages:" + JSON.stringify(pages));
if (!("stack_alignContent" == pages.name)) {
console.info("get stack_alignContent pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push stack_alignContent page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push stack_alignContent page error " + JSON.stringify(err));
expect().assertFail();
}
console.info("Stack_AlignContent_Test beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(2000);
console.info("stack_alignContent after each called")
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0100
* @tc.name testStackAlignContentNotConfig
* @tc.desc The stack component does not set alignContent
*/
it('testStackAlignContentCenter', 0, async function (done) {
console.info('[testStackAlignContentCenter] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('Stack_AlignContent_01');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Center');
let stack_alignContent_011 = CommonFunc.getComponentRect('Stack_AlignContent_011');
let stack_alignContent_012 = CommonFunc.getComponentRect('Stack_AlignContent_012');
let stack_alignContent_013 = CommonFunc.getComponentRect('Stack_AlignContent_013');
let stack_alignContent_01 = CommonFunc.getComponentRect('Stack_AlignContent_01');
expect(Math.round(stack_alignContent_011.left - stack_alignContent_01.left))
.assertEqual(Math.round(stack_alignContent_01.right - stack_alignContent_011.right));
expect(Math.round(stack_alignContent_012.left - stack_alignContent_01.left))
.assertEqual(Math.round(stack_alignContent_01.right - stack_alignContent_012.right));
expect(Math.round(stack_alignContent_013.left - stack_alignContent_01.left))
.assertEqual(Math.round(stack_alignContent_01.right - stack_alignContent_013.right));
expect(Math.round(stack_alignContent_011.top - stack_alignContent_01.top))
.assertEqual(Math.round(stack_alignContent_01.bottom - stack_alignContent_011.bottom));
expect(Math.round(stack_alignContent_012.top - stack_alignContent_01.top))
.assertEqual(Math.round(stack_alignContent_01.bottom - stack_alignContent_012.bottom));
expect(Math.round(stack_alignContent_013.top - stack_alignContent_01.top))
.assertEqual(Math.round(stack_alignContent_01.bottom - stack_alignContent_013.bottom));
expect(Math.round(stack_alignContent_011.bottom - stack_alignContent_011.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_012.bottom - stack_alignContent_012.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_013.bottom - stack_alignContent_013.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_011.right - stack_alignContent_011.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_012.right - stack_alignContent_012.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_013.right - stack_alignContent_013.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentCenter] END');
done();
});
/**
* @tc.number SUB_ACE_stack_alignContent_TEST_0200
* @tc.name testStackAlignContentTopStart
* @tc.desc The stack component sets alignContent to Alignment.TopStart
*/
it('testStackAlignContentTopStart', 0, async function (done) {
console.info('[testStackAlignContentTopStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.TopStart});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopStart');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_022.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_023.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_021.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_022.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_023.top).assertEqual(stack_alignContent_02.top);
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentTopStart] END');
done();
});
/**
* @tc.number SUB_ACE_stack_alignContent_TEST_0300
* @tc.name testStackAlignContentTop
* @tc.desc The stack component sets alignContent to Alignment.Top
*/
it('testStackAlignContentTop', 0, async function (done) {
console.info('[testStackAlignContentTop] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Top});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Top');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(Math.round(stack_alignContent_021.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_021.right));
expect(Math.round(stack_alignContent_022.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_022.right));
expect(Math.round(stack_alignContent_023.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_023.right));
expect(stack_alignContent_021.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_022.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_023.top).assertEqual(stack_alignContent_02.top);
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentTop] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0400
* @tc.name testStackAlignContentTopEnd
* @tc.desc The stack component sets alignContent to Alignment.TopEnd
*/
it('testStackAlignContentTopEnd', 0, async function (done) {
console.info('[testStackAlignContentTopEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.TopEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.TopEnd');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_022.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_023.top).assertEqual(stack_alignContent_02.top);
expect(stack_alignContent_021.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_022.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_023.right).assertEqual(stack_alignContent_02.right);
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentTopEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0500
* @tc.name testStackAlignContentStart
* @tc.desc The stack component sets alignContent to Alignment.Start
*/
it('testStackAlignContentStart', 0, async function (done) {
console.info('[testStackAlignContentStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Start});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Start');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_022.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_023.left).assertEqual(stack_alignContent_02.left);
expect(Math.round(stack_alignContent_021.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_021.bottom));
expect(Math.round(stack_alignContent_022.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_022.bottom));
expect(Math.round(stack_alignContent_023.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_023.bottom));
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0600
* @tc.name testStackAlignContentCenter
* @tc.desc The stack component sets alignContent to Alignment.Center
*/
it('testStackAlignContentCenter', 0, async function (done) {
console.info('[testStackAlignContentCenter] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Center});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Center');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(Math.round(stack_alignContent_021.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_021.right));
expect(Math.round(stack_alignContent_022.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_022.right));
expect(Math.round(stack_alignContent_023.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_023.right));
expect(Math.round(stack_alignContent_021.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_021.bottom));
expect(Math.round(stack_alignContent_022.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_022.bottom));
expect(Math.round(stack_alignContent_023.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_023.bottom));
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentCenter] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0700
* @tc.name testStackAlignContentEnd
* @tc.desc The stack component sets alignContent to Alignment.End
*/
it('testStackAlignContentEnd', 0, async function (done) {
console.info('[testStackAlignContentEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.End});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.End');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_022.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_023.right).assertEqual(stack_alignContent_02.right);
expect(Math.round(stack_alignContent_021.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_021.bottom));
expect(Math.round(stack_alignContent_022.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_022.bottom));
expect(Math.round(stack_alignContent_023.top - stack_alignContent_02.top))
.assertEqual(Math.round(stack_alignContent_02.bottom - stack_alignContent_023.bottom));
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentEnd] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0800
* @tc.name testStackAlignContentBottomStart
* @tc.desc The stack component sets alignContent to Alignment.BottomStart
*/
it('testStackAlignContentBottomStart', 0, async function (done) {
console.info('[testStackAlignContentBottomStart] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomStart});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomStart');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_022.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_023.left).assertEqual(stack_alignContent_02.left);
expect(stack_alignContent_021.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_022.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_023.bottom).assertEqual(stack_alignContent_02.bottom);
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentBottomStart] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_0900
* @tc.name testStackAlignContentBottom
* @tc.desc The stack component sets alignContent to Alignment.Bottom
*/
it('testStackAlignContentBottom', 0, async function (done) {
console.info('[testStackAlignContentBottom] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.Bottom});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.Bottom');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_022.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_023.bottom).assertEqual(stack_alignContent_02.bottom);
expect(Math.round(stack_alignContent_021.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_021.right));
expect(Math.round(stack_alignContent_022.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_022.right));
expect(Math.round(stack_alignContent_023.left - stack_alignContent_02.left))
.assertEqual(Math.round(stack_alignContent_02.right - stack_alignContent_023.right));
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentBottom] END');
done();
});
/**
* @tc.number SUB_ACE_STACK_ALIGNCONTENT_TEST_1000
* @tc.name testStackAlignContentBottomEnd
* @tc.desc The stack component sets alignContent to Alignment.BottomEnd
*/
it('testStackAlignContentBottomEnd', 0, async function (done) {
console.info('[testStackAlignContentBottomEnd] START');
globalThis.value.message.notify({name:'addAlignContent', value:Alignment.BottomEnd});
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('Stack_AlignContent_02');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Stack');
expect(obj.$attrs.alignContent).assertEqual('Alignment.BottomEnd');
let stack_alignContent_021 = CommonFunc.getComponentRect('Stack_AlignContent_021');
let stack_alignContent_022 = CommonFunc.getComponentRect('Stack_AlignContent_022');
let stack_alignContent_023 = CommonFunc.getComponentRect('Stack_AlignContent_023');
let stack_alignContent_02 = CommonFunc.getComponentRect('Stack_AlignContent_02');
expect(stack_alignContent_021.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_022.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_023.bottom).assertEqual(stack_alignContent_02.bottom);
expect(stack_alignContent_021.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_022.right).assertEqual(stack_alignContent_02.right);
expect(stack_alignContent_023.right).assertEqual(stack_alignContent_02.right);
expect(Math.round(stack_alignContent_021.bottom - stack_alignContent_021.top)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.bottom - stack_alignContent_022.top)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.bottom - stack_alignContent_023.top)).assertEqual(vp2px(100));
expect(Math.round(stack_alignContent_021.right - stack_alignContent_021.left)).assertEqual(vp2px(300));
expect(Math.round(stack_alignContent_022.right - stack_alignContent_022.left)).assertEqual(vp2px(200));
expect(Math.round(stack_alignContent_023.right - stack_alignContent_023.left)).assertEqual(vp2px(100));
console.info('[testStackAlignContentBottomEnd] END');
done();
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录