diff --git a/pages/component/web-view/web-view.test.js b/pages/component/web-view/web-view.test.js index b20b7f5a715c62f214a2ae3310389c64b86e1eb5..091e610fee10c532bc59776e72bbaf868d33f3f3 100644 --- a/pages/component/web-view/web-view.test.js +++ b/pages/component/web-view/web-view.test.js @@ -44,43 +44,23 @@ describe('component-native-web-view', () => { x: 1, y: info.statusBarHeight + 44 + 1 }); - start = Date.now(); - await page.waitFor(async () => { - return (await page.data('eventTouchstart')) && (await page.data('eventTap')) || (Date.now() - start > 500); - }); + await page.waitFor(500); if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) { - expect(await page.data('eventTouchstart')).toEqual({ - clientX: 1, - clientY: 1 - }); - - expect(await page.data('eventTap')).toEqual({ - clientX: 1, - clientY: 1 - }); + expect(await page.data('isTouchEnable')).toBe(true); } await page.setData({ - pointerEvents: 'none' + pointerEvents: 'none', + isTouchEnable: false }); await page.waitFor(100); await program.tap({ x: 10, y: info.statusBarHeight + 44 + 10 }); - start = Date.now(); - await page.waitFor(async () => { - return (await page.data('eventTouchstart')) && (await page.data('eventTap')) || (Date.now() - start > 500); - }); + await page.waitFor(500); if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) { - expect(await page.data('eventTouchstart')).toEqual({ - clientX: 1, - clientY: 1 - }); - expect(await page.data('eventTap')).toEqual({ - clientX: 1, - clientY: 1 - }); + expect(await page.data('isTouchEnable')).toBe(false); } await page.setData({ pointerEvents: 'auto' diff --git a/pages/component/web-view/web-view.uvue b/pages/component/web-view/web-view.uvue index f8fb9bec5a5a9930bf2a1f153872ff154de0a9bb..aa3210afb28694b23add80fb6ad03fdaf22b8d7b 100644 --- a/pages/component/web-view/web-view.uvue +++ b/pages/component/web-view/web-view.uvue @@ -71,9 +71,8 @@ eventLoading: null as UTSJSONObject | null, eventLoad: null as UTSJSONObject | null, eventError: null as UTSJSONObject | null, - eventTouchstart: null as UTSJSONObject | null, - eventTap: null as UTSJSONObject | null, - pointerEvents: 'auto' + pointerEvents: 'auto', + isTouchEnable: false } }, onReady() { @@ -183,18 +182,12 @@ // 自动化测试 touchstart(event : UniTouchEvent) { if (this.autoTest) { - this.eventTouchstart = { - clientX: Math.ceil(event.touches[0].clientX), - clientY: Math.ceil(event.touches[0].clientY) - }; + isTouchEnable = event.touches[0].clientX > 0 && event.touches[0].clientY > 0; } }, tap(event : UniPointerEvent) { if (this.autoTest) { - this.eventTap = { - clientX: Math.ceil(event.clientX), - clientY: Math.ceil(event.clientY) - }; + isTouchEnable = event.clientX > 0 && event.clientY > 0; } }, getWindowInfo() : GetWindowInfoResult {