From d2e56768af98de348e58ba9c3b81e36ab521ab14 Mon Sep 17 00:00:00 2001 From: jixinbao Date: Fri, 6 Sep 2024 16:52:52 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=20ios=20PointEvent?= =?UTF-8?q?=20=E7=9B=B8=E5=85=B3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-events/global-events.test.js | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/pages/component/global-events/global-events.test.js b/pages/component/global-events/global-events.test.js index 51a333c0..9d1f1681 100644 --- a/pages/component/global-events/global-events.test.js +++ b/pages/component/global-events/global-events.test.js @@ -305,4 +305,45 @@ describe('event trigger', () => { } } }) -}) + + it.only('mock tap event', async () => { + + // ios only 坐标换算准确 + if (isIos) { + + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + const el = await page.$('#longpress-target') + + const size = await el.size() + const position = await el.offset() + // console.log('position', position) + // console.log('size', size); + const x = position.left + size.width / 2.0 + const y = position.top + size.height / 2.0 + const res = await uni.getWindowInfo(); + // console.log('res', res.statusBarHeight); + const baseStatusTextHeight = 44 + const baseTop = res.statusBarHeight ?? 0 + + await program.tap({ + x: x, + y: y + baseTop + baseStatusTextHeight, + duration: 100 + }) + await page.waitFor(500) + + const clickEventX = await page.$('#click-event-x') + const StringX = await clickEventX.text() + + expect(Number(StringX)).toBeGreaterThan(0) + const clickEventY = await page.$('#click-event-y') + const StringY = await clickEventY.text() + expect(Number(StringY)).toBeGreaterThan(0) + } else { + expect(1).toBe(1) + } + + + }) +}) \ No newline at end of file -- GitLab