未验证 提交 6e682495 编写于 作者: O openharmony_ci 提交者: Gitee

!9434 【ACE子系统】新增基础组件用例

Merge pull request !9434 from 王旭鹏/cherry-pick-1690015846
......@@ -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
......
/**
* 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
/**
* 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();
});
})
}
......@@ -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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册