From c7636102f732c8c486026f37af9ae30f2e167105 Mon Sep 17 00:00:00 2001 From: XHY Date: Thu, 19 Dec 2024 17:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20touch=20preventDefault?= =?UTF-8?q?=E3=80=81stopPropagation=20=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 6 ++ .../global-events/touch-events-case.test.js | 57 +++++++++++++++++ .../global-events/touch-events-case.uvue | 63 +++++++++++++++++++ testSequencer.js | 1 + 4 files changed, 127 insertions(+) create mode 100644 pages/component/global-events/touch-events-case.test.js create mode 100644 pages/component/global-events/touch-events-case.uvue diff --git a/pages.json b/pages.json index 29971db8..1e61148d 100644 --- a/pages.json +++ b/pages.json @@ -499,6 +499,12 @@ "navigationBarTitleText": "Touch Events bubbles" } }, + { + "path": "pages/component/global-events/touch-events-case", + "style": { + "navigationBarTitleText": "Touch Events case" + } + }, // #ifdef APP-ANDROID || APP-IOS { "path": "pages/component/nested-scroll-header/nested-scroll-header", diff --git a/pages/component/global-events/touch-events-case.test.js b/pages/component/global-events/touch-events-case.test.js new file mode 100644 index 00000000..75174e09 --- /dev/null +++ b/pages/component/global-events/touch-events-case.test.js @@ -0,0 +1,57 @@ +const PAGE_PATH = '/pages/component/global-events/touch-events-case' + +describe('touch-events-test', () => { + const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() + const isAndroid = platformInfo.startsWith('android') + const isIOS = platformInfo.startsWith('ios') + const isMP = platformInfo.startsWith('mp') + const isWeb = platformInfo.startsWith('web') + + if ( + isWeb || + isMP + ) { + it('other platform', () => { + expect(1).toBe(1) + }) + return + } + + if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') { + it('跳过横屏模式', () => { + expect(1).toBe(1) + }) + return + } + + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500); + }) + + + it('touch-event-preventDefault', async () => { + + let x = 25 + let y = 150 + + // 滑动事件 + await program.swipe({ + startPoint: {x: x, y: y}, + endPoint: {x: x+200,y: y}, + duration: 300 + }) + + await page.waitFor(1500); + const ret = await page.callMethod('isPassTest1') + expect(ret).toBe(true) + }) + + it('touch-event-stopPropagation', async () => { + + const ret = await page.callMethod('isPassTest2') + expect(ret).toBe(true) + }) + +}) diff --git a/pages/component/global-events/touch-events-case.uvue b/pages/component/global-events/touch-events-case.uvue new file mode 100644 index 00000000..ba3b67a9 --- /dev/null +++ b/pages/component/global-events/touch-events-case.uvue @@ -0,0 +1,63 @@ + + + + + diff --git a/testSequencer.js b/testSequencer.js index c3f11469..69d08738 100644 --- a/testSequencer.js +++ b/testSequencer.js @@ -7,6 +7,7 @@ const sortTestFilePaths = [ "pages/component/scroll-view/scroll-view-refresher.test.js", "pages/component/global-events/touch-events.test.js", "pages/component/global-events/touch-events-bubbles.test.js", + "pages/component/global-events/touch-events-case.test.js", "pages/component/swiper/swiper2.test.js", "pages/component/slider/slider-maxValue.test.js", "pages/CSS/overflow/overflow-visible-event.test.js", -- GitLab