提交 a36e40fe 编写于 作者: DCloud-yinjiacheng's avatar DCloud-yinjiacheng 提交者: 雪洛

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

上级 6637c2cd
......@@ -75,9 +75,7 @@ describe('component-native-image', () => {
autoTest: true,
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png'
});
await page.waitFor(async () => {
return await page.data('eventLoad');
});
await page.waitFor(300);
expect(await page.data('eventLoad')).toEqual({
tagName: 'IMAGE',
type: 'load',
......@@ -90,9 +88,7 @@ describe('component-native-image', () => {
await page.setData({
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/404.png'
});
await page.waitFor(async () => {
return await page.data('eventError');
});
await page.waitFor(300);
expect(await page.data('eventError')).toEqual({
tagName: 'IMAGE',
type: 'error'
......
......@@ -52,17 +52,13 @@ describe('component-native-video', () => {
autoTest: true
});
await page.callMethod('play');
await page.waitFor(async () => {
return await page.data('eventPlay');
});
await page.waitFor(100);
expect(await page.data('eventPlay')).toEqual({
tagName: 'VIDEO',
type: 'play'
});
await page.callMethod('pause');
await page.waitFor(async () => {
return await page.data('eventPause');
});
await page.waitFor(100);
expect(await page.data('eventPause')).toEqual({
tagName: 'VIDEO',
type: 'pause'
......@@ -75,38 +71,36 @@ describe('component-native-video', () => {
pos: 10
});
await page.callMethod('seek');
await page.waitFor(async () => {
return await page.data('eventWaiting');
});
await page.waitFor(100);
expect(await page.data('eventWaiting')).toEqual({
tagName: 'VIDEO',
type: 'waiting'
});
await page.waitFor(async () => {
return await page.data('eventProgress');
});
await page.waitFor(200);
expect(await page.data('eventProgress')).toEqual({
tagName: 'VIDEO',
type: 'progress',
buffered: 100
});
await page.waitFor(250);
expect(await page.data('eventTimeupdate')).toEqual({
tagName: 'VIDEO',
type: 'timeupdate',
currentTime: 10,
duration: 121
isBufferedValid: true
});
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (process.env.uniTestPlatformInfo.startsWith('android') && version > 5) {
await page.waitFor(200);
expect(await page.data('eventTimeupdate')).toEqual({
tagName: 'VIDEO',
type: 'timeupdate',
currentTime: 10,
duration: 121
});
}
});
it('test event fullscreenchange fullscreenclick controlstoggle', async () => {
if (process.env.uniTestPlatformInfo.startsWith('ios')) {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
return;
}
await page.callMethod('requestFullScreen');
await page.waitFor(async () => {
return await page.data('eventFullscreenchange');
});
await page.waitFor(500);
expect(await page.data('eventFullscreenchange')).toEqual({
tagName: 'VIDEO',
type: 'fullscreenchange',
......@@ -144,9 +138,7 @@ describe('component-native-video', () => {
pos: 120
});
await page.callMethod('seek');
await page.waitFor(async () => {
return await page.data('eventEnded');
});
await page.waitFor(2500);
expect(await page.data('eventEnded')).toEqual({
tagName: 'VIDEO',
type: 'ended'
......@@ -158,9 +150,7 @@ describe('component-native-video', () => {
await page.setData({
src: 'invalid url'
});
await page.waitFor(async () => {
return await page.data('eventError');
});
await page.waitFor(300);
expect(await page.data('eventError')).toEqual({
tagName: 'VIDEO',
type: 'error',
......
......@@ -447,7 +447,7 @@
this.eventProgress = {
"tagName": res.target?.tagName,
"type": res.type,
"buffered": res.detail.buffered
"isBufferedValid": res.detail.buffered > 0
};
}
},
......
......@@ -27,58 +27,58 @@ describe('component-native-web-view', () => {
autoTest: true
});
await page.callMethod('testEventDownload');
await page.waitFor(async () => {
return await page.data('eventDownload');
});
if (process.env.uniTestPlatformInfo.startsWith('ios')) {
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: `uni-app-x/${process.env.HX_Version.split('-')[0].split('.').slice(0, 2).join('.')}`,
contentDisposition: '',
mimetype: 'application/vnd.android.package-archive',
isContentLengthValid: true
});
return;
}
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (version > 8) {
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: `uni-app-x/${process.env.HX_Version.split('-')[0].split('.').slice(0, 2).join('.')}`,
contentDisposition: `attachment; filename="hello-uniappx.apk"; filename*=utf-8''hello-uniappx.apk`,
mimetype: 'application/vnd.android.package-archive',
isContentLengthValid: true
});
} else { // 低版本webview内核,部分属性无有效值
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: '',
contentDisposition: '',
mimetype: '',
isContentLengthValid: false
});
await page.waitFor(500);
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: `uni-app-x/${process.env.HX_Version.split('-')[0].split('.').slice(0, 2).join('.')}`,
contentDisposition: '',
mimetype: 'application/vnd.android.package-archive',
isContentLengthValid: true
});
return;
}
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (version > 8) {
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: `uni-app-x/${process.env.HX_Version.split('-')[0].split('.').slice(0, 2).join('.')}`,
contentDisposition: `attachment; filename="hello-uniappx.apk"; filename*=utf-8''hello-uniappx.apk`,
mimetype: 'application/vnd.android.package-archive',
isContentLengthValid: true
});
} else if (version > 6) { // 低版本webview内核,部分属性无有效值
expect(await page.data('eventDownload')).toEqual({
tagName: 'WEB-VIEW',
type: 'download',
url: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/pkg/hello-uniappx.apk',
userAgent: '',
contentDisposition: '',
mimetype: '',
isContentLengthValid: false
});
}
});
it('test event message', async () => {
await page.callMethod('testEventMessage');
await page.waitFor(async () => {
return await page.data('eventMessage');
});
expect(await page.data('eventMessage')).toEqual({
tagName: 'WEB-VIEW',
type: 'message',
data: [{
action: 'message'
}]
});
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (process.env.uniTestPlatformInfo.startsWith('android') && version > 6) {
await page.callMethod('testEventMessage');
await page.waitFor(200);
expect(await page.data('eventMessage')).toEqual({
tagName: 'WEB-VIEW',
type: 'message',
data: [{
action: 'message'
}]
});
}
await page.setData({
autoTest: false
});
......
......@@ -17,17 +17,13 @@ describe('component-native-web-view', () => {
autoTest: true
});
await page.callMethod('reload');
await page.waitFor(async () => {
return await page.data('eventLoading');
});
await page.waitFor(100);
expect(await page.data('eventLoading')).toEqual({
tagName: 'WEB-VIEW',
type: 'loading',
src: 'https://www.dcloud.io/'
});
await page.waitFor(async () => {
return await page.data('eventLoad');
});
await page.waitFor(1000);
expect(await page.data('eventLoad')).toEqual({
tagName: 'WEB-VIEW',
type: 'load',
......@@ -36,21 +32,23 @@ describe('component-native-web-view', () => {
});
it('test event error', async () => {
await page.setData({
src: 'https://www.dclou.io/uni-app-x'
});
await page.waitFor(async () => {
return await page.data('eventError');
});
expect(await page.data('eventError')).toEqual({
tagName: 'WEB-VIEW',
type: 'error',
errCode: 100002,
errMsg: 'page error',
url: 'https://www.dclou.io',
fullUrl: 'https://www.dclou.io/uni-app-x',
src: 'https://www.dclou.io/uni-app-x'
});
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (process.env.uniTestPlatformInfo.startsWith('android') && version > 5) {
await page.setData({
src: 'https://www.dclou.io/uni-app-x'
});
await page.waitFor(500);
expect(await page.data('eventError')).toEqual({
tagName: 'WEB-VIEW',
type: 'error',
errCode: 100002,
errMsg: 'page error',
url: 'https://www.dclou.io',
fullUrl: 'https://www.dclou.io/uni-app-x',
src: 'https://www.dclou.io/uni-app-x'
});
}
await page.setData({
autoTest: false
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册