From 584e95180316ece713e31f7e7f76c617450e9830 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Wed, 20 Mar 2024 16:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0video=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/video/video-format.uvue | 1 + pages/component/video/video.test.js | 38 +++++-------------------- pages/component/video/video.uvue | 4 +-- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/pages/component/video/video-format.uvue b/pages/component/video/video-format.uvue index 42dfc27c..7dc2cf86 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 33b22d2c..39f57dc8 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 895f3b66..eeb3b3e8 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)); -- GitLab