From b6bd4b49221a890ba2fb55f801e80d86f67f2580 Mon Sep 17 00:00:00 2001 From: wangguan Date: Tue, 29 Aug 2023 11:00:41 +0800 Subject: [PATCH] =?UTF-8?q?Grid=20XTS=207=E4=B8=AA=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangguan --- .../MainAbility/pages/GridCallbackPage.ets | 270 ++++++++++++++++++ .../main/ets/test/GridCallbackJsunit.test.ets | 113 ++++++++ .../src/main/ets/test/GridJsunit.test.ets | 157 +++++----- .../entry/src/main/ets/test/List.test.ets | 2 + .../resources/base/profile/main_pages.json | 4 +- 5 files changed, 454 insertions(+), 92 deletions(-) create mode 100644 arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets create mode 100644 arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets 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 new file mode 100644 index 000000000..fd4fd3cbd --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridCallbackPage.ets @@ -0,0 +1,270 @@ +/** + * Copyright (c) 2022 Huawei Device 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 '../utils/MessageManager'; + +@Entry +@Component +struct GridCallbackPage { + @State Number: String[] = ['0', '1', '2', '3', '4'] + @State columnsTemplate: string = '1fr 1fr 1fr 1fr 1fr' + @State rowsTemplate: string = '1fr 1fr 1fr 1fr 1fr' + @State columnsGap: number = 10 + @State rowsGap: number = 10 + @State scrollBar: BarState = BarState.Off + @State scrollBarColor: Color = Color.Grey + @State scrollBarWidth: number = 20 + @State cachedCount: number = 1 + @State editMode: boolean = false + @State layoutDirection: GridDirection = GridDirection.Column + @State maxCount: number = Infinity + @State minCount: number = 1 + @State cellLength: number = 40 + @State multiSelectable: boolean = false + @State supportAnimation: boolean = false + @State onScrollIndex: number = 2 + @State buttonName: string = 'next page' + @State onItemDragStart: string = 'onItemDragStart' + @State onItemDragEnter: string = 'onItemDragEnter' + @State onItemDragMove: string = 'onItemDragMove' + @State onItemDragLeave: string = 'onItemDragLeave' + @State onItemDrop: string = 'onItemDrop' + @State onScrollText: string = 'onScroll' + @State onScrollIndexText: string = 'onScrollIndex' + @State onReachStartText: string = 'onReachStart' + @State onReachEndText: string = 'onReachEnd' + @State onScrollStartText: string = 'onScrollStart' + @State onScrollStopText: string = 'onScrollStop' + @State onScrollFrameBeginText: string = 'onScrollFrameBegin' + @State onScrollBarUpdateText: string = 'onScrollBarUpdate' + @State myKey: number = 0 + scroller: Scroller = new Scroller() + messageManager:MessageManager = new MessageManager() + + onPageShow() { + console.info('GridPage onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'columnsTemplate') { + this.columnsTemplate = message.value + } + if (message.name == 'rowsTemplate') { + this.rowsTemplate = message.value + } + if (message.name == 'columnsGap') { + this.columnsGap = message.value + } + if (message.name == 'rowsGap') { + this.rowsGap = message.value + } + if (message.name == 'scrollBar') { + this.scrollBar = message.value + } + if (message.name == 'scrollBarColor') { + this.scrollBarColor = message.value + } + if (message.name == 'scrollBarWidth') { + this.scrollBarWidth = message.value + } + if (message.name == 'cachedCount') { + this.cachedCount = message.value + } + if (message.name == 'editMode') { + this.editMode = message.value + } + if (message.name == 'layoutDirection') { + this.layoutDirection = message.value + } + if (message.name == 'maxCount') { + this.maxCount = message.value + } + if (message.name == 'minCount') { + this.minCount = message.value + } + if (message.name == 'cellLength') { + this.cellLength = message.value + } + if (message.name == 'multiSelectable') { + this.multiSelectable = message.value + } + if (message.name == 'supportAnimation') { + this.supportAnimation = message.value + } + } + this.messageManager.registerCallback(callback) + } + + build() { + Column({ space: 5 }) { + Text('default').fontColor(0xCCCCCC).fontSize(9).width('90%') + Grid() { + GridItem() { + Text("abc").fontSize(16).backgroundColor(0xF9CF93).width('100%') + .height(40).textAlign(TextAlign.Center) + }.width('90%') + }.columnsTemplate('1fr') + .rowsTemplate('1fr') + .height(50) + .key('grid_default') + + Grid() { + ForEach(this.Number, (day: string) => { + ForEach(this.Number, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width(40) + .height(40) + .textAlign(TextAlign.Center) + .key(day) + } + }, day => day) + }, day => day) + } + .columnsTemplate(this.columnsTemplate) + .rowsTemplate(this.rowsTemplate) + .columnsGap(this.columnsGap) + .rowsGap(this.rowsGap) + .scrollBar(this.scrollBar) + .cachedCount(this.cachedCount) + .editMode(this.editMode) + .layoutDirection(this.layoutDirection) + .maxCount(this.maxCount) + .minCount(this.minCount) + .cellLength(this.cellLength) + .multiSelectable(this.multiSelectable) + .supportAnimation(this.supportAnimation) + .width('90%') + .key('grid1') + .backgroundColor(0xFAEEE0) + .height(150) + .edgeEffect(EdgeEffect.Spring) + .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { + this.onItemDragStart = 'onItemDragStart:succ' + console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y) + console.info(itemIndex.toString()) + }) + .onItemDragEnter((event: ItemDragInfo) => { + this.onItemDragEnter = 'onItemDragEnter:succ' + console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y) + }) + .onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => { + this.onItemDragMove = 'onItemDragMove:succ' + console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y + ' itemIndex: ' + itemIndex + ' insertIndex: ' + insertIndex) + }) + .onItemDragLeave((event: ItemDragInfo, itemIndex: number) => { + this.onItemDragLeave = 'onItemDragLeave:succ' + console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y + ' itemIndex: ' + itemIndex) + }) + .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { + this.onItemDrop = 'onItemDrop:succ' + console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y + ' itemIndex: ' + itemIndex + ' insertIndex: ' + insertIndex + ' isSuccess: ' + isSuccess) + }) + + Text('scroll').fontColor(0xCCCCCC).fontSize(9).width('90%') + Grid(this.scroller) { + ForEach(this.Number, (day: string) => { + ForEach(this.Number, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + }, day => day) + }, day => day) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .key('grid2') + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .onScrollIndex((first: number) => { + this.onScrollIndex = first + console.info(first.toString()) + }) + .width('90%') + .backgroundColor(0xFAEEE0) + .height(200) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + this.onScrollText = 'onScroll:succ' + console.info('onScroll scrollOffset:' + scrollOffset.toString() + ' ScrollState:' + ScrollState.toString()) + }) + .onScrollIndex((first: number,last: number) => { + this.onScrollIndexText = "onScrollIndex:succ" + console.info("onScrollIndex first:" + first.toString() + " last:" + last.toString()) + }) + .onReachStart(() => { + this.onReachStartText = 'onReachStart:succ' + console.info('onReachStart !') + }) + .onReachEnd(() => { + this.onReachEndText = 'onReachEnd:succ' + console.info('onReachEnd !') + }) + .onScrollStart(() => { + this.onScrollStartText = 'onScrollStart:succ' + console.info('onScrollStart !') + }) + .onScrollStop(() => { + this.onScrollStopText = 'onScrollStop:succ' + console.info('onScrollStop !') + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + this.onScrollFrameBeginText = 'onScrollFrameBegin:succ' + console.info('onScrollFrameBegin offset:' + offset +' state:' + state) + return { offsetRemain: offset } + }) + + 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') + Text(this.onItemDragMove).key('onItemDragMove') + Text(this.onItemDragLeave).key('onItemDragLeave') + Text(this.onItemDrop).key('onItemDrop') + Row() + { + Text(this.onScrollText).margin({right:10}).key('onScrollText') + Text(this.onReachStartText).key('onReachStartText') + } + Row() + { + Text(this.onReachEndText).margin({right:10}).key('onReachEndText') + Text(this.onScrollStartText).key('onScrollStartText') + } + Row() + { + Text(this.onScrollIndexText).margin({right:10}).key('onScrollIndexText') + Text(this.onScrollStopText).key('onScrollStopText') + } + + Text(this.onScrollFrameBeginText).key('onScrollFrameBeginText') + Text(this.onScrollBarUpdateText).key('onScrollBarUpdateText') + }.width('100%').margin({ top: 5 }) + } +} 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 new file mode 100644 index 000000000..fa8498598 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridCallbackJsunit.test.ets @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2022 Huawei Device 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 {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; + + +export default function GridCallbackJsunit() { + describe('GridCallbackJsunit', function () { + beforeEach(async function (done) { + console.info("GridCallbackJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/GridCallbackPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get GridCallbackJsunit state pages: " + JSON.stringify(pages)); + if (!("GridCallbackPage" == pages.name)) { + console.info("get GridCallbackJsunit state pages.name: " + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push GridCallbackJsunit success: " + JSON.stringify(result)); + } + } catch (err) { + console.error("push GridCallbackJsunit page error: " + err); + expect().assertFail(); + } + done(); + }); + + it('GridCallbackJsunit_1000', 0, async function (done) { + // Verify Neither rowsTemplate nor columnsTemplate is set + console.info('[GridCallbackJsunit_1000] START'); + + let grid2 = CommonFunc.getComponentRect('grid2'); + let top = grid2.top + let bottom = grid2.bottom + let left = grid2.left + let right = grid2.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); + let onReachStartText = await driver.findComponent(BY.key('onReachStartText')); + + let text5 = await onReachStartText.getText(); + console.info('[GridCallbackJsunit_1000] onReachStartText' + text5); + expect(text5).assertEqual('onReachStart:succ'); + await CommonFunc.sleep(200); + + let onScrollText = await driver.findComponent(BY.key('onScrollText')); + let text3 = await onScrollText.getText(); + console.info('[GridCallbackJsunit_1000] onScrollText' + text3); + expect(text3).assertEqual('onScroll:succ'); + + let onScrollIndexText = await driver.findComponent(BY.key('onScrollIndexText')); + let text2 = await onScrollIndexText.getText(); + console.info('[GridCallbackJsunit_1000] onScrollIndexText' + text2); + expect(text2).assertEqual('onScrollIndex:succ'); + + let onScrollStartText = await driver.findComponent(BY.key('onScrollStartText')); + let text4 = await onScrollStartText.getText(); + console.info('[GridCallbackJsunit_1000] onScrollStartText' + text4); + expect(text4).assertEqual('onScrollStart:succ'); + await CommonFunc.sleep(200); + + + let onScrollStopText = await driver.findComponent(BY.key('onScrollStopText')); + let text6 = await onScrollStopText.getText(); + console.info('[GridCallbackJsunit_1000] onScrollStopText' + text6); + expect(text6).assertEqual('onScrollStop:succ'); + await CommonFunc.sleep(200); + + let onScrollFrameBeginText = await driver.findComponent(BY.key('onScrollFrameBeginText')); + let text7 = await onScrollFrameBeginText.getText(); + console.info('[GridCallbackJsunit_1000] nScrollFrameBeginText ' + text7); + 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 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); + + console.info('[GridCallbackJsunit_1000] END'); + done(); + }); + }) +} diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridJsunit.test.ets index c185bee16..07b0aaab7 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridJsunit.test.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridJsunit.test.ets @@ -70,17 +70,29 @@ export default function GridJsunit() { // Modify the properties of component Grid console.info('[GridJsunit_0200] START'); await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'columnsGap',value:'15'}) + globalThis.value.message.notify({ + name: 'columnsGap', value: '15' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'rowsGap',value:'20'}) + globalThis.value.message.notify({ + name: 'rowsGap', value: '20' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBar',value:'BarState.On'}) + globalThis.value.message.notify({ + name: 'scrollBar', value: 'BarState.On' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBarColor',value:'Color.Blue'}) + globalThis.value.message.notify({ + name: 'scrollBarColor', value: 'Color.Blue' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBarWidth',value:'30'}) + globalThis.value.message.notify({ + name: 'scrollBarWidth', value: '30' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'cachedCount',value:2}) + globalThis.value.message.notify({ + name: 'cachedCount', value: 2 + }) await CommonFunc.sleep(2000); // Get the propoties value of the Grid component @@ -104,17 +116,29 @@ export default function GridJsunit() { // Illegal modification of properties of component grid console.info('[GridJsunit_0300] START'); await CommonFunc.sleep(1000); - globalThis.value.message.notify({name:'columnsGap',value:'a'}) + globalThis.value.message.notify({ + name: 'columnsGap', value: 'a' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'rowsGap',value:'-10'}) + globalThis.value.message.notify({ + name: 'rowsGap', value: '-10' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBar',value:'123'}) + globalThis.value.message.notify({ + name: 'scrollBar', value: '123' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBarColor',value:'aaa'}) + globalThis.value.message.notify({ + name: 'scrollBarColor', value: 'aaa' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'scrollBarWidth',value:'-10'}) + globalThis.value.message.notify({ + name: 'scrollBarWidth', value: '-10' + }) await CommonFunc.sleep(200); - globalThis.value.message.notify({name:'cachedCount',value:'a'}) + globalThis.value.message.notify({ + name: 'cachedCount', value: 'a' + }) await CommonFunc.sleep(200); // Get the propoties value of the Grid component @@ -146,22 +170,22 @@ export default function GridJsunit() { let bottom = grid2.bottom let left = grid2.left let right = grid2.right - let driver = await Driver.create() + let driver = await UiDriver.create() await driver.swipe(Math.round((right - left) / 2), Math.round(bottom - 10), Math.round((right - left) / 2), Math.round(top + 10)); await driver.swipe(Math.round((right - left) / 2), Math.round(bottom - 10), Math.round((right - left) / 2), Math.round(top + 10)); - let onScrollIndex1 = await driver.findComponent(ON.text('onScrollIndex')); + let onScrollIndex1 = await driver.findComponent(BY.key('onScrollIndex')); let text1 = await onScrollIndex1.getText(); - expect(text1).assertEqual('onScrollIndex:10'); + expect(text1).assertEqual('onScrollIndex:2'); await CommonFunc.sleep(1000); await driver.swipe(Math.round((right - left) / 2), Math.round(bottom - 10), Math.round((right - left) / 2), Math.round(top + 10)); await driver.swipe(Math.round((right - left) / 2), Math.round(bottom - 10), Math.round((right - left) / 2), Math.round(top + 10)); - let onScrollIndex2 = await driver.findComponent(ON.text('onScrollIndex')); + let onScrollIndex2 = await driver.findComponent(BY.key('onScrollIndex')); let text2 = await onScrollIndex2.getText(); - expect(text2).assertEqual('onScrollIndex:10'); + expect(text2).assertEqual('onScrollIndex:2'); // Verify common attribute click event - let button = await driver.findComponent(ON.text('button')); + let button = await driver.findComponent(BY.key('button')); await button.click(); await CommonFunc.sleep(1000); let strJson = getInspectorByKey('button'); @@ -196,9 +220,13 @@ export default function GridJsunit() { it('GridJsunit_0600', 0, async function (done) { // Verify that rowsTemplate and columnsTemplate are set at the same time console.info('[GridJsunit_0600] START'); - globalThis.value.message.notify({name:'columnsTemplate',value:'1fr 1fr'}) + globalThis.value.message.notify({ + name: 'columnsTemplate', value: '1fr 1fr' + }) await CommonFunc.sleep(1000); - globalThis.value.message.notify({name:'rowsTemplate',value:'1fr 1fr'}) + globalThis.value.message.notify({ + name: 'rowsTemplate', value: '1fr 1fr' + }) await CommonFunc.sleep(1000); let gridItem1 = CommonFunc.getComponentRect('0'); let bottom = gridItem1.bottom @@ -218,9 +246,13 @@ export default function GridJsunit() { it('GridJsunit_0700', 0, async function (done) { // Verify only setting columnsTemplate of Grid component console.info('[GridJsunit_0700] START'); - globalThis.value.message.notify({name:'columnsTemplate',value:'1fr 1fr 1fr 1fr'}) + globalThis.value.message.notify({ + name: 'columnsTemplate', value: '1fr 1fr 1fr 1fr' + }) await CommonFunc.sleep(1000); - globalThis.value.message.notify({name:'rowsTemplate',value:''}) + globalThis.value.message.notify({ + name: 'rowsTemplate', value: '' + }) await CommonFunc.sleep(1000); let gridItem1 = CommonFunc.getComponentRect('0'); let left1 = gridItem1.left @@ -234,9 +266,13 @@ export default function GridJsunit() { it('GridJsunit_0800', 0, async function (done) { // Verify only setting rowsTemplate of grid component console.info('[GridJsunit_0800] START'); - globalThis.value.message.notify({name:'columnsTemplate',value:''}) + globalThis.value.message.notify({ + name: 'columnsTemplate', value: '' + }) await CommonFunc.sleep(1000); - globalThis.value.message.notify({name:'rowsTemplate',value:'1fr 1fr 1fr 1fr'}) + globalThis.value.message.notify({ + name: 'rowsTemplate', value: '1fr 1fr 1fr 1fr' + }) await CommonFunc.sleep(1000); let driver = await UiDriver.create() let gridItem1 = CommonFunc.getComponentRect('0'); @@ -251,9 +287,13 @@ export default function GridJsunit() { it('GridJsunit_0900', 0, async function (done) { // Verify Neither rowsTemplate nor columnsTemplate is set console.info('[GridJsunit_0900] START'); - globalThis.value.message.notify({name:'columnsTemplate',value:''}) + globalThis.value.message.notify({ + name: 'columnsTemplate', value: '' + }) await CommonFunc.sleep(1000); - globalThis.value.message.notify({name:'rowsTemplate',value:''}) + globalThis.value.message.notify({ + name: 'rowsTemplate', value: '' + }) await CommonFunc.sleep(1000); // Verify grid componentcan cannot scroll let driver = await UiDriver.create() @@ -263,70 +303,5 @@ export default function GridJsunit() { console.info('[GridJsunit_0900] END'); done(); }); - it('GridJsunit_1000', 0, async function (done) { - // Verify Neither rowsTemplate nor columnsTemplate is set - console.info('[GridJsunit_1000] START'); - - let grid2 = CommonFunc.getComponentRect('grid2'); - let top = grid2.top - let bottom = grid2.bottom - let left = grid2.left - let right = grid2.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); - - let onReachStartText = await driver.findComponent(BY.key('onReachStartText')); - let text3 = await onReachStartText.getText(); - console.info('[GridJsunit_1000] onReachStartText' + text3); - expect(text3).assertEqual('onReachStart:succ'); - await CommonFunc.sleep(200); - - let onScrollText = await driver.findComponent(BY.key('onScrollText')); - let text4 = await onScrollText.getText(); - console.info('[GridJsunit_1000] onScrollText' + text4); - expect(text4).assertEqual('onScroll:succ'); - - let onScrollIndexText = await driver.findComponent(BY.key('onScrollIndexText')); - let text5 = await onScrollIndexText.getText(); - console.info('[GridJsunit_1000] onScrollIndexText' + text5); - expect(text5).assertEqual('onScrollIndex:succ'); - - let onScrollStartText = await driver.findComponent(BY.key('onScrollStartText')); - let text6 = await onScrollStartText.getText(); - console.info('[GridJsunit_1000] onScrollStartText' + text6); - expect(text6).assertEqual('onScrollStart:succ'); - await CommonFunc.sleep(200); - - let onScrollStopText = await driver.findComponent(BY.key('onScrollStopText')); - let text7 = await onScrollStopText.getText(); - console.info('[GridJsunit_1000] onScrollStopText' + text7); - expect(text7).assertEqual('onScrollStop:succ'); - await CommonFunc.sleep(200); - - let onScrollFrameBeginText = await driver.findComponent(BY.key('onScrollFrameBeginText')); - let text8 = await onScrollFrameBeginText.getText(); - console.info('[GridJsunit_1000] nScrollFrameBeginText ' + text8); - expect(text8).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 onReachEndText = await driver.findComponent(BY.key('onReachEndText')); - let text9= await onReachEndText.getText(); - console.info("[GridJsunit_1000] onReachEndText: " + text9); - expect(text9).assertEqual('onReachEnd:succ'); - await CommonFunc.sleep(1000); - - console.info('[GridJsunit_1000] END'); - done(); - }); }) } diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets index 9e4069a9a..b8c86d9da 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets @@ -70,6 +70,7 @@ import TextPickerDialogJsunit from './TextPickerDialogJsunit.test.ets'; import TimePickerDialogJsunit from './TimePickerDialogJsunit.test.ets'; import OverlayJsunit from './OverlayJsunit.test.ets'; import PanelJsunit from './PanelJsunit.test.ets'; +import GridCallbackJsunit from './GridCallbackJsunit.test.ets'; export default function testsuite() { DialogJsunit(); @@ -129,4 +130,5 @@ export default function testsuite() { TimePickerDialogJsunit(); OverlayJsunit(); PanelJsunit(); + GridCallbackJsunit(); } \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json index c55b83910..7ecbe8046 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json @@ -101,6 +101,8 @@ "MainAbility/pages/TextPickerDialogOptions", "MainAbility/pages/TimePickerDialogOptions", "MainAbility/pages/overlay", - "MainAbility/pages/Panel" + "MainAbility/pages/Panel", + "MainAbility/pages/GridCallbackPage" + ] } \ No newline at end of file -- GitLab