提交 b92ef6a3 编写于 作者: DCloud-yinjiacheng's avatar DCloud-yinjiacheng

更新web-view自动化测试用例

上级 7b440e89
......@@ -34,10 +34,47 @@ describe('component-native-web-view', () => {
await page.callMethod('reload');
});
it('test event loading load', async () => {
it('test touch event', async () => {
await page.setData({
autoTest: true
});
const info = await page.callMethod('getWindowInfo');
await program.tap({
x: 1,
y: (info.statusBarHeight + 44) * info.pixelRatio + 1
});
await page.waitFor(100);
expect(await page.data('eventTouchstart')).toEqual({
clientX: 1,
clientY: 1
});
expect(await page.data('eventTap')).toEqual({
clientX: 1,
clientY: 1
});
await page.setData({
pointerEvents: 'none'
});
await page.waitFor(100);
await program.tap({
x: 10,
y: (info.statusBarHeight + 44) * info.pixelRatio + 10
});
await page.waitFor(100);
expect(await page.data('eventTouchstart')).toEqual({
clientX: 1,
clientY: 1
});
expect(await page.data('eventTap')).toEqual({
clientX: 1,
clientY: 1
});
await page.setData({
pointerEvents: 'auto'
});
});
it('test event loading load', async () => {
await page.callMethod('reload');
await page.waitFor(100);
expect(await page.data('eventLoading')).toEqual({
......
<template>
<scroll-view class="uni-flex-item">
<web-view id="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles"
:horizontalScrollBarAccess="horizontalScrollBarAccess" :verticalScrollBarAccess="verticalScrollBarAccess"
@message="message" @error="error" @loading="loading" @load="load" @download="download">
<web-view id="web-view" class="uni-flex-item" :style="{ 'pointer-events': pointerEvents }" :src="src"
:webview-styles="webview_styles" :horizontalScrollBarAccess="horizontalScrollBarAccess"
:verticalScrollBarAccess="verticalScrollBarAccess" @message="message" @error="error" @loading="loading"
@load="load" @download="download" @touchstart="touchstart" @tap="tap">
</web-view>
<!-- #ifdef APP -->
<view class="uni-padding-wrap uni-common-mt">
......@@ -55,7 +56,10 @@
autoTest: false,
eventLoading: null as UTSJSONObject | null,
eventLoad: null as UTSJSONObject | null,
eventError: null as UTSJSONObject | null
eventError: null as UTSJSONObject | null,
eventTouchstart: null as UTSJSONObject | null,
eventTap: null as UTSJSONObject | null,
pointerEvents: 'auto'
}
},
onReady() {
......@@ -137,6 +141,26 @@
},
changeVerticalScrollBarAccess(event : UniSwitchChangeEvent) {
this.verticalScrollBarAccess = event.detail.value;
},
// 自动化测试
touchstart(event : UniTouchEvent) {
if (this.autoTest) {
this.eventTouchstart = {
clientX: Math.ceil(event.touches[0].clientX),
clientY: Math.ceil(event.touches[0].clientY)
};
}
},
tap(event : UniPointerEvent) {
if (this.autoTest) {
this.eventTap = {
clientX: Math.ceil(event.clientX),
clientY: Math.ceil(event.clientY)
};
}
},
getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册