diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/lazyForEach.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/lazyForEach.ets index 76da45be35946c49d3131f86d1644077462f10d8..0d76cdcf4a197d06562793fba7e5a32e3b2b9caa 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/lazyForEach.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/lazyForEach.ets @@ -67,7 +67,7 @@ class BasicDataSource implements IDataSource { } class MyDataSource extends BasicDataSource { - private dataArray: string[] = ['/path/image0', '/path/image1', '/path/image2', '/path/image3'] + private dataArray: string[] = ['/path/image0'] public totalCount(): number { return this.dataArray.length diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridColoffsetPage.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridColoffsetPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..b25eb4be67b32c517be556755918af0d6f61bf3e --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/GridColoffsetPage.ets @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2023 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 GridColOffSetExample { + @State bgColors: Color[] = [Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Pink, Color.Grey, Color.Blue, Color.Brown] + @State currentBp: string = 'unknown' + @State gridColoffsetValue : number = -3; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('GridColOffset onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'gridColoffset') { + this.gridColoffsetValue = message.value + } + } + this.messageManager.registerCallback(callback) + + } + build() { + Column() { + GridRow({ + columns: 5, + gutter: { x: 5, y: 10 }, + breakpoints: { value: ["400vp", "600vp", "800vp"], + reference: BreakpointsReference.WindowSize }, + direction: GridRowDirection.Row + }) { + ForEach(this.bgColors, (color,index) => { + GridCol({ span: { xs: 1, sm: 2, md: 3, lg: 4 } }) { + Row().width("100%").height("20vp") + }.borderColor(color).borderWidth(2).gridColOffset(this.gridColoffsetValue).key('keykey'+index) + }) + }.width("100%").height("100%") + + .onBreakpointChange((breakpoint) => { + this.currentBp = breakpoint + }) + }.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200) + .border({ color: '#880606', width: 2 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridColoffsetJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridColoffsetJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..52c80ef0e9a526f8fc47ab82384ec6678dce020a --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/GridColoffsetJsunit.test.ets @@ -0,0 +1,71 @@ +/** + * 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 GridColOffsetJsunit() { + describe('GridColOffsetJsunit', function () { + beforeEach(async function (done) { + console.info("GridColOffsetJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/GridColoffsetPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get GridColOffsetJsunit state pages: " + JSON.stringify(pages)); + if (!("GridColoffsetPage" == pages.name)) { + console.info("get GridColOffsetJsunit state pages.name: " + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push GridColOffsetJsunit success: " + JSON.stringify(result)); + } + } catch (err) { + console.error("push GridColOffsetJsunit page error: " + err); + expect().assertFail(); + } + done(); + }); + + it('GridColOffsetJsunit_0100', 0, async function (done) { + // Get the information of the GridCol component + let strJson = getInspectorByKey('keykey2'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('GridCol'); + console.info("[GridColOffsetJsunit_0100] component strJson:" + JSON.stringify(obj.$attrs.gridColOffset)); + expect(obj.$attrs.gridColOffset).assertEqual("0"); + done(); + }); + + it('GridColOffsetJsunit_0200', 0, async function (done) { + // Modify the properties of component GridCol + console.info('[GridColOffsetJsunit_0200] START'); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'gridColoffset',value:2}); + await CommonFunc.sleep(200); + let strJson = getInspectorByKey('keykey2'); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('GridCol'); + console.info("[GridColOffsetJsunit_0100] component strJson:" + JSON.stringify(obj.$attrs.gridColOffset)); + expect(obj.$attrs.gridColOffset).assertEqual("2"); + 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 a5cc896870f95dcac8d98983ff74d283ec4a7ce3..85d546a9e9824a6cdc284402b040d1f4fc9868f6 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 @@ -55,6 +55,7 @@ import ToggleJsunit from './ToggleJsunit.test.ets'; import NavDestinationJsunit from './NavDestinationJsunit.test.ets'; import GridItemJsunit from './GridItemJsunit.test.ets'; import NavigationJsunit from './NavigationJsunit.test.ets'; +import GridColOffsetJsunit from './GridColoffsetJsunit.test.ets'; export default function testsuite() { blankJsunit(); @@ -99,4 +100,5 @@ export default function testsuite() { NavDestinationJsunit(); GridItemJsunit(); NavigationJsunit(); + GridColOffsetJsunit(); } \ 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 30d60bbdfe260f5b0873285090811e520093aaf1..a77ea7508f5955ba208a062993c17e0339536951 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 @@ -45,6 +45,7 @@ "MainAbility/pages/TogglePage", "MainAbility/pages/NavDestinationPage", "MainAbility/pages/NavigationPage", - "MainAbility/pages/GridItemPage" + "MainAbility/pages/GridItemPage", + "MainAbility/pages/GridColoffsetPage" ] } \ No newline at end of file