提交 75114d6c 编写于 作者: W wangguan

添加Grid回调函数相关的XTS

Signed-off-by: Nwangguan <wangguan27@huawei.com>
上级 da449947
...@@ -40,6 +40,13 @@ struct GridPage { ...@@ -40,6 +40,13 @@ struct GridPage {
@State onItemDragMove: string = 'onItemDragMove' @State onItemDragMove: string = 'onItemDragMove'
@State onItemDragLeave: string = 'onItemDragLeave' @State onItemDragLeave: string = 'onItemDragLeave'
@State onItemDrop: string = 'onItemDrop' @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 myKey: number = 0 @State myKey: number = 0
scroller: Scroller = new Scroller() scroller: Scroller = new Scroller()
messageManager:MessageManager = new MessageManager() messageManager:MessageManager = new MessageManager()
...@@ -144,7 +151,8 @@ struct GridPage { ...@@ -144,7 +151,8 @@ struct GridPage {
.width('90%') .width('90%')
.key('grid1') .key('grid1')
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.height(200) .height(150)
.edgeEffect(EdgeEffect.Spring)
.onItemDragStart((event: ItemDragInfo, itemIndex: number) => { .onItemDragStart((event: ItemDragInfo, itemIndex: number) => {
this.onItemDragStart = 'onItemDragStart:succ' this.onItemDragStart = 'onItemDragStart:succ'
console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y) console.info('DragInfo_x: ' + event.x + ' DragInfo_y: ' + event.y)
...@@ -195,7 +203,36 @@ struct GridPage { ...@@ -195,7 +203,36 @@ struct GridPage {
}) })
.width('90%') .width('90%')
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.height(250) .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) Button(this.buttonName)
.key('button') .key('button')
...@@ -209,6 +246,22 @@ struct GridPage { ...@@ -209,6 +246,22 @@ struct GridPage {
Text(this.onItemDragMove).key('onItemDragMove') Text(this.onItemDragMove).key('onItemDragMove')
Text(this.onItemDragLeave).key('onItemDragLeave') Text(this.onItemDragLeave).key('onItemDragLeave')
Text(this.onItemDrop).key('onItemDrop') 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')
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
} }
} }
...@@ -146,21 +146,22 @@ export default function GridJsunit() { ...@@ -146,21 +146,22 @@ export default function GridJsunit() {
let bottom = grid2.bottom let bottom = grid2.bottom
let left = grid2.left let left = grid2.left
let right = grid2.right let right = grid2.right
let driver = await UiDriver.create() let driver = await Driver.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));
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(BY.key('onScrollIndex')); let onScrollIndex1 = await driver.findComponent(ON.text('onScrollIndex'));
let text1 = await onScrollIndex1.getText(); let text1 = await onScrollIndex1.getText();
expect(text1).assertEqual('onScrollIndex:10'); expect(text1).assertEqual('onScrollIndex:10');
await CommonFunc.sleep(1000); 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));
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(BY.key('onScrollIndex')); let onScrollIndex2 = await driver.findComponent(ON.text('onScrollIndex'));
let text2 = await onScrollIndex2.getText(); let text2 = await onScrollIndex2.getText();
expect(text2).assertEqual('onScrollIndex:10'); expect(text2).assertEqual('onScrollIndex:10');
// Verify common attribute click event // Verify common attribute click event
let button = await driver.findComponent(BY.key('button')); let button = await driver.findComponent(ON.text('button'));
await button.click(); await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('button'); let strJson = getInspectorByKey('button');
...@@ -262,5 +263,70 @@ export default function GridJsunit() { ...@@ -262,5 +263,70 @@ export default function GridJsunit() {
console.info('[GridJsunit_0900] END'); console.info('[GridJsunit_0900] END');
done(); 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();
});
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册