From e1664e030c4caa59f67841484404561947514c10 Mon Sep 17 00:00:00 2001 From: zmshij Date: Tue, 7 Feb 2023 16:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4flex=E7=BB=84=E4=BB=B6alignCo?= =?UTF-8?q?ntent=20SpaceEvenly=E7=9B=B8=E5=85=B3=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=8F=8A=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmshij --- .../SpaceEvenly/AlignContentFlex.ets | 56 +++++ .../AlignContentFlexP_Fixed_Margin.ets | 57 +++++ .../AlignContentFlexP_Fixed_Offset.ets | 45 ++++ .../AlignContentFlexP_Fixed_Visibility.ets | 58 ++++++ .../SpaceEvenly/AlignContentFlexP_fixed.ets | 59 ++++++ ...gnContent_FlexAlign_SpaceEvenly_Margin.ets | 44 ++++ ...t_FlexAlign_SpaceEvenly_Margin_padding.ets | 68 ++++++ ...nContent_FlexAlign_SpaceEvenly_padding.ets | 59 ++++++ .../AlignContentFlexJsunit.test.ets | 174 ++++++++++++++++ .../AlignContentFlexP_Fixed_Margin.test.ets | 183 ++++++++++++++++ .../AlignContentFlexP_Fixed_Offset.test.ets | 124 +++++++++++ ...lignContentFlexP_Fixed_Visibility.test.ets | 167 +++++++++++++++ .../AlignContentFlexP_fixed.test.ets | 173 +++++++++++++++ ...tent_FlexAlign_SpaceEvenly_Margin.test.ets | 120 +++++++++++ ...xAlign_SpaceEvenly_Margin_padding.test.ets | 197 ++++++++++++++++++ ...ent_FlexAlign_SpaceEvenly_padding.test.ets | 186 +++++++++++++++++ 16 files changed, 1770 insertions(+) create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlex.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.test.ets diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlex.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlex.ets new file mode 100644 index 000000000..a9084d114 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlex.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 AlignContentFlex { + @State flexHeight: number = 300; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.flexHeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column() { + Text('AlignContentFlex').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenly_flex001_1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenly_flex001_2') + Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenly_flex001_3') + Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenly_flex001_4') + } + .key('AlignContentFlexSpaceEvenly_flex001') + .width(400) + .height(this.flexHeight) + .backgroundColor(0xAFEEEE) + + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.ets new file mode 100644 index 000000000..03fb9def0 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.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 AlignContentFlexP_Fixed_Margin { + @State textMargin: number = 5; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'margin') { + this.textMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + build() { + Column() { + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_Margin_flex001_1') + .margin(this.textMargin) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_Margin_flex001_2') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_Margin_flex001_3') + Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_Margin_flex001_4') + } + .key('AlignContentFlexP_fixed_Margin_flex001') + .size({ width: 500, height: 400 }) + .backgroundColor(0xAFEEEE) + } + .width('100%') + .alignItems(HorizontalAlign.Start) + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.ets new file mode 100644 index 000000000..23cd42734 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.ets @@ -0,0 +1,45 @@ +/* +* 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. + */ + +@Entry +@Component +struct AlignContentFlexP_fixed_Offset { + alignContent: number + + build() { + Column() { + + Text('AlignContentFlexP_fixed_Offset').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_Offset_flex_1') + .offset({ x: 15, y: 30 }) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_Offset_flex_2') + Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_Offset_flex_3') + Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_Offset_flex_4') + } + .key('AlignContentFlexP_fixed_Offset_flex') + .width(500) + .height(400) + .backgroundColor(0xAFEEEE) + + + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.ets new file mode 100644 index 000000000..ecddb8d59 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.ets @@ -0,0 +1,58 @@ +/* +* 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 AlignContentFlexP_Fixed_Visibility { + @State textVisibility: number = Visibility.Visible; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'visibility') { + this.textVisibility = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + build() { + Column() { + + Text('AlignContentFlexP_Fixed_Visibility').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexP_Fixed_Visibility_1') + .visibility(this.textVisibility) + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexP_Fixed_Visibility_2') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContentFlexP_Fixed_Visibility_3') + Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContentFlexP_Fixed_Visibility_4') + } + .key('AlignContentFlexP_Fixed_Visibility_flex') + .width(500) + .height(400) + .backgroundColor(0xAFEEEE) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.ets new file mode 100644 index 000000000..c235db32a --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.ets @@ -0,0 +1,59 @@ +/* +* 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 AlignContentFlexP_fixed { + @State textHeight: number = 50; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.textHeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + + build() { + Column() { + + Text('AlignContentFlexP_fixed').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(this.textHeight).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_2') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('AlignContentFlexP_fixed_3') + Text('4').width(150).height(200).backgroundColor(0xD2B48C).key('AlignContentFlexP_fixed_4') + } + .key('AlignContentFlexSpaceEvenlyP_fixed_flex') + .width(500) + .height(400) + .backgroundColor(0xAFEEEE) + + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.ets new file mode 100644 index 000000000..95a20a232 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.ets @@ -0,0 +1,44 @@ +/* +* 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. + */ + +@Entry +@Component +struct AlignContent_FlexAlign_SpaceEvenly_Margin { + + build() { + Column() { + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenlyMargin_flex_1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenlyMargin_flex_2') + Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenlyMargin_flex_3') + Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenlyMargin_flex_4') + + } + .key('AlignContentFlexSpaceEvenlyMargin_flex') + .width(400) + .height(360) + .backgroundColor(0xAFEEEE) + .margin(15) + + } + .width('100%') + .key('SpaceEvenly_Margin_Column') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.ets new file mode 100644 index 000000000..61defa6e7 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.ets @@ -0,0 +1,68 @@ +/* +* 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 AlignContent_FlexAlign_SpaceEvenly_Margin_padding { + @State flexPadding: number = 10; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.flexPadding = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + build() { + Column() { + Column(){ + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3) + .key('AlignContentFlexSpaceEvenlyMargin&padding_flex001_1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C) + .key('AlignContentFlexSpaceEvenlyMargin&padding_flex001_2') + Text('3').width(150).height(150).backgroundColor(0xD2B48C) + .key('AlignContentFlexSpaceEvenlyMargin&padding_flex001_3') + Text('4').width(150).height(200).backgroundColor(0xF5DEB3) + .key('AlignContentFlexSpaceEvenlyMargin&padding_flex001_4') + } + .key('AlignContentFlexSpaceEvenlyMargin&padding_flex001') + .width(400) + .height(360) + .backgroundColor(0xAFEEEE) + .margin(10) + .padding(this.flexPadding) + + } + .key('AlignContentFlexSpaceEvenlyMargin&paddingColumn_1') + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .key('AlignContentFlexSpaceEvenlyMargin&paddingColumn') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.ets new file mode 100644 index 000000000..854a65aee --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.ets @@ -0,0 +1,59 @@ +/* +* 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 AlignContent_FlexAlign_SpaceEvenly_padding { + @State flexPadding: number = 10; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('AlignContentFlex onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.flexPadding = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + build() { + Column() { + Text('AlignContent_FlexAlign_SpaceEvenly_padding').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + alignContent: FlexAlign.SpaceEvenly, + alignItems: ItemAlign.Start + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenlyPadding_flex001_1') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenlyPadding_flex001_2') + Text('3').width(150).height(150).backgroundColor(0xD2B48C).key('AlignContentFlexSpaceEvenlyPadding_flex001_3') + Text('4').width(150).height(200).backgroundColor(0xF5DEB3).key('AlignContentFlexSpaceEvenlyPadding_flex001_4') + } + .key('AlignContentFlexSpaceEvenlyPadding_flex001') + .width(400) + .height(360) + .backgroundColor(0xAFEEEE) + .padding(this.flexPadding) + + + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexJsunit.test.ets new file mode 100644 index 000000000..00973e3a4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexJsunit.test.ets @@ -0,0 +1,174 @@ +/* + * 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 AlignContentFlexJsunit() { + + describe('AlignContentFlexJsunitTest', function () { + beforeEach(async function (done) { + console.info("AlignContentFlexJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlex', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContentFlex state success " + JSON.stringify(pages)); + if (!("AlignContentFlex" == pages.name)) { + console.info("get AlignContentFlex state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContentFlex page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContentFlex page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContentFlexJsunit beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContentFlexJsunit after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0100 + * @tc.name testAlignContentSpaceEvenlyFlexHeightSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and set the height of + * the flex component so that it meets the subcomponent size requirements. + */ + + it('testAlignContentSpaceEvenlyFlexHeightSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexHeightSatisfy START'); + globalThis.value.message.notify({ name:'height', value:360 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenly_flex001'); + let obj = JSON.parse(strJson); + console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj)); + console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_4'); + + console.log('AlignContentFlexSpaceEvenly_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_2.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + console.info('testAlignContentSpaceEvenlyFlexHeightSatisfy END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0200 + * @tc.name testAlignContentSpaceEvenlyFlexHeightNoSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and set the height of + * the flex component so that it does not meet the subcomponent size requirements. + */ + + it('testAlignContentSpaceEvenlyFlexHeightNoSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexHeightNoSatisfy START'); + globalThis.value.message.notify({ name:'height', value:250 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenly_flex001'); + let obj = JSON.parse(strJson); + let AlignContentFlexSpaceEvenly_flex002 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenly_flex001_4'); + + console.log('AlignContentFlexSpaceEvenly_flex002 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex002)) + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_1.top).assertEqual(AlignContentFlexSpaceEvenly_flex002.top); + expect(AlignContentFlexSpaceEvenly_4.bottom).assertLarger(AlignContentFlexSpaceEvenly_flex002.bottom); + expect(AlignContentFlexSpaceEvenly_2.bottom).assertEqual(AlignContentFlexSpaceEvenly_4.top); + + console.info('testAlignContentSpaceEvenlyFlexHeightNoSatisfy END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.test.ets new file mode 100644 index 000000000..208b390e1 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin.test.ets @@ -0,0 +1,183 @@ +/* + * 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 AlignContentFlexP_Fixed_Margin() { + + describe('AlignContentFlexP_Fixed_Margin', function () { + beforeEach(async function (done) { + console.info("AlignContentFlexP_Fixed_Margin beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Margin', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContentFlexP_Fixed_Margin state success " + JSON.stringify(pages)); + if (!("AlignContentFlexP_Fixed_Margin" == pages.name)) { + console.info("get AlignContentFlexP_Fixed_Margin state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContentFlexP_Fixed_Margin page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContentFlexP_Fixed_Margin page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContentFlexP_Fixed_Margin beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContentFlexP_Fixed_Margin after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_1100 + * @tc.name testAlignContentSpaceEvenlyFlexFixedMarginSatisfy + * @tc.desc Set the margin for the flex subcomponents to meet the size of flex. + */ + + it('testAlignContentSpaceEvenlyFlexFixedMarginSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexFixedMarginSatisfy START'); + globalThis.value.message.notify({ name:'margin', value:10 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexP_fixed_Margin_flex001'); + let obj = JSON.parse(strJson); + console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj)); + console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_4'); + + console.log('AlignContentFlexP_fixed_Margin_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_2.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_3.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_2.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.left - AlignContentFlexSpaceEvenly_flex001.left)) + .assertEqual(vp2px(10)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top)) + .assertEqual(vp2px(50/3)+vp2px(10)); + + console.info('testAlignContentSpaceEvenlyFlexFixedMarginSatisfy END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_1200 + * @tc.name testAlignContentSpaceEvenlyFlexfixedMarginNOSatisfy + * @tc.desc Set a margin for a flex subcomponent that does not fit the flex size. + */ + + it('testAlignContentSpaceEvenlyFlexfixedMarginNOSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexfixedMarginNOSatisfy START'); + globalThis.value.message.notify({ name:'margin', value:100 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexP_fixed_Margin_flex001'); + let obj = JSON.parse(strJson); + let AlignContentFlexSpaceEvenly_flex002 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Margin_flex001_4'); + + console.log('AlignContentFlexSpaceEvenlyP_fixed_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex002)) + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_4.bottom).assertLarger(AlignContentFlexSpaceEvenly_flex002.bottom); + expect(Math.round(AlignContentFlexSpaceEvenly_3.top - AlignContentFlexSpaceEvenly_1.bottom)) + .assertEqual(vp2px(100)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex002.top)) + .assertEqual(vp2px(100)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.left - AlignContentFlexSpaceEvenly_flex002.left)) + .assertEqual(vp2px(100)); + + console.info('testAlignContentSpaceEvenlyFlexfixedMarginNOSatisfy END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.test.ets new file mode 100644 index 000000000..d8b773053 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset.test.ets @@ -0,0 +1,124 @@ +/* + * 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 AlignContentFlexP_Fixed_Offset() { + + describe('AlignContentFlexP_Fixed_Offset', function () { + beforeEach(async function (done) { + console.info("AlignContentFlexP_Fixed_Offset beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Offset', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContentFlexP_Fixed_Offset state success " + JSON.stringify(pages)); + if (!("AlignContentFlexP_Fixed_Offset" == pages.name)) { + console.info("get AlignContentFlexP_Fixed_Offset state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContentFlexP_Fixed_Offset page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContentFlexP_Fixed_Offset page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContentFlexP_Fixed_Offset beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContentFlexP_Fixed_Offset after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_1000 + * @tc.name testAlignContentSpaceEvenlyFlexPfixedOffset + * @tc.desc Set offsize to the flex child component. + */ + + it('testAlignContentSpaceEvenlyFlexPfixedOffset', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexPfixedOffset START'); + let strJson = getInspectorByKey('AlignContentFlexP_fixed_Offset_flex'); + let obj = JSON.parse(strJson); + console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj)); + console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Offset_flex'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Offset_flex_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Offset_flex_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Offset_flex_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_Offset_flex_4'); + + console.log('AlignContentFlexP_fixed_Offset_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round(AlignContentFlexSpaceEvenly_2.left - AlignContentFlexSpaceEvenly_flex001.left)) + .assertEqual(vp2px(150)); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(vp2px(50/3)); + + expect(Math.round((AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_2.left)*10)/10) + .assertEqual(vp2px(15)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(30)); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_2.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_3.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_2.top - AlignContentFlexSpaceEvenly_flex001.top); + + console.info('testAlignContentSpaceEvenlyFlexPfixedOffset END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.test.ets new file mode 100644 index 000000000..4577279f2 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility.test.ets @@ -0,0 +1,167 @@ +/* + * 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 AlignContentFlexP_Fixed_Visibility() { + + describe('AlignContentFlexP_Fixed_Visibility', function () { + beforeEach(async function (done) { + console.info("AlignContentFlexP_Fixed_Visibility beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_Fixed_Visibility', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContentFlexP_Fixed_Visibility state success " + JSON.stringify(pages)); + if (!("AlignContentFlexP_Fixed_Visibility" == pages.name)) { + console.info("get AlignContentFlexP_Fixed_Visibility state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContentFlexP_Fixed_Visibility page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContentFlexP_Fixed_Visibility page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContentFlexP_Fixed_Visibility beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContentFlexP_Fixed_Visibility after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_1300 + * @tc.name testAlignContentSpaceEvenlyFlexfixedVisibilityHidden + * @tc.desc Set the visibility property of the subcomponents of flex to Visibility.Hidden. + */ + + it('testAlignContentSpaceEvenlyFlexfixedVisibilityHidden', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexfixedVisibilityHidden START'); + globalThis.value.message.notify({ name:'visibility', value:Visibility.Hidden }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexP_Fixed_Visibility_flex'); + let obj = JSON.parse(strJson); + let textStrJson = getInspectorByKey('AlignContentFlexP_Fixed_Visibility_1'); + let textObj = JSON.parse(textStrJson); + console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj)); + console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor)); + console.info('text1 textObj.$attrs.constructor is:' + JSON.stringify(textObj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_flex'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_4'); + + console.log('AlignContentFlexP_Fixed_Visibility_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + expect(textObj.$attrs.visibility).assertEqual("Visibility.Hidden"); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_3.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_3.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_3.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(Math.round(AlignContentFlexSpaceEvenly_2.left - AlignContentFlexSpaceEvenly_flex001.left)) + .assertEqual(vp2px(150)); + + console.info('testAlignContentSpaceEvenlyFlexfixedVisibilityHidden END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_1400 + * @tc.name testAlignContentSpaceEvenlyFlexfixedVisibilityNone + * @tc.desc Set the visibility property of the subcomponents of flex to Visibility.None. + */ + + it('testAlignContentSpaceEvenlyFlexfixedVisibilityNone', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexfixedVisibilityNone START'); + globalThis.value.message.notify({ name:'visibility', value:Visibility.None }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexP_Fixed_Visibility_flex'); + let obj = JSON.parse(strJson); + let textStrJson = getInspectorByKey('AlignContentFlexP_Fixed_Visibility_1'); + let textObj = JSON.parse(textStrJson); + console.info('text1 textObj.$attrs.constructor is:' + JSON.stringify(textObj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex002 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_flex'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_Fixed_Visibility_4'); + + console.log('AlignContentFlexP_Fixed_Visibility_flex002 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex002)) + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + expect(textObj.$attrs.visibility).assertEqual("Visibility.None"); + + expect(AlignContentFlexSpaceEvenly_2.top).assertEqual(AlignContentFlexSpaceEvenly_3.top); + expect(AlignContentFlexSpaceEvenly_4.top).assertEqual(AlignContentFlexSpaceEvenly_3.top); + expect(AlignContentFlexSpaceEvenly_2.left).assertEqual(AlignContentFlexSpaceEvenly_flex002.left); + + console.info('testAlignContentSpaceEvenlyFlexfixedVisibilityNone END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.test.ets new file mode 100644 index 000000000..6eb6e9f4e --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed.test.ets @@ -0,0 +1,173 @@ +/* + * 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 AlignContentFlexP_fixed() { + + describe('AlignContentFlexP_fixed', function () { + beforeEach(async function (done) { + console.info("AlignContentFlexP_fixed beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContentFlexP_fixed', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContentFlexP_fixed state success " + JSON.stringify(pages)); + if (!("AlignContentFlexP_fixed" == pages.name)) { + console.info("get AlignContentFlexP_fixed state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContentFlexP_fixed page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContentFlexP_fixed page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContentFlexP_fixed beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContentFlexP_fixed after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0800 + * @tc.name testAlignContentSpaceEvenlyFlexFixedSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly, and adjust the height + * of the child component to meet the flex component size. + */ + + it('testAlignContentSpaceEvenlyFlexFixedSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexFixedSatisfy START'); + globalThis.value.message.notify({ name:'height', value:80 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyP_fixed_flex'); + let obj = JSON.parse(strJson); + console.info('flex [getInspectorByKey] is:'+ JSON.stringify(obj)); + console.info('flex obj.$attrs.constructor is:' + JSON.stringify(obj.$attrs.constructor)); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyP_fixed_flex'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_4'); + + console.log('AlignContentFlexSpaceEvenly_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(80)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_3.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + console.info('testAlignContentSpaceEvenlyFlexFixedSatisfy END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0900 + * @tc.name testAlignContentSpaceEvenlyFlexFixedNOSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and adjust the + * sub-component heights so that they do not meet the flex component size. + */ + + it('testAlignContentSpaceEvenlyFlexFixedNOSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexFixedNOSatisfy START'); + globalThis.value.message.notify({ name:'height', value:300 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyP_fixed_flex'); + let obj = JSON.parse(strJson); + let AlignContentFlexSpaceEvenly_flex002 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyP_fixed_flex'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexP_fixed_4'); + + console.log('AlignContentFlexSpaceEvenly_flex002 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex002)) + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(300)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(AlignContentFlexSpaceEvenly_1.top).assertEqual(AlignContentFlexSpaceEvenly_flex002.top); + expect(AlignContentFlexSpaceEvenly_4.bottom).assertLarger(AlignContentFlexSpaceEvenly_flex002.bottom); + expect(AlignContentFlexSpaceEvenly_1.bottom).assertEqual(AlignContentFlexSpaceEvenly_4.top); + + console.info('testAlignContentSpaceEvenlyFlexFixedNOSatisfy END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.test.ets new file mode 100644 index 000000000..da6853047 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin.test.ets @@ -0,0 +1,120 @@ +/* + * 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 AlignContent_FlexAlign_SpaceEvenly_Margin() { + + describe('AlignContent_FlexAlign_SpaceEvenly_Margin', function () { + beforeEach(async function (done) { + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContent_FlexAlign_SpaceEvenly_Margin state success " + JSON.stringify(pages)); + if (!("AlignContent_FlexAlign_SpaceEvenly_Margin" == pages.name)) { + console.info("get AlignContent_FlexAlign_SpaceEvenly_Margin state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContent_FlexAlign_SpaceEvenly_Margin page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContent_FlexAlign_SpaceEvenly_Margin page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0500 + * @tc.name testAlignContentSpaceEvenlyFlexMarginSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly + * and the flex component to margin. + */ + + it('testAlignContentSpaceEvenlyFlexMarginSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexMarginSatisfy START'); + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyMargin_flex'); + let obj = JSON.parse(strJson); + let SpaceEvenly_Margin_Column = CommonFunc.getComponentRect('SpaceEvenly_Margin_Column'); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin_flex'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin_flex_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin_flex_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin_flex_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin_flex_4'); + + console.log('AlignContentFlexSpaceEvenlyMargin_flex rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenlyMargin_flex_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenlyMargin_flex_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenlyMargin_flex_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenlyMargin_flex_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round((AlignContentFlexSpaceEvenly_flex001.top - SpaceEvenly_Margin_Column.top)*10)/10) + .assertEqual(vp2px(15)) + expect(Math.round((AlignContentFlexSpaceEvenly_1.top - SpaceEvenly_Margin_Column.top)*10)/10) + .assertEqual(vp2px(35)) + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_2.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top); + + expect(Math.round(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_2.bottom)) + .assertEqual(vp2px(20)); + + console.info('testAlignContentSpaceEvenlyFlexMarginSatisfy END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.test.ets new file mode 100644 index 000000000..4b0cf62dd --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding.test.ets @@ -0,0 +1,197 @@ +/* + * 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 AlignContent_FlexAlign_SpaceEvenly_Margin_padding() { + + describe('AlignContent_FlexAlign_SpaceEvenly_Margin_padding', function () { + beforeEach(async function (done) { + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin_padding beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_Margin_padding', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContent_FlexAlign_SpaceEvenly_Margin_padding state success " + JSON.stringify(pages)); + if (!("AlignContent_FlexAlign_SpaceEvenly_Margin_padding" == pages.name)) { + console.info("get AlignContent_FlexAlign_SpaceEvenly_Margin_padding state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContent_FlexAlign_SpaceEvenly_Margin_padding page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContent_FlexAlign_SpaceEvenly_Margin_padding page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin_padding beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContent_FlexAlign_SpaceEvenly_Margin_padding after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0600 + * @tc.name testAlignContentSpaceEvenlyFlexMarginAndPaddingNOSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and set the margin and + * padding of the flex component so that it does not meet the child component size requirements. + */ + + it('testAlignContentSpaceEvenlyFlexMarginAndPaddingNOSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexMarginAndPaddingNOSatisfy START'); + globalThis.value.message.notify({ name:'padding', value:40 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyMargin&padding_flex001'); + let obj = JSON.parse(strJson); + let SpaceEvenly_Margin_Column_1 = + CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyMargin&paddingColumn_1'); + let AlignContentFlexSpaceEvenly_flex001 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_4'); + + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_1 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_2 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_3 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_4 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round(AlignContentFlexSpaceEvenly_flex001.top - SpaceEvenly_Margin_Column_1.top)) + .assertEqual(vp2px(10)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.top - SpaceEvenly_Margin_Column_1.top)) + .assertEqual(vp2px(50)); + + expect(AlignContentFlexSpaceEvenly_4.top).assertEqual(AlignContentFlexSpaceEvenly_2.bottom); + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom).assertLess(vp2px(40)); + + console.info('testAlignContentSpaceEvenlyFlexMarginAndPaddingNOSatisfy END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0700 + * @tc.name testAlignContentSpaceEvenlyFlexMarginAndPaddingSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and set the margin and + * padding of the flex component so that it meets the child component size requirements. + */ + + it('testAlignContentSpaceEvenlyFlexMarginAndPaddingSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexMarginAndPaddingSatisfy START'); + globalThis.value.message.notify({ name:'padding', value:15 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyMargin&padding_flex001'); + let obj = JSON.parse(strJson); + let SpaceEvenly_Margin_Column_2 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&paddingColumn_1'); + let AlignContentFlexSpaceEvenly_flex002 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc + .getComponentRect('AlignContentFlexSpaceEvenlyMargin&padding_flex001_4'); + + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_flex002)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_1 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_2 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_3 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenlyMargin&padding_flex001_4 rect_value is:' + + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round(AlignContentFlexSpaceEvenly_flex002.top - SpaceEvenly_Margin_Column_2.top)) + .assertEqual(vp2px(10)) + + expect(Math.round((AlignContentFlexSpaceEvenly_1.top - SpaceEvenly_Margin_Column_2.top)*10)/10) + .assertEqual(Math.round(vp2px(35)*10)/10) + + expect(AlignContentFlexSpaceEvenly_flex002.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertEqual(AlignContentFlexSpaceEvenly_2.top - AlignContentFlexSpaceEvenly_flex002.top); + + expect(Math.round(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_2.bottom)) + .assertEqual(vp2px(10)); + + expect(Math.round((AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex002.top)*10)/10) + .assertEqual(Math.round(vp2px(25)*10)/10); + + console.info('testAlignContentSpaceEvenlyFlexMarginAndPaddingSatisfy END') + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.test.ets new file mode 100644 index 000000000..d8f806b13 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding.test.ets @@ -0,0 +1,186 @@ +/* + * 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 AlignContent_FlexAlign_SpaceEvenly_padding() { + + describe('AlignContent_FlexAlign_SpaceEvenly_padding', function () { + beforeEach(async function (done) { + console.info("AlignContent_FlexAlign_SpaceEvenly_padding beforeEach start"); + let options = { + uri: 'MainAbility/pages/Flex/alignContent/SpaceEvenly/AlignContent_FlexAlign_SpaceEvenly_padding', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get AlignContent_FlexAlign_SpaceEvenly_padding state success " + JSON.stringify(pages)); + if (!("AlignContent_FlexAlign_SpaceEvenly_padding" == pages.name)) { + console.info("get AlignContent_FlexAlign_SpaceEvenly_padding state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push AlignContent_FlexAlign_SpaceEvenly_padding page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push AlignContent_FlexAlign_SpaceEvenly_padding page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(1000) + console.info("AlignContent_FlexAlign_SpaceEvenly_padding beforeEach end"); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(2000) + console.info("AlignContent_FlexAlign_SpaceEvenly_padding after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0300 + * @tc.name testAlignContentSpaceEvenlyFlexPaddingNoSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly, and set the padding + * of the flex component so that it does not meet the child component size requirements. + */ + + it('testAlignContentSpaceEvenlyFlexPaddingNoSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexPaddingNoSatisfy START'); + globalThis.value.message.notify({ name:'padding', value:40 }) + await CommonFunc.sleep(3000) + + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyPadding_flex001'); + let obj = JSON.parse(strJson); + let AlignContentFlexSpaceEvenly_flex001 = + CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_4'); + + console.log('AlignContentFlexSpaceEvenlyPadding_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_flex001)); + + console.log('AlignContentFlexSpaceEvenlyPadding_flex001_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenlyPadding_flex001_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenlyPadding_flex001_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenlyPadding_flex001_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenly_flex001.top)) + .assertEqual(vp2px(40)); + + expect(AlignContentFlexSpaceEvenly_flex001.bottom - AlignContentFlexSpaceEvenly_4.bottom) + .assertLess(vp2px(40)); + + expect(AlignContentFlexSpaceEvenly_4.top).assertEqual(AlignContentFlexSpaceEvenly_2.bottom); + console.info('testAlignContentSpaceEvenlyFlexPaddingNoSatisfy END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNCONTENT_SPACEEVENLY_0400 + * @tc.name testAlignContentSpaceEvenlyFlexPaddingSatisfy + * @tc.desc Set the alignContent property of the flex component to FlexAlign.SpaceEvenly and the padding of the + * flex component to meet the child component sizing requirements. + */ + it('testAlignContentSpaceEvenlyFlexPaddingSatisfy', 0, async function (done) { + console.info('testAlignContentSpaceEvenlyFlexPaddingSatisfy START'); + globalThis.value.message.notify({ name:'padding', value:15 }) + await CommonFunc.sleep(3000) + let strJson = getInspectorByKey('AlignContentFlexSpaceEvenlyPadding_flex001'); + let obj = JSON.parse(strJson); + let AlignContentFlexSpaceEvenlyPadding_flex002 = + CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001'); + let AlignContentFlexSpaceEvenly_1 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_1'); + let AlignContentFlexSpaceEvenly_2 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_2'); + let AlignContentFlexSpaceEvenly_3 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_3'); + let AlignContentFlexSpaceEvenly_4 = CommonFunc.getComponentRect('AlignContentFlexSpaceEvenlyPadding_flex001_4'); + + console.log('AlignContentFlexSpaceEvenlyPadding_flex001 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenlyPadding_flex002)) + + console.log('AlignContentFlexSpaceEvenly_1 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_1)); + console.log('AlignContentFlexSpaceEvenly_2 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_2)); + console.log('AlignContentFlexSpaceEvenly_3 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_3)); + console.log('AlignContentFlexSpaceEvenly_4 rect_value is:'+ + JSON.stringify(AlignContentFlexSpaceEvenly_4)); + + expect(Math.round(AlignContentFlexSpaceEvenly_1.bottom - AlignContentFlexSpaceEvenly_1.top)) + .assertEqual(vp2px(50)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.bottom - AlignContentFlexSpaceEvenly_3.top)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + expect(Math.round(AlignContentFlexSpaceEvenly_1.right - AlignContentFlexSpaceEvenly_1.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_2.right - AlignContentFlexSpaceEvenly_2.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_3.right - AlignContentFlexSpaceEvenly_3.left)) + .assertEqual(vp2px(150)); + expect(Math.round(AlignContentFlexSpaceEvenly_4.right - AlignContentFlexSpaceEvenly_4.left)) + .assertEqual(vp2px(150)); + + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Row"); + expect(obj.$attrs.constructor.alignContent).assertEqual("FlexAlign.SpaceEvenly"); + + expect(Math.round(AlignContentFlexSpaceEvenly_4.top - AlignContentFlexSpaceEvenly_2.bottom)) + .assertEqual(vp2px(10)); + + expect(Math.round((AlignContentFlexSpaceEvenly_1.top - AlignContentFlexSpaceEvenlyPadding_flex002.top)*10)/10) + .assertEqual(vp2px(25)); + + expect(Math.round((AlignContentFlexSpaceEvenlyPadding_flex002.bottom - AlignContentFlexSpaceEvenly_4.bottom)*10)/10) + .assertEqual(vp2px(25)); + + expect(Math.round(AlignContentFlexSpaceEvenly_4.bottom - AlignContentFlexSpaceEvenly_4.top)) + .assertEqual(vp2px(200)); + + expect(Math.round(AlignContentFlexSpaceEvenly_2.bottom - AlignContentFlexSpaceEvenly_2.top)) + .assertEqual(vp2px(100)); + + console.info('testAlignContentSpaceEvenlyFlexPaddingSatisfy END'); + done(); + }); + }) +} -- GitLab