From 37761836a818623945997effc1e91fd3f6c6d88b Mon Sep 17 00:00:00 2001 From: duqingquan Date: Sat, 2 Mar 2024 20:00:11 +0800 Subject: [PATCH] =?UTF-8?q?prompt=20=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E6=B5=8B=E8=AF=95=E6=88=AA=E5=9B=BE=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E6=9F=90=E4=BA=9B=E5=9E=8B=E5=8F=B7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8C=BA=E5=9F=9F=E5=BD=B1=E5=93=8D=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/action-sheet/action-sheet.test.js | 26 +++---- pages/API/modal/modal.test.js | 78 ++++++++++++++------- pages/API/toast/toast.test.js | 32 +++++++++ pages/API/toast/toast.uvue | 4 ++ 4 files changed, 103 insertions(+), 37 deletions(-) diff --git a/pages/API/action-sheet/action-sheet.test.js b/pages/API/action-sheet/action-sheet.test.js index ff37aa33..3b60dd34 100644 --- a/pages/API/action-sheet/action-sheet.test.js +++ b/pages/API/action-sheet/action-sheet.test.js @@ -23,7 +23,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -64,7 +64,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -106,7 +106,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -147,7 +147,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -188,7 +188,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -229,7 +229,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -273,7 +273,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -314,7 +314,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -355,7 +355,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -396,7 +396,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -438,7 +438,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -479,7 +479,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); @@ -520,7 +520,7 @@ describe('API-loading', () => { area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 100, width:windowWidth }, }); diff --git a/pages/API/modal/modal.test.js b/pages/API/modal/modal.test.js index 01f2012b..3d8a0add 100644 --- a/pages/API/modal/modal.test.js +++ b/pages/API/modal/modal.test.js @@ -16,13 +16,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -54,13 +56,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -93,13 +97,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -132,13 +138,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -171,13 +179,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -210,13 +220,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -249,13 +260,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -288,13 +300,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -327,13 +340,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -366,13 +380,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -405,13 +421,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -444,13 +462,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -483,13 +503,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -522,13 +544,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -561,13 +585,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -601,13 +627,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -640,13 +667,15 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -679,13 +708,14 @@ describe('API-loading', () => { if (isAndroid) { const res = await page.callMethod('jest_getWindowInfo') const windowHeight = res.windowHeight * res.pixelRatio; - + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, - height: windowHeight, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); diff --git a/pages/API/toast/toast.test.js b/pages/API/toast/toast.test.js index 05c94e65..528d3587 100644 --- a/pages/API/toast/toast.test.js +++ b/pages/API/toast/toast.test.js @@ -5,6 +5,7 @@ describe('API-toast', () => { let page; const isAndroid = process.env.UNI_OS_NAME === "android"; + beforeAll(async () => { page = await program.reLaunch('/pages/API/toast/toast') await page.waitFor(600); @@ -13,12 +14,21 @@ describe('API-toast', () => { it("onload-toast-test", async () => { + + if (isAndroid) { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -38,11 +48,18 @@ describe('API-toast', () => { await btnToastDefaultButton.tap() await page.waitFor(200) if (isAndroid) { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -62,11 +79,16 @@ describe('API-toast', () => { await btnToastDurationButton.tap() await page.waitFor(2000) if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -84,11 +106,16 @@ describe('API-toast', () => { await btnToastErrorIconButton.tap() await page.waitFor(200) if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); @@ -112,11 +139,16 @@ describe('API-toast', () => { await page.waitFor(200) if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; const image = await program.screenshot({ adb: true, area: { x: 0, y: 200, + height: windowHeight - 200, + width:windowWidth }, }); expect(image).toMatchImageSnapshot(); diff --git a/pages/API/toast/toast.uvue b/pages/API/toast/toast.uvue index 8ad3f8a0..10a952e8 100644 --- a/pages/API/toast/toast.uvue +++ b/pages/API/toast/toast.uvue @@ -37,6 +37,10 @@ }, 2000); }, methods: { + //自动化测试例专用 + jest_getWindowInfo() : GetWindowInfoResult { + return uni.getWindowInfo(); + }, toast1Tap: function () { uni.showToast({ title: "默认", -- GitLab