diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.ets new file mode 100644 index 0000000000000000000000000000000000000000..c998a06ac9c83b2860187dbbb6b49eae3260d61c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.ets @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedChild { + @State testHeight: number = 150 + @State testWidth: number = 450 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedChild Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedChild page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.testHeight = message.value; + } + if (message.name == 'width') { + this.testWidth = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedChild page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround1').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround2') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround3') + } + .key('FlexAlignSpaceAround1') + .height(this.testHeight) + .width(this.testWidth) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.ets new file mode 100644 index 0000000000000000000000000000000000000000..53d6190bd5cfc5151cb22a40b0bc297c73db90e0 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.ets @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedChildParentItemAlignEnd { + @State testHeight: number = 150 + @State testWidth: number = 450 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedChildParentItemAlignEnd Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedChildParentItemAlignEnd page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.testHeight = message.value; + } + if (message.name == 'width') { + this.testWidth = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedChildParentItemAlignEnd page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround8').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround22') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround23') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround24') + } + .key('FlexAlignSpaceAround8') + .height(this.testHeight) + .width(this.testWidth) + .align(Alignment.BottomEnd) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd0846aa78b0c6ddc75f84724a268bf6f0075fab --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.ets @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedChildParentMarPad { + @State testPadding: number = 10 + @State testMargin: number = 10 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedChildParentMarPad Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedChildParentMarPad page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.testPadding = message.value; + } + if (message.name == 'margin') { + this.testMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedChildParentMarPad page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround6').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround16') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround17') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround18') + } + .key('FlexAlignSpaceAround6') + .height(200) + .width(500) + .margin(this.testMargin) + .padding(this.testPadding) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c2d9f9faaa8e191d40e71d54c21ec2f14a47989 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedChildParentMargin { + @State testMargin: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedChildParentMargin Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedChildParentMargin page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'margin') { + this.testMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedChildParentMargin page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround5').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround13') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround14') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround15') + } + .key('FlexAlignSpaceAround5') + .height(200) + .width(500) + .margin(this.testMargin) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.ets new file mode 100644 index 0000000000000000000000000000000000000000..af069ec920cd5d7bddc0af06e69ba6bb7e20d81b --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedChildParentPadding { + @State testPadding: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedChildParentPadding Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedChildParentPadding page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.testPadding = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedChildParentPadding page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround3').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround7') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround8') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround9') + } + .key('FlexAlignSpaceAround3') + .height(200) + .width(500) + .padding(this.testPadding) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.ets new file mode 100644 index 0000000000000000000000000000000000000000..69f96d856dda4dd6f17a1aa79989bd152d7a43c3 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.ets @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedParent { + @State testOffsetX: number = 0 + @State testOffsetY: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedParent Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedParent page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'x') { + this.testOffsetX = message.value; + } + if (message.name == 'y') { + this.testOffsetY = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedParent page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround9').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround25') + .offset({ x: this.testOffsetX, y: this.testOffsetY }) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround26') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround27') + } + .key('FlexAlignSpaceAround9') + .height(200) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.ets new file mode 100644 index 0000000000000000000000000000000000000000..267f39321b8eb855b40864731506733b8e0f0f9c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.ets @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedParentChangeFirst { + @State testFirstlayoutWeight: number = 0 + @State testSecondlayoutWeight: number = 0 + @State testThirdlayoutWeight: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedParentChangeFirst Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedParentChangeFirst page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'testFirstlayoutWeight') { + this.testFirstlayoutWeight = message.value; + } + if (message.name == 'testSecondlayoutWeight') { + this.testSecondlayoutWeight = message.value; + } + if (message.name == 'testThirdlayoutWeight') { + this.testThirdlayoutWeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedParentChangeFirst page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround12').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround34') + .layoutWeight(this.testFirstlayoutWeight) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround35') + .layoutWeight(this.testSecondlayoutWeight) + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround36') + .layoutWeight(this.testThirdlayoutWeight) + } + .key('FlexAlignSpaceAround12') + .height(200) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.ets new file mode 100644 index 0000000000000000000000000000000000000000..4284a1f9a4ea23f9071043b5d702317fd0371cad --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.ets @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedParentChangeFirstWidth { + @State testWidth: number = 150 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedParentChangeFirstWidth Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedParentChangeFirstWidth page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'width') { + this.testWidth = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedParentChangeFirstWidth page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround13').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(this.testWidth).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround37') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround38') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround39') + } + .key('FlexAlignSpaceAround13') + .height(200) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.ets new file mode 100644 index 0000000000000000000000000000000000000000..19a5ee7bb31d0e8233bc08c9d0360741f6eee933 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.ets @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedParentMarginFirst { + @State testMargin: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedParentMarginFirst Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedParentMarginFirst page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'margin') { + this.testMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedParentMarginFirst page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround14').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround40').margin(this.testMargin) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround41') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround42') + } + .key('FlexAlignSpaceAround14') + .height(200) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.ets new file mode 100644 index 0000000000000000000000000000000000000000..530c3a33125c43a3f6c3c5e65ec3b6f4e0551cb6 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.ets @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager, Callback } from '../../../../common/MessageManager'; + +@Entry +@Component +struct FlexAlign_SpaceAround_fixedParentVisibility { + @State testVisibility: number = Visibility.Visible + messageManager:MessageManager = new MessageManager() + private content: string = "FlexAlign_SpaceAround_fixedParentVisibility Page" + + onPageShow() { + console.info('FlexAlign_SpaceAround_fixedParentVisibility page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'visibility') { + this.testVisibility = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexAlign_SpaceAround_fixedParentVisibility page build done called'); + } + + build() { + Column() { + Text('justifyContent:Align_SpaceAround10').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignSpaceAround28').visibility(this.testVisibility) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignSpaceAround29') + Text('3').width(150).height(150).backgroundColor(0xffa500).key('AlignSpaceAround30') + } + .key('FlexAlignSpaceAround10') + .height(200) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b14a472c95af6d26b4a5de92a83da108bfa50dc --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild.test.ets @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedChild() { + describe('FlexAlign_SpaceAround_fixedChild', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedChild beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChild', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedChild state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedChild" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedChild state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedChild page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedChild page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedChild afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0100 + * @tc.name testAlignSpaceAroundRowNoWrapOutRange + * @tc.desc The child component is fixed, and parent component is bound with width and height attributes, + * the layout space of parent is insufficient to meet the spindle layout requirements of child + */ + it('testAlignSpaceAroundRowNoWrapOutRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapOutRange START'); + globalThis.value.message.notify({name:'height', value:200}) + globalThis.value.message.notify({name:'width', value:400}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround1'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround1'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround2'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround3'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround1'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(locationText1.left).assertEqual(locationFlex.left); + expect(locationText1.right).assertEqual(locationText2.left); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(locationFlex.right); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(Math.round(vp2px(400/3))); + console.info('new testAlignSpaceAroundRowNoWrapOutRange END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0200 + * @tc.name testAlignSpaceAroundRowNoWrapInRange + * @tc.desc The child component is fixed, and parent component is bound with width and height attributes, + * the layout space of parent meets the spindle layout requirements of child + */ + it('testAlignSpaceAroundRowNoWrapInRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapInRange START'); + globalThis.value.message.notify({name:'height', value:200}) + globalThis.value.message.notify({name:'width', value:500}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround1'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround1'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround2'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround3'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround1'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(50/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapInRange END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c542d4df0f53354d0c41ffcf4840ebdd21f9316 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd.test.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedChildParentItemAlignEnd() { + describe('FlexAlign_SpaceAround_fixedChildParentItemAlignEnd', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedChildParentItemAlignEnd beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentItemAlignEnd', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedChildParentItemAlignEnd state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedChildParentItemAlignEnd" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedChildParentItemAlignEnd pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedChildParentItemAlignEnd page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedChildParentItemAlignEnd page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedChildParentItemAlignEnd afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0800 + * @tc.name testAlignSpaceAroundRowNoWrapAlignmentBottomEnd + * @tc.desc The child component is fixed, and the parent component is bound with Alignment.BottomEnd attributes + */ + it('testAlignSpaceAroundRowNoWrapAlignmentBottomEnd', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapAlignmentBottomEnd START'); + globalThis.value.message.notify({name:'height', value:200}) + globalThis.value.message.notify({name:'width', value:500}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround8'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround22'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround23'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround24'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround8'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(vp2px(0)); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(50/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapAlignmentBottomEnd END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2328dc59c9d6c9be328f299bcf477a5e6a6c8b9f --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad.test.ets @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedChildParentMarPad() { + describe('FlexAlign_SpaceAround_fixedChildParentMarPad', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedChildParentMarPad beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMarPad', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedChildParentMarPad state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedChildParentMarPad" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedChildParentMarPad pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedChildParentMarPad page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedChildParentMarPad page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedChildParentMarPad afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0600 + * @tc.name testAlignSpaceAroundRowNoWrapMarPadOutRange + * @tc.desc The child component is fixed, and parent component is bound with padding and margin attributes, + * the layout space of parent is insufficient to meet the spindle layout requirements of child + */ + it('testAlignSpaceAroundRowNoWrapMarPadOutRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapMarPadOutRange START'); + globalThis.value.message.notify({name:'margin', value:20}) + globalThis.value.message.notify({name:'padding', value:50}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround6'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround16'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround17'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround18'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround6'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(locationFlex.bottom).assertEqual(locationText3.bottom); + expect(Math.round(locationText1.left - locationFlex.left)).assertEqual(vp2px(50)); + expect(locationText1.right).assertEqual(locationText2.left); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(Math.round(locationFlex.right - vp2px(50))); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(Math.round(vp2px(400/3))); + console.info('new testAlignSpaceAroundRowNoWrapMarPadOutRange END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0700 + * @tc.name testAlignSpaceAroundRowNoWrapMarPadInRange + * @tc.desc The child component is fixed, and parent component is bound with padding and margin attributes, + * the layout space of parent component meets the spindle layout requirements of child component + */ + it('testAlignSpaceAroundRowNoWrapMarPadInRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapMarPadInRange START'); + globalThis.value.message.notify({name:'margin', value:20}) + globalThis.value.message.notify({name:'padding', value:5}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround6'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround16'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround17'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround18'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround6'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(Math.round((locationText1.top - locationFlex.top)*10)/10).assertEqual(Math.round(vp2px(5)*10)/10); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round((locationFlex.bottom - locationText3.bottom)*10)/10).assertEqual(Math.round(vp2px(45)*10)/10); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(40/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(35/3)*10)/10); + expect(Math.round((locationText2.left - locationText1.right)*10)/10) + .assertEqual(Math.round(20*(locationFlex.right - locationText3.right - vp2px(5)))/10); + console.info('new testAlignSpaceAroundRowNoWrapMarPadInRange END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b86e50f49639e81679cc09b3ec61244c1933652 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin.test.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedChildParentMargin() { + describe('FlexAlign_SpaceAround_fixedChildParentMargin', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedChildParentMargin beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentMargin', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedChildParentMargin state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedChildParentMargin" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedChildParentMargin pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedChildParentMargin page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedChildParentMargin page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedChildParentMargin afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0500 + * @tc.name testAlignSpaceAroundRowNoWrapMargin + * @tc.desc The child component is fixed, and the parent component is bound with margin attributes + */ + it('testAlignSpaceAroundRowNoWrapMargin', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapMargin START'); + globalThis.value.message.notify({name:'margin', value:20}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround5'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround13'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround14'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround15'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround5'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(50/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapMargin END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c849233bf412098ac415e3a00f5ca839e8b4e9a7 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding.test.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedChildParentPadding() { + describe('FlexAlign_SpaceAround_fixedChildParentPadding', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedChildParentPadding beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedChildParentPadding', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedChildParentPadding state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedChildParentPadding" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedChildParentPadding pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedChildParentPadding page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedChildParentPadding page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedChildParentPadding afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0300 + * @tc.name testAlignSpaceAroundRowNoWrapPaddingOutRange + * @tc.desc The child component is fixed, and parent component is bound with padding attributes, the layout + * space of parent is insufficient to meet the spindle layout requirements of child component + */ + it('testAlignSpaceAroundRowNoWrapPaddingOutRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapPaddingOutRange START'); + globalThis.value.message.notify({name:'padding', value:50}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround3'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround7'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround8'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround9'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround3'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(locationFlex.bottom).assertEqual(locationText3.bottom); + expect(Math.round(locationText1.left - locationFlex.left)).assertEqual(vp2px(50)); + expect(locationText1.right).assertEqual(locationText2.left); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(Math.round(locationFlex.right - vp2px(50))); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(Math.round(vp2px(400/3))); + console.info('new testAlignSpaceAroundRowNoWrapPaddingOutRange END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0400 + * @tc.name testAlignSpaceAroundRowNoWrapPaddingInRange + * @tc.desc The child component is fixed, and parent component is bound with padding attributes, the layout + * space of parent component meets the spindle layout requirements of the child component + */ + it('testAlignSpaceAroundRowNoWrapPaddingInRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapPaddingInRange START'); + globalThis.value.message.notify({name:'padding', value:5}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround3'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround7'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround8'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround9'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround3'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(Math.round((locationText1.top - locationFlex.top)*10)/10).assertEqual(Math.round(vp2px(5)*10)/10); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round((locationFlex.bottom - locationText3.bottom)*10)/10) + .assertEqual(Math.round(vp2px(45)*10)/10); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(40/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(35/3)*10)/10); + expect(Math.round((locationText2.left - locationText1.right)*10)/10) + .assertEqual(Math.round(20*(locationFlex.right - locationText3.right - vp2px(5)))/10); + console.info('new testAlignSpaceAroundRowNoWrapPaddingInRange END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de73d1a386eac1b9948470a1d43958ca79c880e4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent.test.ets @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedParent() { + describe('FlexAlign_SpaceAround_fixedParent', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedParent beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParent', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedParent state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedParent" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedParent state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedParent page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedParent page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedParent afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_0900 + * @tc.name testAlignSpaceAroundRowNoWrapOffset + * @tc.desc Parent component fixed, child component binding offset properties + */ + it('testAlignSpaceAroundRowNoWrapOffset', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapOffset START'); + globalThis.value.message.notify({name:'x', value:15}) + globalThis.value.message.notify({name:'y', value:30}) + globalThis.value.message.notify({name:'visibility', value:Visibility.Visible}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround9'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let strJson2 = getInspectorByKey('AlignSpaceAround25'); + let obj2 = JSON.parse(strJson2); + expect(obj2.$attrs.visibility).assertEqual('Visibility.Visible'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround25'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround26'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround27'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround9'); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(vp2px(30)) + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round((vp2px(15) + (locationFlex.right - locationText3.right))*10)/10) + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText3.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round((locationText2.left - locationText1.right + vp2px(15))*10)/10) + .assertEqual(Math.round((locationText3.left - locationText2.right)*10)/10); + expect(Math.round((locationText1.left - locationFlex.left - vp2px(15))*10)/10) + .assertEqual(Math.round((locationFlex.right - locationText3.right)*10)/10); + expect(Math.round((locationText3.left - locationText2.right)*10)/10) + .assertEqual(Math.round(20*(locationFlex.right - locationText3.right))/10); + console.info('new testAlignSpaceAroundRowNoWrapOffset END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ba928c4166d794609767aebc3ce8172f962f2b0 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst.test.ets @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedParentChangeFirst() { + describe('FlexAlign_SpaceAround_fixedParentChangeFirst', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedParentChangeFirst beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirst', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedParentChangeFirst state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedParentChangeFirst" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedParentChangeFirst pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedParentChangeFirst page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedParentChangeFirst page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedParentChangeFirst afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1200 + * @tc.name testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight122 + * @tc.desc Parent component fixed, child component binding layoutWeight first1 second2 third2 properties + */ + it('testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight122', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight122 START'); + globalThis.value.message.notify({name:'testFirstlayoutWeight', value:1}) + globalThis.value.message.notify({name:'testSecondlayoutWeight', value:2}) + globalThis.value.message.notify({name:'testThirdlayoutWeight', value:2}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround12'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround34'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround35'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround36'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround12'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(locationText1.left).assertEqual(locationFlex.left); + expect(locationText1.right).assertEqual(locationText2.left); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(locationFlex.right); + expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(200)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(200)); + console.info('new testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight122 END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1600 + * @tc.name testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight120 + * @tc.desc Parent component fixed, child component binding layoutWeight first1 second2 third0 properties + */ + it('testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight120', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight120 START'); + globalThis.value.message.notify({name:'testFirstlayoutWeight', value:1}) + globalThis.value.message.notify({name:'testSecondlayoutWeight', value:2}) + globalThis.value.message.notify({name:'testThirdlayoutWeight', value:0}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround12'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround34'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround35'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround36'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround12'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(locationText1.left).assertEqual(locationFlex.left); + expect(locationText1.right).assertEqual(locationText2.left); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(locationFlex.right); + expect(Math.round(locationText1.right - locationText1.left)).assertEqual(Math.round(vp2px(350/3))); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(Math.round(vp2px(700/3))); + expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(150)); + console.info('new testAlignSpaceAroundRowNoWrapChangeFirstLayoutWeight120 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b45817a09734dbc26548b829e81241b5dbed4ce --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth.test.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedParentChangeFirstWidth() { + describe('FlexAlign_SpaceAround_fixedParentChangeFirstWidth', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedParentChangeFirstWidth beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentChangeFirstWidth', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedParentChangeFirstWidth state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedParentChangeFirstWidth" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedParentChangeFirstWidth pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedParentChangeFirstWidth page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedParentChangeFirstWidth page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedParentChangeFirstWidth afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1300 + * @tc.name testAlignSpaceAroundRowNoWrapChangeFirst + * @tc.desc Parent component fixed, child component binding width properties + */ + it('testAlignSpaceAroundRowNoWrapChangeFirst', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapChangeFirst START'); + globalThis.value.message.notify({name:'width', value:175}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround13'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround37'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround38'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround39'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround13'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round((locationText2.left - locationText1.right)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round((locationText1.right - locationText1.left)*10)/10).assertEqual(Math.round(vp2px(175)*10)/10); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(25/6)*10)/10); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapChangeFirst END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0678b78bd7706c1034af1a33afcec506abfce95d --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst.test.ets @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedParentMarginFirst() { + describe('FlexAlign_SpaceAround_fixedParentMarginFirst', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedParentMarginFirst beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentMarginFirst', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedParentMarginFirst state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedParentMarginFirst" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedParentMarginFirst state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedParentMarginFirst page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedParentMarginFirst page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedParentMarginFirst afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1400 + * @tc.name testAlignSpaceAroundRowNoWrapMarginFirstInRange + * @tc.desc Parent component fixed, child component binding margin properties, the layout space of the parent + * component meets the spindle layout requirements of the child component + */ + it('testAlignSpaceAroundRowNoWrapMarginFirstInRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapMarginFirstInRange START'); + globalThis.value.message.notify({name:'margin', value:20}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround14'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround40'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround41'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround42'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround14'); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(vp2px(20)) + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText3.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right - vp2px(20))) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText1.left - locationFlex.left - vp2px(20))) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round(locationText2.left - locationText1.right - vp2px(20))) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapMarginFirstInRange END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1500 + * @tc.name testAlignSpaceAroundRowNoWrapMarginFirstOutRange + * @tc.desc Parent component fixed, child component binding margin properties, the layout space of the parent + * component is insufficient to meet the spindle layout requirements of the child component + */ + it('testAlignSpaceAroundRowNoWrapMarginFirstOutRange', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapMarginFirstOutRange START'); + globalThis.value.message.notify({name:'margin', value:50}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround14'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround40'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround41'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround42'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround14'); + expect(Math.round(locationText1.top - locationFlex.top)).assertEqual(Math.round(vp2px(50))); + expect(Math.round(locationText1.left - locationFlex.left)).assertEqual(Math.round(vp2px(50))); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText3.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(locationText2.right).assertEqual(locationText3.left); + expect(locationText3.right).assertEqual(locationFlex.right); + expect(Math.round(locationText1.right - locationText1.left)).assertEqual(Math.round(vp2px(400/3))); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(Math.round(vp2px(400/3))); + expect(Math.round(locationText3.right - locationText3.left)).assertEqual(Math.round(vp2px(400/3))); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(50))); + console.info('new testAlignSpaceAroundRowNoWrapMarginFirstOutRange END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0650af525b23b8aa02c8698f1deafc1a92703680 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility.test.ets @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from '../../../../MainAbility/common/Common'; +import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager'; + +export default function flexAlign_SpaceAround_fixedParentVisibility() { + describe('FlexAlign_SpaceAround_fixedParentVisibility', function () { + beforeEach(async function (done) { + console.info("FlexAlign_SpaceAround_fixedParentVisibility beforeEach called"); + let options = { + uri: 'MainAbility/pages/Flex/justifyContent/SpaceAround/FlexAlign_SpaceAround_fixedParentVisibility', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexAlign_SpaceAround_fixedParentVisibility state pages:" + JSON.stringify(pages)); + if (!("FlexAlign_SpaceAround_fixedParentVisibility" == pages.name)) { + console.info("get FlexAlign_SpaceAround_fixedParentVisibility state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push FlexAlign_SpaceAround_fixedParentVisibility page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexAlign_SpaceAround_fixedParentVisibility page error:" + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexAlign_SpaceAround_fixedParentVisibility afterEach called"); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1000 + * @tc.name testAlignSpaceAroundRowNoWrapVisibilityNone + * @tc.desc Parent component fixed, child component binding visibility none properties + */ + it('testAlignSpaceAroundRowNoWrapVisibilityNone', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapVisibilityNone START'); + globalThis.value.message.notify({name:'visibility', value:Visibility.None}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround10'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let strJson2 = getInspectorByKey('AlignSpaceAround28'); + let obj2 = JSON.parse(strJson2); + expect(obj2.$attrs.visibility).assertEqual('Visibility.None'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround28'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround29'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround30'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround10'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText2.top).assertEqual(locationFlex.top); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.left - locationFlex.left)).assertEqual(vp2px(50)); + expect(Math.round(locationFlex.right - locationText3.right)).assertEqual(vp2px(50)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText3.left - locationText2.right)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.left - locationText2.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapVisibilityNone END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEAROUND_TEST_1100 + * @tc.name testAlignSpaceAroundRowNoWrapVisibilityHidden + * @tc.desc Parent component fixed, child component binding visibility hidden properties + */ + it('testAlignSpaceAroundRowNoWrapVisibilityHidden', 0, async function (done) { + console.info('new testAlignSpaceAroundRowNoWrapVisibilityHidden START'); + globalThis.value.message.notify({name:'visibility', value:Visibility.Hidden}) + await CommonFunc.sleep(3000); + let strJson = getInspectorByKey('FlexAlignSpaceAround10'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Flex'); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + expect(obj.$attrs.constructor.wrap).assertEqual('FlexWrap.NoWrap'); + expect(obj.$attrs.constructor.justifyContent).assertEqual('FlexAlign.SpaceAround'); + let strJson2 = getInspectorByKey('AlignSpaceAround28'); + let obj2 = JSON.parse(strJson2); + expect(obj2.$attrs.visibility).assertEqual('Visibility.Hidden'); + let locationText1 = CommonFunc.getComponentRect('AlignSpaceAround28'); + let locationText2 = CommonFunc.getComponentRect('AlignSpaceAround29'); + let locationText3 = CommonFunc.getComponentRect('AlignSpaceAround30'); + let locationFlex = CommonFunc.getComponentRect('FlexAlignSpaceAround10'); + expect(locationText1.top).assertEqual(locationText2.top); + expect(locationText2.top).assertEqual(locationText3.top); + expect(locationText1.top).assertEqual(locationFlex.top); + expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(50)); + expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100)); + expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(150)); + expect(Math.round(locationFlex.bottom - locationText3.bottom)).assertEqual(vp2px(50)); + expect(Math.round((locationText1.left - locationFlex.left)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round((locationFlex.right - locationText3.right)*10)/10).assertEqual(Math.round(vp2px(25/3)*10)/10); + expect(Math.round(locationText1.right - locationText1.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText3.right - locationText3.left)) + .assertEqual(Math.round(locationText2.right - locationText2.left)); + expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(150)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(locationText3.left - locationText2.right)); + expect(Math.round(locationText2.left - locationText1.right)).assertEqual(Math.round(vp2px(50/3))); + expect(Math.round(locationText1.left - locationFlex.left)) + .assertEqual(Math.round(locationFlex.right - locationText3.right)); + expect(Math.round(locationText2.left - locationText1.right)) + .assertEqual(Math.round(2*(locationFlex.right - locationText3.right))); + console.info('new testAlignSpaceAroundRowNoWrapVisibilityHidden END'); + done(); + }); + }) +} \ No newline at end of file