diff --git a/pages/API/action-sheet/action-sheet.test.js b/pages/API/action-sheet/action-sheet.test.js index ff37aa33f6aed5d431cfdac18509034e2c673573..3b60dd345e9279c283d4125ee0b7adda7ead15a2 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 01f2012bd9a70685f2ed7bf7a3dd30d423690464..3d8a0add841e024928b1296176d165073877ee6c 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 05c94e65e53574e07c3b91b3d6141ad010b17bd6..528d3587c5fd198919e94449d68d4d55c11e8f18 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 8ad3f8a08a7e70fb9596bf284b2e499990fec8c4..10a952e84ed079b584e0c4fabcc350925a16e7ac 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: "默认",