diff --git a/pages/component/video/video-format.uvue b/pages/component/video/video-format.uvue index 42dfc27c53a7e8691078c32426473a820d5b3574..7dc2cf864a1ffdff7ff3536ba409f26e6bc68e7c 100644 --- a/pages/component/video/video-format.uvue +++ b/pages/component/video/video-format.uvue @@ -88,6 +88,7 @@ src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.avi' } ] as Array, + // 自动化测试 isError: false } }, diff --git a/pages/component/video/video.test.js b/pages/component/video/video.test.js index 33b22d2ce2bbf96449f929fcc57bfba9b1650879..39f57dc8abbfb506aa2c3bd43c5aebc3a4fee88e 100644 --- a/pages/component/video/video.test.js +++ b/pages/component/video/video.test.js @@ -1,5 +1,3 @@ -// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ -jest.setTimeout(20000); describe('component-native-video', () => { if(process.env.uniTestPlatformInfo.startsWith('web')){ // TODO: web 端暂不支持测试 @@ -9,47 +7,25 @@ describe('component-native-video', () => { return } let page; - beforeAll(async () => { page = await program.reLaunch('/pages/component/video/video'); - await page.waitFor('video'); - await page.waitFor(300) + await page.waitFor(1000); }); it('test API', async () => { + expect(await page.data('isError')).toBe(false); // play await page.callMethod('play'); - await page.waitFor(async () => { - return (await page.data('isPlaying')) == true; - }); - // requestFullScreen - // await page.callMethod('requestFullScreen', null); - // await page.waitFor(async () => { - // return (await page.data('isFullScreen')) == true; - // }); - // exitFullScreen - // await page.callMethod('exitFullScreen'); - // await page.waitFor(async () => { - // return (await page.data('isFullScreen')) == false; - // }); + await page.waitFor(100); + expect(await page.data('isPlaying')).toBe(true); // pause await page.callMethod('pause'); - await page.waitFor(async () => { - return (await page.data('isPause')) == true; - }); - // await page.callMethod('play'); - // await page.waitFor(async () => { - // return (await page.data('isPlaying')) == true; - // }); - // stop - // await page.callMethod('stop'); - // await page.waitFor(async () => { - // return (await page.data('isPause')) == true; - // }); + await page.waitFor(100); + expect(await page.data('isPause')).toBe(true); }); it('test format', async () => { - page = await program.reLaunch('/pages/component/video/video-format'); + page = await program.navigateTo('/pages/component/video/video-format'); await page.waitFor(1000); expect(await page.data('isError')).toBe(false); }); diff --git a/pages/component/video/video.uvue b/pages/component/video/video.uvue index 895f3b66540ff40e128da5e4acebb21279454a06..eeb3b3e8276edddf9ebad854e0aaa51519ddf15b 100644 --- a/pages/component/video/video.uvue +++ b/pages/component/video/video.uvue @@ -219,7 +219,7 @@ // 自动化测试 isPlaying: false, isPause: false, - isFullScreen: false + isError: false } }, onLoad() { @@ -391,13 +391,13 @@ }, onFullScreenChange: function (res : UniVideoFullScreenChangeEvent) { console.log(res.type + " -> " + JSON.stringify(res.detail)); - this.isFullScreen = !this.isFullScreen; }, onWaiting: function (res : UniEvent) { console.log(res.type); }, onError: function (res : UniVideoErrorEvent) { console.log(res.type + " -> " + JSON.stringify(res.detail)); + this.isError = true; }, onProgress: function (res : UniVideoProgressEvent) { console.log(res.type + " -> " + JSON.stringify(res.detail));