diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_SpaceChange/List_SpaceChange.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_SpaceChange/List_SpaceChange.ets new file mode 100644 index 0000000000000000000000000000000000000000..22b0d697bab8d33986e4ee22e805e7e12baa49ac --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_SpaceChange/List_SpaceChange.ets @@ -0,0 +1,74 @@ +/** + * 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 List_SpaceChange{ + @State testSpace: number = 0; + messageManager:MessageManager = new MessageManager(); + + onPageShow() { + console.info('Grid_RowCol_ItemContentSize onPageShow'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value); + if (message.name == 'Space') { + this.testSpace = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build(){ + Column({space:30}){ + List({space:this.testSpace}){ + ListItem() { + Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3); + } + .width(300) + .height(100) + .key('List_SpaceChange01') + ListItem() { + Text('2').width('100%').height('100%').backgroundColor(0xD2B48C); + } + .width(300) + .height(100) + .key('List_SpaceChange02') + ListItem() { + Text('3').width('100%').height('100%').backgroundColor(0xF5DEB3); + } + .width(300) + .height(100) + .key('List_SpaceChange03') + ListItem() { + Text('4').width('100%').height('100%').backgroundColor(0xD2B48C); + } + .width(300) + .height(100) + .key('List_SpaceChange04') + } + .width(350) + .height(520) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .backgroundColor(0xAFEEEE) + .key('List_SpaceChange_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex1.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex1.ets new file mode 100644 index 0000000000000000000000000000000000000000..c497fe9d5329f0d089321a2e2bffdae6483961ef --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex1.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex1{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = 2; + @State testLanes: number = 1; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex1_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex1_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex2.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex2.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d87c19897565be7aa65f62e4a8c5d0fec9be4fd --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex2.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex2{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = 0; + @State testLanes: number = 1; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex2_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex2_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex3.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex3.ets new file mode 100644 index 0000000000000000000000000000000000000000..33fbb8b3fc7dc6436b63966aa2153e67062114d9 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex3.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex3{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = -1; + @State testLanes: number = 1; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex3_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex3_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex4.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex4.ets new file mode 100644 index 0000000000000000000000000000000000000000..1573ca17698a329f283d5e759b51dba5a2a0e751 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex4.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex4{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = 12; + @State testLanes: number = 1; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex4_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex4_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex5.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex5.ets new file mode 100644 index 0000000000000000000000000000000000000000..5fb01370c9cdc8e023fd4a09c559cf7cd9e84a1f --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex5.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex5{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = 12; + @State testLanes: number = 2; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex5_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex5_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex6.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex6.ets new file mode 100644 index 0000000000000000000000000000000000000000..f60634f06f2826617164cb672399adec30b2adde --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_initialIndex/List_ListInitialIndex6.ets @@ -0,0 +1,46 @@ +/** + * 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 List_ListInitialIndex6{ + @State arr: String[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']; + @State testInitialIndex: number = 3; + @State testLanes: number = 2; + build(){ + Column({space:30}){ + List({space:20, initialIndex:this.testInitialIndex}){ + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('100%').height('100%').backgroundColor(0xF5DEB3) + } + .width(100) + .height(100) + .key('List_ListInitialIndex6_'+ item) + }, item => item) + } + .width(300) + .height(500) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .lanes(this.testLanes) + .backgroundColor(0xAFEEEE) + .key('List_ListInitialIndex6_Container01') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_SpaceChange/List_SpaceChange.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_SpaceChange/List_SpaceChange.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4e40c9f119ac4f32260c61535dfbac40afd38a0 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_SpaceChange/List_SpaceChange.test.ets @@ -0,0 +1,209 @@ + +/** + * 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 '@ohos.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 list_SpaceChangeTest() { + describe('list_SpaceChangeTest', function () { + beforeEach(async function (done) { + console.info("list_SpaceChangeTest beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_SpaceChange/List_SpaceChange', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_SpaceChange state pages:" + JSON.stringify(pages)); + if (!("List_SpaceChange" == pages.name)) { + console.info("get List_SpaceChange pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_SpaceChange page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_SpaceChange page error:" + err); + } + console.info("list_SpaceChangeTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("list_SpaceChangeTest after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_SPACECHANGE_0100 + * @tc.name testListSpaceChangeUnfill + * @tc.desc set the space of list to 20 + */ + it('testListSpaceChangeUnfill', 0, async function (done) { + console.info('[testListSpaceChangeUnfill] START'); + globalThis.value.message.notify({name:'Space', value:20}); + await CommonFunc.sleep(1000); + let firstListItem = CommonFunc.getComponentRect('List_SpaceChange01'); + let secondListItem = CommonFunc.getComponentRect('List_SpaceChange02'); + let thirdListItem = CommonFunc.getComponentRect('List_SpaceChange03'); + let fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + let listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + let listContainerStrJson = getInspectorByKey('List_SpaceChange_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(20)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(listContainer.bottom - fourthListItem.bottom)).assertEqual(vp2px(60)); + + let driver = await Driver.create(); + await driver.swipe( + Math.round(fourthListItem.left + ((fourthListItem.right - fourthListItem.left) / 2)), + Math.round(fourthListItem.bottom), + Math.round(thirdListItem.left + ((thirdListItem.right - thirdListItem.left) / 2)), + Math.round(thirdListItem.bottom)); + + fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + expect(Math.round(listContainer.bottom - fourthListItem.bottom)).assertEqual(vp2px(60)); + + console.info('[testListSpaceChangeUnfill] END'); + done(); + }); + /** + * @tc.number SUB_ACE_LIST_SPACECHANGE_0200 + * @tc.name testListSpaceChangeFill + * @tc.desc set the space of list to 40 + */ + it('testListSpaceChangeFill', 0, async function (done) { + console.info('[testListSpaceChangeFill] START'); + globalThis.value.message.notify({name:'Space', value:40}); + await CommonFunc.sleep(1000); + let firstListItem = CommonFunc.getComponentRect('List_SpaceChange01'); + let secondListItem = CommonFunc.getComponentRect('List_SpaceChange02'); + let thirdListItem = CommonFunc.getComponentRect('List_SpaceChange03'); + let fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + let listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + let listContainerStrJson = getInspectorByKey('List_SpaceChange_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(40)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(40)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(40)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(listContainer.bottom).assertEqual(fourthListItem.bottom); + + let driver = await Driver.create(); + await driver.swipe( + Math.round(fourthListItem.left + ((fourthListItem.right - fourthListItem.left) / 2)), + Math.round(fourthListItem.bottom -10), + Math.round(thirdListItem.left + ((thirdListItem.right - thirdListItem.left) / 2)), + Math.round(thirdListItem.bottom)); + + fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + expect(listContainer.bottom).assertEqual(fourthListItem.bottom); + + console.info('[testListSpaceChangeFill] END'); + done(); + }); + /** + * @tc.number SUB_ACE_LIST_SPACECHANGE_0300 + * @tc.name testListSpaceChangeOverflow + * @tc.desc set the space of list to 60 + */ + it('testListSpaceChangeOverflow', 0, async function (done) { + console.info('[testListSpaceChangeOverflow] START'); + globalThis.value.message.notify({name:'Space', value:60}); + await CommonFunc.sleep(1000); + let firstListItem = CommonFunc.getComponentRect('List_SpaceChange01'); + let secondListItem = CommonFunc.getComponentRect('List_SpaceChange02'); + let thirdListItem = CommonFunc.getComponentRect('List_SpaceChange03'); + let fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + let listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + let listContainerStrJson = getInspectorByKey('List_SpaceChange_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(60)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(60)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(60)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(300)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.bottom - listContainer.bottom)).assertEqual(vp2px(60)); + let driver = await Driver.create(); + await driver.swipe( + Math.round(thirdListItem.left + ((thirdListItem.right - thirdListItem.left) / 2)), + Math.round(thirdListItem.bottom), + Math.round(secondListItem.left + ((secondListItem.right - secondListItem.left) / 2)), + Math.round(secondListItem.bottom)); + await CommonFunc.sleep(1000); + fourthListItem = CommonFunc.getComponentRect('List_SpaceChange04'); + listContainer = CommonFunc.getComponentRect('List_SpaceChange_Container01'); + expect(listContainer.bottom).assertEqual(fourthListItem.bottom); + console.info('[testListSpaceChangeOverflow] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex1.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex1.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c37816b75b941974bd37c821b10d972840248707 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex1.test.ets @@ -0,0 +1,140 @@ + +/** + * 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 '@ohos.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'; +import { MessageManager,Callback } from '../../../MainAbility/common/MessageManager'; +export default function list_ListInitialIndex1Test() { + describe('List_ListInitialIndex1Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndexTest beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex1', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex1 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex1" == pages.name)) { + console.info("get List_ListInitialIndex1 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex1 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex1 page error:" + err); + } + console.info("List_ListInitialIndexTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex1Test after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0100 + * @tc.name testListInitialIndexToTwoWithOneLane + * @tc.desc the InitialIndex of list set to 2 + */ + it('testListInitialIndexToTwoWithOneLane', 0, async function (done) { + console.info('[testListInitialIndexToTwoWithOneLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex1_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex1_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(0)); + + expect(thirdListItem.top).assertEqual(listContainer.top); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(sixthListItem.left).assertEqual(listContainer.left); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(0)); + + let driver = await Driver.create(); + await driver.swipe(Math.round(thirdListItem.left + ((thirdListItem.right - thirdListItem.left) / 2)), + Math.round(thirdListItem.bottom), Math.round(fifthListItem.left + (fifthListItem.right - fifthListItem.left) / 2), + Math.round(fifthListItem.bottom)); + await CommonFunc.sleep(2000); + firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_1'); + secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex1_2'); + listContainer = CommonFunc.getComponentRect('List_ListInitialIndex1_Container01'); + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + console.info('[testListInitialIndexToTwoWithOneLane] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex2.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex2.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..38df51f69a7b30b16509fa827af909dfc3752e37 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex2.test.ets @@ -0,0 +1,141 @@ + +/** + * 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 '@ohos.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 list_ListInitialIndex2Test() { + describe('List_ListInitialIndex2Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndex2Test beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex2', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex2 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex2" == pages.name)) { + console.info("get List_ListInitialIndex2 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex2 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex2 page error:" + err); + } + console.info("List_ListInitialIndex2Test beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex2 after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0200 + * @tc.name testListInitialIndexToZeroWithOneLane + * @tc.desc the InitialIndex of list set to 0 + */ + it('testListInitialIndexToZeroWithOneLane', 0, async function (done) { + console.info('[testListInitialIndexToZeroWithOneLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex2_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex2_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(firstListItem.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(20)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(0)); + + let driver = await Driver.create(); + await driver.swipe(Math.round(fourthListItem.left + ((fourthListItem.right - fourthListItem.left) / 2)), + Math.round(fourthListItem.bottom), Math.round(firstListItem.left + (firstListItem.right - firstListItem.left) / 2), + Math.round(firstListItem.bottom)); + await CommonFunc.sleep(2000); + fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_5'); + sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_6'); + seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex2_7'); + listContainer = CommonFunc.getComponentRect('List_ListInitialIndex2_Container01'); + + expect(Math.round(sixthListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(sixthListItem.left).assertEqual(listContainer.left); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + console.info('[testListInitialIndexToZeroWithOneLane] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex3.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex3.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9523a11caf8b5dc95f60cdd5c274dc84b525549a --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex3.test.ets @@ -0,0 +1,141 @@ + +/** + * 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 '@ohos.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 list_ListInitialIndex3Test() { + describe('List_ListInitialIndex3Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndex3Test beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex3', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex3 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex3" == pages.name)) { + console.info("get List_ListInitialIndex3 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex3 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex3 page error:" + err); + } + console.info("List_ListInitialIndex3Test beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex3Test after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0300 + * @tc.name testListInitialIndexToNegativeWithOneLane + * @tc.desc the InitialIndex of list set to -1 + */ + it('testListInitialIndexToNegativeWithOneLane', 0, async function (done) { + console.info('[testListInitialIndexToNegativeWithOneLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex3_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex3_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(firstListItem.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(20)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(0)); + + let driver = await Driver.create(); + await driver.swipe(Math.round(fourthListItem.left + ((fourthListItem.right - fourthListItem.left) / 2)), + Math.round(fourthListItem.bottom), Math.round(firstListItem.left + (firstListItem.right - firstListItem.left) / 2), + Math.round(firstListItem.bottom)); + await CommonFunc.sleep(2000); + fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_5'); + sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_6'); + seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex3_7'); + listContainer = CommonFunc.getComponentRect('List_ListInitialIndex3_Container01'); + + expect(Math.round(sixthListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(sixthListItem.left).assertEqual(listContainer.left); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + console.info('[testListInitialIndexToNegativeWithOneLane] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex4.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex4.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..46832e690eb0699c54818b6ac2f88b5079bdf144 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex4.test.ets @@ -0,0 +1,141 @@ + +/** + * 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 '@ohos.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 list_ListInitialIndex4Test() { + describe('List_ListInitialIndex4Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndex4Test beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex4', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex4 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex4" == pages.name)) { + console.info("get List_ListInitialIndex4 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex4 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex4 page error:" + err); + } + console.info("List_ListInitialIndex4Test beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex4Test after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0400 + * @tc.name testListInitialIndexToTwelveWithOneLane + * @tc.desc the InitialIndex of list set to 12 + */ + it('testListInitialIndexToTwelveWithOneLane', 0, async function (done) { + console.info('[testListInitialIndexToTwelveWithOneLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex4_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex4_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(firstListItem.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(secondListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(secondListItem.left).assertEqual(listContainer.left); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - secondListItem.bottom)).assertEqual(vp2px(20)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fourthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(0)); + + let driver = await Driver.create(); + await driver.swipe(Math.round(fourthListItem.left + ((fourthListItem.right - fourthListItem.left) / 2)), + Math.round(fourthListItem.bottom), Math.round(firstListItem.left + (firstListItem.right - firstListItem.left) / 2), + Math.round(firstListItem.bottom)); + await CommonFunc.sleep(2000); + fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_5'); + sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_6'); + seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex4_7'); + listContainer = CommonFunc.getComponentRect('List_ListInitialIndex4_Container01'); + + expect(Math.round(sixthListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(sixthListItem.left).assertEqual(listContainer.left); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + console.info('[testListInitialIndexToTwelveWithOneLane] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex5.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex5.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0fbb89cb9759d5e8a16a86839d60d3cc9449637e --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex5.test.ets @@ -0,0 +1,152 @@ + +/** + * 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 '@ohos.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 list_ListInitialIndex5Test() { + describe('List_ListInitialIndex5Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndex5Test beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex5', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex5 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex5" == pages.name)) { + console.info("get List_ListInitialIndex5 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex5 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex5 page error:" + err); + } + console.info("List_ListInitialIndex5Test beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex5Test after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0500 + * @tc.name testListInitialIndexToTwelveWithTwoLane + * @tc.desc the InitialIndex of list set to 12,the lanes of list set to 2 + */ + it('testListInitialIndexToTwelveWithTwoLane', 0, async function (done) { + console.info('[testListInitialIndexToTwelveWithTwoLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex5_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex5_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(secondListItem.top).assertEqual(listContainer.top); + expect(Math.round(secondListItem.left - firstListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(thirdListItem.top - firstListItem.bottom)).assertEqual(vp2px(20)); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fourthListItem.top - secondListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(fourthListItem.left - thirdListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(sixthListItem.left - fifthListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(eighthListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(eighthListItem.left - seventhListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(ninthListItem.top - seventhListItem.bottom)).assertEqual(vp2px(20)); + expect(ninthListItem.left).assertEqual(listContainer.left); + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(tenthListItem.top - eighthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(tenthListItem.left - ninthListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(0)); + + + let driver = await Driver.create(); + await driver.swipe(Math.round(fifthListItem.left + ((fifthListItem.right - fifthListItem.left) / 2)), + Math.round(fifthListItem.bottom), Math.round(firstListItem.left + (firstListItem.right - firstListItem.left) / 2), + Math.round(firstListItem.bottom)); + + ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_9'); + tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_10'); + eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_11'); + twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex5_12'); + + expect(Math.round(eleventhListItem.top - ninthListItem.bottom)).assertEqual(vp2px(20)); + expect(eleventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(twelfthListItem.top - tenthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(twelfthListItem.left - eleventhListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(100)); + console.info('[testListInitialIndexToTwelveWithTwoLane] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex6.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex6.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb1a1cc2540e97a1345b82ed2ed05cb5910cfe3b --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_initialIndex/List_ListInitialIndex6.test.ets @@ -0,0 +1,150 @@ + +/** + * 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 '@ohos.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 list_ListInitialIndex6Test() { + describe('List_ListInitialIndex6Test', function () { + beforeEach(async function (done) { + console.info("List_ListInitialIndex6Test beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_initialIndex/List_ListInitialIndex6', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListInitialIndex6 state pages:" + JSON.stringify(pages)); + if (!("List_ListInitialIndex6" == pages.name)) { + console.info("get List_ListInitialIndex6 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListInitialIndex6 page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListInitialIndex6 page error:" + err); + } + console.info("List_ListInitialIndex6Test beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListInitialIndex6Test after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTINITIALINDEX_0600 + * @tc.name testListInitialIndexToThreeWithTwoLane + * @tc.desc set the InitialIndex of list to 3,the lanes of list to 2 + */ + it('testListInitialIndexToThreeWithTwoLane', 0, async function (done) { + console.info('[testListInitialIndexToThreeWithTwoLane] START'); + let firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_1'); + let secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_2'); + let thirdListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_3'); + let fourthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_4'); + let fifthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_5'); + let sixthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_6'); + let seventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_7'); + let eighthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_8'); + let ninthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_9'); + let tenthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_10'); + let eleventhListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_11'); + let twelfthListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_12'); + let listContainer = CommonFunc.getComponentRect('List_ListInitialIndex6_Container01'); + let listContainerStrJson = getInspectorByKey('List_ListInitialIndex6_Container01'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(0)); + + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(0)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(0)); + + expect(thirdListItem.top).assertEqual(listContainer.top); + expect(thirdListItem.left).assertEqual(listContainer.left); + expect(Math.round(thirdListItem.right - thirdListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(thirdListItem.bottom - thirdListItem.top)).assertEqual(vp2px(100)); + + expect(thirdListItem.top).assertEqual(listContainer.top); + expect(Math.round(fourthListItem.left - thirdListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(fourthListItem.right - fourthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fourthListItem.bottom - fourthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(fifthListItem.top - thirdListItem.bottom)).assertEqual(vp2px(20)); + expect(fifthListItem.left).assertEqual(listContainer.left); + expect(Math.round(fifthListItem.right - fifthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(fifthListItem.bottom - fifthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(sixthListItem.top - fourthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(sixthListItem.left - fifthListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(sixthListItem.right - sixthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(sixthListItem.bottom - sixthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(seventhListItem.top - fifthListItem.bottom)).assertEqual(vp2px(20)); + expect(seventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(seventhListItem.right - seventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(seventhListItem.bottom - seventhListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(eighthListItem.top - sixthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(eighthListItem.left - seventhListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(eighthListItem.right - eighthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(eighthListItem.bottom - eighthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(ninthListItem.top - seventhListItem.bottom)).assertEqual(vp2px(20)); + expect(ninthListItem.left).assertEqual(listContainer.left); + expect(Math.round(ninthListItem.right - ninthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(ninthListItem.bottom - ninthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(tenthListItem.top - eighthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(tenthListItem.left - ninthListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(tenthListItem.right - tenthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(tenthListItem.bottom - tenthListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(eleventhListItem.top - ninthListItem.bottom)).assertEqual(vp2px(20)); + expect(eleventhListItem.left).assertEqual(listContainer.left); + expect(Math.round(eleventhListItem.right - eleventhListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(eleventhListItem.bottom - eleventhListItem.top)).assertEqual(vp2px(100)); + + expect(Math.round(twelfthListItem.top - tenthListItem.bottom)).assertEqual(vp2px(20)); + expect(Math.round(twelfthListItem.left - eleventhListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(twelfthListItem.right - twelfthListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(twelfthListItem.bottom - twelfthListItem.top)).assertEqual(vp2px(100)); + + + let driver = await Driver.create(); + await driver.swipe(Math.round(thirdListItem.left + ((thirdListItem.right - thirdListItem.left) / 2)), + Math.round(thirdListItem.bottom), Math.round(fifthListItem.left + (fifthListItem.right - fifthListItem.left) / 2), + Math.round(fifthListItem.bottom)); + await CommonFunc.sleep(2000); + firstListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_1'); + secondListItem = CommonFunc.getComponentRect('List_ListInitialIndex6_2'); + + expect(firstListItem.top).assertEqual(listContainer.top); + expect(firstListItem.left).assertEqual(listContainer.left); + expect(Math.round(firstListItem.right - firstListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(firstListItem.bottom - firstListItem.top)).assertEqual(vp2px(100)); + + expect(secondListItem.top).assertEqual(listContainer.top); + expect(Math.round(secondListItem.left - firstListItem.right)).assertEqual(vp2px(50)); + expect(Math.round(secondListItem.right - secondListItem.left)).assertEqual(vp2px(100)); + expect(Math.round(secondListItem.bottom - secondListItem.top)).assertEqual(vp2px(100)); + console.info('[SUB_ACE_LIST_LISTINITIALINDEX_0600] END'); + done(); + }); + }) +}