From 4de1c63be1def789216f28b9d3dac8e1f7190203 Mon Sep 17 00:00:00 2001 From: zhangshuqi Date: Fri, 28 Apr 2023 10:24:27 +0800 Subject: [PATCH] Column_New Signed-off-by: zhangshuqi --- .../columnNesting/columnNesting_Space.ets | 48 ++ .../columnNesting_alignItems.ets | 48 ++ .../columnNesting_justifyContent.ets | 48 ++ .../Column/flexBasis/flexBasis_Default.ets | 48 ++ .../pages/Column/flexBasis/flexBasis_Type.ets | 51 ++ .../Column/flexGrow/flexGrow_Default.ets | 49 ++ .../pages/Column/flexGrow/flexGrow_Part.ets | 54 ++ .../Column/flexShrink/flexShrink_Default.ets | 50 ++ .../Column/flexShrink/flexShrink_Part.ets | 42 ++ .../Column/layoutWeight/layoutWeight_All.ets | 49 ++ .../layoutWeight/layoutWeight_Default.ets | 51 ++ .../Column/layoutWeight/layoutWeight_Part.ets | 46 ++ .../layoutWeight/layoutWeight_flexGrow.ets | 41 ++ .../layoutWeight/layoutWeight_flexShrink.ets | 41 ++ .../spaceChanged/Column_Space_Default.ets | 54 ++ .../spaceChanged/Column_Space_String.ets | 41 ++ .../columnNesting_Space.test.ets | 122 +++++ .../columnNesting_alignItems.test.ets | 126 +++++ .../columnNesting_justifyContent.test.ets | 126 +++++ .../flexBasis/flexBasis_Default.test.ets | 197 +++++++ .../Column/flexBasis/flexBasis_Type.test.ets | 308 +++++++++++ .../Column/flexGrow/flexGrow_Default.test.ets | 202 ++++++++ .../Column/flexGrow/flexGrow_Part.test.ets | 250 +++++++++ .../flexShrink/flexShrink_Default.test.ets | 206 ++++++++ .../flexShrink/flexShrink_Part.test.ets | 129 +++++ .../layoutWeight/layoutWeight_All.test.ets | 129 +++++ .../layoutWeight_Default.test.ets | 202 ++++++++ .../layoutWeight/layoutWeight_Part.test.ets | 168 ++++++ .../layoutWeight_flexGrow.test.ets | 166 ++++++ .../layoutWeight_flexShrink.test.ets | 166 ++++++ .../Column_Space_Default.test.ets | 234 +++++++++ .../spaceChanged/Column_Space_String.test.ets | 484 ++++++++++++++++++ .../entry/src/main/ets/test/List.test.ets | 30 ++ .../resources/base/profile/main_pages.json | 15 + 34 files changed, 4021 insertions(+) create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_Space.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_alignItems.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_justifyContent.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Default.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Type.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Default.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Part.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Default.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Part.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_All.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Default.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Part.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_Default.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_String.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_Space.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_alignItems.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_justifyContent.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Default.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Type.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Default.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Part.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Default.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Part.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_All.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Default.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Part.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexGrow.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexShrink.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_Default.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_String.test.ets diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_Space.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_Space.ets new file mode 100644 index 000000000..c2a461e16 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_Space.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_Space { + @State addSpace: string = '10vp' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('columnNesting_Space onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addSpace') { + this.addSpace = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:30}){ + Column({space:this.addSpace}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_Space_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('columnNesting_Space_012') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('columnNesting_Space_013') + }.key('columnNesting_Space_01').width(350).height(400).backgroundColor(0xAFEEEE) + Column({space:this.addSpace}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_Space_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('columnNesting_Space_022') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('columnNesting_Space_023') + }.key('columnNesting_Space_02').width(350).height(400).backgroundColor(0xAFEEEE) + }.width(300).height(1000).backgroundColor(0xF5DEB3).key('columnNesting_Space_1') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_alignItems.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_alignItems.ets new file mode 100644 index 000000000..295b8b6d2 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_alignItems.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_alignItems { + @State addSpace: string = '10vp' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('columnNesting_alignItems onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addSpace') { + this.addSpace = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:30}){ + Column({space:this.addSpace}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_alignItems_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('columnNesting_alignItems_012') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('columnNesting_alignItems_013') + }.key('columnNesting_alignItems_01').width(350).height(400).backgroundColor(0xAFEEEE).alignItems(HorizontalAlign.Start) + Column({space:this.addSpace}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_alignItems_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('columnNesting_alignItems_022') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('columnNesting_alignItems_023') + }.key('columnNesting_alignItems_02').width(350).height(400).backgroundColor(0xAFEEEE).alignItems(HorizontalAlign.End) + }.width(300).height(1000).backgroundColor(0xF5DEB3).key('columnNesting_alignItems_1').alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_justifyContent.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_justifyContent.ets new file mode 100644 index 000000000..df7f559a4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/columnNesting/columnNesting_justifyContent.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_justifyContent { + @State addSpace: string = '10vp' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('columnNesting_justifyContent onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addSpace') { + this.addSpace = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:10}){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_justifyContent_011') + Column(){Text('2')}.width(300).height(50).backgroundColor(0xD2B48C).key('columnNesting_justifyContent_012') + Column(){Text('3')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_justifyContent_013') + }.key('columnNesting_justifyContent_01').width(350).height(300).backgroundColor(0xAFEEEE).justifyContent(FlexAlign.Start) + Column({space:10}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_justifyContent_021') + Column(){Text('2')}.width(300).height(50).backgroundColor(0xD2B48C).key('columnNesting_justifyContent_022') + Column(){Text('3')}.width(300).height(50).backgroundColor(0xF5DEB3).key('columnNesting_justifyContent_023') + }.key('columnNesting_justifyContent_02').width(350).height(300).backgroundColor(0xAFEEEE).justifyContent(FlexAlign.End) + }.width(350).height(700).backgroundColor(0xF5DEB3).key('columnNesting_justifyContent_1').justifyContent(FlexAlign.SpaceBetween) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Default.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Default.ets new file mode 100644 index 000000000..2d6d283ed --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Default.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexBasis_Default { + @State addflexBasis: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexBasis_Default onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexBasis') { + this.addflexBasis = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(200).flexBasis(this.addflexBasis).backgroundColor(0xF5DEB3).key('Column_flexBasis_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexBasis_012') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexBasis_013') + }.key('Column_flexBasis_01').width(350).height(470).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(200).backgroundColor(0xF5DEB3).key('Column_flexBasis_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexBasis_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexBasis_023') + }.key('Column_flexBasis_02').width(350).height(470).backgroundColor(0xAFEEEE) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Type.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Type.ets new file mode 100644 index 000000000..4341a87e1 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexBasis/flexBasis_Type.ets @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexBasis_Type { + @State addflexBasis1: number = 0 + @State addflexBasis2: string = '0' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexBasis_Type onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexBasis1') { + this.addflexBasis1 = message.value; + }else if(message.name == 'addflexBasis2'){ + this.addflexBasis2 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(200).flexBasis(this.addflexBasis1).backgroundColor(0xF5DEB3).key('Column_flexBasis_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexBasis_012') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexBasis_013') + }.key('Column_flexBasis_01').width(350).height(470).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(220).flexBasis(this.addflexBasis2).backgroundColor(0xF5DEB3).key('Column_flexBasis_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexBasis_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexBasis_023') + }.key('Column_flexBasis_02').width(350).height(470).backgroundColor(0xAFEEEE) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Default.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Default.ets new file mode 100644 index 000000000..f29952aff --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Default.ets @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexGrow_Default { + @State addflexGrow: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexGrow_Default onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexGrow') { + this.addflexGrow = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).flexGrow(this.addflexGrow).backgroundColor(0xF5DEB3).key('Column_flexGrow_Default_011') + Column(){Text('2')}.width(300).height(100).flexGrow(this.addflexGrow).backgroundColor(0xD2B48C).key('Column_flexGrow_Default_012') + Column(){Text('3')}.width(300).height(100).flexGrow(this.addflexGrow).backgroundColor(0xF5DEB3).key('Column_flexGrow_Default_013') + }.key('Column_flexGrow_Default_01').width(350).height(450).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexGrow_Default_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexGrow_Default_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexGrow_Default_023') + }.key('Column_flexGrow_Default_02').width(350).height(450).backgroundColor(0xAFEEEE) + } + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Part.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Part.ets new file mode 100644 index 000000000..6d94b285d --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexGrow/flexGrow_Part.ets @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexGrow_Part { + @State addflexGrow1: number = 0 + @State addflexGrow2: number = 0 + @State addflexGrow3: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexGrow_Part onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexGrow1') { + this.addflexGrow1 = message.value; + }else if (message.name == 'addflexGrow2') { + this.addflexGrow2 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).layoutWeight(1).flexGrow(this.addflexGrow1).backgroundColor(0xF5DEB3).key('Column_flexGrow_011') + Column(){Text('2')}.width(300).height(100).flexGrow(this.addflexGrow2).backgroundColor(0xD2B48C).key('Column_flexGrow_012') + Column(){Text('3')}.width(300).height(100).flexGrow(this.addflexGrow3).backgroundColor(0xF5DEB3).key('Column_flexGrow_013') + }.key('Column_flexGrow_01').width(350).height(470).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexGrow_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexGrow_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexGrow_023') + }.key('Column_flexGrow_02').width(350).height(470).backgroundColor(0xAFEEEE) + } + + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Default.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Default.ets new file mode 100644 index 000000000..18967c190 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Default.ets @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexShrink_Default { + @State addflexShrink: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexShrink_Default onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexShrink') { + this.addflexShrink = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(200).flexShrink(this.addflexShrink).backgroundColor(0xF5DEB3).key('Column_flexShrink_011') + Column(){Text('2')}.width(300).height(100).flexShrink(this.addflexShrink).backgroundColor(0xD2B48C).key('Column_flexShrink_012') + Column(){Text('3')}.width(300).height(100).flexShrink(this.addflexShrink).backgroundColor(0xF5DEB3).key('Column_flexShrink_013') + }.key('Column_flexShrink_01').width(350).height(450).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(200).backgroundColor(0xF5DEB3).key('Column_flexShrink_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_flexShrink_012') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_flexShrink_013') + }.key('Column_flexShrink_01').width(350).height(450).backgroundColor(0xAFEEEE) + } + + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Part.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Part.ets new file mode 100644 index 000000000..a51d1ebd4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/flexShrink/flexShrink_Part.ets @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexShrink_Part { + @State addflexShrink: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('flexShrink_Part onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addflexShrink') { + this.addflexShrink = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:10}) { + Column(){Text('1')}.width(300).height(300).backgroundColor(0xF5DEB3).key('Column_flexShrink_011') + Column(){Text('2')}.width(300).height(100).flexShrink(this.addflexShrink).backgroundColor(0xD2B48C).key('Column_flexShrink_012') + Column(){Text('3')}.width(300).height(100).flexShrink(this.addflexShrink).backgroundColor(0xF5DEB3).key('Column_flexShrink_013') + }.key('Column_flexShrink_01').width(350).height(450).backgroundColor(0xAFEEEE) + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_All.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_All.ets new file mode 100644 index 000000000..10f04d28c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_All.ets @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_All { + @State layoutWeight1: string = '0' + @State layoutWeight2: string = '0' + @State layoutWeight3: string = '0' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('layoutWeight_All onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if(message.name == 'layoutWeight1'){ + this.layoutWeight1 = message.value; + }else if(message.name == 'layoutWeight2'){ + this.layoutWeight2 = message.value; + }else if(message.name == 'layoutWeight3'){ + this.layoutWeight3 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).layoutWeight(this.layoutWeight1).backgroundColor(0xF5DEB3).key('Column_layoutWeight_All_021') + Column(){Text('2')}.width(300).height(100).layoutWeight(this.layoutWeight2).backgroundColor(0xD2B48C).key('Column_layoutWeight_All_022') + Column(){Text('3')}.width(300).height(100).layoutWeight(this.layoutWeight3).backgroundColor(0xF5DEB3).key('Column_layoutWeight_All_023') + }.key('Column_layoutWeight_All_02').width(350).height(470).backgroundColor(0xAFEEEE) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Default.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Default.ets new file mode 100644 index 000000000..3acbf2180 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Default.ets @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_Default { + @State layoutWeight1: number = 0 + @State layoutWeight2: string = '0' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('layoutWeight_Default onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'layoutWeight1') { + this.layoutWeight1 = message.value; + }else if(message.name == 'layoutWeight2'){ + this.layoutWeight2 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).layoutWeight(this.layoutWeight1).backgroundColor(0xF5DEB3).key('Column_layoutWeight_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_layoutWeight_012') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_layoutWeight_013') + }.key('Column_layoutWeight_01').width(350).height(450).backgroundColor(0xAFEEEE) + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).layoutWeight(this.layoutWeight2).backgroundColor(0xF5DEB3).key('Column_layoutWeight_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_layoutWeight_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_layoutWeight_023') + }.key('Column_layoutWeight_02').width(350).height(450).backgroundColor(0xAFEEEE) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Part.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Part.ets new file mode 100644 index 000000000..ef59a59c3 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_Part.ets @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_Part { + @State layoutWeight1: string = '0' + @State layoutWeight2: string = '0' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('layoutWeight_Part onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'layoutWeight1') { + this.layoutWeight1 = message.value; + }else if(message.name == 'layoutWeight2'){ + this.layoutWeight2 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).layoutWeight(this.layoutWeight1).backgroundColor(0xF5DEB3).key('Column_layoutWeight_021') + Column(){Text('2')}.width(300).height(100).layoutWeight(this.layoutWeight2).backgroundColor(0xD2B48C).key('Column_layoutWeight_022') + Column(){Text('3')}.width(300).height(100).backgroundColor(0xF5DEB3).key('Column_layoutWeight_023') + }.key('Column_layoutWeight_02').width(350).height(450).backgroundColor(0xAFEEEE) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow.ets new file mode 100644 index 000000000..b8f0ec7cd --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow.ets @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_flexGrow { + @State addLayoutWeight: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('layoutWeight_flexGrow onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addLayoutWeight') { + this.addLayoutWeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).flexGrow(1).layoutWeight(this.addLayoutWeight).backgroundColor(0xF5DEB3).key('Column_layoutWeight_011') + Column(){Text('2')}.width(300).height(100).flexGrow(2).layoutWeight(this.addLayoutWeight).backgroundColor(0xD2B48C).key('Column_layoutWeight_012') + Column(){Text('3')}.width(300).height(100).flexGrow(1).layoutWeight(this.addLayoutWeight).backgroundColor(0xF5DEB3).key('Column_layoutWeight_013') + }.key('Column_layoutWeight_01').width(350).height(470).backgroundColor(0xAFEEEE) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink.ets new file mode 100644 index 000000000..d64cc2039 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink.ets @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_flexShrink { + @State addLayoutWeight: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('layoutWeight_flexShrink onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addLayoutWeight') { + this.addLayoutWeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:10}) { + Column(){Text('1')}.width(300).height(100).flexShrink(1).layoutWeight(this.addLayoutWeight).backgroundColor(0xF5DEB3).key('Column_layoutWeight_011') + Column(){Text('2')}.width(300).height(100).flexShrink(2).layoutWeight(this.addLayoutWeight).backgroundColor(0xD2B48C).key('Column_layoutWeight_012') + Column(){Text('3')}.width(300).height(100).flexShrink(2).layoutWeight(this.addLayoutWeight).backgroundColor(0xF5DEB3).key('Column_layoutWeight_013') + }.key('Column_layoutWeight_01').width(350).height(470).backgroundColor(0xAFEEEE) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_Default.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_Default.ets new file mode 100644 index 000000000..82f832797 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_Default.ets @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2023 Huawei Device 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 Column_Space_Default { + @State addSpace1:number=0 + @State addSpace2:string='0' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Column_Space_Default onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addSpace1') { + this.addSpace1 = message.value; + }else if(message.name == 'addSpace2'){ + this.addSpace2 = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column(){ + Column({space:this.addSpace1}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('Column_Space_Default_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_Space_Default_012') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('Column_Space_Default_013') + }.key('Column_Space_Default_01').width(350).height(400).backgroundColor(0xAFEEEE) + + Column({space:this.addSpace2}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('Column_Space_Default_021') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_Space_Default_022') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('Column_Space_Default_023') + }.key('Column_Space_Default_02').width(350).height(400).backgroundColor(0xAFEEEE) + + } + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_String.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_String.ets new file mode 100644 index 000000000..46af9a786 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Column/spaceChanged/Column_Space_String.ets @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2023 Huawei Device 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 Column_Space_String { + @State addSpace: string = '10vp' + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Column_Space_String onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'addSpace') { + this.addSpace = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({space:this.addSpace}) { + Column(){Text('1')}.width(300).height(50).backgroundColor(0xF5DEB3).key('Column_Space_String_011') + Column(){Text('2')}.width(300).height(100).backgroundColor(0xD2B48C).key('Column_Space_String_012') + Column(){Text('3')}.width(300).height(150).backgroundColor(0xF5DEB3).key('Column_Space_String_013') + }.key('Column_Space_String_01').width(350).height(400).backgroundColor(0xAFEEEE) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_Space.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_Space.test.ets new file mode 100644 index 000000000..b206c1d59 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_Space.test.ets @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_Space() { + describe('columnNesting_Space', function () { + beforeEach(async function (done) { + console.info("columnNesting_Space beforeEach start"); + let options = { + url: "MainAbility/pages/Column/columnNesting/columnNesting_Space", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get columnNesting_Space state pages1:" + JSON.stringify(pages)); + if (!("columnNesting_Space" == pages.name)) { + console.info("get columnNesting_Space pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + pages = router.getState(); + console.info("get columnNesting_Space state pages2:" + JSON.stringify(pages)); + console.info("push columnNesting_Space page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push columnNesting_Space page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("columnNesting_Space after each called") + }); + + /** + * @tc.number SUB_ACE_columnNesting_Space_TEST_0100 + * @tc.name testColumnSpace + * @tc.desc column_1 and column_01, column_02 settings space do not affect each other + */ + it('SUB_ACE_columnNesting_Space_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_columnNesting_Space_TEST_0100] START'); + await CommonFunc.sleep(4000); + console.log('get Initial value') + let columnNesting_Space_011 = CommonFunc.getComponentRect('columnNesting_Space_011'); + let columnNesting_Space_012 = CommonFunc.getComponentRect('columnNesting_Space_012'); + let columnNesting_Space_013 = CommonFunc.getComponentRect('columnNesting_Space_013'); + let columnNesting_Space_01 = CommonFunc.getComponentRect('columnNesting_Space_01'); + let columnNesting_Space_021 = CommonFunc.getComponentRect('columnNesting_Space_021'); + let columnNesting_Space_022 = CommonFunc.getComponentRect('columnNesting_Space_022'); + let columnNesting_Space_023 = CommonFunc.getComponentRect('columnNesting_Space_023'); + let columnNesting_Space_02 = CommonFunc.getComponentRect('columnNesting_Space_02'); + let columnNesting_Space_1 = CommonFunc.getComponentRect('columnNesting_Space_1'); + console.log('assert position') + expect(Math.round(columnNesting_Space_011.left - columnNesting_Space_01.left)).assertEqual(Math.round(columnNesting_Space_01.right - columnNesting_Space_011.right)); + expect(Math.round(columnNesting_Space_012.left - columnNesting_Space_01.left)).assertEqual(Math.round(columnNesting_Space_01.right - columnNesting_Space_012.right)); + expect(Math.round(columnNesting_Space_013.left - columnNesting_Space_01.left)).assertEqual(Math.round(columnNesting_Space_01.right - columnNesting_Space_013.right)); + expect(Math.round(columnNesting_Space_012.top - columnNesting_Space_011.bottom)).assertEqual(Math.round(columnNesting_Space_013.top - columnNesting_Space_012.bottom)) + + expect(Math.round(columnNesting_Space_021.left - columnNesting_Space_02.left)).assertEqual(Math.round(columnNesting_Space_02.right - columnNesting_Space_021.right)); + expect(Math.round(columnNesting_Space_022.left - columnNesting_Space_02.left)).assertEqual(Math.round(columnNesting_Space_02.right - columnNesting_Space_022.right)); + expect(Math.round(columnNesting_Space_023.left - columnNesting_Space_02.left)).assertEqual(Math.round(columnNesting_Space_02.right - columnNesting_Space_023.right)); + expect(Math.round(columnNesting_Space_022.top - columnNesting_Space_021.bottom)).assertEqual(Math.round(columnNesting_Space_023.top - columnNesting_Space_022.bottom)) + + expect(columnNesting_Space_01.top).assertEqual(columnNesting_Space_011.top); + + console.log('assert space') + expect(Math.round(columnNesting_Space_012.top - columnNesting_Space_011.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_Space_012.top - columnNesting_Space_011.bottom', + columnNesting_Space_012.top - columnNesting_Space_011.bottom) + expect(Math.round(columnNesting_Space_013.top - columnNesting_Space_012.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_Space_013.top - columnNesting_Space_012.bottom', + columnNesting_Space_013.top - columnNesting_Space_012.bottom) + expect(Math.round(columnNesting_Space_022.top - columnNesting_Space_021.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_Space_012.top - columnNesting_Space_011.bottom', + columnNesting_Space_012.top - columnNesting_Space_011.bottom) + expect(Math.round(columnNesting_Space_023.top - columnNesting_Space_022.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_Space_013.top - columnNesting_Space_012.bottom', + columnNesting_Space_013.top - columnNesting_Space_012.bottom) + expect(Math.round(columnNesting_Space_02.top - columnNesting_Space_01.bottom)).assertEqual(Math.round(vp2px(30))); + console.log('columnNesting_Space_02.top - columnNesting_Space_01.bottom', + columnNesting_Space_02.top - columnNesting_Space_01.bottom) + + console.log('assert height') + console.log('column_01 assert height') + expect(Math.round(columnNesting_Space_011.bottom - columnNesting_Space_011.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_Space_012.bottom - columnNesting_Space_012.top)).assertEqual(vp2px(100)); + expect(Math.round(columnNesting_Space_013.bottom - columnNesting_Space_013.top)).assertEqual(vp2px(150)); + + console.log('column_02 assert height') + expect(Math.round(columnNesting_Space_021.bottom - columnNesting_Space_021.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_Space_022.bottom - columnNesting_Space_022.top)).assertEqual(vp2px(100)); + expect(Math.round(columnNesting_Space_023.bottom - columnNesting_Space_023.top)).assertEqual(vp2px(150)); + + expect(Math.round(columnNesting_Space_01.bottom - columnNesting_Space_01.top)).assertEqual(vp2px(400)); + expect(Math.round(columnNesting_Space_02.bottom - columnNesting_Space_02.top)).assertEqual(vp2px(400)); + + console.log('assert weight') + expect(Math.round(columnNesting_Space_011.right - columnNesting_Space_011.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_Space_012.right - columnNesting_Space_012.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_Space_013.right - columnNesting_Space_013.left)).assertEqual(vp2px(300)); + + expect(Math.round(columnNesting_Space_021.right - columnNesting_Space_021.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_Space_022.right - columnNesting_Space_022.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_Space_023.right - columnNesting_Space_023.left)).assertEqual(vp2px(300)); + + expect(Math.round(columnNesting_Space_01.right - columnNesting_Space_01.left)).assertEqual(vp2px(350)); + expect(Math.round(columnNesting_Space_02.right - columnNesting_Space_02.left)).assertEqual(vp2px(350)); + + console.info('[SUB_ACE_columnNesting_Space_TEST_0100] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_alignItems.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_alignItems.test.ets new file mode 100644 index 000000000..2b7df9189 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_alignItems.test.ets @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_alignItems() { + describe('columnNesting_alignItems', function () { + beforeEach(async function (done) { + console.info("columnNesting_alignItems beforeEach start"); + let options = { + url: "MainAbility/pages/Column/columnNesting/columnNesting_alignItems", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get columnNesting_alignItems state pages1:" + JSON.stringify(pages)); + if (!("columnNesting_alignItems" == pages.name)) { + console.info("get columnNesting_alignItems pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + pages = router.getState(); + console.info("get columnNesting_alignItems state pages2:" + JSON.stringify(pages)); + console.info("push columnNesting_alignItems page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push columnNesting_alignItems page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("columnNesting_alignItems after each called") + }); + + /** + * @tc.number SUB_ACE_columnNesting_alignItems_TEST_0100 + * @tc.name testColumnSpace + * @tc.desc column_1 and column_01, column_02 settings justifyContent do not affect each other + */ + it('SUB_ACE_columnNesting_alignItems_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_columnNesting_alignItems_TEST_0100] START'); + await CommonFunc.sleep(4000); + console.log('get Initial value') + let columnNesting_alignItems_011 = CommonFunc.getComponentRect('columnNesting_alignItems_011'); + let columnNesting_alignItems_012 = CommonFunc.getComponentRect('columnNesting_alignItems_012'); + let columnNesting_alignItems_013 = CommonFunc.getComponentRect('columnNesting_alignItems_013'); + let columnNesting_alignItems_01 = CommonFunc.getComponentRect('columnNesting_alignItems_01'); + let columnNesting_alignItems_021 = CommonFunc.getComponentRect('columnNesting_alignItems_021'); + let columnNesting_alignItems_022 = CommonFunc.getComponentRect('columnNesting_alignItems_022'); + let columnNesting_alignItems_023 = CommonFunc.getComponentRect('columnNesting_alignItems_023'); + let columnNesting_alignItems_02 = CommonFunc.getComponentRect('columnNesting_alignItems_02'); + let columnNesting_alignItems_1 = CommonFunc.getComponentRect('columnNesting_alignItems_1'); + console.log('assert position') + expect(columnNesting_alignItems_011.left).assertEqual(columnNesting_alignItems_01.left ); + expect(columnNesting_alignItems_012.left).assertEqual(columnNesting_alignItems_01.left ); + expect(columnNesting_alignItems_013.left).assertEqual(columnNesting_alignItems_01.left ); + + expect(columnNesting_alignItems_021.right).assertEqual(columnNesting_alignItems_02.right); + expect(columnNesting_alignItems_022.right).assertEqual(columnNesting_alignItems_02.right); + expect(columnNesting_alignItems_023.right).assertEqual(columnNesting_alignItems_02.right); + + expect(columnNesting_alignItems_01.top).assertEqual(columnNesting_alignItems_011.top); + expect(columnNesting_alignItems_1.top).assertEqual(columnNesting_alignItems_01.top); + + console.log('assert space') + expect(Math.round(columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom)).assertEqual(Math.round(columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom)) + expect(Math.round(columnNesting_alignItems_022.top - columnNesting_alignItems_021.bottom)).assertEqual(Math.round(columnNesting_alignItems_023.top - columnNesting_alignItems_022.bottom)) + + expect(Math.round(columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom', + columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom) + expect(Math.round(columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom', + columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom) + expect(Math.round(columnNesting_alignItems_022.top - columnNesting_alignItems_021.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom', + columnNesting_alignItems_012.top - columnNesting_alignItems_011.bottom) + expect(Math.round(columnNesting_alignItems_023.top - columnNesting_alignItems_022.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom', + columnNesting_alignItems_013.top - columnNesting_alignItems_012.bottom) + expect(Math.round(columnNesting_alignItems_02.top - columnNesting_alignItems_01.bottom)).assertEqual(Math.round(vp2px(30))); + console.log('columnNesting_alignItems_02.top - columnNesting_alignItems_01.bottom', + columnNesting_alignItems_02.top - columnNesting_alignItems_01.bottom) + + console.log('assert height') + console.log('column_01 assert height') + expect(Math.round(columnNesting_alignItems_011.bottom - columnNesting_alignItems_011.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_alignItems_012.bottom - columnNesting_alignItems_012.top)).assertEqual(vp2px(100)); + expect(Math.round(columnNesting_alignItems_013.bottom - columnNesting_alignItems_013.top)).assertEqual(vp2px(150)); + + console.log('column_02 assert height') + expect(Math.round(columnNesting_alignItems_021.bottom - columnNesting_alignItems_021.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_alignItems_022.bottom - columnNesting_alignItems_022.top)).assertEqual(vp2px(100)); + expect(Math.round(columnNesting_alignItems_023.bottom - columnNesting_alignItems_023.top)).assertEqual(vp2px(150)); + + expect(Math.round(columnNesting_alignItems_01.bottom - columnNesting_alignItems_01.top)).assertEqual(vp2px(400)); + expect(Math.round(columnNesting_alignItems_02.bottom - columnNesting_alignItems_02.top)).assertEqual(vp2px(400)); + + console.log('assert weight') + console.log('column_01 assert weight') + expect(Math.round(columnNesting_alignItems_011.right - columnNesting_alignItems_011.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_alignItems_012.right - columnNesting_alignItems_012.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_alignItems_013.right - columnNesting_alignItems_013.left)).assertEqual(vp2px(300)); + + console.log('column_02 assert weight') + expect(Math.round(columnNesting_alignItems_021.right - columnNesting_alignItems_021.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_alignItems_022.right - columnNesting_alignItems_022.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_alignItems_023.right - columnNesting_alignItems_023.left)).assertEqual(vp2px(300)); + + expect(Math.round(columnNesting_alignItems_01.right - columnNesting_alignItems_01.left)).assertEqual(vp2px(350)); + expect(Math.round(columnNesting_alignItems_02.right - columnNesting_alignItems_02.left)).assertEqual(vp2px(350)); + + console.info('[SUB_ACE_columnNesting_alignItems_TEST_0100] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_justifyContent.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_justifyContent.test.ets new file mode 100644 index 000000000..f613fdd12 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/columnNesting/columnNesting_justifyContent.test.ets @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2023 Huawei Device 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 columnNesting_justifyContent() { + describe('columnNesting_justifyContent', function () { + beforeEach(async function (done) { + console.info("columnNesting_justifyContent beforeEach start"); + let options = { + url: "MainAbility/pages/Column/columnNesting/columnNesting_justifyContent", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get columnNesting_justifyContent state pages1:" + JSON.stringify(pages)); + if (!("columnNesting_justifyContent" == pages.name)) { + console.info("get columnNesting_justifyContent pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + pages = router.getState(); + console.info("get columnNesting_justifyContent state pages2:" + JSON.stringify(pages)); + console.info("push columnNesting_justifyContent page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push columnNesting_justifyContent page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("columnNesting_justifyContent after each called") + }); + + /** + * @tc.number SUB_ACE_columnNesting_justifyContent_TEST_0100 + * @tc.name testColumnSpace + * @tc.desc column_1 and column_01, column_02 settings justifyContent do not affect each other + */ + it('SUB_ACE_columnNesting_justifyContent_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_columnNesting_justifyContent_TEST_0100] START'); + await CommonFunc.sleep(4000); + console.log('get Initial value') + let columnNesting_justifyContent_011 = CommonFunc.getComponentRect('columnNesting_justifyContent_011'); + let columnNesting_justifyContent_012 = CommonFunc.getComponentRect('columnNesting_justifyContent_012'); + let columnNesting_justifyContent_013 = CommonFunc.getComponentRect('columnNesting_justifyContent_013'); + let columnNesting_justifyContent_01 = CommonFunc.getComponentRect('columnNesting_justifyContent_01'); + let columnNesting_justifyContent_021 = CommonFunc.getComponentRect('columnNesting_justifyContent_021'); + let columnNesting_justifyContent_022 = CommonFunc.getComponentRect('columnNesting_justifyContent_022'); + let columnNesting_justifyContent_023 = CommonFunc.getComponentRect('columnNesting_justifyContent_023'); + let columnNesting_justifyContent_02 = CommonFunc.getComponentRect('columnNesting_justifyContent_02'); + let columnNesting_justifyContent_1 = CommonFunc.getComponentRect('columnNesting_justifyContent_1'); + console.log('assert position') + expect(Math.round(columnNesting_justifyContent_011.left - columnNesting_justifyContent_01.left)).assertEqual(Math.round(columnNesting_justifyContent_01.right - columnNesting_justifyContent_011.right)); + expect(Math.round(columnNesting_justifyContent_012.left - columnNesting_justifyContent_01.left)).assertEqual(Math.round(columnNesting_justifyContent_01.right - columnNesting_justifyContent_012.right)); + expect(Math.round(columnNesting_justifyContent_013.left - columnNesting_justifyContent_01.left)).assertEqual(Math.round(columnNesting_justifyContent_01.right - columnNesting_justifyContent_013.right)); + + expect(Math.round(columnNesting_justifyContent_021.left - columnNesting_justifyContent_02.left)).assertEqual(Math.round(columnNesting_justifyContent_02.right - columnNesting_justifyContent_021.right)); + expect(Math.round(columnNesting_justifyContent_022.left - columnNesting_justifyContent_02.left)).assertEqual(Math.round(columnNesting_justifyContent_02.right - columnNesting_justifyContent_022.right)); + expect(Math.round(columnNesting_justifyContent_023.left - columnNesting_justifyContent_02.left)).assertEqual(Math.round(columnNesting_justifyContent_02.right - columnNesting_justifyContent_023.right)); + + expect(columnNesting_justifyContent_01.top).assertEqual(columnNesting_justifyContent_011.top); + expect(columnNesting_justifyContent_1.top).assertEqual(columnNesting_justifyContent_01.top); + + console.log('assert space') + expect(Math.round(columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom)).assertEqual(Math.round(columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom)) + expect(Math.round(columnNesting_justifyContent_022.top - columnNesting_justifyContent_021.bottom)).assertEqual(Math.round(columnNesting_justifyContent_023.top - columnNesting_justifyContent_022.bottom)) + + expect(Math.round(columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom', + columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom) + expect(Math.round(columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom', + columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom) + expect(Math.round(columnNesting_justifyContent_022.top - columnNesting_justifyContent_021.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom', + columnNesting_justifyContent_012.top - columnNesting_justifyContent_011.bottom) + expect(Math.round(columnNesting_justifyContent_023.top - columnNesting_justifyContent_022.bottom)).assertEqual(Math.round(vp2px(10))); + console.log('columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom', + columnNesting_justifyContent_013.top - columnNesting_justifyContent_012.bottom) + expect(Math.round(columnNesting_justifyContent_02.top - columnNesting_justifyContent_01.bottom)).assertEqual(Math.round(vp2px(100))); + console.log('columnNesting_justifyContent_02.top - columnNesting_justifyContent_01.bottom', + columnNesting_justifyContent_02.top - columnNesting_justifyContent_01.bottom) + + console.log('assert height') + console.log('column_01 assert height') + expect(Math.round(columnNesting_justifyContent_011.bottom - columnNesting_justifyContent_011.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_justifyContent_012.bottom - columnNesting_justifyContent_012.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_justifyContent_013.bottom - columnNesting_justifyContent_013.top)).assertEqual(vp2px(50)); + + console.log('column_02 assert height') + expect(Math.round(columnNesting_justifyContent_021.bottom - columnNesting_justifyContent_021.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_justifyContent_022.bottom - columnNesting_justifyContent_022.top)).assertEqual(vp2px(50)); + expect(Math.round(columnNesting_justifyContent_023.bottom - columnNesting_justifyContent_023.top)).assertEqual(vp2px(50)); + + expect(Math.round(columnNesting_justifyContent_01.bottom - columnNesting_justifyContent_01.top)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_justifyContent_02.bottom - columnNesting_justifyContent_02.top)).assertEqual(vp2px(300)); + + console.log('assert weight') + console.log('column_01 assert weight') + expect(Math.round(columnNesting_justifyContent_011.right - columnNesting_justifyContent_011.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_justifyContent_012.right - columnNesting_justifyContent_012.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_justifyContent_013.right - columnNesting_justifyContent_013.left)).assertEqual(vp2px(300)); + + console.log('column_02 assert weight') + expect(Math.round(columnNesting_justifyContent_021.right - columnNesting_justifyContent_021.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_justifyContent_022.right - columnNesting_justifyContent_022.left)).assertEqual(vp2px(300)); + expect(Math.round(columnNesting_justifyContent_023.right - columnNesting_justifyContent_023.left)).assertEqual(vp2px(300)); + + expect(Math.round(columnNesting_justifyContent_01.right - columnNesting_justifyContent_01.left)).assertEqual(vp2px(350)); + expect(Math.round(columnNesting_justifyContent_02.right - columnNesting_justifyContent_02.left)).assertEqual(vp2px(350)); + + console.info('[SUB_ACE_columnNesting_justifyContent_TEST_0100] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Default.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Default.test.ets new file mode 100644 index 000000000..d916574ff --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Default.test.ets @@ -0,0 +1,197 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexBasis_Default() { + describe('flexBasis_Default', function () { + beforeEach(async function (done) { + console.info("flexBasis_Default beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexBasis/flexBasis_Default", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexBasis_Default state pages:" + JSON.stringify(pages)); + if (!("flexBasis_Default" == pages.name)) { + console.info("get flexBasis_Default pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexBasis_Default page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexBasis_Default page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexBasis_Default after each called") + }); + /** + * @tc.number SUB_ACE_flexBasis_Default_TEST_0100 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis(null) , the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Default_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Default_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexBasis', value:null}); + await CommonFunc.sleep(3000); + let Column_flexBasis_011 = CommonFunc.getComponentRect('Column_flexBasis_011'); + let Column_flexBasis_012 = CommonFunc.getComponentRect('Column_flexBasis_012'); + let Column_flexBasis_013 = CommonFunc.getComponentRect('Column_flexBasis_013'); + let Column_flexBasis_01 = CommonFunc.getComponentRect('Column_flexBasis_01'); + console.log('assert position') + expect(Math.round(Column_flexBasis_011.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_011.right)); + expect(Math.round(Column_flexBasis_012.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_012.right)); + expect(Math.round(Column_flexBasis_013.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_013.right)); + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexBasis_012.top - Column_flexBasis_011.bottom', + Column_flexBasis_012.top - Column_flexBasis_011.bottom) + console.log('Column_flexBasis_013.top - Column_flexBasis_012.bottom', + Column_flexBasis_013.top - Column_flexBasis_012.bottom) + expect(Column_flexBasis_01.top).assertEqual(Column_flexBasis_011.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_011.bottom - Column_flexBasis_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_011.bottom - Column_flexBasis_011.top', + Column_flexBasis_011.bottom - Column_flexBasis_011.top) + expect(Math.round(Column_flexBasis_012.bottom - Column_flexBasis_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_012.bottom - Column_flexBasis_012.top', + Column_flexBasis_012.bottom - Column_flexBasis_012.top) + expect(Math.round(Column_flexBasis_013.bottom - Column_flexBasis_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_013.bottom - Column_flexBasis_013.top', + Column_flexBasis_013.bottom - Column_flexBasis_013.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_011.right - Column_flexBasis_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_012.right - Column_flexBasis_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_013.right - Column_flexBasis_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Default_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Default_TEST_0200 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis(undefined) , the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Default_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Default_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexBasis', value:undefined}); + await CommonFunc.sleep(3000); + let Column_flexBasis_011 = CommonFunc.getComponentRect('Column_flexBasis_011'); + let Column_flexBasis_012 = CommonFunc.getComponentRect('Column_flexBasis_012'); + let Column_flexBasis_013 = CommonFunc.getComponentRect('Column_flexBasis_013'); + let Column_flexBasis_01 = CommonFunc.getComponentRect('Column_flexBasis_01'); + console.log('assert position') + expect(Math.round(Column_flexBasis_011.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_011.right)); + expect(Math.round(Column_flexBasis_012.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_012.right)); + expect(Math.round(Column_flexBasis_013.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_013.right)); + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexBasis_012.top - Column_flexBasis_011.bottom', + Column_flexBasis_012.top - Column_flexBasis_011.bottom) + console.log('Column_flexBasis_013.top - Column_flexBasis_012.bottom', + Column_flexBasis_013.top - Column_flexBasis_012.bottom) + expect(Column_flexBasis_01.top).assertEqual(Column_flexBasis_011.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_011.bottom - Column_flexBasis_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_011.bottom - Column_flexBasis_011.top', + Column_flexBasis_011.bottom - Column_flexBasis_011.top) + expect(Math.round(Column_flexBasis_012.bottom - Column_flexBasis_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_012.bottom - Column_flexBasis_012.top', + Column_flexBasis_012.bottom - Column_flexBasis_012.top) + expect(Math.round(Column_flexBasis_013.bottom - Column_flexBasis_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_013.bottom - Column_flexBasis_013.top', + Column_flexBasis_013.bottom - Column_flexBasis_013.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_011.right - Column_flexBasis_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_012.right - Column_flexBasis_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_013.right - Column_flexBasis_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Default_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Default_TEST_0300 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis(-5) , the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Default_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Default_TEST_0300] START'); + globalThis.value.message.notify({name:'addflexBasis', value:-5}); + await CommonFunc.sleep(3000); + let Column_flexBasis_011 = CommonFunc.getComponentRect('Column_flexBasis_011'); + let Column_flexBasis_012 = CommonFunc.getComponentRect('Column_flexBasis_012'); + let Column_flexBasis_013 = CommonFunc.getComponentRect('Column_flexBasis_013'); + let Column_flexBasis_01 = CommonFunc.getComponentRect('Column_flexBasis_01'); + console.log('assert position') + expect(Math.round(Column_flexBasis_011.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_011.right)); + expect(Math.round(Column_flexBasis_012.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_012.right)); + expect(Math.round(Column_flexBasis_013.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_013.right)); + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexBasis_012.top - Column_flexBasis_011.bottom', + Column_flexBasis_012.top - Column_flexBasis_011.bottom) + console.log('Column_flexBasis_013.top - Column_flexBasis_012.bottom', + Column_flexBasis_013.top - Column_flexBasis_012.bottom) + expect(Column_flexBasis_01.top).assertEqual(Column_flexBasis_011.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_011.bottom - Column_flexBasis_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_011.bottom - Column_flexBasis_011.top', + Column_flexBasis_011.bottom - Column_flexBasis_011.top) + expect(Math.round(Column_flexBasis_012.bottom - Column_flexBasis_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_012.bottom - Column_flexBasis_012.top', + Column_flexBasis_012.bottom - Column_flexBasis_012.top) + expect(Math.round(Column_flexBasis_013.bottom - Column_flexBasis_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_013.bottom - Column_flexBasis_013.top', + Column_flexBasis_013.bottom - Column_flexBasis_013.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_011.right - Column_flexBasis_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_012.right - Column_flexBasis_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_013.right - Column_flexBasis_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Default_TEST_0300] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_flexBasis_Default_TEST_0400 + * @tc.name testFlexBasis + * @tc.desc column1、column2 and column3 do not set flexBasis, the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Default_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Default_TEST_0400] START'); + await CommonFunc.sleep(3000); + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Default_TEST_0400] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Type.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Type.test.ets new file mode 100644 index 000000000..7b9cbc539 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexBasis/flexBasis_Type.test.ets @@ -0,0 +1,308 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexBasis_Type() { + describe('flexBasis_Type', function () { + beforeEach(async function (done) { + console.info("flexBasis_Type beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexBasis/flexBasis_Type", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexBasis_Type state pages:" + JSON.stringify(pages)); + if (!("flexBasis_Type" == pages.name)) { + console.info("get flexBasis_Type pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexBasis_Type page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexBasis_Type page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexBasis_Type after each called") + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0100 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis(100) , the height of column1 is 100vp + */ + it('SUB_ACE_flexBasis_Type_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexBasis1', value:100}); + await CommonFunc.sleep(3000); + let Column_flexBasis_011 = CommonFunc.getComponentRect('Column_flexBasis_011'); + let Column_flexBasis_012 = CommonFunc.getComponentRect('Column_flexBasis_012'); + let Column_flexBasis_013 = CommonFunc.getComponentRect('Column_flexBasis_013'); + let Column_flexBasis_01 = CommonFunc.getComponentRect('Column_flexBasis_01'); + console.log('assert position') + expect(Math.round(Column_flexBasis_011.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_011.right)); + expect(Math.round(Column_flexBasis_012.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_012.right)); + expect(Math.round(Column_flexBasis_013.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_013.right)); + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexBasis_012.top - Column_flexBasis_011.bottom', + Column_flexBasis_012.top - Column_flexBasis_011.bottom) + console.log('Column_flexBasis_013.top - Column_flexBasis_012.bottom', + Column_flexBasis_013.top - Column_flexBasis_012.bottom) + expect(Column_flexBasis_01.top).assertEqual(Column_flexBasis_011.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_011.bottom - Column_flexBasis_011.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_011.bottom - Column_flexBasis_011.top', + Column_flexBasis_011.bottom - Column_flexBasis_011.top) + expect(Math.round(Column_flexBasis_012.bottom - Column_flexBasis_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_012.bottom - Column_flexBasis_012.top', + Column_flexBasis_012.bottom - Column_flexBasis_012.top) + expect(Math.round(Column_flexBasis_013.bottom - Column_flexBasis_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_013.bottom - Column_flexBasis_013.top', + Column_flexBasis_013.bottom - Column_flexBasis_013.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_011.right - Column_flexBasis_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_012.right - Column_flexBasis_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_013.right - Column_flexBasis_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0200 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis(0) , the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Type_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexBasis1', value:0}); + await CommonFunc.sleep(3000); + let Column_flexBasis_011 = CommonFunc.getComponentRect('Column_flexBasis_011'); + let Column_flexBasis_012 = CommonFunc.getComponentRect('Column_flexBasis_012'); + let Column_flexBasis_013 = CommonFunc.getComponentRect('Column_flexBasis_013'); + let Column_flexBasis_01 = CommonFunc.getComponentRect('Column_flexBasis_01'); + console.log('assert position') + expect(Math.round(Column_flexBasis_011.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_011.right)); + expect(Math.round(Column_flexBasis_012.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_012.right)); + expect(Math.round(Column_flexBasis_013.left - Column_flexBasis_01.left)).assertEqual(Math.round(Column_flexBasis_01.right - Column_flexBasis_013.right)); + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_012.top - Column_flexBasis_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_013.top - Column_flexBasis_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexBasis_012.top - Column_flexBasis_011.bottom', + Column_flexBasis_012.top - Column_flexBasis_011.bottom) + console.log('Column_flexBasis_013.top - Column_flexBasis_012.bottom', + Column_flexBasis_013.top - Column_flexBasis_012.bottom) + expect(Column_flexBasis_01.top).assertEqual(Column_flexBasis_011.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_011.bottom - Column_flexBasis_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_011.bottom - Column_flexBasis_011.top', + Column_flexBasis_011.bottom - Column_flexBasis_011.top) + expect(Math.round(Column_flexBasis_012.bottom - Column_flexBasis_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_012.bottom - Column_flexBasis_012.top', + Column_flexBasis_012.bottom - Column_flexBasis_012.top) + expect(Math.round(Column_flexBasis_013.bottom - Column_flexBasis_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_013.bottom - Column_flexBasis_013.top', + Column_flexBasis_013.bottom - Column_flexBasis_013.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_011.right - Column_flexBasis_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_012.right - Column_flexBasis_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_013.right - Column_flexBasis_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0200] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0300 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis('auto') , the height of column1 is the original height + */ + it('SUB_ACE_flexBasis_Type_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0300] START'); + globalThis.value.message.notify({name:'addflexBasis2', value:'auto'}); + await CommonFunc.sleep(3000); + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(vp2px(220)); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0400] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0400 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis('200vp') , the height of column1 is 200vp + */ + it('SUB_ACE_flexBasis_Type_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0400] START'); + globalThis.value.message.notify({name:'addflexBasis2', value:'200vp'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(vp2px(200)); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0400] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0500 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis('200px') , the height of column1 is 200px + */ + it('SUB_ACE_flexBasis_Type_TEST_0500', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0500] START'); + globalThis.value.message.notify({name:'addflexBasis2', value:'200px'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(200); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0500] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0600 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis('200fp') , the height of column1 is 200fp + */ + it('SUB_ACE_flexBasis_Type_TEST_0600', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0600] START'); + globalThis.value.message.notify({name:'addflexBasis2', value:'200fp'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(fp2px(200)); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0600] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexBasis_Type_TEST_0700 + * @tc.name testFlexBasis + * @tc.desc column1 is set to flexBasis('200lpx') , the height of column1 is 200lpx + */ + it('SUB_ACE_flexBasis_Type_TEST_0700', 0, async function (done) { + console.info('[SUB_ACE_flexBasis_Type_TEST_0700] START'); + globalThis.value.message.notify({name:'addflexBasis2', value:'200lpx'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexBasis_021 = CommonFunc.getComponentRect('Column_flexBasis_021'); + let Column_flexBasis_022 = CommonFunc.getComponentRect('Column_flexBasis_022'); + let Column_flexBasis_023 = CommonFunc.getComponentRect('Column_flexBasis_023'); + let Column_flexBasis_02 = CommonFunc.getComponentRect('Column_flexBasis_02'); + console.log('assert position') + expect(Math.round(Column_flexBasis_021.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_021.right)); + expect(Math.round(Column_flexBasis_022.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_022.right)); + expect(Math.round(Column_flexBasis_023.left - Column_flexBasis_02.left)).assertEqual(Math.round(Column_flexBasis_02.right - Column_flexBasis_023.right)); + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexBasis_022.top - Column_flexBasis_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexBasis_023.top - Column_flexBasis_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexBasis_02.top).assertEqual(Column_flexBasis_021.top); + console.log('assert height') + expect(Math.round(Column_flexBasis_021.bottom - Column_flexBasis_021.top)).assertEqual(Math.round(lpx2px(200))); + console.log('Column_flexBasis_021.bottom - Column_flexBasis_021.top', + Column_flexBasis_021.bottom - Column_flexBasis_021.top) + expect(Math.round(Column_flexBasis_022.bottom - Column_flexBasis_022.top)).assertEqual(Math.round(vp2px(100))); + console.log('Column_flexBasis_022.bottom - Column_flexBasis_022.top', + Column_flexBasis_022.bottom - Column_flexBasis_022.top) + expect(Math.round(Column_flexBasis_023.bottom - Column_flexBasis_023.top)).assertEqual(Math.round(vp2px(100))); + console.log('Column_flexBasis_023.bottom - Column_flexBasis_023.top', + Column_flexBasis_023.bottom - Column_flexBasis_023.top) + console.log('assert weight') + expect(Math.round(Column_flexBasis_021.right - Column_flexBasis_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_022.right - Column_flexBasis_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexBasis_023.right - Column_flexBasis_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexBasis_Type_TEST_0700] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Default.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Default.test.ets new file mode 100644 index 000000000..f28222bc0 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Default.test.ets @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexGrow_Default() { + describe('flexGrow_Default', function () { + beforeEach(async function (done) { + console.info("flexGrow_Default beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexGrow/flexGrow_Default", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexGrow_Default state pages:" + JSON.stringify(pages)); + if (!("flexGrow_Default" == pages.name)) { + console.info("get flexGrow_Default pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexGrow_Default page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexGrow_Default page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexGrow_Default after each called") + }); + + /** + * @tc.number SUB_ACE_flexGrow_Default_TEST_0100 + * @tc.name testFlexGrow + * @tc.desc colum1、colum2、colum3 set flexGrow(null) + */ + it('SUB_ACE_flexGrow_Default_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Default_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexGrow', value:null}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_Default_011 = CommonFunc.getComponentRect('Column_flexGrow_Default_011'); + let Column_flexGrow_Default_012 = CommonFunc.getComponentRect('Column_flexGrow_Default_012'); + let Column_flexGrow_Default_013 = CommonFunc.getComponentRect('Column_flexGrow_Default_013'); + let Column_flexGrow_Default_01 = CommonFunc.getComponentRect('Column_flexGrow_Default_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_Default_011.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_011.right)); + expect(Math.round(Column_flexGrow_Default_012.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_012.right)); + expect(Math.round(Column_flexGrow_Default_013.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_013.right)); + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom', + Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom) + console.log('Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom', + Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom) + expect(Column_flexGrow_Default_01.top).assertEqual(Column_flexGrow_Default_011.top); + console.log('assert height') + expect(Math.round(Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top', + Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top) + expect(Math.round(Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top', + Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top) + expect(Math.round(Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top', + Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_Default_011.right - Column_flexGrow_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_012.right - Column_flexGrow_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_013.right - Column_flexGrow_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Default_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Default_TEST_0200 + * @tc.name testFlexGrow + * @tc.desc colum1、colum2、colum3 set flexGrow(undefined) + */ + it('SUB_ACE_flexGrow_Default_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Default_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexGrow', value:undefined}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_Default_011 = CommonFunc.getComponentRect('Column_flexGrow_Default_011'); + let Column_flexGrow_Default_012 = CommonFunc.getComponentRect('Column_flexGrow_Default_012'); + let Column_flexGrow_Default_013 = CommonFunc.getComponentRect('Column_flexGrow_Default_013'); + let Column_flexGrow_Default_01 = CommonFunc.getComponentRect('Column_flexGrow_Default_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_Default_011.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_011.right)); + expect(Math.round(Column_flexGrow_Default_012.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_012.right)); + expect(Math.round(Column_flexGrow_Default_013.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_013.right)); + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom', + Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom) + console.log('Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom', + Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom) + expect(Column_flexGrow_Default_01.top).assertEqual(Column_flexGrow_Default_011.top); + console.log('assert height') + expect(Math.round(Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top', + Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top) + expect(Math.round(Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top', + Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top) + expect(Math.round(Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top', + Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_Default_011.right - Column_flexGrow_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_012.right - Column_flexGrow_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_013.right - Column_flexGrow_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Default_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Default_TEST_0300 + * @tc.name testFlexGrow + * @tc.desc colum1、colum2、colum3 set flexGrow(-5) + */ + it('SUB_ACE_flexGrow_Default_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Default_TEST_0300] START'); + globalThis.value.message.notify({name:'addflexGrow', value:-5}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_Default_011 = CommonFunc.getComponentRect('Column_flexGrow_Default_011'); + let Column_flexGrow_Default_012 = CommonFunc.getComponentRect('Column_flexGrow_Default_012'); + let Column_flexGrow_Default_013 = CommonFunc.getComponentRect('Column_flexGrow_Default_013'); + let Column_flexGrow_Default_01 = CommonFunc.getComponentRect('Column_flexGrow_Default_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_Default_011.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_011.right)); + expect(Math.round(Column_flexGrow_Default_012.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_012.right)); + expect(Math.round(Column_flexGrow_Default_013.left - Column_flexGrow_Default_01.left)).assertEqual(Math.round(Column_flexGrow_Default_01.right - Column_flexGrow_Default_013.right)); + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom', + Column_flexGrow_Default_012.top - Column_flexGrow_Default_011.bottom) + console.log('Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom', + Column_flexGrow_Default_013.top - Column_flexGrow_Default_012.bottom) + expect(Column_flexGrow_Default_01.top).assertEqual(Column_flexGrow_Default_011.top); + console.log('assert height') + expect(Math.round(Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top', + Column_flexGrow_Default_011.bottom - Column_flexGrow_Default_011.top) + expect(Math.round(Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top', + Column_flexGrow_Default_012.bottom - Column_flexGrow_Default_012.top) + expect(Math.round(Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top', + Column_flexGrow_Default_013.bottom - Column_flexGrow_Default_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_Default_011.right - Column_flexGrow_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_012.right - Column_flexGrow_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_013.right - Column_flexGrow_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Default_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Default_TEST_0400 + * @tc.name testFlexGrow + * @tc.desc colum1、colum2 and colum3 do not set flexGrow + */ + it('SUB_ACE_flexGrow_Default_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Default_TEST_0400] START'); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_Default_021 = CommonFunc.getComponentRect('Column_flexGrow_Default_021'); + let Column_flexGrow_Default_022 = CommonFunc.getComponentRect('Column_flexGrow_Default_022'); + let Column_flexGrow_Default_023 = CommonFunc.getComponentRect('Column_flexGrow_Default_023'); + let Column_flexGrow_Default_02 = CommonFunc.getComponentRect('Column_flexGrow_Default_02'); + console.log('assert position') + expect(Math.round(Column_flexGrow_Default_021.left - Column_flexGrow_Default_02.left)).assertEqual(Math.round(Column_flexGrow_Default_02.right - Column_flexGrow_Default_021.right)); + expect(Math.round(Column_flexGrow_Default_022.left - Column_flexGrow_Default_02.left)).assertEqual(Math.round(Column_flexGrow_Default_02.right - Column_flexGrow_Default_022.right)); + expect(Math.round(Column_flexGrow_Default_023.left - Column_flexGrow_Default_02.left)).assertEqual(Math.round(Column_flexGrow_Default_02.right - Column_flexGrow_Default_023.right)); + expect(Math.round(Column_flexGrow_Default_022.top - Column_flexGrow_Default_021.bottom)).assertEqual(Math.round(Column_flexGrow_Default_023.top - Column_flexGrow_Default_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_Default_022.top - Column_flexGrow_Default_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_Default_023.top - Column_flexGrow_Default_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexGrow_Default_02.top).assertEqual(Column_flexGrow_Default_021.top); + console.log('assert height') + expect(Math.round(Column_flexGrow_Default_021.bottom - Column_flexGrow_Default_021.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_021.bottom - Column_flexGrow_Default_021.top', + Column_flexGrow_Default_021.bottom - Column_flexGrow_Default_021.top) + expect(Math.round(Column_flexGrow_Default_022.bottom - Column_flexGrow_Default_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_022.bottom - Column_flexGrow_Default_022.top', + Column_flexGrow_Default_022.bottom - Column_flexGrow_Default_022.top) + expect(Math.round(Column_flexGrow_Default_023.bottom - Column_flexGrow_Default_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_Default_023.bottom - Column_flexGrow_Default_023.top', + Column_flexGrow_Default_023.bottom - Column_flexGrow_Default_023.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_Default_021.right - Column_flexGrow_Default_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_022.right - Column_flexGrow_Default_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_Default_023.right - Column_flexGrow_Default_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Default_TEST_0400] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Part.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Part.test.ets new file mode 100644 index 000000000..ac05fc5d2 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexGrow/flexGrow_Part.test.ets @@ -0,0 +1,250 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexGrow_Part() { + describe('flexGrow_Part', function () { + beforeEach(async function (done) { + console.info("flexGrow_Part beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexGrow/flexGrow_Part", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexGrow_Part state pages:" + JSON.stringify(pages)); + if (!("flexGrow_Part" == pages.name)) { + console.info("get flexGrow_Part pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexGrow_Part page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexGrow_Part page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexGrow_Part after each called") + }); + + /** + * @tc.number SUB_ACE_flexGrow_Part_TEST_0100 + * @tc.name testFlexGrow + * @tc.desc colum1 set layoutWeight(1), colum2、colum3 set flexGrow(1) + */ + it('SUB_ACE_flexGrow_Part_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Part_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexGrow2', value:1}); + globalThis.value.message.notify({name:'addflexGrow3', value:1}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_011 = CommonFunc.getComponentRect('Column_flexGrow_011'); + let Column_flexGrow_012 = CommonFunc.getComponentRect('Column_flexGrow_012'); + let Column_flexGrow_013 = CommonFunc.getComponentRect('Column_flexGrow_013'); + let Column_flexGrow_01 = CommonFunc.getComponentRect('Column_flexGrow_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_011.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_011.right)); + expect(Math.round(Column_flexGrow_012.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_012.right)); + expect(Math.round(Column_flexGrow_013.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_013.right)); + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_012.top - Column_flexGrow_011.bottom', + Column_flexGrow_012.top - Column_flexGrow_011.bottom) + console.log('Column_flexGrow_013.top - Column_flexGrow_012.bottom', + Column_flexGrow_013.top - Column_flexGrow_012.bottom) + expect(Column_flexGrow_01.top).assertEqual(Column_flexGrow_011.top); + expect(Column_flexGrow_013.bottom).assertEqual(Column_flexGrow_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexGrow_011.bottom - Column_flexGrow_011.top)).assertEqual(vp2px(250)); + console.log('Column_flexGrow_011.bottom - Column_flexGrow_011.top', + Column_flexGrow_011.bottom - Column_flexGrow_011.top) + expect(Math.round(Column_flexGrow_012.bottom - Column_flexGrow_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_012.bottom - Column_flexGrow_012.top', + Column_flexGrow_012.bottom - Column_flexGrow_012.top) + expect(Math.round(Column_flexGrow_013.bottom - Column_flexGrow_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_013.bottom - Column_flexGrow_013.top', + Column_flexGrow_013.bottom - Column_flexGrow_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_011.right - Column_flexGrow_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_012.right - Column_flexGrow_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_013.right - Column_flexGrow_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Part_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Part_TEST_0200 + * @tc.name testFlexGrow + * @tc.desc colum1 set layoutWeight(1),colum2、colum3 set flexGrow(2) + */ + it('SUB_ACE_flexGrow_Part_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Part_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexGrow2', value:2}); + globalThis.value.message.notify({name:'addflexGrow3', value:2}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_011 = CommonFunc.getComponentRect('Column_flexGrow_011'); + let Column_flexGrow_012 = CommonFunc.getComponentRect('Column_flexGrow_012'); + let Column_flexGrow_013 = CommonFunc.getComponentRect('Column_flexGrow_013'); + let Column_flexGrow_01 = CommonFunc.getComponentRect('Column_flexGrow_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_011.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_011.right)); + expect(Math.round(Column_flexGrow_012.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_012.right)); + expect(Math.round(Column_flexGrow_013.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_013.right)); + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_012.top - Column_flexGrow_011.bottom', + Column_flexGrow_012.top - Column_flexGrow_011.bottom) + console.log('Column_flexGrow_013.top - Column_flexGrow_012.bottom', + Column_flexGrow_013.top - Column_flexGrow_012.bottom) + expect(Column_flexGrow_01.top).assertEqual(Column_flexGrow_011.top); + expect(Column_flexGrow_013.bottom).assertEqual(Column_flexGrow_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexGrow_011.bottom - Column_flexGrow_011.top)).assertEqual(vp2px(250)); + console.log('Column_flexGrow_011.bottom - Column_flexGrow_011.top', + Column_flexGrow_011.bottom - Column_flexGrow_011.top) + expect(Math.round(Column_flexGrow_012.bottom - Column_flexGrow_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_012.bottom - Column_flexGrow_012.top', + Column_flexGrow_012.bottom - Column_flexGrow_012.top) + expect(Math.round(Column_flexGrow_013.bottom - Column_flexGrow_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_013.bottom - Column_flexGrow_013.top', + Column_flexGrow_013.bottom - Column_flexGrow_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_011.right - Column_flexGrow_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_012.right - Column_flexGrow_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_013.right - Column_flexGrow_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Part_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Part_TEST_0300 + * @tc.name testFlexGrow + * @tc.desc colum1 set layoutWeight(1),colum2、colum3 set flexGrow(3) + */ + it('SUB_ACE_flexGrow_Part_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Part_TEST_0300] START'); + globalThis.value.message.notify({name:'addflexGrow2', value:3}); + globalThis.value.message.notify({name:'addflexGrow3', value:3}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_011 = CommonFunc.getComponentRect('Column_flexGrow_011'); + let Column_flexGrow_012 = CommonFunc.getComponentRect('Column_flexGrow_012'); + let Column_flexGrow_013 = CommonFunc.getComponentRect('Column_flexGrow_013'); + let Column_flexGrow_01 = CommonFunc.getComponentRect('Column_flexGrow_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_011.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_011.right)); + expect(Math.round(Column_flexGrow_012.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_012.right)); + expect(Math.round(Column_flexGrow_013.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_013.right)); + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_012.top - Column_flexGrow_011.bottom', + Column_flexGrow_012.top - Column_flexGrow_011.bottom) + console.log('Column_flexGrow_013.top - Column_flexGrow_012.bottom', + Column_flexGrow_013.top - Column_flexGrow_012.bottom) + expect(Column_flexGrow_01.top).assertEqual(Column_flexGrow_011.top); + expect(Column_flexGrow_013.bottom).assertEqual(Column_flexGrow_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexGrow_011.bottom - Column_flexGrow_011.top)).assertEqual(vp2px(250)); + console.log('Column_flexGrow_011.bottom - Column_flexGrow_011.top', + Column_flexGrow_011.bottom - Column_flexGrow_011.top) + expect(Math.round(Column_flexGrow_012.bottom - Column_flexGrow_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_012.bottom - Column_flexGrow_012.top', + Column_flexGrow_012.bottom - Column_flexGrow_012.top) + expect(Math.round(Column_flexGrow_013.bottom - Column_flexGrow_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_013.bottom - Column_flexGrow_013.top', + Column_flexGrow_013.bottom - Column_flexGrow_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_011.right - Column_flexGrow_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_012.right - Column_flexGrow_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_013.right - Column_flexGrow_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Part_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Part_TEST_0400 + * @tc.name testFlexGrow + * @tc.desc colum1 set layoutWeight(1),colum2、colum3 set flexGrow(3) + */ + it('SUB_ACE_flexGrow_Part_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Part_TEST_0400] START'); + globalThis.value.message.notify({name:'addflexGrow1', value:3}); + globalThis.value.message.notify({name:'addflexGrow2', value:2}); + globalThis.value.message.notify({name:'addflexGrow3', value:1}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_011 = CommonFunc.getComponentRect('Column_flexGrow_011'); + let Column_flexGrow_012 = CommonFunc.getComponentRect('Column_flexGrow_012'); + let Column_flexGrow_013 = CommonFunc.getComponentRect('Column_flexGrow_013'); + let Column_flexGrow_01 = CommonFunc.getComponentRect('Column_flexGrow_01'); + console.log('assert position') + expect(Math.round(Column_flexGrow_011.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_011.right)); + expect(Math.round(Column_flexGrow_012.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_012.right)); + expect(Math.round(Column_flexGrow_013.left - Column_flexGrow_01.left)).assertEqual(Math.round(Column_flexGrow_01.right - Column_flexGrow_013.right)); + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_012.top - Column_flexGrow_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_013.top - Column_flexGrow_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexGrow_012.top - Column_flexGrow_011.bottom', + Column_flexGrow_012.top - Column_flexGrow_011.bottom) + console.log('Column_flexGrow_013.top - Column_flexGrow_012.bottom', + Column_flexGrow_013.top - Column_flexGrow_012.bottom) + expect(Column_flexGrow_01.top).assertEqual(Column_flexGrow_011.top); + expect(Column_flexGrow_013.bottom).assertEqual(Column_flexGrow_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexGrow_011.bottom - Column_flexGrow_011.top)).assertEqual(vp2px(250)); + console.log('Column_flexGrow_011.bottom - Column_flexGrow_011.top', + Column_flexGrow_011.bottom - Column_flexGrow_011.top) + expect(Math.round(Column_flexGrow_012.bottom - Column_flexGrow_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_012.bottom - Column_flexGrow_012.top', + Column_flexGrow_012.bottom - Column_flexGrow_012.top) + expect(Math.round(Column_flexGrow_013.bottom - Column_flexGrow_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_013.bottom - Column_flexGrow_013.top', + Column_flexGrow_013.bottom - Column_flexGrow_013.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_011.right - Column_flexGrow_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_012.right - Column_flexGrow_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_013.right - Column_flexGrow_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Part_TEST_0400] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexGrow_Part_TEST_0500 + * @tc.name testFlexGrow + * @tc.desc colum1、colum2 and colum3 do not set flexGrow + */ + it('SUB_ACE_flexGrow_Part_TEST_0500', 0, async function (done) { + console.info('[SUB_ACE_flexGrow_Part_TEST_0500] START'); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexGrow_021 = CommonFunc.getComponentRect('Column_flexGrow_021'); + let Column_flexGrow_022 = CommonFunc.getComponentRect('Column_flexGrow_022'); + let Column_flexGrow_023 = CommonFunc.getComponentRect('Column_flexGrow_023'); + let Column_flexGrow_02 = CommonFunc.getComponentRect('Column_flexGrow_02'); + console.log('assert position') + expect(Math.round(Column_flexGrow_021.left - Column_flexGrow_02.left)).assertEqual(Math.round(Column_flexGrow_02.right - Column_flexGrow_021.right)); + expect(Math.round(Column_flexGrow_022.left - Column_flexGrow_02.left)).assertEqual(Math.round(Column_flexGrow_02.right - Column_flexGrow_022.right)); + expect(Math.round(Column_flexGrow_023.left - Column_flexGrow_02.left)).assertEqual(Math.round(Column_flexGrow_02.right - Column_flexGrow_023.right)); + expect(Math.round(Column_flexGrow_022.top - Column_flexGrow_021.bottom)).assertEqual(Math.round(Column_flexGrow_023.top - Column_flexGrow_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexGrow_022.top - Column_flexGrow_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexGrow_023.top - Column_flexGrow_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexGrow_02.top).assertEqual(Column_flexGrow_021.top); + console.log('assert height') + expect(Math.round(Column_flexGrow_021.bottom - Column_flexGrow_021.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_021.bottom - Column_flexGrow_021.top', + Column_flexGrow_021.bottom - Column_flexGrow_021.top) + expect(Math.round(Column_flexGrow_022.bottom - Column_flexGrow_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_022.bottom - Column_flexGrow_022.top', + Column_flexGrow_022.bottom - Column_flexGrow_022.top) + expect(Math.round(Column_flexGrow_023.bottom - Column_flexGrow_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexGrow_023.bottom - Column_flexGrow_023.top', + Column_flexGrow_023.bottom - Column_flexGrow_023.top) + console.log('assert weight') + expect(Math.round(Column_flexGrow_021.right - Column_flexGrow_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_022.right - Column_flexGrow_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexGrow_023.right - Column_flexGrow_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexGrow_Part_TEST_0500] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Default.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Default.test.ets new file mode 100644 index 000000000..baa588c64 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Default.test.ets @@ -0,0 +1,206 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexShrink_Default() { + describe('flexShrink_Default', function () { + beforeEach(async function (done) { + console.info("flexShrink_Default beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexShrink/flexShrink_Default", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexShrink_Default state pages:" + JSON.stringify(pages)); + if (!("flexShrink_Default" == pages.name)) { + console.info("get flexShrink_Default pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexShrink_Default page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexShrink_Default page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexShrink_Default after each called") + }); + + /** + * @tc.number SUB_ACE_flexShrink_Default_TEST_0100 + * @tc.name testflexShrink + * @tc.desc column1、column2、column3 set flexShrink(null) + */ + it('SUB_ACE_flexShrink_Default_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Default_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexShrink', value:null}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_011 = CommonFunc.getComponentRect('Column_flexShrink_011'); + let Column_flexShrink_012 = CommonFunc.getComponentRect('Column_flexShrink_012'); + let Column_flexShrink_013 = CommonFunc.getComponentRect('Column_flexShrink_013'); + let Column_flexShrink_01 = CommonFunc.getComponentRect('Column_flexShrink_01'); + console.log('assert position') + expect(Math.round(Column_flexShrink_011.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_011.right)); + expect(Math.round(Column_flexShrink_012.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_012.right)); + expect(Math.round(Column_flexShrink_013.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_013.right)); + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexShrink_012.top - Column_flexShrink_011.bottom', + Column_flexShrink_012.top - Column_flexShrink_011.bottom) + console.log('Column_flexShrink_013.top - Column_flexShrink_012.bottom', + Column_flexShrink_013.top - Column_flexShrink_012.bottom) + expect(Column_flexShrink_01.top).assertEqual(Column_flexShrink_011.top); + expect(Column_flexShrink_013.bottom).assertLess(Column_flexShrink_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_011.bottom - Column_flexShrink_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexShrink_011.bottom - Column_flexShrink_011.top', + Column_flexShrink_011.bottom - Column_flexShrink_011.top) + expect(Math.round(Column_flexShrink_012.bottom - Column_flexShrink_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_012.bottom - Column_flexShrink_012.top', + Column_flexShrink_012.bottom - Column_flexShrink_012.top) + expect(Math.round(Column_flexShrink_013.bottom - Column_flexShrink_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_013.bottom - Column_flexShrink_013.top', + Column_flexShrink_013.bottom - Column_flexShrink_013.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_011.right - Column_flexShrink_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_012.right - Column_flexShrink_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_013.right - Column_flexShrink_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Default_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexShrink_Default_TEST_0200 + * @tc.name testflexShrink + * @tc.desc column1、column2、column3 set flexShrink(undefined) + */ + it('SUB_ACE_flexShrink_Default_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Default_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexShrink', value:undefined}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_011 = CommonFunc.getComponentRect('Column_flexShrink_011'); + let Column_flexShrink_012 = CommonFunc.getComponentRect('Column_flexShrink_012'); + let Column_flexShrink_013 = CommonFunc.getComponentRect('Column_flexShrink_013'); + let Column_flexShrink_01 = CommonFunc.getComponentRect('Column_flexShrink_01'); + console.log('assert position') + expect(Math.round(Column_flexShrink_011.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_011.right)); + expect(Math.round(Column_flexShrink_012.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_012.right)); + expect(Math.round(Column_flexShrink_013.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_013.right)); + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexShrink_012.top - Column_flexShrink_011.bottom', + Column_flexShrink_012.top - Column_flexShrink_011.bottom) + console.log('Column_flexShrink_013.top - Column_flexShrink_012.bottom', + Column_flexShrink_013.top - Column_flexShrink_012.bottom) + expect(Column_flexShrink_01.top).assertEqual(Column_flexShrink_011.top); + expect(Column_flexShrink_013.bottom).assertLess(Column_flexShrink_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_011.bottom - Column_flexShrink_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexShrink_011.bottom - Column_flexShrink_011.top', + Column_flexShrink_011.bottom - Column_flexShrink_011.top) + expect(Math.round(Column_flexShrink_012.bottom - Column_flexShrink_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_012.bottom - Column_flexShrink_012.top', + Column_flexShrink_012.bottom - Column_flexShrink_012.top) + expect(Math.round(Column_flexShrink_013.bottom - Column_flexShrink_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_013.bottom - Column_flexShrink_013.top', + Column_flexShrink_013.bottom - Column_flexShrink_013.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_011.right - Column_flexShrink_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_012.right - Column_flexShrink_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_013.right - Column_flexShrink_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Default_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexShrink_Default_TEST_0300 + * @tc.name testflexShrink + * @tc.desc column1、column2、column3 set flexShrink(undefined) + */ + it('SUB_ACE_flexShrink_Default_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Default_TEST_0300] START'); + globalThis.value.message.notify({name:'addflexShrink', value:-5}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_011 = CommonFunc.getComponentRect('Column_flexShrink_011'); + let Column_flexShrink_012 = CommonFunc.getComponentRect('Column_flexShrink_012'); + let Column_flexShrink_013 = CommonFunc.getComponentRect('Column_flexShrink_013'); + let Column_flexShrink_01 = CommonFunc.getComponentRect('Column_flexShrink_01'); + console.log('assert position') + expect(Math.round(Column_flexShrink_011.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_011.right)); + expect(Math.round(Column_flexShrink_012.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_012.right)); + expect(Math.round(Column_flexShrink_013.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_013.right)); + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexShrink_012.top - Column_flexShrink_011.bottom', + Column_flexShrink_012.top - Column_flexShrink_011.bottom) + console.log('Column_flexShrink_013.top - Column_flexShrink_012.bottom', + Column_flexShrink_013.top - Column_flexShrink_012.bottom) + expect(Column_flexShrink_01.top).assertEqual(Column_flexShrink_011.top); + expect(Column_flexShrink_013.bottom).assertLess(Column_flexShrink_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_011.bottom - Column_flexShrink_011.top)).assertEqual(vp2px(200)); + console.log('Column_flexShrink_011.bottom - Column_flexShrink_011.top', + Column_flexShrink_011.bottom - Column_flexShrink_011.top) + expect(Math.round(Column_flexShrink_012.bottom - Column_flexShrink_012.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_012.bottom - Column_flexShrink_012.top', + Column_flexShrink_012.bottom - Column_flexShrink_012.top) + expect(Math.round(Column_flexShrink_013.bottom - Column_flexShrink_013.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_013.bottom - Column_flexShrink_013.top', + Column_flexShrink_013.bottom - Column_flexShrink_013.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_011.right - Column_flexShrink_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_012.right - Column_flexShrink_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_013.right - Column_flexShrink_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Default_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexShrink_Default_TEST_0400 + * @tc.name testflexShrink + * @tc.desc column1、column2 and column3 do not set flexShrink + */ + it('SUB_ACE_flexShrink_Default_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Default_TEST_0400] START'); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_021 = CommonFunc.getComponentRect('Column_flexShrink_021'); + let Column_flexShrink_022 = CommonFunc.getComponentRect('Column_flexShrink_022'); + let Column_flexShrink_023 = CommonFunc.getComponentRect('Column_flexShrink_023'); + let Column_flexShrink_02 = CommonFunc.getComponentRect('Column_flexShrink_02'); + console.log('assert position') + expect(Math.round(Column_flexShrink_021.left - Column_flexShrink_02.left)).assertEqual(Math.round(Column_flexShrink_02.right - Column_flexShrink_021.right)); + expect(Math.round(Column_flexShrink_022.left - Column_flexShrink_02.left)).assertEqual(Math.round(Column_flexShrink_02.right - Column_flexShrink_022.right)); + expect(Math.round(Column_flexShrink_023.left - Column_flexShrink_02.left)).assertEqual(Math.round(Column_flexShrink_02.right - Column_flexShrink_023.right)); + expect(Math.round(Column_flexShrink_022.top - Column_flexShrink_021.bottom)).assertEqual(Math.round(Column_flexShrink_023.top - Column_flexShrink_022.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_022.top - Column_flexShrink_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_023.top - Column_flexShrink_022.bottom)).assertEqual(vp2px(10)); + expect(Column_flexShrink_02.top).assertEqual(Column_flexShrink_021.top); + expect(Column_flexShrink_023.bottom).assertLess(Column_flexShrink_02.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_021.bottom - Column_flexShrink_021.top)).assertEqual(vp2px(200)); + console.log('Column_flexShrink_021.bottom - Column_flexShrink_021.top', + Column_flexShrink_021.bottom - Column_flexShrink_021.top) + expect(Math.round(Column_flexShrink_022.bottom - Column_flexShrink_022.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_022.bottom - Column_flexShrink_022.top', + Column_flexShrink_022.bottom - Column_flexShrink_022.top) + expect(Math.round(Column_flexShrink_023.bottom - Column_flexShrink_023.top)).assertEqual(vp2px(100)); + console.log('Column_flexShrink_023.bottom - Column_flexShrink_023.top', + Column_flexShrink_023.bottom - Column_flexShrink_023.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_021.right - Column_flexShrink_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_022.right - Column_flexShrink_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_023.right - Column_flexShrink_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Default_TEST_0400] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Part.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Part.test.ets new file mode 100644 index 000000000..7a5c80ee8 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/flexShrink/flexShrink_Part.test.ets @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2023 Huawei Device 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 flexShrink_Part() { + describe('flexShrink_Part', function () { + beforeEach(async function (done) { + console.info("flexShrink_Part beforeEach start"); + let options = { + url: "MainAbility/pages/Column/flexShrink/flexShrink_Part", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get flexShrink_Part state pages:" + JSON.stringify(pages)); + if (!("flexShrink_Part" == pages.name)) { + console.info("get flexShrink_Part pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push flexShrink_Part page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexShrink_Part page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("flexShrink_Part after each called") + }); + + /** + * @tc.number SUB_ACE_flexShrink_Part_TEST_0100 + * @tc.name testflexShrink + * @tc.desc colum2、colum3 set flexShrink(1) + */ + it('SUB_ACE_flexShrink_Part_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Part_TEST_0100] START'); + globalThis.value.message.notify({name:'addflexShrink', value:1}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_011 = CommonFunc.getComponentRect('Column_flexShrink_011'); + let Column_flexShrink_012 = CommonFunc.getComponentRect('Column_flexShrink_012'); + let Column_flexShrink_013 = CommonFunc.getComponentRect('Column_flexShrink_013'); + let Column_flexShrink_01 = CommonFunc.getComponentRect('Column_flexShrink_01'); + console.log('assert position') + expect(Math.round(Column_flexShrink_011.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_011.right)); + expect(Math.round(Column_flexShrink_012.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_012.right)); + expect(Math.round(Column_flexShrink_013.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_013.right)); + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexShrink_012.top - Column_flexShrink_011.bottom', + Column_flexShrink_012.top - Column_flexShrink_011.bottom) + console.log('Column_flexShrink_013.top - Column_flexShrink_012.bottom', + Column_flexShrink_013.top - Column_flexShrink_012.bottom) + expect(Column_flexShrink_01.top).assertEqual(Column_flexShrink_011.top); + expect(Column_flexShrink_013.bottom).assertEqual(Column_flexShrink_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_011.bottom - Column_flexShrink_011.top)).assertEqual(vp2px(300)); + console.log('Column_flexShrink_011.bottom - Column_flexShrink_011.top', + Column_flexShrink_011.bottom - Column_flexShrink_011.top) + expect(Column_flexShrink_012.bottom - Column_flexShrink_012.top).assertEqual(vp2px(65)); + console.log('Column_flexShrink_012.bottom - Column_flexShrink_012.top', + Column_flexShrink_012.bottom - Column_flexShrink_012.top) + expect(Column_flexShrink_013.bottom - Column_flexShrink_013.top).assertEqual(vp2px(65)); + console.log('Column_flexShrink_013.bottom - Column_flexShrink_013.top', + Column_flexShrink_013.bottom - Column_flexShrink_013.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_011.right - Column_flexShrink_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_012.right - Column_flexShrink_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_013.right - Column_flexShrink_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Part_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_flexShrink_Part_TEST_0200 + * @tc.name testflexShrink + * @tc.desc colum2、colum3 set flexShrink(2) + */ + it('SUB_ACE_flexShrink_Part_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_flexShrink_Part_TEST_0200] START'); + globalThis.value.message.notify({name:'addflexShrink', value:2}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_flexShrink_011 = CommonFunc.getComponentRect('Column_flexShrink_011'); + let Column_flexShrink_012 = CommonFunc.getComponentRect('Column_flexShrink_012'); + let Column_flexShrink_013 = CommonFunc.getComponentRect('Column_flexShrink_013'); + let Column_flexShrink_01 = CommonFunc.getComponentRect('Column_flexShrink_01'); + console.log('assert position') + expect(Math.round(Column_flexShrink_011.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_011.right)); + expect(Math.round(Column_flexShrink_012.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_012.right)); + expect(Math.round(Column_flexShrink_013.left - Column_flexShrink_01.left)).assertEqual(Math.round(Column_flexShrink_01.right - Column_flexShrink_013.right)); + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)) + console.log('assert space') + expect(Math.round(Column_flexShrink_012.top - Column_flexShrink_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_flexShrink_013.top - Column_flexShrink_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_flexShrink_012.top - Column_flexShrink_011.bottom', + Column_flexShrink_012.top - Column_flexShrink_011.bottom) + console.log('Column_flexShrink_013.top - Column_flexShrink_012.bottom', + Column_flexShrink_013.top - Column_flexShrink_012.bottom) + expect(Column_flexShrink_01.top).assertEqual(Column_flexShrink_011.top); + expect(Column_flexShrink_013.bottom).assertEqual(Column_flexShrink_01.bottom); + console.log('assert height') + expect(Math.round(Column_flexShrink_011.bottom - Column_flexShrink_011.top)).assertEqual(vp2px(300)); + console.log('Column_flexShrink_011.bottom - Column_flexShrink_011.top', + Column_flexShrink_011.bottom - Column_flexShrink_011.top) + expect(Column_flexShrink_012.bottom - Column_flexShrink_012.top).assertEqual(vp2px(65)); + console.log('Column_flexShrink_012.bottom - Column_flexShrink_012.top', + Column_flexShrink_012.bottom - Column_flexShrink_012.top) + expect(Column_flexShrink_013.bottom - Column_flexShrink_013.top).assertEqual(vp2px(65)); + console.log('Column_flexShrink_013.bottom - Column_flexShrink_013.top', + Column_flexShrink_013.bottom - Column_flexShrink_013.top) + console.log('assert weight') + expect(Math.round(Column_flexShrink_011.right - Column_flexShrink_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_012.right - Column_flexShrink_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_flexShrink_013.right - Column_flexShrink_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_flexShrink_Part_TEST_0200] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_All.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_All.test.ets new file mode 100644 index 000000000..44e79649c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_All.test.ets @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_All() { + describe('layoutWeight_All', function () { + beforeEach(async function (done) { + console.info("layoutWeight_All beforeEach start"); + let options = { + url: "MainAbility/pages/Column/layoutWeight/layoutWeight_All", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutWeight_All state pages:" + JSON.stringify(pages)); + if (!("layoutWeight_All" == pages.name)) { + console.info("get layoutWeight_All pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push layoutWeight_All page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutWeight_All page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("layoutWeight_All after each called") + }); + + /** + * @tc.number SUB_ACE_layoutWeight_All_TEST_0100 + * @tc.name testLayoutWeight + * @tc.desc colum1 ,column2 and column3 set layoutWeight('3') + */ + it('SUB_ACE_layoutWeight_All_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_All_TEST_0100] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:'3'}); + globalThis.value.message.notify({name:'layoutWeight2', value:'3'}); + globalThis.value.message.notify({name:'layoutWeight3', value:'3'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_All_021 = CommonFunc.getComponentRect('Column_layoutWeight_All_021'); + let Column_layoutWeight_All_022 = CommonFunc.getComponentRect('Column_layoutWeight_All_022'); + let Column_layoutWeight_All_023 = CommonFunc.getComponentRect('Column_layoutWeight_All_023'); + let Column_layoutWeight_All_02 = CommonFunc.getComponentRect('Column_layoutWeight_All_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_All_021.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_021.right)); + expect(Math.round(Column_layoutWeight_All_022.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_022.right)); + expect(Math.round(Column_layoutWeight_All_023.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_023.right)); + expect(Math.round(Column_layoutWeight_All_022.top - Column_layoutWeight_All_021.bottom)).assertEqual(Math.round(Column_layoutWeight_All_023.top - Column_layoutWeight_All_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_All_022.top - Column_layoutWeight_All_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_All_023.top - Column_layoutWeight_All_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_All_02.top).assertEqual(Column_layoutWeight_All_021.top); + expect(Column_layoutWeight_All_023.bottom).assertEqual(Column_layoutWeight_All_02.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top', + Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top) + expect(Math.round(Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top', + Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top) + expect(Math.round(Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top', + Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_All_021.right - Column_layoutWeight_All_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_All_022.right - Column_layoutWeight_All_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_All_023.right - Column_layoutWeight_All_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_All_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_All_TEST_0200 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight('3') , column2 set layoutWeight('2'),column3 set layoutWeight('1') + */ + it('SUB_ACE_layoutWeight_All_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_All_TEST_0200] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:'3'}); + globalThis.value.message.notify({name:'layoutWeight2', value:'2'}); + globalThis.value.message.notify({name:'layoutWeight3', value:'1'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_All_021 = CommonFunc.getComponentRect('Column_layoutWeight_All_021'); + let Column_layoutWeight_All_022 = CommonFunc.getComponentRect('Column_layoutWeight_All_022'); + let Column_layoutWeight_All_023 = CommonFunc.getComponentRect('Column_layoutWeight_All_023'); + let Column_layoutWeight_All_02 = CommonFunc.getComponentRect('Column_layoutWeight_All_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_All_021.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_021.right)); + expect(Math.round(Column_layoutWeight_All_022.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_022.right)); + expect(Math.round(Column_layoutWeight_All_023.left - Column_layoutWeight_All_02.left)).assertEqual(Math.round(Column_layoutWeight_All_02.right - Column_layoutWeight_All_023.right)); + expect(Math.round(Column_layoutWeight_All_022.top - Column_layoutWeight_All_021.bottom)).assertEqual(Math.round(Column_layoutWeight_All_023.top - Column_layoutWeight_All_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_All_022.top - Column_layoutWeight_All_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_All_023.top - Column_layoutWeight_All_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_All_02.top).assertEqual(Column_layoutWeight_All_021.top); + expect(Column_layoutWeight_All_023.bottom).assertEqual(Column_layoutWeight_All_02.bottom); + console.log('assert height') + expect(Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top).assertEqual(vp2px(225)); + console.log('Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top', + Column_layoutWeight_All_021.bottom - Column_layoutWeight_All_021.top) + expect(Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top', + Column_layoutWeight_All_022.bottom - Column_layoutWeight_All_022.top) + expect(Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top).assertEqual(vp2px(75)); + console.log('Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top', + Column_layoutWeight_All_023.bottom - Column_layoutWeight_All_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_All_021.right - Column_layoutWeight_All_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_All_022.right - Column_layoutWeight_All_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_All_023.right - Column_layoutWeight_All_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_All_TEST_0200] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Default.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Default.test.ets new file mode 100644 index 000000000..563a7ed38 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Default.test.ets @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_Default() { + describe('layoutWeight_Default', function () { + beforeEach(async function (done) { + console.info("layoutWeight_Default beforeEach start"); + let options = { + url: "MainAbility/pages/Column/layoutWeight/layoutWeight_Default", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutWeight_Default state pages:" + JSON.stringify(pages)); + if (!("layoutWeight_Default" == pages.name)) { + console.info("get layoutWeight_Default pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push layoutWeight_Default page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutWeight_Default page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("layoutWeight_Default after each called") + }); + /** + * @tc.number SUB_ACE_layoutWeight_Default_TEST_0100 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight(undefined),column1, column2, and column3 are displayed according to their own height + */ + it('SUB_ACE_layoutWeight_Default_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Default_TEST_0100] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:undefined}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Default_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_Default_TEST_0200 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight(null),column1, column2, and column3 are displayed according to their own height + */ + it('SUB_ACE_layoutWeight_Default_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Default_TEST_0200] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:null}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Default_TEST_0200] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_layoutWeight_Default_TEST_0300 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight(-10),column1, column2, and column3 are displayed according to their own height + */ + it('SUB_ACE_layoutWeight_Default_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Default_TEST_0300] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:-10}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Default_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_Default_TEST_0400 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight('aaa'),column1, column2, and column3 are displayed according to their own height + */ + it('SUB_ACE_layoutWeight_Default_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Default_TEST_0400] START'); + globalThis.value.message.notify({name:'layoutWeight2', value:'aaa'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_021 = CommonFunc.getComponentRect('Column_layoutWeight_021'); + let Column_layoutWeight_022 = CommonFunc.getComponentRect('Column_layoutWeight_022'); + let Column_layoutWeight_023 = CommonFunc.getComponentRect('Column_layoutWeight_023'); + let Column_layoutWeight_02 = CommonFunc.getComponentRect('Column_layoutWeight_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_021.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_021.right)); + expect(Math.round(Column_layoutWeight_022.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_022.right)); + expect(Math.round(Column_layoutWeight_023.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_023.right)); + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_02.top).assertEqual(Column_layoutWeight_021.top); + console.log('assert height') + expect(Math.round(Column_layoutWeight_021.bottom - Column_layoutWeight_021.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_021.bottom - Column_layoutWeight_021.top', + Column_layoutWeight_021.bottom - Column_layoutWeight_021.top) + expect(Math.round(Column_layoutWeight_022.bottom - Column_layoutWeight_022.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_022.bottom - Column_layoutWeight_022.top', + Column_layoutWeight_022.bottom - Column_layoutWeight_022.top) + expect(Math.round(Column_layoutWeight_023.bottom - Column_layoutWeight_023.top)).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_023.bottom - Column_layoutWeight_023.top', + Column_layoutWeight_023.bottom - Column_layoutWeight_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_021.right - Column_layoutWeight_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_022.right - Column_layoutWeight_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_023.right - Column_layoutWeight_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Default_TEST_0400] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Part.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Part.test.ets new file mode 100644 index 000000000..8d6e070b3 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_Part.test.ets @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_Part() { + describe('layoutWeight_Part', function () { + beforeEach(async function (done) { + console.info("layoutWeight_Part beforeEach start"); + let options = { + url: "MainAbility/pages/Column/layoutWeight/layoutWeight_Part", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutWeight_Part state pages:" + JSON.stringify(pages)); + if (!("layoutWeight_Part" == pages.name)) { + console.info("get layoutWeight_Part pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push layoutWeight_Part page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutWeight_Part page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("layoutWeight_Part after each called") + }); + + /** + * @tc.number SUB_ACE_layoutWeight_Part_TEST_0100 + * @tc.name testLayoutWeight + * @tc.desc colum1 and column2 set layoutWeight('2'),the cloumn3 placeholder remains unchanged + */ + it('SUB_ACE_layoutWeight_Part_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Part_TEST_0100] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:'2'}); + globalThis.value.message.notify({name:'layoutWeight2', value:'2'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_021 = CommonFunc.getComponentRect('Column_layoutWeight_021'); + let Column_layoutWeight_022 = CommonFunc.getComponentRect('Column_layoutWeight_022'); + let Column_layoutWeight_023 = CommonFunc.getComponentRect('Column_layoutWeight_023'); + let Column_layoutWeight_02 = CommonFunc.getComponentRect('Column_layoutWeight_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_021.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_021.right)); + expect(Math.round(Column_layoutWeight_022.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_022.right)); + expect(Math.round(Column_layoutWeight_023.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_023.right)); + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_02.top).assertEqual(Column_layoutWeight_021.top); + expect(Column_layoutWeight_023.bottom).assertEqual(Column_layoutWeight_02.bottom); + console.log('assert height') + expect(Column_layoutWeight_021.bottom - Column_layoutWeight_021.top).assertEqual(vp2px(165)); + console.log('Column_layoutWeight_021.bottom - Column_layoutWeight_021.top', + Column_layoutWeight_021.bottom - Column_layoutWeight_021.top) + expect(Column_layoutWeight_022.bottom - Column_layoutWeight_022.top).assertEqual(vp2px(165)); + console.log('Column_layoutWeight_022.bottom - Column_layoutWeight_022.top', + Column_layoutWeight_022.bottom - Column_layoutWeight_022.top) + expect(Column_layoutWeight_023.bottom - Column_layoutWeight_023.top).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_023.bottom - Column_layoutWeight_023.top', + Column_layoutWeight_023.bottom - Column_layoutWeight_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_021.right - Column_layoutWeight_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_022.right - Column_layoutWeight_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_023.right - Column_layoutWeight_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Part_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_Part_TEST_0200 + * @tc.name testLayoutWeight + * @tc.desc colum1 and column2 set layoutWeight('3'), the cloumn3 placeholder remains unchanged + */ + it('SUB_ACE_layoutWeight_Part_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Part_TEST_0200] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:'3'}); + globalThis.value.message.notify({name:'layoutWeight2', value:'3'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_021 = CommonFunc.getComponentRect('Column_layoutWeight_021'); + let Column_layoutWeight_022 = CommonFunc.getComponentRect('Column_layoutWeight_022'); + let Column_layoutWeight_023 = CommonFunc.getComponentRect('Column_layoutWeight_023'); + let Column_layoutWeight_02 = CommonFunc.getComponentRect('Column_layoutWeight_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_021.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_021.right)); + expect(Math.round(Column_layoutWeight_022.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_022.right)); + expect(Math.round(Column_layoutWeight_023.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_023.right)); + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_02.top).assertEqual(Column_layoutWeight_021.top); + expect(Column_layoutWeight_023.bottom).assertEqual(Column_layoutWeight_02.bottom); + console.log('assert height') + expect(Column_layoutWeight_021.bottom - Column_layoutWeight_021.top).assertEqual(vp2px(165)); + console.log('Column_layoutWeight_021.bottom - Column_layoutWeight_021.top', + Column_layoutWeight_021.bottom - Column_layoutWeight_021.top) + expect(Column_layoutWeight_022.bottom - Column_layoutWeight_022.top).assertEqual(vp2px(165)); + console.log('Column_layoutWeight_022.bottom - Column_layoutWeight_022.top', + Column_layoutWeight_022.bottom - Column_layoutWeight_022.top) + expect(Column_layoutWeight_023.bottom - Column_layoutWeight_023.top).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_023.bottom - Column_layoutWeight_023.top', + Column_layoutWeight_023.bottom - Column_layoutWeight_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_021.right - Column_layoutWeight_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_022.right - Column_layoutWeight_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_023.right - Column_layoutWeight_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Part_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_Part_TEST_0300 + * @tc.name testLayoutWeight + * @tc.desc colum1 set layoutWeight('3') and column2 set layoutWeight('2') + */ + it('SUB_ACE_layoutWeight_Part_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_Part_TEST_0300] START'); + globalThis.value.message.notify({name:'layoutWeight1', value:'3'}); + globalThis.value.message.notify({name:'layoutWeight2', value:'2'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_layoutWeight_021 = CommonFunc.getComponentRect('Column_layoutWeight_021'); + let Column_layoutWeight_022 = CommonFunc.getComponentRect('Column_layoutWeight_022'); + let Column_layoutWeight_023 = CommonFunc.getComponentRect('Column_layoutWeight_023'); + let Column_layoutWeight_02 = CommonFunc.getComponentRect('Column_layoutWeight_02'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_021.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_021.right)); + expect(Math.round(Column_layoutWeight_022.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_022.right)); + expect(Math.round(Column_layoutWeight_023.left - Column_layoutWeight_02.left)).assertEqual(Math.round(Column_layoutWeight_02.right - Column_layoutWeight_023.right)); + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_022.top - Column_layoutWeight_021.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_023.top - Column_layoutWeight_022.bottom)).assertEqual(vp2px(10)); + expect(Column_layoutWeight_02.top).assertEqual(Column_layoutWeight_021.top); + expect(Column_layoutWeight_023.bottom).assertEqual(Column_layoutWeight_02.bottom); + console.log('assert height') + expect(Column_layoutWeight_021.bottom - Column_layoutWeight_021.top).assertEqual(vp2px(198)); + console.log('Column_layoutWeight_021.bottom - Column_layoutWeight_021.top', + Column_layoutWeight_021.bottom - Column_layoutWeight_021.top) + expect(Column_layoutWeight_022.bottom - Column_layoutWeight_022.top).assertEqual(vp2px(132)); + console.log('Column_layoutWeight_022.bottom - Column_layoutWeight_022.top', + Column_layoutWeight_022.bottom - Column_layoutWeight_022.top) + expect(Column_layoutWeight_023.bottom - Column_layoutWeight_023.top).assertEqual(vp2px(100)); + console.log('Column_layoutWeight_023.bottom - Column_layoutWeight_023.top', + Column_layoutWeight_023.bottom - Column_layoutWeight_023.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_021.right - Column_layoutWeight_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_022.right - Column_layoutWeight_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_023.right - Column_layoutWeight_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_Part_TEST_0300] END'); + done(); + }); + + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexGrow.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexGrow.test.ets new file mode 100644 index 000000000..aa52d8075 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexGrow.test.ets @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_flexGrow() { + describe('layoutWeight_flexGrow', function () { + beforeEach(async function (done) { + console.info("layoutWeight_flexGrow beforeEach start"); + let options = { + url: "MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutWeight_flexGrow state pages:" + JSON.stringify(pages)); + if (!("layoutWeight_flexGrow" == pages.name)) { + console.info("get layoutWeight_flexGrow pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push layoutWeight_flexGrow page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutWeight_flexGrow page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("layoutWeight_flexGrow after each called") + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexGrow_TEST_0100 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2 and column3 set layoutWeight(1),the layoutWeight property takes precedence over flexGrow + */ + it('SUB_ACE_layoutWeight_flexGrow_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0100] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:1}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexGrow_TEST_0200 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2 and column3 set layoutWeight(2), the layoutWeight property takes precedence over flexGrow + */ + it('SUB_ACE_layoutWeight_flexGrow_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0200] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:2}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexGrow_TEST_0300 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2 and column3 set layoutWeight(3), the layoutWeight property takes precedence over flexGrow + */ + it('SUB_ACE_layoutWeight_flexGrow_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0300] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:3}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexGrow_TEST_0300] END'); + done(); + }); + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexShrink.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexShrink.test.ets new file mode 100644 index 000000000..5e2207fa6 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/layoutWeight/layoutWeight_flexShrink.test.ets @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2023 Huawei Device 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 layoutWeight_flexShrink() { + describe('layoutWeight_flexShrink', function () { + beforeEach(async function (done) { + console.info("layoutWeight_flexShrink beforeEach start"); + let options = { + url: "MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutWeight_flexShrink state pages:" + JSON.stringify(pages)); + if (!("layoutWeight_flexShrink" == pages.name)) { + console.info("get layoutWeight_flexShrink pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push layoutWeight_flexShrink page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutWeight_flexShrink page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("layoutWeight_flexShrink after each called") + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexShrink_TEST_0100 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2, column3 set layoutWeight(3), layoutWeight(2), layoutWeight(1),the layoutWeight property takes precedence over flexShrink,the height ratio of colum1, column2, and column3 is 3:2:1 + */ + it('SUB_ACE_layoutWeight_flexShrink_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0100] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:1}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexShrink_TEST_0200 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2, column3 set layoutWeight(3), layoutWeight(2), layoutWeight(1),the layoutWeight property takes precedence over flexShrink,the height ratio of colum1, column2, and column3 is 3:2:1 + */ + it('SUB_ACE_layoutWeight_flexShrink_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0200] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:2}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_layoutWeight_flexShrink_TEST_0300 + * @tc.name testLayoutWeight + * @tc.desc colum1, column2, column3 set layoutWeight(3), layoutWeight(2), layoutWeight(1),the layoutWeight property takes precedence over flexShrink,the height ratio of colum1, column2, and column3 is 3:2:1 + */ + it('SUB_ACE_layoutWeight_flexShrink_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0300] START'); + globalThis.value.message.notify({name:'addLayoutWeight', value:3}); + await CommonFunc.sleep(3000); + let Column_layoutWeight_011 = CommonFunc.getComponentRect('Column_layoutWeight_011'); + let Column_layoutWeight_012 = CommonFunc.getComponentRect('Column_layoutWeight_012'); + let Column_layoutWeight_013 = CommonFunc.getComponentRect('Column_layoutWeight_013'); + let Column_layoutWeight_01 = CommonFunc.getComponentRect('Column_layoutWeight_01'); + console.log('assert position') + expect(Math.round(Column_layoutWeight_011.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_011.right)); + expect(Math.round(Column_layoutWeight_012.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_012.right)); + expect(Math.round(Column_layoutWeight_013.left - Column_layoutWeight_01.left)).assertEqual(Math.round(Column_layoutWeight_01.right - Column_layoutWeight_013.right)); + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)) + console.log('assert space') + expect(Math.round(Column_layoutWeight_012.top - Column_layoutWeight_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_layoutWeight_013.top - Column_layoutWeight_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_layoutWeight_012.top - Column_layoutWeight_011.bottom', + Column_layoutWeight_012.top - Column_layoutWeight_011.bottom) + console.log('Column_layoutWeight_013.top - Column_layoutWeight_012.bottom', + Column_layoutWeight_013.top - Column_layoutWeight_012.bottom) + expect(Column_layoutWeight_01.top).assertEqual(Column_layoutWeight_011.top); + expect(Column_layoutWeight_013.bottom).assertEqual(Column_layoutWeight_01.bottom); + console.log('assert height') + expect(Math.round(Column_layoutWeight_011.bottom - Column_layoutWeight_011.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_011.bottom - Column_layoutWeight_011.top', + Column_layoutWeight_011.bottom - Column_layoutWeight_011.top) + expect(Math.round(Column_layoutWeight_012.bottom - Column_layoutWeight_012.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_012.bottom - Column_layoutWeight_012.top', + Column_layoutWeight_012.bottom - Column_layoutWeight_012.top) + expect(Math.round(Column_layoutWeight_013.bottom - Column_layoutWeight_013.top)).assertEqual(vp2px(150)); + console.log('Column_layoutWeight_013.bottom - Column_layoutWeight_013.top', + Column_layoutWeight_013.bottom - Column_layoutWeight_013.top) + console.log('assert weight') + expect(Math.round(Column_layoutWeight_011.right - Column_layoutWeight_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_012.right - Column_layoutWeight_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_layoutWeight_013.right - Column_layoutWeight_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_layoutWeight_flexShrink_TEST_0300] END'); + done(); + }); + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_Default.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_Default.test.ets new file mode 100644 index 000000000..0a7114809 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_Default.test.ets @@ -0,0 +1,234 @@ +/** + * Copyright (c) 2023 Huawei Device 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 Column_Space_Default() { + describe('Column_Space_Default', function () { + beforeEach(async function (done) { + console.info("Column_Space_Default beforeEach start"); + let options = { + url: "MainAbility/pages/Column/spaceChanged/Column_Space_Default", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get Column_Space_Default state pages:" + JSON.stringify(pages)); + if (!("Column_Space_Default" == pages.name)) { + console.info("get Column_Space_Default pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push Column_Space_Default page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push Column_Space_Default page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("Column_Space_Default after each called") + }); + + /** + * @tc.number SUB_ACE_Column_Space_Default_TEST_0200 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to undefined + */ + it('SUB_ACE_Column_Space_Default_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_Default_TEST_0200] START'); + globalThis.value.message.notify({name:'addSpace1', value:null}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_Default_011 = CommonFunc.getComponentRect('Column_Space_Default_011'); + let Column_Space_Default_012 = CommonFunc.getComponentRect('Column_Space_Default_012'); + let Column_Space_Default_013 = CommonFunc.getComponentRect('Column_Space_Default_013'); + let Column_Space_Default_01 = CommonFunc.getComponentRect('Column_Space_Default_01'); + console.log('assert position') + expect(Math.round(Column_Space_Default_011.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_011.right)); + expect(Math.round(Column_Space_Default_012.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_012.right)); + expect(Math.round(Column_Space_Default_013.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_013.right)); + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(vp2px(0)); + expect(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)).assertEqual(vp2px(0)); + console.log('Column_Space_Default_012.top - Column_Space_Default_011.bottom', + Column_Space_Default_012.top - Column_Space_Default_011.bottom) + console.log('Column_Space_Default_013.top - Column_Space_Default_012.bottom', + Column_Space_Default_013.top - Column_Space_Default_012.bottom) + expect(Column_Space_Default_01.top).assertEqual(Column_Space_Default_011.top); + expect(Column_Space_Default_013.bottom).assertLess(Column_Space_Default_01.bottom); + console.log('assert height') + expect(Math.round(Column_Space_Default_011.bottom - Column_Space_Default_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_Default_012.bottom - Column_Space_Default_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_Default_013.bottom - Column_Space_Default_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_Default_011.right - Column_Space_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_012.right - Column_Space_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_013.right - Column_Space_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_Default_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_Default_TEST_0200 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to -10 + */ + it('SUB_ACE_Column_Space_Default_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_Default_TEST_0300] START'); + globalThis.value.message.notify({name:'addSpace1', value:-10}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_Default_011 = CommonFunc.getComponentRect('Column_Space_Default_011'); + let Column_Space_Default_012 = CommonFunc.getComponentRect('Column_Space_Default_012'); + let Column_Space_Default_013 = CommonFunc.getComponentRect('Column_Space_Default_013'); + let Column_Space_Default_01 = CommonFunc.getComponentRect('Column_Space_Default_01'); + console.log('assert position') + expect(Math.round(Column_Space_Default_011.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_011.right)); + expect(Math.round(Column_Space_Default_012.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_012.right)); + expect(Math.round(Column_Space_Default_013.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_013.right)); + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(vp2px(0)); + expect(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)).assertEqual(vp2px(0)); + console.log('Column_Space_Default_012.top - Column_Space_Default_011.bottom', + Column_Space_Default_012.top - Column_Space_Default_011.bottom) + console.log('Column_Space_Default_013.top - Column_Space_Default_012.bottom', + Column_Space_Default_013.top - Column_Space_Default_012.bottom) + expect(Column_Space_Default_01.top).assertEqual(Column_Space_Default_011.top); + expect(Column_Space_Default_013.bottom).assertLess(Column_Space_Default_01.bottom); + console.log('assert height') + expect(Math.round(Column_Space_Default_011.bottom - Column_Space_Default_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_Default_012.bottom - Column_Space_Default_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_Default_013.bottom - Column_Space_Default_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_Default_011.right - Column_Space_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_012.right - Column_Space_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_013.right - Column_Space_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_Default_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_Default_TEST_0400 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to 'abc' + */ + it('SUB_ACE_Column_Space_Default_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_Default_TEST_0400] START'); + globalThis.value.message.notify({name:'addSpace2', value:'abc'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_Default_021 = CommonFunc.getComponentRect('Column_Space_Default_021'); + let Column_Space_Default_022 = CommonFunc.getComponentRect('Column_Space_Default_022'); + let Column_Space_Default_023 = CommonFunc.getComponentRect('Column_Space_Default_023'); + let Column_Space_Default_02 = CommonFunc.getComponentRect('Column_Space_Default_02'); + console.log('assert position') + expect(Math.round(Column_Space_Default_021.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_021.right)); + expect(Math.round(Column_Space_Default_022.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_022.right)); + expect(Math.round(Column_Space_Default_023.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_023.right)); + expect(Math.round(Column_Space_Default_022.top - Column_Space_Default_021.bottom)).assertEqual(Math.round(Column_Space_Default_023.top - Column_Space_Default_022.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_Default_022.top - Column_Space_Default_021.bottom)).assertEqual(vp2px(0)); + expect(Math.round(Column_Space_Default_023.top - Column_Space_Default_022.bottom)).assertEqual(vp2px(0)); + console.log('Column_Space_Default_022.top - Column_Space_Default_021.bottom', + Column_Space_Default_022.top - Column_Space_Default_021.bottom) + console.log('Column_Space_Default_023.top - Column_Space_Default_022.bottom', + Column_Space_Default_023.top - Column_Space_Default_022.bottom) + expect(Column_Space_Default_02.top).assertEqual(Column_Space_Default_021.top); + expect(Column_Space_Default_023.bottom).assertLess(Column_Space_Default_02.bottom); + console.log('assert height') + expect(Math.round(Column_Space_Default_021.bottom - Column_Space_Default_021.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_Default_022.bottom - Column_Space_Default_022.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_Default_023.bottom - Column_Space_Default_023.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_Default_021.right - Column_Space_Default_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_022.right - Column_Space_Default_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_023.right - Column_Space_Default_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_Default_TEST_0400] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_Default_TEST_0500 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '80%' + */ + it('SUB_ACE_Column_Space_Default_TEST_0500', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_Default_TEST_0500] START'); + globalThis.value.message.notify({name:'addSpace2', value:'80%'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_Default_021 = CommonFunc.getComponentRect('Column_Space_Default_021'); + let Column_Space_Default_022 = CommonFunc.getComponentRect('Column_Space_Default_022'); + let Column_Space_Default_023 = CommonFunc.getComponentRect('Column_Space_Default_023'); + let Column_Space_Default_02 = CommonFunc.getComponentRect('Column_Space_Default_02'); + console.log('assert position') + expect(Math.round(Column_Space_Default_021.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_021.right)); + expect(Math.round(Column_Space_Default_022.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_022.right)); + expect(Math.round(Column_Space_Default_023.left - Column_Space_Default_02.left)).assertEqual(Math.round(Column_Space_Default_02.right - Column_Space_Default_023.right)); + expect(Math.round(Column_Space_Default_022.top - Column_Space_Default_021.bottom)).assertEqual(Math.round(Column_Space_Default_023.top - Column_Space_Default_022.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_Default_022.top - Column_Space_Default_021.bottom)).assertEqual(vp2px(0)); + expect(Math.round(Column_Space_Default_023.top - Column_Space_Default_022.bottom)).assertEqual(vp2px(0)); + console.log('Column_Space_Default_022.top - Column_Space_Default_021.bottom', + Column_Space_Default_022.top - Column_Space_Default_021.bottom) + console.log('Column_Space_Default_023.top - Column_Space_Default_022.bottom', + Column_Space_Default_023.top - Column_Space_Default_022.bottom) + expect(Column_Space_Default_02.top).assertEqual(Column_Space_Default_021.top); + expect(Column_Space_Default_023.bottom).assertLess(Column_Space_Default_02.bottom); + console.log('assert height') + expect(Math.round(Column_Space_Default_021.bottom - Column_Space_Default_021.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_Default_022.bottom - Column_Space_Default_022.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_Default_023.bottom - Column_Space_Default_023.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_Default_021.right - Column_Space_Default_021.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_022.right - Column_Space_Default_022.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_023.right - Column_Space_Default_023.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_Default_TEST_0500] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_Default_TEST_0100 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to null + */ + it('SUB_ACE_Column_Space_Default_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_Default_TEST_0100] START'); + globalThis.value.message.notify({name:'addSpace1', value:undefined}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_Default_011 = CommonFunc.getComponentRect('Column_Space_Default_011'); + let Column_Space_Default_012 = CommonFunc.getComponentRect('Column_Space_Default_012'); + let Column_Space_Default_013 = CommonFunc.getComponentRect('Column_Space_Default_013'); + let Column_Space_Default_01 = CommonFunc.getComponentRect('Column_Space_Default_01'); + console.log('assert position') + expect(Math.round(Column_Space_Default_011.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_011.right)); + expect(Math.round(Column_Space_Default_012.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_012.right)); + expect(Math.round(Column_Space_Default_013.left - Column_Space_Default_01.left)).assertEqual(Math.round(Column_Space_Default_01.right - Column_Space_Default_013.right)); + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_Default_012.top - Column_Space_Default_011.bottom)).assertEqual(vp2px(0)); + expect(Math.round(Column_Space_Default_013.top - Column_Space_Default_012.bottom)).assertEqual(vp2px(0)); + console.log('Column_Space_Default_012.top - Column_Space_Default_011.bottom', + Column_Space_Default_012.top - Column_Space_Default_011.bottom) + console.log('Column_Space_Default_013.top - Column_Space_Default_012.bottom', + Column_Space_Default_013.top - Column_Space_Default_012.bottom) + expect(Column_Space_Default_01.top).assertEqual(Column_Space_Default_011.top); + expect(Column_Space_Default_013.bottom).assertLess(Column_Space_Default_01.bottom); + console.log('assert height') + expect(Math.round(Column_Space_Default_011.bottom - Column_Space_Default_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_Default_012.bottom - Column_Space_Default_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_Default_013.bottom - Column_Space_Default_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_Default_011.right - Column_Space_Default_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_012.right - Column_Space_Default_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_Default_013.right - Column_Space_Default_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_Default_TEST_0100] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_String.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_String.test.ets new file mode 100644 index 000000000..a8bf6a430 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Column/spaceChanged/Column_Space_String.test.ets @@ -0,0 +1,484 @@ +/** + * Copyright (c) 2023 Huawei Device 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 Column_Space_String() { + describe('Column_Space_String', function () { + beforeEach(async function (done) { + console.info("Column_Space_String beforeEach start"); + let options = { + url: "MainAbility/pages/Column/spaceChanged/Column_Space_String", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get Column_Space_String state pages1:" + JSON.stringify(pages)); + if (!("Column_Space_String" == pages.name)) { + console.info("get Column_Space_String pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + pages = router.getState(); + console.info("get Column_Space_String state pages2:" + JSON.stringify(pages)); + console.info("push Column_Space_String page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push Column_Space_String page error " + JSON.stringify(err)); + expect().assertFail(); + } + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(2000); + console.info("Column_Space_String after each called") + }); + + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0100 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '30' + */ + it('SUB_ACE_Column_Space_String_TEST_0100', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0100] START'); + globalThis.value.message.notify({name:'addSpace', value:'30'}); + await CommonFunc.sleep(4000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(vp2px(30)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(vp2px(30)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0200 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '50px' + */ + it('SUB_ACE_Column_Space_String_TEST_0200', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0200] START'); + globalThis.value.message.notify({name:'addSpace', value:'50px'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(50); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(50); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0200] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0300 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '50fp' + */ + it('SUB_ACE_Column_Space_String_TEST_0300', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0300] START'); + globalThis.value.message.notify({name:'addSpace', value:'50fp'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(fp2px(50)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(fp2px(50)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + expect(Column_Space_String_013.bottom).assertEqual(Column_Space_String_01.bottom); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0300] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0400 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '50lpx' + */ + it('SUB_ACE_Column_Space_String_TEST_0400', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0400] START'); + globalThis.value.message.notify({name:'addSpace', value:'50lpx'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(lpx2px(50))); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(Math.round(lpx2px(50))); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0400] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0500 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to vp2px(10) + */ + it('SUB_ACE_Column_Space_String_TEST_0500', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0500] START'); + globalThis.value.message.notify({name:'addSpace', value:vp2px(10) + 'px'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(vp2px(10)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(vp2px(10)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0500] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0600 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to px2vp(10) + */ + it('SUB_ACE_Column_Space_String_TEST_0600', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0600] START'); + globalThis.value.message.notify({name:'addSpace', value:px2vp(10) + 'vp'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(10); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(10); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0600] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0700 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to fp2px(10) + */ + it('SUB_ACE_Column_Space_String_TEST_0700', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0700] START'); + globalThis.value.message.notify({name:'addSpace', value:fp2px(10) + 'px'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(fp2px(10)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(fp2px(10)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0700] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0800 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to px2fp(10) + */ + it('SUB_ACE_Column_Space_String_TEST_0800', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0800] START'); + globalThis.value.message.notify({name:'addSpace', value:px2fp(10) + 'fp'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(10); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(10); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0800] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_0900 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to lpx2px(10) + */ + it('SUB_ACE_Column_Space_String_TEST_0900', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_0900] START'); + globalThis.value.message.notify({name:'addSpace', value:lpx2px(10) + 'px'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(lpx2px(10))); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(Math.round(lpx2px(10))); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_0900] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_1000 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to px2lpx(10) + */ + it('SUB_ACE_Column_Space_String_TEST_1000', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_1000] START'); + globalThis.value.message.notify({name:'addSpace', value:px2lpx(10) + 'lpx'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(10); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(10); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_01000] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_1100 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '3'+'0' + */ + it('SUB_ACE_Column_Space_String_TEST_1100', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_01100] START'); + globalThis.value.message.notify({name:'addSpace', value:'3'+'0'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(vp2px(30)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(vp2px(30)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_01100] END'); + done(); + }); + /** + * @tc.number SUB_ACE_Column_Space_String_TEST_1200 + * @tc.name testColumnSpace + * @tc.desc The value of space is set to '50' + */ + it('SUB_ACE_Column_Space_String_TEST_1200', 0, async function (done) { + console.info('[SUB_ACE_Column_Space_String_TEST_1200] START'); + globalThis.value.message.notify({name:'addSpace', value:'50'}); + await CommonFunc.sleep(3000); + console.log('get Initial value') + let Column_Space_String_011 = CommonFunc.getComponentRect('Column_Space_String_011'); + let Column_Space_String_012 = CommonFunc.getComponentRect('Column_Space_String_012'); + let Column_Space_String_013 = CommonFunc.getComponentRect('Column_Space_String_013'); + let Column_Space_String_01 = CommonFunc.getComponentRect('Column_Space_String_01'); + console.log('assert position') + expect(Math.round(Column_Space_String_011.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_011.right)); + expect(Math.round(Column_Space_String_012.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_012.right)); + expect(Math.round(Column_Space_String_013.left - Column_Space_String_01.left)).assertEqual(Math.round(Column_Space_String_01.right - Column_Space_String_013.right)); + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)) + console.log('assert space') + expect(Math.round(Column_Space_String_012.top - Column_Space_String_011.bottom)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_013.top - Column_Space_String_012.bottom)).assertEqual(vp2px(50)); + console.log('Column_Space_String_012.top - Column_Space_String_011.bottom', + Column_Space_String_012.top - Column_Space_String_011.bottom) + console.log('Column_Space_String_013.top - Column_Space_String_012.bottom', + Column_Space_String_013.top - Column_Space_String_012.bottom) + expect(Column_Space_String_01.top).assertEqual(Column_Space_String_011.top); + console.log('assert height') + expect(Math.round(Column_Space_String_011.bottom - Column_Space_String_011.top)).assertEqual(vp2px(50)); + expect(Math.round(Column_Space_String_012.bottom - Column_Space_String_012.top)).assertEqual(vp2px(100)); + expect(Math.round(Column_Space_String_013.bottom - Column_Space_String_013.top)).assertEqual(vp2px(150)); + console.log('assert weight') + expect(Math.round(Column_Space_String_011.right - Column_Space_String_011.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_012.right - Column_Space_String_012.left)).assertEqual(vp2px(300)); + expect(Math.round(Column_Space_String_013.right - Column_Space_String_013.left)).assertEqual(vp2px(300)); + console.info('[SUB_ACE_Column_Space_String_TEST_1200] END'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets index 52f42f79e..0588e28fd 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets @@ -23,6 +23,21 @@ import flexTextMargin_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexTextMarginJsunit.test.ets'; import Row_Space from './Row/spaceChanged/Row_Space.test.ets'; import Column_Space from './Column/spaceChanged/Column_Space.test.ets'; + import Column_Space_String from './Column/spaceChanged/Column_Space_String.test.ets'; + import Column_Space_Default from './Column/spaceChanged/Column_Space_Default.test.ets'; + import layoutWeight_Part from './Column/layoutWeight/layoutWeight_Part.test'; + import layoutWeight_All from './Column/layoutWeight/layoutWeight_All.test'; + import layoutWeight_Default from './Column/layoutWeight/layoutWeight_Default.test.ets'; + import layoutWeight_flexGrow from './Column/layoutWeight/layoutWeight_flexGrow.test.ets'; + import layoutWeight_flexShrink from './Column/layoutWeight/layoutWeight_flexShrink.test.ets'; + import flexGrow_Part from './Column/flexGrow/flexGrow_Part.test.ets'; + import flexGrow_Default from './Column/flexGrow/flexGrow_Default.test.ets'; + import flexShrink_Part from './Column/flexShrink/flexShrink_Part.test.ets'; + import flexBasis_Type from './Column/flexBasis/flexBasis_Type.test.ets'; + import flexBasis_Default from './Column/flexBasis/flexBasis_Default.test.ets'; + import columnNesting_Space from './Column/columnNesting/columnNesting_Space.test.ets'; + import columnNesting_alignItems from './Column/columnNesting/columnNesting_alignItems.test.ets'; + import columnNesting_justifyContent from './Column/columnNesting/columnNesting_justifyContent.test.ets'; import Grid_RowCol_TemplateChange from './Grid/GridTemplatesAllSet/GridTemplateChange/Grid_RowCol_TemplateChange.test.ets'; import Grid_RowCol_GridSize from './Grid/GridTemplatesAllSet/GridChange/Grid_RowCol_GridSize.test.ets'; import Grid_RowCol_PadMar from './Grid/GridTemplatesAllSet/GridChange/Grid_RowCol_PadMar.test.ets'; @@ -101,6 +116,21 @@ export default function testsuite() { flexTextMargin_AutoJsunit() Row_Space() Column_Space() + Column_Space_String() + Column_Space_Default() + layoutWeight_Part() + layoutWeight_All() + layoutWeight_Default() + layoutWeight_flexGrow() + layoutWeight_flexShrink() + flexGrow_Part() + flexGrow_Default() + flexShrink_Part() + flexBasis_Type() + flexBasis_Default() + columnNesting_Space() + columnNesting_alignItems() + columnNesting_justifyContent() Grid_RowCol_TemplateChange() Grid_RowCol_GridSize() Grid_RowCol_PadMar() diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json index f2d0d6adb..a5ea74d70 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json @@ -12,6 +12,21 @@ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin", "MainAbility/pages/Row/spaceChanged/Row_Space", "MainAbility/pages/Column/spaceChanged/Column_Space", + "MainAbility/pages/Column/spaceChanged/Column_Space_String", + "MainAbility/pages/Column/spaceChanged/Column_Space_Default", + "MainAbility/pages/Column/layoutWeight/layoutWeight_Part", + "MainAbility/pages/Column/layoutWeight/layoutWeight_All", + "MainAbility/pages/Column/layoutWeight/layoutWeight_Default", + "MainAbility/pages/Column/layoutWeight/layoutWeight_flexGrow", + "MainAbility/pages/Column/layoutWeight/layoutWeight_flexShrink", + "MainAbility/pages/Column/flexGrow/flexGrow_Part", + "MainAbility/pages/Column/flexGrow/flexGrow_Default", + "MainAbility/pages/Column/flexShrink/flexShrink_Part", + "MainAbility/pages/Column/flexBasis/flexBasis_Type", + "MainAbility/pages/Column/flexBasis/flexBasis_Default", + "MainAbility/pages/Column/columnNesting/columnNesting_Space", + "MainAbility/pages/Column/columnNesting/columnNesting_alignItems", + "MainAbility/pages/Column/columnNesting/columnNesting_justifyContent", "MainAbility/pages/Grid/GridTemplatesAllSet/GridTemplateChange/Grid_RowCol_TemplateChange", "MainAbility/pages/Grid/GridTemplatesAllSet/GridChange/Grid_RowCol_GridSize", "MainAbility/pages/Grid/GridTemplatesAllSet/GridChange/Grid_RowCol_PadMar", -- GitLab