From 89d75a3345669ba25dece12ff8e0e097efb9aeac Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Thu, 13 Jun 2024 16:06:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Elist-view=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../list-view/list-view-refresh.test.js | 22 +++++ .../list-view/list-view-refresh.uvue | 78 ++++++++++++++++-- pages/component/list-view/list-view.test.js | 53 ++++++++++++ pages/component/list-view/list-view.uvue | 80 +++++++++++++++++-- 4 files changed, 222 insertions(+), 11 deletions(-) diff --git a/pages/component/list-view/list-view-refresh.test.js b/pages/component/list-view/list-view-refresh.test.js index 09699044..05c30fcf 100644 --- a/pages/component/list-view/list-view-refresh.test.js +++ b/pages/component/list-view/list-view-refresh.test.js @@ -20,5 +20,27 @@ describe('component-native-list-view-refresh', () => { await page.waitFor(500) const image = await program.screenshot({fullPage: true}); expect(image).toSaveImageSnapshot(); + // 手动设置下拉刷新状态refresher-triggered为true时,在iOS不触发@refresherpulling事件 + if(process.env.UNI_UTS_PLATFORM.startsWith('app-android')){ + expect(await page.data('onRefresherpullingTest')).toBe('refresherpulling:Success') + } + expect(await page.data('refresherrefreshTest')).toBe('refresherrefresh:Success') + await page.waitFor(1000); + expect(await page.data('onRefresherrestoreTest')).toBe('refresherrestore:Success') }) + + it('check_refresherabort', async () => { + // 仅App端支持手势下拉刷新 + await program.swipe({ + startPoint: {x: 100,y: 400}, + endPoint: {x: 100,y: 500}, + duration: 1000 + }) + await page.waitFor(1500) + // 下拉刷新被中止,在iOS不触发@refresherabort事件 + if(process.env.UNI_UTS_PLATFORM.startsWith('app-android')){ + expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success') + } + }); + }) diff --git a/pages/component/list-view/list-view-refresh.uvue b/pages/component/list-view/list-view-refresh.uvue index 9299b9fa..fb4195e3 100644 --- a/pages/component/list-view/list-view-refresh.uvue +++ b/pages/component/list-view/list-view-refresh.uvue @@ -1,6 +1,6 @@ - diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js index 68454aef..cd44ef19 100644 --- a/pages/component/list-view/list-view.test.js +++ b/pages/component/list-view/list-view.test.js @@ -32,10 +32,63 @@ describe('component-native-list-view', () => { expect(scrollLeft-600).toBeGreaterThanOrEqual(0) }) + it('Event check_scroll', async () => { + await page.callMethod('change_scroll_y_boolean', true) + await page.callMethod('change_scroll_x_boolean', false) + await page.waitFor(600) + await page.callMethod('confirm_scroll_top_input', 300) + await page.waitFor(600) + // 在web端scroll事件event参数中detail类型报错,先忽略测试 + if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){ + const scrollDetail = await page.data('scrollDetailTest') + expect(scrollDetail.scrollLeft).toBe(0) + expect(scrollDetail.scrollTop).toBe(300) + expect(scrollDetail.scrollHeight).toBeGreaterThan(0) + // 在安卓端 "scrollWidth":0 + if(!process.env.UNI_UTS_PLATFORM.startsWith('app-android')){ + expect(scrollDetail.scrollWidth).toBeGreaterThan(0) + } + expect(scrollDetail.deltaX).toBe(0) + expect(scrollDetail.deltaY).toBe(300) + } + expect(await page.data('isScrollTest')).toBe('scroll:Success') + }) + + it('Event scrolltolower-滚动到底部/右边',async()=>{ + // 滚动到底部,是否触发scrolltolower事件 + await page.callMethod('confirm_scroll_top_input', 2500) + await page.waitFor(600) + expect(await page.data('isScrolltolowerTest')).toBe('scrolltolower:Success-bottom') + }) + + it('Event scrolltoupper-滚动到顶部/左边',async()=>{ + // 滚动到顶部50,是否触发scrolltoupper事件 + await page.callMethod('confirm_scroll_top_input', 50) + await page.waitFor(600) + expect(await page.data('isScrolltoupperTest')).toBe('scrolltoupper:Success-top') + }) + if (process.env.uniTestPlatformInfo.indexOf('web') > -1) { return } + it('Event scrollend-滚动结束时触发',async()=>{ + // 仅App端支持,向下滑动页面 + await program.swipe({ + startPoint: { x: 100, y: 500 }, + endPoint: { x: 100, y: 200 }, + duration: 1000 + }) + await page.waitFor(600) + const endDetail = await page.data('scrollEndDetailTest') + expect(endDetail.deltaY).toBe(0) + expect(endDetail.deltaX).toBe(0) + expect(endDetail.scrollLeft).toBe(0) + expect(endDetail.scrollTop).toBeGreaterThan(0) + expect(endDetail.scrollHeight).toBeGreaterThan(0) + // 在安卓端 "scrollWidth":0 + // expect(endDetail.scrollWidth).toBeGreaterThan(0) + }) if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { return diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue index 4877bfa3..aad832e4 100644 --- a/pages/component/list-view/list-view.uvue +++ b/pages/component/list-view/list-view.uvue @@ -1,4 +1,10 @@