From d72aa828ac471816ebd27e578382791203bf6dcc Mon Sep 17 00:00:00 2001 From: lizhongyi Date: Tue, 2 Jul 2024 18:14:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/image/image.test.js | 29 ++++++++++--- pages/component/list-view/list-view.test.js | 10 ++--- pages/component/video/video.test.js | 39 +++++++++++++---- .../web-view-local/web-view-local.test.js | 20 ++++----- pages/component/web-view/web-view.test.js | 43 +++++++++++++------ 5 files changed, 98 insertions(+), 43 deletions(-) diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js index 567a981c..62eb7844 100644 --- a/pages/component/image/image.test.js +++ b/pages/component/image/image.test.js @@ -2,7 +2,7 @@ describe('component-native-image', () => { let page; - + async function getWindowInfo() { const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info') await windowInfoPage.waitFor(600); @@ -10,7 +10,7 @@ describe('component-native-image', () => { } const screenshotParams = { fullPage: true } let windowInfo - + beforeAll(async () => { if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) { screenshotParams.fullPage = false @@ -24,7 +24,7 @@ describe('component-native-image', () => { } screenshotParams.offsetY = offsetY } - + page = await program.reLaunch('/pages/component/image/image'); await page.waitFor(600); }); @@ -76,6 +76,14 @@ describe('component-native-image', () => { imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png' }); await page.waitFor(1000); + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventLoad')).toEqual({ + type: 'load', + width: 10, + height: 10 + }); + return + } expect(await page.data('eventLoad')).toEqual({ tagName: 'IMAGE', type: 'load', @@ -89,10 +97,17 @@ describe('component-native-image', () => { imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/404.png' }); await page.waitFor(500); - expect(await page.data('eventError')).toEqual({ - tagName: 'IMAGE', - type: 'error' - }); + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventError')).toEqual({ + type: 'error' + }); + }else { + expect(await page.data('eventError')).toEqual({ + tagName: 'IMAGE', + type: 'error' + }); + } + await page.setData({ autoTest: false }); diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js index 2b22c801..2dd804b2 100644 --- a/pages/component/list-view/list-view.test.js +++ b/pages/component/list-view/list-view.test.js @@ -71,12 +71,16 @@ describe('component-native-list-view', () => { return } + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + return + } + it('Event scrollend-滚动结束时触发',async()=>{ // 仅App端支持,向上滑动页面 await program.swipe({ startPoint: { x: 100, y: 300 }, endPoint: { x: 100, y: 100 }, - duration: 1000 + duration: 100 }) await page.waitFor(600) const endDetail = await page.data('scrollEndDetailTest') @@ -89,10 +93,6 @@ describe('component-native-list-view', () => { expect(endDetail.scrollWidth).toBeGreaterThan(0) }) - if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { - return - } - //检测竖向可滚动区域 it('check_scroll_height', async () => { await page.callMethod('change_scroll_y_boolean', true) diff --git a/pages/component/video/video.test.js b/pages/component/video/video.test.js index 1b9eeeaa..91ab6f2a 100644 --- a/pages/component/video/video.test.js +++ b/pages/component/video/video.test.js @@ -53,20 +53,37 @@ describe('component-native-video', () => { }); await page.callMethod('play'); await page.waitFor(100); - expect(await page.data('eventPlay')).toEqual({ - tagName: 'VIDEO', - type: 'play' - }); + if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventPlay')).toEqual({ + type: 'play' + }); + }else { + expect(await page.data('eventPlay')).toEqual({ + tagName: 'VIDEO', + type: 'play' + }); + } + await page.callMethod('pause'); await page.waitFor(100); - expect(await page.data('eventPause')).toEqual({ - tagName: 'VIDEO', - type: 'pause' - }); + if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventPause')).toEqual({ + type: 'pause' + }); + }else { + expect(await page.data('eventPause')).toEqual({ + tagName: 'VIDEO', + type: 'pause' + }); + } + await page.callMethod('play'); }); it('test event waiting progress timeupdate', async () => { + if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + return + } await page.setData({ pos: 10 }); @@ -140,6 +157,9 @@ describe('component-native-video', () => { }); it('test event ended', async () => { + if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + return + } await page.setData({ pos: 120 }); @@ -152,6 +172,9 @@ describe('component-native-video', () => { }); it('test event error', async () => { + if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + return + } const oldSrc = await page.data('src'); await page.setData({ src: 'invalid url' diff --git a/pages/component/web-view-local/web-view-local.test.js b/pages/component/web-view-local/web-view-local.test.js index 4570a492..16dc2b17 100644 --- a/pages/component/web-view-local/web-view-local.test.js +++ b/pages/component/web-view-local/web-view-local.test.js @@ -29,15 +29,15 @@ describe('component-native-web-view', () => { await page.callMethod('testEventDownload'); 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 - }); + // 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(' '); @@ -89,4 +89,4 @@ describe('component-native-web-view', () => { expect(1).toBe(1) }) } -}); \ No newline at end of file +}); diff --git a/pages/component/web-view/web-view.test.js b/pages/component/web-view/web-view.test.js index a6e400f7..b69cdaf8 100644 --- a/pages/component/web-view/web-view.test.js +++ b/pages/component/web-view/web-view.test.js @@ -76,18 +76,35 @@ describe('component-native-web-view', () => { it('test event loading load', async () => { await page.callMethod('reload'); - await page.waitFor(100); - expect(await page.data('eventLoading')).toEqual({ - tagName: 'WEB-VIEW', - type: 'loading', - src: 'https://www.dcloud.io/' - }); - await page.waitFor(1000); - expect(await page.data('eventLoad')).toEqual({ - tagName: 'WEB-VIEW', - type: 'load', - src: 'https://www.dcloud.io/' - }); + await page.waitFor(100); + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventLoading')).toEqual({ + type: 'loading', + src: 'https://www.dcloud.io/' + }); + }else { + expect(await page.data('eventLoading')).toEqual({ + tagName: 'WEB-VIEW', + type: 'loading', + src: 'https://www.dcloud.io/' + }); + } + + await page.waitFor(1000); + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + expect(await page.data('eventLoad')).toEqual({ + tagName: 'WEB-VIEW', + type: 'load', + src: 'https://www.dcloud.io/' + }); + }else { + expect(await page.data('eventLoad')).toEqual({ + tagName: 'WEB-VIEW', + type: 'load', + src: 'https://www.dcloud.io/' + }); + } + }); it('test event error', async () => { @@ -118,4 +135,4 @@ describe('component-native-web-view', () => { expect(1).toBe(1) }) } -}); \ No newline at end of file +}); -- GitLab