From 3786cb986c88734b6d7555ddb5968c1e12f525d4 Mon Sep 17 00:00:00 2001 From: zhanghailin Date: Tue, 7 Feb 2023 20:52:06 +0800 Subject: [PATCH] FlexAlignItems xts code submit Signed-off-by: zhanghailin --- .../ItemAlign_Start/FlexAlignSelf.ets | 48 +++++++ .../alignItems/ItemAlign_Start/FlexBase.ets | 64 +++++++++ .../alignItems/ItemAlign_Start/FlexExceed.ets | 66 +++++++++ .../ItemAlign_Start/FlexHeightModify.ets | 60 ++++++++ .../alignItems/ItemAlign_Start/FlexMargin.ets | 49 +++++++ .../alignItems/ItemAlign_Start/FlexOffset.ets | 48 +++++++ .../ItemAlign_Start/FlexPadding.ets | 61 +++++++++ .../ItemAlign_Start/FlexTextMargin.ets | 60 ++++++++ .../ItemAlign_Start/FlexVisibility.ets | 60 ++++++++ .../FlexAlignSelfJsunit.test.ets | 83 ++++++++++++ .../ItemAlign_Start/FlexBaseJsunit.test.ets | 118 ++++++++++++++++ .../ItemAlign_Start/FlexExceedJsunit.test.ets | 123 +++++++++++++++++ .../FlexHeightModifyJsunit.test.ets | 115 ++++++++++++++++ .../ItemAlign_Start/FlexMarginJsunit.test.ets | 81 +++++++++++ .../ItemAlign_Start/FlexOffsetJsunit.test.ets | 77 +++++++++++ .../FlexPaddingJsunit.test.ets | 122 +++++++++++++++++ .../FlexTextMarginJsunit.test.ets | 119 ++++++++++++++++ .../FlexVisibilityJsunit.test.ets | 128 ++++++++++++++++++ 18 files changed, 1482 insertions(+) create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexAlignSelf.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexBase.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexExceed.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexHeightModify.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexMargin.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexOffset.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexPadding.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexTextMargin.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexVisibility.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexAlignSelfJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexBaseJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexExceedJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexHeightModifyJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexMarginJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexOffsetJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexPaddingJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexTextMarginJsunit.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexVisibilityJsunit.test.ets diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexAlignSelf.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexAlignSelf.ets new file mode 100644 index 000000000..bbca17e8b --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexAlignSelf.ets @@ -0,0 +1,48 @@ +/* + * 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 FlexAlignSelf_Start { + private content: string = "FlexAlignSelf_Start Page"; + + onPageShow() { + console.info('FlexAlignSelf_Start page show called'); + } + + onBuildDone() { + console.info('FlexAlignSelf_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexTest12').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).alignSelf(ItemAlign.End).key('textAlignSelf01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textAlignSelf02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textAlignSelf03') + } + .key('flexAlignSelf') + .height(150) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexBase.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexBase.ets new file mode 100644 index 000000000..4c7469cf1 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexBase.ets @@ -0,0 +1,64 @@ +/* + * 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 FlexBase_Start { + @State testHeight: number = 150 + @State testWidth: number = 450 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexBase_Start Page"; + onPageShow() { + console.info('FlexBase_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.testHeight = message.value; + } + if (message.name == 'width') { + this.testWidth = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexBase_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexBase_1').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlex01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlex02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlex03') + } + .key('flex01') + .height(this.testHeight) + .width(this.testWidth) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexExceed.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexExceed.ets new file mode 100644 index 000000000..90c4d7651 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexExceed.ets @@ -0,0 +1,66 @@ +/* + * 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 FlexExceed_Start { + @State testPadding: number = 0 + @State testMargin: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexExceed_Start Page"; + onPageShow() { + console.info('FlexExceed_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.testPadding = message.value; + } + if (message.name == 'margin') { + this.testMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexExceed_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexExceed_1').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textExceed01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textExceed02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textExceed03') + } + .key('flexExceed01') + .height(200) + .width(500) + .margin(this.testMargin) + .padding(this.testPadding) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexHeightModify.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexHeightModify.ets new file mode 100644 index 000000000..3042ed4d2 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexHeightModify.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager,Callback } from '../../../../common/MessageManager'; +@Entry +@Component +struct FlexHeightModify_Start { + @State testHeight: number = 50 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexHeightModify_Start Page"; + onPageShow() { + console.info('FlexHeightModify_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'height') { + this.testHeight = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexHeightModify_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexHeightModify').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(this.testHeight).backgroundColor(0xF5DEB3).key('textHeightModify01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textHeightModify02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textHeightModify03') + } + .key('flexHeightModify') + .height(150) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexMargin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexMargin.ets new file mode 100644 index 000000000..c1146d3dc --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexMargin.ets @@ -0,0 +1,49 @@ +/* + * 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 FlexMargin_Start { + private content: string = "FlexMargin_Start Page"; + + onPageShow() { + console.info('FlexMargin_Start page show called'); + } + + onBuildDone() { + console.info('FlexMargin_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexTest05').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlexMargin01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlexMargin02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlexMargin03') + } + .key('flexMargin') + .height(200) + .width(500) + .margin(10) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexOffset.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexOffset.ets new file mode 100644 index 000000000..4dca72c07 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexOffset.ets @@ -0,0 +1,48 @@ +/* + * 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 FlexOffset_Start { + private content: string = "FlexOffset_Start Page"; + + onPageShow() { + console.info('FlexOffset_Start page show called'); + } + + onBuildDone() { + console.info('FlexOffset_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexTest09').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).offset({ x: 15, y: 30 }).key('textOffset01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textOffset02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textOffset03') + } + .key('flexOffset') + .height(150) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexPadding.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexPadding.ets new file mode 100644 index 000000000..9943693d5 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexPadding.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager,Callback } from '../../../../common/MessageManager'; +@Entry +@Component +struct FlexPadding_Start { + @State testPadding: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexPadding_Start Page"; + onPageShow() { + console.info('FlexPadding_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'padding') { + this.testPadding = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexPadding_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexPadding_1').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlexPadding01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlexPadding02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlexPadding03') + } + .key('flexPadding01') + .height(200) + .width(500) + .padding(this.testPadding) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexTextMargin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexTextMargin.ets new file mode 100644 index 000000000..183ac2be4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexTextMargin.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager,Callback } from '../../../../common/MessageManager'; +@Entry +@Component +struct FlexTextMargin_Start { + @State testTextMargin: number = 0 + messageManager:MessageManager = new MessageManager() + private content: string = "FlexTextMargin_Start Page"; + onPageShow() { + console.info('FlexTextMargin_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'margin') { + this.testTextMargin = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexTextMargin_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexTextMargin_1').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).margin(this.testTextMargin).key('textMargin01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textMargin02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textMargin03') + } + .key('flexTextMargin01') + .height(150) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexVisibility.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexVisibility.ets new file mode 100644 index 000000000..0584c98bc --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexVisibility.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MessageManager,Callback } from '../../../../common/MessageManager'; +@Entry +@Component +struct FlexVisibility_Start { + @State testVisibility: number = Visibility.Visible + messageManager:MessageManager = new MessageManager() + private content: string = "FlexVisibility_Start Page"; + onPageShow() { + console.info('FlexVisibility_Start onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'visibility') { + this.testVisibility = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + onBuildDone() { + console.info('FlexVisibility_Start page build done called'); + } + + build() { + Column() { + Column() { + Text('FlexTest10').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + alignItems: ItemAlign.Start, + wrap: FlexWrap.NoWrap, + }) { + Text('1').width(150).height(50).backgroundColor(0xF5DEB3).visibility(this.testVisibility).key('textVisible01') + Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textVisible02') + Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textVisible03') + } + .key('flexVisible') + .height(150) + .width(500) + .backgroundColor(0xAFEEEE) + }.width('100%').alignItems(HorizontalAlign.Start) + }.width('100%') + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexAlignSelfJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexAlignSelfJsunit.test.ets new file mode 100644 index 000000000..3df2bbe4a --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexAlignSelfJsunit.test.ets @@ -0,0 +1,83 @@ +/* + * 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"; + +export default function flexAlignSelf_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexAlignSelf', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexSecond state success " + JSON.stringify(pages)); + if (!("FlexSecond" == pages.name)) { + console.info("get FlexSecond state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexSecond page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexSecond page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexSecond after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1300 + * @tc.name testFlexItemAlignStartSetAlignSelf + * @tc.desc The first subcomponent set ItemAlign.End attribute + */ + it('testFlexItemAlignStartSetAlignSelf', 0, async function (done) { + console.info('new testFlexItemAlignStartSetAlignSelf START'); + let strJson1 = getInspectorByKey('flexAlignSelf'); + let obj1 = JSON.parse(strJson1); + let strJson2 = getInspectorByKey('textAlignSelf01'); + let obj2 = JSON.parse(strJson2); + let textAlignSelf01 = CommonFunc.getComponentRect('textAlignSelf01'); + let textAlignSelf02 = CommonFunc.getComponentRect('textAlignSelf02'); + let textAlignSelf03 = CommonFunc.getComponentRect('textAlignSelf03'); + let flexAlignSelf01 = CommonFunc.getComponentRect('flexAlignSelf'); + expect(textAlignSelf01.left).assertEqual(flexAlignSelf01.left) + expect(textAlignSelf01.right).assertEqual(textAlignSelf02.left) + expect(textAlignSelf01.top).assertEqual(textAlignSelf02.bottom) + expect(textAlignSelf02.top).assertEqual(textAlignSelf03.top) + expect(textAlignSelf01.bottom).assertEqual(flexAlignSelf01.bottom) + + expect(Math.round(textAlignSelf01.bottom - textAlignSelf01.top)).assertEqual(vp2px(50)) + expect(Math.round(textAlignSelf01.right - textAlignSelf01.left)).assertEqual(vp2px(150)) + expect(Math.round(textAlignSelf02.bottom - textAlignSelf02.top)).assertEqual(vp2px(100)) + expect(Math.round(textAlignSelf02.right - textAlignSelf02.left)).assertEqual(vp2px(150)) + expect(Math.round(textAlignSelf03.bottom - textAlignSelf03.top)).assertEqual(vp2px(150)) + expect(Math.round(textAlignSelf03.right - textAlignSelf03.left)).assertEqual(vp2px(150)) + + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + expect(obj2.$attrs.alignSelf).assertEqual("ItemAlign.End"); + console.info('new testFlexItemAlignStartSetAlignSelf END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexBaseJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexBaseJsunit.test.ets new file mode 100644 index 000000000..66c2b963f --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexBaseJsunit.test.ets @@ -0,0 +1,118 @@ +/* + * 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 flexBase_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexBase', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexBase state success " + JSON.stringify(pages)); + if (!("FlexBase" == pages.name)) { + console.info("get FlexBase state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexBase page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexBase page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexBase after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0100 + * @tc.name testFlexItemAlignStart + * @tc.desc The subcomponent is inside the parent component. + */ + it('testFlexItemAlignStart', 0, async function (done) { + console.info('new testFlexItemAlignStart START'); + globalThis.value.message.notify({name:'height', value:200}); + globalThis.value.message.notify({name:'width', value:500}); + await CommonFunc.sleep(3000); + let strJson1 = getInspectorByKey('flex01'); + let obj1 = JSON.parse(strJson1); + let textFlex01 = CommonFunc.getComponentRect('textFlex01'); + let textFlex02 = CommonFunc.getComponentRect('textFlex02'); + let textFlex03 = CommonFunc.getComponentRect('textFlex03'); + let flex01 = CommonFunc.getComponentRect('flex01'); + expect(flex01.top).assertEqual(textFlex01.top) + expect(textFlex01.top).assertEqual(textFlex02.top) + expect(textFlex02.top).assertEqual(textFlex03.top) + + expect(textFlex01.right).assertEqual(textFlex02.left) + expect(textFlex02.right).assertEqual(textFlex03.left) + expect(Math.round(flex01.right - textFlex03.right)).assertEqual(vp2px(50)) + + expect(Math.round(textFlex01.bottom - textFlex01.top)).assertEqual(vp2px(50)) + expect(Math.round(textFlex02.bottom - textFlex02.top)).assertEqual(vp2px(100)) + expect(Math.round(textFlex03.bottom - textFlex03.top)).assertEqual(vp2px(150)) + expect(Math.round(textFlex01.right - textFlex01.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlex02.right - textFlex02.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlex03.right - textFlex03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStart END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0200 + * @tc.name testFlexItemAlignStartExceed + * @tc.desc The subcomponent exceeds the parent component. + */ + it('testFlexItemAlignStartExceed', 0, async function (done) { + console.info('new testFlexItemAlignStartExceed START'); + globalThis.value.message.notify({name:'width', value:420}); + globalThis.value.message.notify({name:'height', value:140}); + await CommonFunc.sleep(3000); + let strJson1 = getInspectorByKey('flex01'); + let obj1 = JSON.parse(strJson1); + let textFlex01 = CommonFunc.getComponentRect('textFlex01'); + let textFlex02 = CommonFunc.getComponentRect('textFlex02'); + let textFlex03 = CommonFunc.getComponentRect('textFlex03'); + let flex01 = CommonFunc.getComponentRect('flex01'); + expect(flex01.top).assertEqual(textFlex01.top) + expect(textFlex01.top).assertEqual(textFlex02.top) + expect(textFlex02.top).assertEqual(textFlex03.top) + + expect(textFlex03.right).assertEqual(flex01.right) + expect(textFlex03.bottom).assertLarger(flex01.bottom) + expect(Math.round(textFlex01.bottom - textFlex01.top)).assertEqual(vp2px(50)) + expect(Math.round(textFlex02.bottom - textFlex02.top)).assertEqual(vp2px(100)) + expect(Math.round(textFlex03.bottom - textFlex03.top)).assertEqual(vp2px(150)) + expect(Math.round(textFlex01.right - textFlex01.left)).assertEqual(vp2px(140)) + expect(Math.round(textFlex02.right - textFlex02.left)).assertEqual(vp2px(140)) + expect(Math.round(textFlex03.right - textFlex03.left)).assertEqual(vp2px(140)) + + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartExceed END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexExceedJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexExceedJsunit.test.ets new file mode 100644 index 000000000..1b68ac08a --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexExceedJsunit.test.ets @@ -0,0 +1,123 @@ +/* + * 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 flexExceed_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexExceed', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexExceed state success " + JSON.stringify(pages)); + if (!("FlexExceed" == pages.name)) { + console.info("get FlexExceed state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexExceed page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexExceed page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexExceed after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0600 + * @tc.name testFlexItemAlignStartSetMarPad + * @tc.desc Subcomponent inside when parent component set margin and padding. + */ + it('testFlexItemAlignStartSetMarPad', 0, async function (done) { + console.info('new testFlexItemAlignStartSetMarPad START'); + globalThis.value.message.notify({name:'padding', value:10}); + globalThis.value.message.notify({name:'margin', value:10}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexExceed01'); + let obj1 = JSON.parse(strJson1); + let textExceed01 = CommonFunc.getComponentRect('textExceed01'); + let textExceed02 = CommonFunc.getComponentRect('textExceed02'); + let textExceed03 = CommonFunc.getComponentRect('textExceed03'); + let flexExceed01 = CommonFunc.getComponentRect('flexExceed01'); + + expect(Math.round(textExceed01.left - flexExceed01.left)).assertEqual(vp2px(10)) + expect(textExceed01.right).assertEqual(textExceed02.left) + expect(textExceed02.right).assertEqual(textExceed03.left) + expect(Math.round(flexExceed01.right - textExceed03.right)).assertEqual(vp2px(40)) + + expect(Math.round(textExceed01.top - flexExceed01.top)).assertEqual(vp2px(10)) + expect(textExceed01.top).assertEqual(textExceed02.top) + expect(textExceed02.top).assertEqual(textExceed03.top) + + expect(Math.round(textExceed01.bottom - textExceed01.top)).assertEqual(vp2px(50)) + expect(Math.round(textExceed02.bottom - textExceed02.top)).assertEqual(vp2px(100)) + expect(Math.round(textExceed03.bottom - textExceed03.top)).assertEqual(vp2px(150)) + expect(Math.round(textExceed01.right - textExceed01.left)).assertEqual(vp2px(150)) + expect(Math.round(textExceed02.right - textExceed02.left)).assertEqual(vp2px(150)) + expect(Math.round(textExceed03.right - textExceed03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartSetMarPad END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0700 + * @tc.name testFlexItemAlignStartSetMarPadExceed + * @tc.desc Subcomponent outside when parent component set margin and padding. + */ + it('testFlexItemAlignStartSetMarPadExceed', 0, async function (done) { + console.info('new testFlexItemAlignStartSetMarPadExceed START'); + globalThis.value.message.notify({name:'padding', value:30}); + globalThis.value.message.notify({name:'margin', value:30}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexExceed01'); + let obj1 = JSON.parse(strJson1); + let textExceed01 = CommonFunc.getComponentRect('textExceed01'); + let textExceed02 = CommonFunc.getComponentRect('textExceed02'); + let textExceed03 = CommonFunc.getComponentRect('textExceed03'); + let flexExceed01 = CommonFunc.getComponentRect('flexExceed01'); + + expect(Math.round(textExceed01.left - flexExceed01.left)).assertEqual(vp2px(30)) + expect(textExceed01.right).assertEqual(textExceed02.left) + expect(textExceed02.right).assertEqual(textExceed03.left) + expect(Math.round(flexExceed01.right - textExceed03.right)).assertEqual(vp2px(30)) + + expect(Math.round(textExceed01.top - flexExceed01.top)).assertEqual(vp2px(30)) + expect(textExceed01.top).assertEqual(textExceed02.top) + expect(textExceed02.top).assertEqual(textExceed03.top) + + expect(Math.round(textExceed01.bottom - textExceed01.top)).assertEqual(vp2px(50)) + expect(Math.round(textExceed02.bottom - textExceed02.top)).assertEqual(vp2px(100)) + expect(Math.round(textExceed03.bottom - textExceed03.top)).assertEqual(vp2px(150)) + expect(Math.round(textExceed01.right - textExceed01.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textExceed02.right - textExceed02.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textExceed03.right - textExceed03.left)).assertEqual(vp2px(440/3)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartSetMarPadExceed END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexHeightModifyJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexHeightModifyJsunit.test.ets new file mode 100644 index 000000000..9a88da115 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexHeightModifyJsunit.test.ets @@ -0,0 +1,115 @@ +/* + * 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 flexHeightModify_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexHeightModify', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexHeightModify state success " + JSON.stringify(pages)); + if (!("FlexHeightModify" == pages.name)) { + console.info("get FlexHeightModify state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexHeightModify page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexHeightModify page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexHeightModify after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0800 + * @tc.name testFlexItemAlignStartDefaultSize + * @tc.desc Check the the default height of the first subcomponent. + */ + it('testFlexItemAlignStartDefaultSize', 0, async function (done) { + console.info('new testFlexItemAlignStartDefaultSize START'); + let strJson1 = getInspectorByKey('flexHeightModify'); + let obj1 = JSON.parse(strJson1); + let textHeightModify01 = CommonFunc.getComponentRect('textHeightModify01'); + let textHeightModify02 = CommonFunc.getComponentRect('textHeightModify02'); + let textHeightModify03 = CommonFunc.getComponentRect('textHeightModify03'); + let flexHeightModify = CommonFunc.getComponentRect('flexHeightModify'); + + expect(textHeightModify01.top).assertEqual(textHeightModify02.top) + expect(textHeightModify02.top).assertEqual(textHeightModify03.top) + expect(textHeightModify01.top).assertEqual(flexHeightModify.top) + + expect(textHeightModify01.left).assertEqual(flexHeightModify.left) + expect(textHeightModify02.left).assertEqual(textHeightModify01.right) + + expect(Math.round(textHeightModify01.bottom - textHeightModify01.top)).assertEqual(vp2px(50)) + expect(Math.round(textHeightModify02.bottom - textHeightModify02.top)).assertEqual(vp2px(100)) + expect(Math.round(textHeightModify03.bottom - textHeightModify03.top)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify01.right - textHeightModify01.left)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify02.right - textHeightModify02.left)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify03.right - textHeightModify03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartDefaultSize END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0900 + * @tc.name testFlexItemAlignStartHeightModify + * @tc.desc Modify the first subcomponent's height. + */ + it('testFlexItemAlignStartHeightModify', 0, async function (done) { + console.info('new testFlexItemAlignStartHeightModify START'); + globalThis.value.message.notify({name:'height', value:80}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexHeightModify'); + let obj1 = JSON.parse(strJson1); + let textHeightModify01 = CommonFunc.getComponentRect('textHeightModify01'); + let textHeightModify02 = CommonFunc.getComponentRect('textHeightModify02'); + let textHeightModify03 = CommonFunc.getComponentRect('textHeightModify03'); + let flexHeightModify = CommonFunc.getComponentRect('flexHeightModify'); + + expect(textHeightModify01.top).assertEqual(textHeightModify02.top) + expect(textHeightModify02.top).assertEqual(textHeightModify03.top) + expect(textHeightModify01.top).assertEqual(flexHeightModify.top) + + expect(textHeightModify01.left).assertEqual(flexHeightModify.left) + expect(textHeightModify02.left).assertEqual(textHeightModify01.right) + + expect(Math.round(textHeightModify01.bottom - textHeightModify01.top)).assertEqual(vp2px(80)) + expect(Math.round(textHeightModify02.bottom - textHeightModify02.top)).assertEqual(vp2px(100)) + expect(Math.round(textHeightModify03.bottom - textHeightModify03.top)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify01.right - textHeightModify01.left)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify02.right - textHeightModify02.left)).assertEqual(vp2px(150)) + expect(Math.round(textHeightModify03.right - textHeightModify03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartHeightModify END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexMarginJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexMarginJsunit.test.ets new file mode 100644 index 000000000..7b8c4a151 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexMarginJsunit.test.ets @@ -0,0 +1,81 @@ +/* + * 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"; +export default function flexMargin_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexMargin', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexMargin state success " + JSON.stringify(pages)); + if (!("FlexMargin" == pages.name)) { + console.info("get FlexMargin state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexMargin page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexMargin page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexMargin after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0500 + * @tc.name testItemAlignStartParentSetMargin + * @tc.desc Parent component set margin attribute. + */ + it('testItemAlignStartParentSetMargin', 0, async function (done) { + console.info('new testItemAlignStartParentSetMargin START'); + let strJson1 = getInspectorByKey('flexMargin'); + let obj1 = JSON.parse(strJson1); + let textFlexMargin01 = CommonFunc.getComponentRect('textFlexMargin01'); + let textFlexMargin02 = CommonFunc.getComponentRect('textFlexMargin02'); + let textFlexMargin03 = CommonFunc.getComponentRect('textFlexMargin03'); + let flexMargin = CommonFunc.getComponentRect('flexMargin'); + + expect(flexMargin.top).assertEqual(textFlexMargin01.top) + expect(textFlexMargin01.top).assertEqual(textFlexMargin02.top) + expect(textFlexMargin02.top).assertEqual(textFlexMargin03.top) + + expect(flexMargin.left).assertEqual(textFlexMargin01.left) + expect(textFlexMargin01.right).assertEqual(textFlexMargin02.left) + expect(textFlexMargin02.right).assertEqual(textFlexMargin03.left) + + expect(Math.round(textFlexMargin01.bottom - textFlexMargin01.top)).assertEqual(vp2px(50)) + expect(Math.round(textFlexMargin02.bottom - textFlexMargin02.top)).assertEqual(vp2px(100)) + expect(Math.round(textFlexMargin03.bottom - textFlexMargin03.top)).assertEqual(vp2px(150)) + expect(Math.round(textFlexMargin01.right - textFlexMargin01.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlexMargin02.right - textFlexMargin02.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlexMargin03.right - textFlexMargin03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testItemAlignStartParentSetMargin END'); + done(); + }); + + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexOffsetJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexOffsetJsunit.test.ets new file mode 100644 index 000000000..6c882c1df --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexOffsetJsunit.test.ets @@ -0,0 +1,77 @@ +/* + * 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"; +export default function flexOffset_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexOffset', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get flexOffsetTest state success " + JSON.stringify(pages)); + if (!("flexOffsetTest" == pages.name)) { + console.info("get flexOffsetTest state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push flexOffsetTest page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push flexOffsetTest page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("flexOffsetTest after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1100 + * @tc.name testFlexItemAlignStartSetOffset + * @tc.desc First subcomponent set offset attribute. + */ + it('testFlexItemAlignStartSetOffset', 0, async function (done) { + console.info('new testFlexItemAlignStartSetOffset START'); + let strJson1 = getInspectorByKey('flexOffset'); + let obj1 = JSON.parse(strJson1); + let textOffset01 = CommonFunc.getComponentRect('textOffset01'); + let textOffset02 = CommonFunc.getComponentRect('textOffset02'); + let textOffset03 = CommonFunc.getComponentRect('textOffset03'); + let flexOffset = CommonFunc.getComponentRect('flexOffset'); + expect(Math.round((textOffset01.right - textOffset02.left)*10)/10).assertEqual(Math.round(vp2px(15)*10)/10) + expect(Math.round(textOffset01.top - flexOffset.top)).assertEqual(vp2px(30)) + expect(Math.round((textOffset01.left - flexOffset.left)*10)/10).assertEqual(Math.round(vp2px(15)*10)/10) + expect(textOffset02.top).assertEqual(textOffset03.top) + expect(textOffset03.top).assertEqual(flexOffset.top) + + expect(Math.round(textOffset01.bottom - textOffset01.top)).assertEqual(vp2px(50)) + expect(Math.round(textOffset02.bottom - textOffset02.top)).assertEqual(vp2px(100)) + expect(Math.round(textOffset03.bottom - textOffset03.top)).assertEqual(vp2px(150)) + expect(Math.round(textOffset01.right - textOffset01.left)).assertEqual(vp2px(150)) + expect(Math.round(textOffset02.right - textOffset02.left)).assertEqual(vp2px(150)) + expect(Math.round(textOffset03.right - textOffset03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartSetOffset END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexPaddingJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexPaddingJsunit.test.ets new file mode 100644 index 000000000..b953a47b4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexPaddingJsunit.test.ets @@ -0,0 +1,122 @@ +/* + * 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 flexPadding_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexPadding', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexPadding state success " + JSON.stringify(pages)); + if (!("FlexPadding" == pages.name)) { + console.info("get FlexPadding state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexPadding page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexPadding page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexPadding after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0300 + * @tc.name testFlexItemAlignStartParentSetPadding + * @tc.desc Parent component set paddding,subcomponent does not exceed the parent component. + */ + it('testFlexItemAlignStartParentSetPadding', 0, async function (done) { + console.info('new testFlexItemAlignStartParentSetPadding START'); + globalThis.value.message.notify({name:'padding', value:10}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexPadding01'); + let obj1 = JSON.parse(strJson1); + let strJson2 = getInspectorByKey('textFlexPadding01'); + let obj2 = JSON.parse(strJson2); + let textFlexPadding01 = CommonFunc.getComponentRect('textFlexPadding01') + let textFlexPadding02 = CommonFunc.getComponentRect('textFlexPadding02') + let textFlexPadding03 = CommonFunc.getComponentRect('textFlexPadding03') + let flexPadding01 = CommonFunc.getComponentRect('flexPadding01') + + expect(Math.round(textFlexPadding01.left - flexPadding01.left)).assertEqual(vp2px(10)) + expect(textFlexPadding01.right).assertEqual(textFlexPadding02.left) + expect(textFlexPadding02.right).assertEqual(textFlexPadding03.left) + + expect(textFlexPadding01.top).assertEqual(textFlexPadding02.top) + expect(textFlexPadding02.top).assertEqual(textFlexPadding03.top) + expect(Math.round(textFlexPadding01.top - flexPadding01.top)).assertEqual(vp2px(10)) + + + expect(Math.round(textFlexPadding01.bottom - textFlexPadding01.top)).assertEqual(vp2px(50)) + expect(Math.round(textFlexPadding02.bottom - textFlexPadding02.top)).assertEqual(vp2px(100)) + expect(Math.round(textFlexPadding03.bottom - textFlexPadding03.top)).assertEqual(vp2px(150)) + + expect(Math.round(textFlexPadding01.right - textFlexPadding01.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlexPadding02.right - textFlexPadding02.left)).assertEqual(vp2px(150)) + expect(Math.round(textFlexPadding03.right - textFlexPadding03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartParentSetPadding END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_0400 + * @tc.name testFlexItemAlignStartParentSetPaddingExceed + * @tc.desc Parent component set paddding,subcomponent exceeds the parent component. + */ + it('testFlexItemAlignStartParentSetPaddingExceed', 0, async function (done) { + console.info('new testFlexItemAlignStartParentSetPaddingExceed START'); + globalThis.value.message.notify({name:'padding', value:30}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexPadding01'); + let obj1 = JSON.parse(strJson1); + let textFlexPadding01 = CommonFunc.getComponentRect('textFlexPadding01'); + let textFlexPadding02 = CommonFunc.getComponentRect('textFlexPadding02'); + let textFlexPadding03 = CommonFunc.getComponentRect('textFlexPadding03'); + let flexPadding01 = CommonFunc.getComponentRect('flexPadding01'); + expect(Math.round(textFlexPadding01.left - flexPadding01.left)).assertEqual(vp2px(30)) + expect(textFlexPadding01.right).assertEqual(textFlexPadding02.left) + expect(textFlexPadding02.right).assertEqual(textFlexPadding03.left) + + expect(textFlexPadding01.top).assertEqual(textFlexPadding02.top) + expect(textFlexPadding02.top).assertEqual(textFlexPadding03.top) + expect(Math.round(textFlexPadding01.top - flexPadding01.top)).assertEqual(vp2px(30)) + + expect(Math.round(textFlexPadding01.bottom - textFlexPadding01.top)).assertEqual(vp2px(50)) + expect(Math.round(textFlexPadding02.bottom - textFlexPadding02.top)).assertEqual(vp2px(100)) + expect(Math.round(textFlexPadding03.bottom - textFlexPadding03.top)).assertEqual(vp2px(150)) + expect(Math.round(textFlexPadding01.right - textFlexPadding01.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textFlexPadding02.right - textFlexPadding02.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textFlexPadding03.right - textFlexPadding03.left)).assertEqual(vp2px(440/3)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartParentSetPaddingExceed END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexTextMarginJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexTextMarginJsunit.test.ets new file mode 100644 index 000000000..092d4d485 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexTextMarginJsunit.test.ets @@ -0,0 +1,119 @@ +/* + * 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 flexTextMargin_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexTextMargin', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexTextMargin state success " + JSON.stringify(pages)); + if (!("FlexTextMargin" == pages.name)) { + console.info("get FlexTextMargin state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexTextMargin page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexTextMargin page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexTextMargin after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1400 + * @tc.name testFlexItemAlignStartSubSetMargin + * @tc.desc Center alignment,subcomponents set margin within the scope of the parent component. + */ + it('testFlexItemAlignStartSubSetMargin', 0, async function (done) { + console.info('new testFlexItemAlignStartSubSetMargin START'); + globalThis.value.message.notify({name:'margin', value:10}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexTextMargin01'); + let obj1 = JSON.parse(strJson1); + let textMargin01 = CommonFunc.getComponentRect('textMargin01'); + let textMargin02 = CommonFunc.getComponentRect('textMargin02'); + let textMargin03 = CommonFunc.getComponentRect('textMargin03'); + let flexTextMargin01 = CommonFunc.getComponentRect('flexTextMargin01'); + expect(Math.round(textMargin01.left - flexTextMargin01.left)).assertEqual(vp2px(10)) + expect(Math.round(textMargin02.left - textMargin01.right)).assertEqual(vp2px(10)) + expect(textMargin02.right).assertEqual(textMargin03.left) + expect(Math.round(flexTextMargin01.right - textMargin03.right)).assertEqual(vp2px(30)) + + expect(Math.round(textMargin01.top - flexTextMargin01.top)).assertEqual(vp2px(10)) + expect(textMargin02.top).assertEqual(textMargin03.top) + expect(textMargin03.top).assertEqual(flexTextMargin01.top) + + expect(Math.round(textMargin01.bottom - textMargin01.top)).assertEqual(vp2px(50)) + expect(Math.round(textMargin02.bottom - textMargin02.top)).assertEqual(vp2px(100)) + expect(Math.round(textMargin03.bottom - textMargin03.top)).assertEqual(vp2px(150)) + expect(Math.round(textMargin01.right - textMargin01.left)).assertEqual(vp2px(150)) + expect(Math.round(textMargin02.right - textMargin02.left)).assertEqual(vp2px(150)) + expect(Math.round(textMargin03.right - textMargin03.left)).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartSubSetMargin END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1500 + * @tc.name testFlexItemAlignStartSubSetMarginExceed + * @tc.desc Center alignment,subcomponents set margin outside the scope of the parent component. + */ + it('testFlexItemAlignStartSubSetMarginExceed', 0, async function (done) { + console.info('new testFlexItemAlignStartSubSetMarginExceed START'); + globalThis.value.message.notify({name:'margin', value:30}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexTextMargin01'); + let obj1 = JSON.parse(strJson1); + let textMargin01 = CommonFunc.getComponentRect('textMargin01'); + let textMargin02 = CommonFunc.getComponentRect('textMargin02'); + let textMargin03 = CommonFunc.getComponentRect('textMargin03'); + let flexTextMargin01 = CommonFunc.getComponentRect('flexTextMargin01'); + expect(Math.round(textMargin01.left - flexTextMargin01.left)).assertEqual(vp2px(30)) + expect(Math.round(textMargin02.left - textMargin01.right)).assertEqual(vp2px(30)) + expect(textMargin02.right).assertEqual(textMargin03.left) + expect(textMargin03.right).assertEqual(flexTextMargin01.right) + + expect(Math.round(textMargin01.top - flexTextMargin01.top)).assertEqual(vp2px(30)) + expect(textMargin02.top).assertEqual(textMargin03.top) + expect(textMargin03.top).assertEqual(flexTextMargin01.top) + + expect(Math.round(textMargin01.bottom - textMargin01.top)).assertEqual(vp2px(50)) + expect(Math.round(textMargin02.bottom - textMargin02.top)).assertEqual(vp2px(100)) + expect(Math.round(textMargin03.bottom - textMargin03.top)).assertEqual(vp2px(150)) + expect(Math.round(textMargin01.right - textMargin01.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textMargin02.right - textMargin02.left)).assertEqual(vp2px(440/3)) + expect(Math.round(textMargin03.right - textMargin03.left)).assertEqual(vp2px(440/3)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + console.info('new testFlexItemAlignStartSubSetMarginExceed END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexVisibilityJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexVisibilityJsunit.test.ets new file mode 100644 index 000000000..379af84ac --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Start/FlexVisibilityJsunit.test.ets @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import router from '@system.router'; +import CommonFunc from "../../../../MainAbility/common/Common"; +import { MessageManager,Callback } from '../../../../MainAbility/common/MessageManager'; +export default function flexVisibility_StartJsunit() { + describe('flexItemAlignStartTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Start/FlexVisibility', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get FlexVisibility state success " + JSON.stringify(pages)); + if (!("FlexVisibility" == pages.name)) { + console.info("get FlexVisibility state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push FlexVisibility page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push FlexVisibility page error " + JSON.stringify(err)); + } + await CommonFunc.sleep(2000); + done() + }); + + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("FlexVisibility after each called"); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1100 + * @tc.name testFlexItemAlignStartSubSetVisibilityNone + * @tc.desc aceFlexAlignItemTest + */ + it('testFlexItemAlignStartSubSetVisibilityNone', 0, async function (done) { + console.info('new testFlexItemAlignStartSubSetVisibilityNone START'); + try { + globalThis.value.message.notify({name:'visibility', value:Visibility.None}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexVisible'); + let obj1 = JSON.parse(strJson1); + let strJson2 = getInspectorByKey('textVisible01'); + let obj2 = JSON.parse(strJson2); + expect(obj2.$attrs.visibility).assertEqual("Visibility.None"); + let textVisible01 = CommonFunc.getComponentRect('textVisible01'); + let textVisible02 = CommonFunc.getComponentRect('textVisible02'); + let textVisible03 = CommonFunc.getComponentRect('textVisible03'); + let flexVisible = CommonFunc.getComponentRect('flexVisible'); + + expect(textVisible01.left).assertEqual(textVisible01.right) + expect(textVisible01.right).assertEqual(flexVisible.left) + expect(textVisible02.top).assertEqual(textVisible03.top) + expect(textVisible03.top).assertEqual(flexVisible.top) + + expect(textVisible02.bottom - textVisible02.top).assertEqual(vp2px(100)) + expect(textVisible03.bottom - textVisible03.top).assertEqual(vp2px(150)) + expect(textVisible02.right - textVisible02.left).assertEqual(vp2px(150)) + expect(textVisible03.right - textVisible03.left).assertEqual(vp2px(150)) + expect(obj1.$attrs.visibility).assertEqual("Visibility.Visible"); + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + } catch (err) { + console.error('[testFlexItemAlignBaselineSubSetVisibilityNone] failed'); + expect().assertFail(); + } + console.info('new testFlexItemAlignStartSubSetVisibilityNone END'); + done(); + }); + + /** + * @tc.number SUB_ACE_FLEXALIGNITEMS_START_1200 + * @tc.name testFlexItemAlignStartSubSetVisibilityHidden + * @tc.desc aceFlexAlignItemTest + */ + it('testFlexItemAlignStartSubSetVisibilityHidden', 0, async function (done) { + console.info('new testFlexItemAlignStartSubSetVisibilityHidden START'); + try { + globalThis.value.message.notify({name:'visibility', value:Visibility.Hidden}); + await CommonFunc.sleep(2000); + let strJson1 = getInspectorByKey('flexVisible'); + let obj1 = JSON.parse(strJson1); + let strJson2 = getInspectorByKey('textVisible01'); + let obj2 = JSON.parse(strJson2); + expect(obj2.$attrs.visibility).assertEqual("Visibility.Hidden"); + let textVisible01 = CommonFunc.getComponentRect('textVisible01'); + let textVisible02 = CommonFunc.getComponentRect('textVisible02'); + let textVisible03 = CommonFunc.getComponentRect('textVisible03'); + let flexVisible = CommonFunc.getComponentRect('flexVisible'); + expect(textVisible01.left).assertEqual(flexVisible.left) + expect(textVisible01.right).assertEqual(textVisible02.left) + expect(textVisible02.top).assertEqual(textVisible03.top) + expect(textVisible03.top).assertEqual(flexVisible.top) + + expect(textVisible01.bottom - textVisible01.top).assertEqual(vp2px(50)) + expect(textVisible02.bottom - textVisible02.top).assertEqual(vp2px(100)) + expect(textVisible03.bottom - textVisible03.top).assertEqual(vp2px(150)) + expect(textVisible01.right - textVisible01.left).assertEqual(vp2px(150)) + expect(textVisible02.right - textVisible02.left).assertEqual(vp2px(150)) + expect(textVisible03.right - textVisible03.left).assertEqual(vp2px(150)) + expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row') + expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Start') + } catch (err) { + console.error('[testFlexItemAlignBaselineSubSetVisibilityHidden] failed'); + expect().assertFail(); + } + console.info('new testFlexItemAlignStartSubSetVisibilityHidden END'); + done(); + }); + }) +} -- GitLab