Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
b92ef6a3
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6007
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b92ef6a3
编写于
6月 27, 2024
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新web-view自动化测试用例
上级
7b440e89
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
7 deletion
+68
-7
pages/component/web-view/web-view.test.js
pages/component/web-view/web-view.test.js
+40
-3
pages/component/web-view/web-view.uvue
pages/component/web-view/web-view.uvue
+28
-4
未找到文件。
pages/component/web-view/web-view.test.js
浏览文件 @
b92ef6a3
...
@@ -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
({
...
...
pages/component/web-view/web-view.uvue
浏览文件 @
b92ef6a3
<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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录