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

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

上级 7b440e89
...@@ -32,12 +32,49 @@ describe('component-native-web-view', () => { ...@@ -32,12 +32,49 @@ describe('component-native-web-view', () => {
}); });
await page.waitFor(100); await page.waitFor(100);
await page.callMethod('reload'); await page.callMethod('reload');
});
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 () => { it('test event loading load', async () => {
await page.setData({
autoTest: true
});
await page.callMethod('reload'); await page.callMethod('reload');
await page.waitFor(100); await page.waitFor(100);
expect(await page.data('eventLoading')).toEqual({ expect(await page.data('eventLoading')).toEqual({
......
<template> <template>
<scroll-view class="uni-flex-item"> <scroll-view class="uni-flex-item">
<web-view id="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles" <web-view id="web-view" class="uni-flex-item" :style="{ 'pointer-events': pointerEvents }" :src="src"
:horizontalScrollBarAccess="horizontalScrollBarAccess" :verticalScrollBarAccess="verticalScrollBarAccess" :webview-styles="webview_styles" :horizontalScrollBarAccess="horizontalScrollBarAccess"
@message="message" @error="error" @loading="loading" @load="load" @download="download"> :verticalScrollBarAccess="verticalScrollBarAccess" @message="message" @error="error" @loading="loading"
@load="load" @download="download" @touchstart="touchstart" @tap="tap">
</web-view> </web-view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
...@@ -55,7 +56,10 @@ ...@@ -55,7 +56,10 @@
autoTest: false, autoTest: false,
eventLoading: null as UTSJSONObject | null, eventLoading: null as UTSJSONObject | null,
eventLoad: 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() { onReady() {
...@@ -137,6 +141,26 @@ ...@@ -137,6 +141,26 @@
}, },
changeVerticalScrollBarAccess(event : UniSwitchChangeEvent) { changeVerticalScrollBarAccess(event : UniSwitchChangeEvent) {
this.verticalScrollBarAccess = event.detail.value; 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.
先完成此消息的编辑!
想要评论请 注册