diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets index fd4fd3cbd0ac65412285b974df257ddecf281d9e..7c5263e235230b02f7ed384682869d2613efdd1b 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets @@ -178,10 +178,10 @@ struct GridCallbackPage { Text('scroll').fontColor(0xCCCCCC).fontSize(9).width('90%') Grid(this.scroller) { - ForEach(this.Number, (day: string) => { - ForEach(this.Number, (day: string) => { + ForEach(this.Number, (row: string) => { + ForEach(this.Number, (column: string) => { GridItem() { - Text(day) + Text(row +"-"+ column) .fontSize(16) .backgroundColor(0xF9CF93) .width('100%') @@ -235,12 +235,20 @@ struct GridCallbackPage { return { offsetRemain: offset } }) - Button(this.buttonName) - .key('button') - .onClick(() => { // 点击后滑到下一页 - this.buttonName = 'clicked' - this.scroller.scrollPage({ next: true }) - }) + Row(){ + Button("scoll to bottom") + .key("bottom") + .onClick(() => { // 滑动到底部 + console.log("滑动到底部") + this.scroller.scrollTo({xOffset:0,yOffset:2000}) + }) + Button(this.buttonName) + .key('button') + .onClick(() => { // 点击后滑到下一页 + this.buttonName = 'clicked' + this.scroller.scrollPage({ next: true }) + }) + } Text('onScrollIndex:' + this.onScrollIndex).key('onScrollIndex') Text(this.onItemDragStart).key('onItemDragStart') Text(this.onItemDragEnter).key('onItemDragEnter') diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets index fa8498598a9e55f829b287178a79fc725ba1f410..ec9a79cb996bb1bd62918a55d86192d796db7f4b 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets @@ -52,6 +52,7 @@ export default function GridCallbackJsunit() { let bottom = grid2.bottom let left = grid2.left let right = grid2.right + console.log('[GridCallbackJsunit_1000] grid 2 top:' + top +" bottom:" + bottom + "left: " + left + " right:" + right) let driver = await UiDriver.create() await driver.swipe(Math.round((right - left)), Math.round(bottom - 60), Math.round((right - left)), Math.round(top + 60)); await CommonFunc.sleep(200); @@ -91,18 +92,13 @@ export default function GridCallbackJsunit() { expect(text7).assertEqual('onScrollFrameBegin:succ'); await CommonFunc.sleep(200); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await CommonFunc.sleep(1000); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await driver.swipe(Math.round((right - left)), Math.round(top + 60), Math.round((right - left)), Math.round(bottom - 60)); - await CommonFunc.sleep(1000); - + let bottomButton = await driver.findComponent(BY.key('bottom')); + await bottomButton.click() + await CommonFunc.sleep(2000) let onReachEndText = await driver.findComponent(BY.key('onReachEndText')); let text9 = await onReachEndText.getText(); console.info("[GridCallbackJsunit_1000] onReachEndText: " + text9); + expect(text9).assertEqual('onReachEnd:succ'); await CommonFunc.sleep(1000);