diff --git a/pages/CSS/overflow/overflow-visible-event.test.js b/pages/CSS/overflow/overflow-visible-event.test.js index 56404926e9143fe24c77dd296510bbcb2e767528..d8614d909b70ec73712a37dfddddced25a505c8e 100644 --- a/pages/CSS/overflow/overflow-visible-event.test.js +++ b/pages/CSS/overflow/overflow-visible-event.test.js @@ -1,14 +1,14 @@ // uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => { - if (!process.env.uniTestPlatformInfo.startsWith('android')) { + let isAndroid = process.env.uniTestPlatformInfo.startsWith('android') + if (!process.env.uniTestPlatformInfo.startsWith('android') && !process.env.uniTestPlatformInfo.toLowerCase().includes('ios')) { it('dummyTest', async () => { expect(1).toBe(1) }) return } - let page; let res; beforeAll(async () => { @@ -27,7 +27,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => { res = await page.callMethod('jest_getRect') const point_x = await page.data('jest_click_x'); const point_y = await page.data('jest_click_y'); - await program.adbCommand("input tap" + " " + point_x + " " + point_y) + if (isAndroid){ + await program.adbCommand("input tap" + " " + point_x + " " + point_y) + } else { + await program.tap({x: point_x, y: point_y}) + } await page.waitFor(500); res = await page.data('jest_result'); expect(res).toBe(true) @@ -41,7 +45,21 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => { const distance = 100; const destY = point_y + 100 const duration = 1000 - await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration) + if (isAndroid) { + await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration) + } else { + await program.swipe({ + startPoint: { + x: point_x, + y: point_y + }, + endPoint: { + x: point_x, + y: destY + }, + duration: duration + }) + } await page.waitFor(1500); await page.callMethod('jest_getParentRect') const currentParentTop = await page.data('jest_parent_top'); @@ -57,7 +75,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => { const point_x = await page.data('jest_click_x'); const point_y = await page.data('jest_click_y'); console.log("input tap" + " " + point_x + " " + point_y); - await program.adbCommand("input tap" + " " + point_x + " " + point_y) + if (isAndroid) { + await program.adbCommand("input tap" + " " + point_x + " " + point_y) + } else { + await program.tap({x: point_x, y: point_y}) + } await page.waitFor(500); res = await page.data('jest_result'); expect(res).toBe(true) @@ -69,7 +91,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => { const point_x = await page.data('jest_click_x'); const point_y = await page.data('jest_click_y'); console.log("input tap" + " " + point_x + " " + point_y); - await program.adbCommand("input tap" + " " + point_x + " " + point_y) + if (isAndroid) { + await program.adbCommand("input tap" + " " + point_x + " " + point_y) + } else { + await program.tap({x: point_x, y: point_y}) + } await page.waitFor(500); res = await page.data('jest_result'); expect(res).toBe(true) diff --git a/pages/CSS/overflow/overflow-visible-event.uvue b/pages/CSS/overflow/overflow-visible-event.uvue index 22985f681f1c003a727e0fa5795b5a5368c2e2d6..d833a650d1e3972e136cb7203ce56f63cb28688f 100644 --- a/pages/CSS/overflow/overflow-visible-event.uvue +++ b/pages/CSS/overflow/overflow-visible-event.uvue @@ -100,7 +100,10 @@ jest_getRect() { const rect = uni.getElementById('child')?.getBoundingClientRect() if (rect != null) { - const ratio = uni.getSystemInfoSync().devicePixelRatio + let ratio = 1 + // #ifdef APP-ANDROID + ratio = uni.getSystemInfoSync().devicePixelRatio + // #endif this.jest_click_x = rect.x * ratio + 10 this.jest_click_y = rect.bottom * ratio - 10 } @@ -109,8 +112,11 @@ const transform = uni.getElementById('parent')?.style.getPropertyValue("transform") if (transform != null) { let value = transform as string - value = value.split(",")[1].slice(0, -3) - const ratio = uni.getSystemInfoSync().devicePixelRatio + value = value.split(",")[1].slice(0, -3) + let ratio = 1 + // #ifdef APP-ANDROID + ratio = uni.getSystemInfoSync().devicePixelRatio + // #endif this.jest_parent_top = Math.round((parseFloat(value) * ratio)) } }, @@ -118,8 +124,11 @@ const rect = uni.getElementById('absolute-view')?.getBoundingClientRect() if (rect != null) { const systemInfo = uni.getSystemInfoSync() - const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - const ratio = systemInfo.devicePixelRatio + const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight + let ratio = 1 + // #ifdef APP-ANDROID + ratio = systemInfo.devicePixelRatio + // #endif this.jest_click_x = rect.x * ratio + 10 this.jest_click_y = (rect.top + titleBarHeight + 10) * ratio } @@ -130,8 +139,11 @@ if (rect != null) { scrollView.scrollTo(0, rect.top) setTimeout(() => { - const systemInfo = uni.getSystemInfoSync() - const ratio = systemInfo.devicePixelRatio + const systemInfo = uni.getSystemInfoSync() + let ratio = 1 + // #ifdef APP-ANDROID + ratio = systemInfo.devicePixelRatio + // #endif const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight const afterRect = uni.getElementById('deep-overflow')?.getBoundingClientRect() if (afterRect != null) {