diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2.ets new file mode 100644 index 0000000000000000000000000000000000000000..00df16eb0bea768801afbfa2b4ed30a9b977c04c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {MessageManager,Callback} from '../../../common/MessageManager'; +@Entry +@Component +struct SwiperItemSizeTest2 { + @State testHeight: number = 150 + @State testWidth: number = 150 + @State testIndex: number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('SwiperItemSize 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.testHeight = message.value; + } + if (message.name == 'width') { + this.testWidth = message.value; + } + if (message.name == 'index') { + this.testIndex = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + build() { + Column({ space: 5 }) { + Swiper() { + Column(){Text ('1')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3).key('itemSizekey2_01') + Column(){Text ('2')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C).key('itemSizekey2_02') + Column(){Text ('3')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3).key('itemSizekey2_03') + Column(){Text ('4')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C) + Column(){Text ('5')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3) + Column(){Text ('6')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C) + } + .key('itemSizekey2') + .height(300) + .width(300) + .index(this.testIndex) + .indicator(true) + .loop(true) + .displayCount(1) + }.margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets index af9c04c524bcd2a39e165addd81639ff260fa925..826b6e5ef8e54718f3150a3f8af81d81d2e72b11 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets @@ -75,10 +75,7 @@ import swiperIndex from './Swiper/Swiper_ParmsChange/swiperIndex.test.ets'; import swiperVertical from './Swiper/Swiper_ParmsChange/swiperVertical.test.ets'; import swiperLoopTrue from './Swiper/Swiper_ParmsChange/swiperLoopTrue.test.ets'; import swiperLoopFalse from './Swiper/Swiper_ParmsChange/swiperLoopFalse.test.ets'; -import swiperAutoPlay_1 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_1.test.ets'; -import swiperAutoPlay_2 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_2.test.ets'; -import swiperAutoPlay_3 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_3.test.ets'; -import swiperAutoPlay_4 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_4.test.ets'; + import swiperItemSpace from './Swiper/Swiper_ParmsChange/swiperItemSpace.test.ets'; import swiperPadding from './Swiper/Swiper_ParmsChange/swiperPadding.test.ets'; import swiperMargin from './Swiper/Swiper_ParmsChange/swiperMargin.test.ets'; @@ -86,6 +83,7 @@ import swiperMarPad from './Swiper/Swiper_ParmsChange/swiperMarPad.test.ets'; import swiperDisableSwipeTrue from './Swiper/Swiper_ParmsChange/swiperDisableSwipeTrue.test.ets'; import swiperDisableSwipeFalse from './Swiper/Swiper_ParmsChange/swiperDisableSwipeFalse.test.ets'; import swiperItemSize from './Swiper/Swiper_ItemChange/swiperItemSize.test.ets'; +import swiperItemSize2 from './Swiper/Swiper_ItemChange/swiperItemSize2.test.ets'; import swiperItemPadding from './Swiper/Swiper_ItemChange/swiperItemPadding.test.ets'; import swiperItemMargin from './Swiper/Swiper_ItemChange/swiperItemMargin.test.ets'; import swiperItemPadMar from './Swiper/Swiper_ItemChange/swiperItemPadMar.test.ets'; @@ -149,7 +147,7 @@ import Grid_Col_Span_Default from './Grid/Grid_Col/Grid_Col_Span/Grid_Col_Span_D import Grid_Col_Offset_Default from './Grid/Grid_Col/Grid_Col_Offset/Grid_Col_Offset_Default.test.ets'; import Grid_Col_Offset_Number from './Grid/Grid_Col/Grid_Col_Offset/Grid_Col_Offset_Number.test.ets'; import Grid_Col_Offset_GridColColumnOption from './Grid/Grid_Col/Grid_Col_Offset/Grid_Col_Offset_GridColColumnOption.test.ets'; - + import Grid_Row_Columns from './Grid/Grid_Row/Grid_Row_Columns/Grid_Row_Columns.test.ets'; import Grid_Row_Columns_Default from './Grid/Grid_Row/Grid_Row_Columns/Grid_Row_Columns_Default.test.ets'; import Grid_Row_Columns_Option from './Grid/Grid_Row/Grid_Row_Columns/Grid_Row_Columns_Option.test.ets'; @@ -469,10 +467,7 @@ swiperIndex() swiperVertical() swiperLoopTrue() swiperLoopFalse() -swiperAutoPlay_1() -swiperAutoPlay_2() -swiperAutoPlay_3() -swiperAutoPlay_4() + swiperItemSpace() swiperPadding() swiperMargin() @@ -480,6 +475,7 @@ swiperMarPad() swiperDisableSwipeTrue() swiperDisableSwipeFalse() swiperItemSize() +swiperItemSize2() swiperItemPadding() swiperItemMargin() swiperItemPadMar() diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize.test.ets index 865f1dcbf1d99f06ca2991133d177203ae1ecd66..58601fa47d7a89ba3b738c181665aa35c3659eab 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize.test.ets +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize.test.ets @@ -60,8 +60,8 @@ export default function swiperItemSize() { console.info("Before page turning , the itemSizekey01.left value is " + JSON.stringify(itemSizekey01.left)); expect(itemSizekey.left).assertEqual(itemSizekey01.left); expect(itemSizekey.top).assertEqual(itemSizekey01.top); - expect(Math.round(itemSizekey.right - itemSizekey01.right)).assertEqual(vp2px(150)); - expect(Math.round(itemSizekey.bottom - itemSizekey01.bottom)).assertEqual(vp2px(150)); + expect(itemSizekey.right).assertEqual(itemSizekey01.right); + // Flipping. let driver = await Driver.create(); await driver.swipe(250, 230, 200, 230); @@ -75,8 +75,8 @@ export default function swiperItemSize() { console.info("After page turning , the itemSizekey02.left value is " + JSON.stringify(itemSizekey02.left)); expect(itemSizekey.left).assertEqual(itemSizekey02.left); expect(itemSizekey.top).assertEqual(itemSizekey02.top); - expect(Math.round(itemSizekey.right - itemSizekey01.right)).assertEqual(vp2px(150)); - expect(Math.round(itemSizekey.bottom - itemSizekey01.bottom)).assertEqual(vp2px(150)); + expect(itemSizekey.right).assertEqual(itemSizekey02.right); + console.info("The type value is " + JSON.stringify(obj.$type)); console.info("The loop value is " + JSON.stringify(obj.$attrs.loop)); console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount)); @@ -87,53 +87,5 @@ export default function swiperItemSize() { done(); }); - /** - * @tc.number SUB_ACE_SWIPER_ITEMCHANGED_0200 - * @tc.name testSwiperItemSizeExceed. - * @tc.desc Set item's height and width values '350*350'. - */ - it('testSwiperItemSizeExceed', 0, async function (done) { - console.info('new testSwiperItemSizeExceed START'); - globalThis.value.message.notify({name:'index', value: 0}); - globalThis.value.message.notify({name:'height', value: 350}); - globalThis.value.message.notify({name:'width', value: 350}); - await CommonFunc.sleep(1000); - let strJson = getInspectorByKey('itemSizekey'); - let obj = JSON.parse(strJson); - let itemSizekey = CommonFunc.getComponentRect('itemSizekey'); - let itemSizekey01 = CommonFunc.getComponentRect('itemSizekey01'); - let itemSizekey02 = CommonFunc.getComponentRect('itemSizekey02'); - let itemSizekey03 = CommonFunc.getComponentRect('itemSizekey03'); - // Before flipping the page. - console.info("Before page turning , the itemSizekey.left value is " + JSON.stringify(itemSizekey.left)); - console.info("Before page turning , the itemSizekey01.left value is " + JSON.stringify(itemSizekey01.left)); - expect(itemSizekey.left).assertEqual(itemSizekey01.left); - expect(itemSizekey.right).assertEqual(itemSizekey01.right); - expect(itemSizekey.top).assertEqual(itemSizekey01.top); - expect(itemSizekey.bottom).assertEqual(itemSizekey01.bottom); - // Flipping. - let driver = await Driver.create(); - await driver.swipe(250, 230, 200, 230); - await CommonFunc.sleep(1000); - // After flipping the page. - itemSizekey = CommonFunc.getComponentRect('itemSizekey'); - itemSizekey01 = CommonFunc.getComponentRect('itemSizekey01'); - itemSizekey02 = CommonFunc.getComponentRect('itemSizekey02'); - itemSizekey03 = CommonFunc.getComponentRect('itemSizekey03'); - console.info("After page turning , the itemSizekey.left value is " + JSON.stringify(itemSizekey.left)); - console.info("After page turning , the itemSizekey02.left value is " + JSON.stringify(itemSizekey02.left)); - expect(itemSizekey.left).assertEqual(itemSizekey02.left); - expect(itemSizekey.right).assertEqual(itemSizekey02.right); - expect(itemSizekey.top).assertEqual(itemSizekey02.top); - expect(itemSizekey.bottom).assertEqual(itemSizekey02.bottom); - console.info("The type value is " + JSON.stringify(obj.$type)); - console.info("The loop value is " + JSON.stringify(obj.$attrs.loop)); - console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount)); - expect(obj.$type).assertEqual('Swiper'); - expect(obj.$attrs.loop).assertEqual('true'); - expect(obj.$attrs.displayCount).assertEqual(1); - console.info('new testSwiperItemSizeExceed END'); - done(); - }); }) } \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize2.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize2.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..56cfae8ee60f33c8becc741058e0fb9bfb273b73 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Swiper/Swiper_ItemChange/swiperItemSize2.test.ets @@ -0,0 +1,95 @@ +/** + * 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 { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest'; +export default function swiperItemSize2() { + describe('swiperItemSizeTest2', function () { + beforeEach(async function (done) { + let options = { + uri: 'MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2', + } + try { + router.clear(); + await CommonFunc.sleep(1000); + let pages = router.getState(); + console.info("get swiperItemSize2 state success " + JSON.stringify(pages)); + if (!("swiperItemSize2" == pages.name)) { + console.info("get swiperItemSize2 state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push swiperItemSize2 page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push swiperItemSize2 page error " + JSON.stringify(err)); + } + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("swiperItemSize2 after each called"); + }); + + + /** + * @tc.number SUB_ACE_SWIPER_ITEMCHANGED_0100 + * @tc.name testSwiperItemSizeExceed. + * @tc.desc Set item's height and width values '350*350'. + */ + it('testSwiperItemSizeExceed2', 0, async function (done) { + console.info('new testSwiperItemSizeExceed2 START'); + globalThis.value.message.notify({name:'index', value: 0}); + globalThis.value.message.notify({name:'height', value: 350}); + globalThis.value.message.notify({name:'width', value: 350}); + await CommonFunc.sleep(1000); + let strJson = getInspectorByKey('itemSizekey2'); + let obj = JSON.parse(strJson); + let itemSizekey2 = CommonFunc.getComponentRect('itemSizekey2'); + let itemSizekey2_01 = CommonFunc.getComponentRect('itemSizekey2_01'); + let itemSizekey2_02 = CommonFunc.getComponentRect('itemSizekey2_02'); + let itemSizekey2_03 = CommonFunc.getComponentRect('itemSizekey2_03'); + // Before flipping the page. + console.info("Before page turning , the itemSizekey2.left value is " + JSON.stringify(itemSizekey2.left)); + console.info("Before page turning , the itemSizekey2_01.left value is " + JSON.stringify(itemSizekey2_01.left)); + expect(itemSizekey2.left).assertEqual(itemSizekey2_01.left); + expect(itemSizekey2.right).assertEqual(itemSizekey2_01.right); + expect(itemSizekey2.top).assertEqual(itemSizekey2_01.top); + expect(itemSizekey2.bottom).assertEqual(itemSizekey2_01.bottom); + // Flipping. + let driver = await Driver.create(); + await driver.swipe(250, 230, 200, 230); + await CommonFunc.sleep(1000); + // After flipping the page. + itemSizekey2 = CommonFunc.getComponentRect('itemSizekey2'); + itemSizekey2_01 = CommonFunc.getComponentRect('itemSizekey2_01'); + itemSizekey2_02 = CommonFunc.getComponentRect('itemSizekey2_02'); + itemSizekey2_03 = CommonFunc.getComponentRect('itemSizekey2_03'); + console.info("After page turning , the itemSizekey2.left value is " + JSON.stringify(itemSizekey2.left)); + console.info("After page turning , the itemSizekey2_02.left value is " + JSON.stringify(itemSizekey2_02.left)); + expect(itemSizekey2.left).assertEqual(itemSizekey2_02.left); + expect(itemSizekey2.right).assertEqual(itemSizekey2_02.right); + expect(itemSizekey2.top).assertEqual(itemSizekey2_02.top); + expect(itemSizekey2.bottom).assertEqual(itemSizekey2_02.bottom); + console.info("The type value is " + JSON.stringify(obj.$type)); + console.info("The loop value is " + JSON.stringify(obj.$attrs.loop)); + console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount)); + expect(obj.$type).assertEqual('Swiper'); + expect(obj.$attrs.loop).assertEqual('true'); + expect(obj.$attrs.displayCount).assertEqual(1); + console.info('new testSwiperItemSizeExceed2 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json index e578c9e43d0c9b7892f80fc0f749a1312cc79dd5..f7dfab2aa376f7a3a171d3856cf63d5b6ba077e0 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json @@ -301,6 +301,7 @@ "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadding", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadMar", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize", + "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemVisibility", "MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_1", "MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_2",