From b5b0ac1726e4963ba79325f7d07d368d4d7ae826 Mon Sep 17 00:00:00 2001 From: wangguan Date: Fri, 1 Sep 2023 19:17:17 +0800 Subject: [PATCH] =?UTF-8?q?Grid=20XTS=20=E7=94=A8=E4=BE=8B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangguan --- .../MainAbility/pages/GridCallbackPage.ets | 26 ++++++++++++------- .../main/ets/test/GridCallbackJsunit.test.ets | 14 ++++------ 2 files changed, 22 insertions(+), 18 deletions(-) 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 fd4fd3cbd..7c5263e23 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 fa8498598..ec9a79cb9 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); -- GitLab