From b014fb59a0480d2ff7e574d46232b301f2efa92f Mon Sep 17 00:00:00 2001 From: dongwei Date: Tue, 26 Aug 2025 11:16:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4ArcScrollBar=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../test/arcScrollBar/ArcScrollBar.test.ets | 352 ++++++++++++++++++ .../pages/arcScrollBar/arcScrollBar01.ets | 88 +++++ .../pages/arcScrollBar/arcScrollBar02.ets | 89 +++++ .../pages/arcScrollBar/arcScrollBar03.ets | 89 +++++ .../pages/arcScrollBar/arcScrollBar04.ets | 88 +++++ .../pages/arcScrollBar/arcScrollBar05.ets | 88 +++++ .../pages/arcScrollBar/arcScrollBar06.ets | 109 ++++++ .../pages/arcScrollBar/arcScrollBar07.ets | 88 +++++ .../pages/arcScrollBar/arcScrollBar08.ets | 125 +++++++ .../pages/arcScrollBar/arcScrollBar09.ets | 159 ++++++++ 10 files changed, 1275 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/arcScrollBar/ArcScrollBar.test.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar04.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar05.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar06.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar07.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar08.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar09.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/arcScrollBar/ArcScrollBar.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/arcScrollBar/ArcScrollBar.test.ets new file mode 100644 index 00000000..99bb073c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/arcScrollBar/ArcScrollBar.test.ets @@ -0,0 +1,352 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON, Component } from '@kit.TestKit'; +import { BusinessError } from '@kit.BasicServicesKit' + +export default function ArcScrollBarTest () { + + describe('ArcScrollBarTest', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err:BusinessError) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010 + * @tc.name : ArcScrollBar binds same scroller with List, Grid, Scroll + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar01") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar与List绑定相同scroller + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010_01') + await Utils.sleep(1000) + + // 步骤2: 滑动List组件,观察ArcScrollBar联动效果 + let scrollButton: Component = await driver.waitForComponent(ON.text('滑动List'), 1000); + await scrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0010 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020 + * @tc.name : ArcScrollBar not binds same scroller with List, Grid, Scroll + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar02") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar不与List绑定相同scroller + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020_01') + await Utils.sleep(1000) + + // 步骤2: 滑动List组件,观察ArcScrollBar无联动效果 + let scrollButton: Component = await driver.waitForComponent(ON.text('滑动List'), 1000); + await scrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0020 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030 + * @tc.name : ArcScrollBar sets state to On + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar03") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar state为On,应该常驻显示 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030_01') + await Utils.sleep(1000) + + // 步骤2: 等待2秒后观察滚动条是否仍然显示 + await Utils.sleep(2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0030 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040 + * @tc.name : ArcScrollBar sets state to Auto + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar04") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar state为Auto + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040_01') + await Utils.sleep(1000) + + // 步骤2: 滑动组件触发滚动条显示 + let scrollButton: Component = await driver.waitForComponent(ON.text('滑动触发'), 1000); + await scrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040_02') + await Utils.sleep(1000) + + // 步骤3: 等待2秒后观察滚动条是否消失 + await Utils.sleep(2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0040 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050 + * @tc.name : ArcScrollBar sets state to Off + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar05") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar state为Off,应该不显示 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050_01') + await Utils.sleep(1000) + + // 步骤2: 滑动组件,观察滚动条仍然不显示 + let scrollButton: Component = await driver.waitForComponent(ON.text('滑动测试'), 1000); + await scrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0050 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060 + * @tc.name : ArcScrollBar dynamically changes state + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar06") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060_01') + await Utils.sleep(1000) + + // 步骤2: 切换到On状态 + let onButton: Component = await driver.waitForComponent(ON.text('切换到On'), 1000); + await onButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060_02') + await Utils.sleep(1000) + + // 步骤3: 切换到Off状态 + let offButton: Component = await driver.waitForComponent(ON.text('切换到Off'), 1000); + await offButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0060 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070 + * @tc.name : ArcScrollBar not sets state + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar07") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ArcScrollBar不设置state,默认按需显示 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070_01') + await Utils.sleep(1000) + + // 步骤2: 滑动触发滚动条显示 + let scrollButton: Component = await driver.waitForComponent(ON.text('滑动触发'), 1000); + await scrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070_02') + await Utils.sleep(1000) + + // 步骤3: 等待2秒后观察滚动条是否消失 + await Utils.sleep(2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0070 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080 + * @tc.name : List and Grid call scrollTo and scrollToIndex + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar08") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080_01') + await Utils.sleep(1000) + + // 步骤2: List调用scrollTo跳转 + let listScrollButton: Component = await driver.waitForComponent(ON.text('List跳转'), 1000); + await listScrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080_02') + await Utils.sleep(1000) + + // 步骤3: Grid调用scrollToIndex跳转 + let gridScrollButton: Component = await driver.waitForComponent(ON.text('Grid跳转'), 1000); + await gridScrollButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0080 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100 + * @tc.name : Use crown rotation to scroll List, Grid, Scroll + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100 start.`); + Settings.createWindow("testability/pages/arcScrollBar/arcScrollBar09") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100_01') + await Utils.sleep(1000) + + // 步骤2: 模拟表冠旋转滚动List + let listCrownButton: Component = await driver.waitForComponent(ON.text('表冠滚动List'), 1000); + await listCrownButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100_02') + await Utils.sleep(1000) + + // 步骤3: 模拟表冠旋转滚动Grid + let gridCrownButton: Component = await driver.waitForComponent(ON.text('表冠滚动Grid'), 1000); + await gridCrownButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT__CROWN_ARCSCROLLBAR_0100 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar01.ets new file mode 100644 index 00000000..ce88a2ed --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar01.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar01 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0010 - ArcScrollBar与List绑定相同scroller') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滑动List') + .onClick(() => { + this.scroller.scrollBy(0, 300); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar与List绑定相同scroller + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('联动测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller, state: BarState.Auto }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar02.ets new file mode 100644 index 00000000..5f1cdfae --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar02.ets @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar02 { + private listScroller: Scroller = new Scroller(); + private arcScroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0020 - ArcScrollBar不与List绑定相同scroller') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滑动List') + .onClick(() => { + this.listScroller.scrollBy(0, 300); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar不与List绑定相同scroller + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.listScroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + Text('无联动测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.arcScroller, state: BarState.Auto }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar03.ets new file mode 100644 index 00000000..05f04065 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar03.ets @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar03 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0030 - ArcScrollBar设置state为On常驻显示') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('ArcScrollBar state: On - 应该常驻显示,等待2秒后观察') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 测试区域 - ArcScrollBar state为On + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Orange) + Text('常驻显示测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller, state: BarState.On }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar04.ets new file mode 100644 index 00000000..76f16d46 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar04.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar04 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0040 - ArcScrollBar设置state为Auto按需显示') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滑动触发') + .onClick(() => { + this.scroller.scrollBy(0, 300); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar state为Auto + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Pink) + Text('按需显示测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller, state: BarState.Auto }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar05.ets new file mode 100644 index 00000000..d0a9a70f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar05.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar05 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0050 - ArcScrollBar设置state为Off不显示') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滑动测试') + .onClick(() => { + this.scroller.scrollBy(0, 300); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar state为Off + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Red) + Text('不显示测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller, state: BarState.Off }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar06.ets new file mode 100644 index 00000000..5a769b0d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar06.ets @@ -0,0 +1,109 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar06 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + @State currentState: BarState = BarState.Auto; + + build() { + Column() { + // 页面标题 + Text('测试用例0060 - ArcScrollBar动态改变state状态') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态显示 + Text(`当前状态: ${this.currentState}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('切换到On') + .onClick(() => { + this.currentState = BarState.On; + }) + Button('切换到Off') + .onClick(() => { + this.currentState = BarState.Off; + }) + Button('切换到Auto') + .onClick(() => { + this.currentState = BarState.Auto; + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar动态改变state + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('状态切换测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('60%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller, state: this.currentState }) + } + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar07.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar07.ets new file mode 100644 index 00000000..f1266e4b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar07.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar07 { + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0070 - ArcScrollBar不设置state状态默认效果') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滑动触发') + .onClick(() => { + this.scroller.scrollBy(0, 300); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - ArcScrollBar不设置state + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Brown) + Text('默认效果测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height('70%') + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scroller }) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar08.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar08.ets new file mode 100644 index 00000000..5efb063e --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar08.ets @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar08 { + private listScroller: Scroller = new Scroller(); + private gridScroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0080 - List和Grid调用滚动控制器跳转') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('List跳转') + .onClick(() => { + this.listScroller.scrollTo({ xOffset: 0, yOffset: 500 }); + }) + Button('Grid跳转') + .onClick(() => { + this.gridScroller.scrollToIndex(10); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - List和Grid的滚动控制器跳转 + Column({ space: 10 }) { + // List测试区域 + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.listScroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('List项目 ' + item.toString()) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + } + .width('100%') + .height(80) + .backgroundColor(0xFFFFFF) + .borderRadius(8) + .padding(10) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height(200) + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.listScroller, state: BarState.Auto }) + } + .width('100%') + .height(200) + + // Grid测试区域 + Stack({ alignContent: Alignment.Center }) { + Grid(this.gridScroller) { + ForEach(this.arr, (item: number) => { + GridItem() { + Text('Grid' + item.toString()) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + .width('100%') + .height('100%') + .backgroundColor(0xFFFFFF) + .borderRadius(8) + .textAlign(TextAlign.Center) + } + .width('100%') + .height(60) + }, (item: string) => item) + } + .columnsTemplate('1fr 1fr 1fr') + .rowsGap(10) + .columnsGap(10) + .width('90%') + .height(200) + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.gridScroller, state: BarState.Auto }) + } + .width('100%') + .height(200) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar09.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar09.ets new file mode 100644 index 00000000..dc5403f9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/arcScrollBar/arcScrollBar09.ets @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArcScrollBar } from '@kit.ArkUI'; + +@Entry +@Component +struct arcScrollBar09 { + private listScroller: Scroller = new Scroller(); + private gridScroller: Scroller = new Scroller(); + private scrollScroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + + build() { + Column() { + // 页面标题 + Text('测试用例0100 - 使用表冠旋转滚动List、Grid、Scroll') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('表冠滚动List') + .onClick(() => { + // 模拟表冠旋转,使用fling方法 + this.listScroller.fling(1000); + }) + Button('表冠滚动Grid') + .onClick(() => { + this.gridScroller.fling(1000); + }) + Button('表冠滚动Scroll') + .onClick(() => { + this.scrollScroller.fling(1000); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 测试区域 - 表冠旋转滚动 + Column({ space: 10 }) { + // List测试区域 + Stack({ alignContent: Alignment.Center }) { + List({ scroller: this.listScroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('List项目 ' + item.toString()) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + } + .width('100%') + .height(60) + .backgroundColor(0xFFFFFF) + .borderRadius(8) + .padding(10) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .width('90%') + .height(150) + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.listScroller, state: BarState.Auto }) + } + .width('100%') + .height(150) + + // Grid测试区域 + Stack({ alignContent: Alignment.Center }) { + Grid(this.gridScroller) { + ForEach(this.arr, (item: number) => { + GridItem() { + Text('Grid' + item.toString()) + .fontSize(14) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + .width('100%') + .height('100%') + .backgroundColor(0xFFFFFF) + .borderRadius(6) + .textAlign(TextAlign.Center) + } + .width('100%') + .height(40) + }, (item: string) => item) + } + .columnsTemplate('1fr 1fr 1fr 1fr') + .rowsGap(8) + .columnsGap(8) + .width('90%') + .height(150) + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.gridScroller, state: BarState.Auto }) + } + .width('100%') + .height(150) + + // Scroll测试区域 + Stack({ alignContent: Alignment.Center }) { + Scroll(this.scrollScroller) { + Column() { + ForEach(this.arr, (item: number) => { + Text('Scroll项目 ' + item.toString()) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Orange) + .width('90%') + .height(50) + .backgroundColor(0xFFFFFF) + .borderRadius(8) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + }, (item: string) => item) + } + .width('100%') + } + .width('90%') + .height(150) + .scrollBar(BarState.Off) + + ArcScrollBar({ scroller: this.scrollScroller, state: BarState.Auto }) + } + .width('100%') + .height(150) + } + .width('100%') + .height('70%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} -- Gitee From 2207912f855a10206cc039520f28dffd95f25e45 Mon Sep 17 00:00:00 2001 From: dongwei Date: Tue, 26 Aug 2025 11:18:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4ArcScrollBar=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../ets/test/other/RefreshTest.test.ets | 452 ++++++++++++++++++ .../refresh/refreshInterconnection01.ets | 182 +++++++ .../other/refresh/refreshPromptText01.ets | 146 ++++++ .../other/refresh/refreshPromptText02.ets | 129 +++++ .../other/refresh/refreshPromptText03.ets | 146 ++++++ .../other/refresh/refreshPullDownRatio01.ets | 106 ++++ .../other/refresh/refreshPullDownRatio02.ets | 106 ++++ .../other/refresh/refreshPullDownRatio03.ets | 106 ++++ .../other/refresh/refreshPullDownRatio04.ets | 106 ++++ .../other/refresh/refreshPullDownRatio05.ets | 106 ++++ .../other/refresh/refreshPullDownRatio06.ets | 105 ++++ .../other/refresh/refreshPullToRefresh01.ets | 105 ++++ 12 files changed, 1795 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/other/RefreshTest.test.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshInterconnection01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio04.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio05.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio06.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullToRefresh01.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/other/RefreshTest.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/other/RefreshTest.test.ets new file mode 100644 index 00000000..e868895c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/other/RefreshTest.test.ets @@ -0,0 +1,452 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON, Component } from '@kit.TestKit'; +import { BusinessError } from '@kit.BasicServicesKit' + +export default function RefreshTest() { + + describe('RefreshTest', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err: BusinessError) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020 + * @tc.name : Refresh nested Swiper test - loop true without edge + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshInterconnection01"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - Refresh嵌套Swiper应该正常显示 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020_01'); + + // 步骤2: 测试Swiper下一页功能 + let nextButton: Component = await driver.waitForComponent(ON.id('refreshInterconnection01_01'), 1000); + await nextButton.click(); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020_02'); + + // 步骤3: 测试Swiper上一页功能 + let prevButton: Component = await driver.waitForComponent(ON.id('refreshInterconnection01_02'), 1000); + await prevButton.click(); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020_03'); + + // 步骤4: 测试Refresh功能 + let refreshButton: Component = await driver.waitForComponent(ON.id('refreshInterconnection01_03'), 1000); + await refreshButton.click(); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020_04'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0020 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010 + * @tc.name : Refresh pullDownRatio 0 test - cannot pull down or up + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio01"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullDownRatio为0时应该无法下拉 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010_01'); + + // 步骤2: 测试下拉操作 - 应该无法下拉 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010_02'); + + // 步骤3: 测试上滑操作 - 应该无法上滑 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0010 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050 + * @tc.name : Refresh pullDownRatio 1 test - can follow hand pull down and up + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio05"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullDownRatio为1时应该可以跟手下拉 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050_01'); + + // 步骤2: 测试下拉操作 - 应该可以跟手下拉 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050_02'); + + // 步骤3: 测试上滑操作 - 应该可以跟手上滑 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0050 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020 + * @tc.name : Refresh pullDownRatio 0.1 test - high resistance when pulling + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio02"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullDownRatio为0.1时应该有很大阻力 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020_01'); + + // 步骤2: 测试下拉操作 - 应该有很大阻力 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020_02'); + + // 步骤3: 测试上滑操作 - 应该有很大阻力 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0020 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040 + * @tc.name : Refresh pullDownRatio 0.9 test - normal pull down and up + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio04"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullDownRatio为0.9时应该可以正常下拉 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040_01'); + + // 步骤2: 测试下拉操作 - 应该可以正常下拉 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040_02'); + + // 步骤3: 测试上滑操作 - 应该可以正常上滑 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0040 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030 + * @tc.name : Refresh pullDownRatio 0.5 test - normal pull down and up + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio03"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullDownRatio为0.5时应该可以正常下拉 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030_01'); + + // 步骤2: 测试下拉操作 - 应该可以正常下拉 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030_02'); + + // 步骤3: 测试上滑操作 - 应该可以正常上滑 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0030 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180 + * @tc.name : Refresh default dynamic pullDownRatio test - resistance increases with pull distance + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullDownRatio06"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 默认使用动态下拉跟手系数 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180_01'); + + // 步骤2: 测试下拉操作 - 下拉距离越大,阻力越大 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180_02'); + + // 步骤3: 测试上滑操作 - 上滑距离越大,阻力越大 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0180 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010 + * @tc.name : Refresh pullToRefresh false test - cannot pull down to refresh + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPullToRefresh01"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - pullToRefresh为false时应该无法下拉刷新 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010_01'); + + // 步骤2: 测试下拉操作 - 应该无法下拉刷新 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010_02'); + + // 步骤3: 测试上滑操作 - 应该无法上滑刷新 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0010 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140 + * @tc.name : Refresh custom builder refresh component test - custom text display + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPromptText01"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 自定义builder刷新组件应该正常显示 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140_01'); + + // 步骤2: 测试下拉操作 - 自定义文本应该正常显示 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140_02'); + + // 步骤3: 测试上滑操作 - 自定义文本应该正常显示 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0140 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130 + * @tc.name : Refresh custom text and bounce animation test - text fades during bounce + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPromptText02"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 自定义文本应该正常显示 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130_01'); + + // 步骤2: 测试下拉操作 - 自定义文本应该显示 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130_02'); + + // 步骤3: 测试上滑操作 - 自定义文本应该显示 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130_03'); + + // 步骤4: 测试回弹过程 - 文本应该由大变小,颜色渐变透明消失 + await driver.swipe(200, 100, 200, 200, 300); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130_04'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0130 finish.`); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190 + * @tc.name : Refresh nested List with custom text test - text display normal + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190 start.`); + + // 创建测试窗口 + Settings.createWindow("testability/pages/other/refresh/refreshPromptText03"); + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - Refresh嵌套List和自定义文本应该正常显示 + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190_01'); + + // 步骤2: 测试下拉操作 - 自定义文本应该正常显示 + await driver.swipe(200, 100, 200, 300, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190_02'); + + // 步骤3: 测试上滑操作 - 自定义文本应该正常显示 + await driver.swipe(200, 300, 200, 100, 600); + await driver.waitForIdle(500, 1000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190_03'); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0190 finish.`); + done(); + }); + }) +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshInterconnection01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshInterconnection01.ets new file mode 100644 index 00000000..2cc6462c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshInterconnection01.ets @@ -0,0 +1,182 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0020页面 + * Refresh嵌套纵向滑动Swiper场景测试 + */ +@Entry +@Component +struct refreshInterconnection01 { + @State isRefreshing: boolean = false; + @State currentIndex: number = 0; + private swiperController: SwiperController = new SwiperController(); + + build() { + Column() { + // 页面标题 + Text('测试用例0020 - Refresh嵌套Swiper测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`当前Swiper索引: ${this.currentIndex}, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh嵌套Swiper测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + // 第一个页面 + Column() { + Text('Swiper页面 1') + .fontSize(18) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }); + + ForEach([1, 2, 3, 4, 5], (item: number) => { + Text(`列表项 ${item}`) + .width('90%') + .height(60) + .fontSize(14) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(8) + .margin({ bottom: 10 }); + }) + } + .width('100%') + .height('100%') + .backgroundColor('0xF0F8FF') + .padding(20) + + // 第二个页面 + Column() { + Text('Swiper页面 2') + .fontSize(18) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }); + + ForEach([6, 7, 8, 9, 10], (item: number) => { + Text(`列表项 ${item}`) + .width('90%') + .height(60) + .fontSize(14) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(8) + .margin({ bottom: 10 }); + }) + } + .width('100%') + .height('100%') + .backgroundColor('0xFFF0F5') + .padding(20) + + // 第三个页面 + Column() { + Text('Swiper页面 3') + .fontSize(18) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }); + + ForEach([11, 12, 13, 14, 15], (item: number) => { + Text(`列表项 ${item}`) + .width('90%') + .height(60) + .fontSize(14) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(8) + .margin({ bottom: 10 }); + }) + } + .width('100%') + .height('100%') + .backgroundColor('0xF0FFF0') + .padding(20) + } + .width('100%') + .height('100%') + .loop(true) + .autoPlay(false) + .indicator(true) + .onChange((index: number) => { + this.currentIndex = index; + console.info('测试用例0020 Swiper onChange:', index); + }) + } + .width('100%') + .height('80%') + .backgroundColor('0xE6E6FA') + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0020 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0020 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0020 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Row({ space: 10 }) { + Button('下一页') + .id("refreshInterconnection01_01") + .onClick(() => { + this.swiperController.showNext(); + }) + + Button('上一页') + .id("refreshInterconnection01_02") + .onClick(() => { + this.swiperController.showPrevious(); + }) + + Button('开始刷新') + .id("refreshInterconnection01_03") + .onClick(() => { + this.isRefreshing = true; + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ top: 10 }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText01.ets new file mode 100644 index 00000000..f3825d0a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText01.ets @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0140页面 + * Refresh组件自定义builder刷新组件和自定义文本测试 + */ +@Entry +@Component +struct refreshPromptText01 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + @State refreshOffset: number = 0; + @State refreshState: RefreshStatus = RefreshStatus.Inactive; + + @Builder + CustomRefreshBuilder() { + Stack({ alignContent: Alignment.Bottom }) { + // 可以通过刷新状态控制是否存在Progress组件 + if (this.refreshState != RefreshStatus.Inactive && this.refreshState != RefreshStatus.Done) { + Column() { + Text('自定义刷新组件') + .fontSize(16) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 8 }); + + Text('正在刷新数据...') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ bottom: 8 }); + + Progress({ value: this.refreshOffset, total: 64, type: ProgressType.Ring }) + .width(32) + .height(32) + .style({ status: this.isRefreshing ? ProgressStatus.LOADING : ProgressStatus.PROGRESSING }) + .color(Color.Blue); + } + .width('100%') + .height(80) + .backgroundColor(Color.White) + .borderRadius(8) + .padding(16) + .justifyContent(FlexAlign.Center) + } + } + .clip(true) + .height("100%") + .width("100%") + } + + build() { + Column() { + // 页面标题 + Text('测试用例0140 - 自定义builder刷新组件测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`自定义刷新组件, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 - 使用自定义builder刷新组件 + Refresh({ refreshing: $$this.isRefreshing, builder: this.CustomRefreshBuilder() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0140 Refresh onStateChange:', refreshStatus); + this.refreshState = refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('测试用例0140 Refresh onOffsetChange:', value); + this.refreshOffset = value; + }) + .onRefreshing(() => { + console.info('测试用例0140 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPromptText01_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText02.ets new file mode 100644 index 00000000..4fe10ea6 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText02.ets @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0130页面 + * Refresh组件自定义文本和回弹动画测试 + */ +@Entry +@Component +struct refreshPromptText02 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + @State refreshOffset: number = 0; + @State refreshState: RefreshStatus = RefreshStatus.Inactive; + + @Builder + CustomTextBuilder() { + Stack({ alignContent: Alignment.Bottom }) { + // 自定义文本显示,支持回弹动画 + if (this.refreshState != RefreshStatus.Inactive) { + Text('下拉刷新') + .fontSize(16) + .fontColor(Color.Black) + .fontWeight(FontWeight.Medium) + .opacity(this.refreshOffset > 32 ? 1.0 : this.refreshOffset / 32) + .scale({ x: this.refreshOffset > 32 ? 1.0 : 0.8 + (this.refreshOffset / 32) * 0.2, y: this.refreshOffset > 32 ? 1.0 : 0.8 + (this.refreshOffset / 32) * 0.2 }) + .margin({ bottom: 20 }) + } + } + .clip(true) + .height("100%") + .width("100%") + } + + build() { + Column() { + // 页面标题 + Text('测试用例0130 - 自定义文本和回弹动画测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`自定义文本: "下拉刷新", 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 - 使用自定义文本 + Refresh({ refreshing: $$this.isRefreshing, builder: this.CustomTextBuilder() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0130 Refresh onStateChange:', refreshStatus); + this.refreshState = refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('测试用例0130 Refresh onOffsetChange:', value); + this.refreshOffset = value; + }) + .onRefreshing(() => { + console.info('测试用例0130 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPromptText02_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText03.ets new file mode 100644 index 00000000..8076bfe2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPromptText03.ets @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0190页面 + * Refresh组件嵌套List和自定义文本测试 + */ +@Entry +@Component +struct refreshPromptText03 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + @State refreshOffset: number = 0; + @State refreshState: RefreshStatus = RefreshStatus.Inactive; + + @Builder + ListRefreshBuilder() { + Stack({ alignContent: Alignment.Bottom }) { + // Refresh嵌套List的自定义文本显示 + if (this.refreshState != RefreshStatus.Inactive) { + Column() { + Text('刷新列表') + .fontSize(16) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 8 }); + + Text('正在更新列表数据...') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ bottom: 8 }); + + LoadingProgress() + .width(24) + .height(24) + .color(Color.Blue); + } + .width('100%') + .height(80) + .backgroundColor(Color.White) + .borderRadius(8) + .padding(16) + .justifyContent(FlexAlign.Center) + .opacity(this.refreshOffset > 32 ? 1.0 : this.refreshOffset / 32) + } + } + .clip(true) + .height("100%") + .width("100%") + } + + build() { + Column() { + // 页面标题 + Text('测试用例0190 - Refresh嵌套List和自定义文本测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`嵌套List, 自定义文本: "刷新列表", 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 - 嵌套List并使用自定义文本 + Refresh({ refreshing: $$this.isRefreshing, builder: this.ListRefreshBuilder() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0190 Refresh onStateChange:', refreshStatus); + this.refreshState = refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('测试用例0190 Refresh onOffsetChange:', value); + this.refreshOffset = value; + }) + .onRefreshing(() => { + console.info('测试用例0190 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPromptText03_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio01.ets new file mode 100644 index 00000000..97d3a069 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio01.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0010页面 + * Refresh组件pullDownRatio为0测试 - 无法下拉、上滑 + */ +@Entry +@Component +struct refreshPullDownRatio01 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0010 - pullDownRatio为0测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullDownRatio: 0, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(true) + .pullDownRatio(0) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0010 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0010 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0010 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio01_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio02.ets new file mode 100644 index 00000000..e8f07bca --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio02.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0020页面 + * Refresh组件pullDownRatio为0.1测试 - 下拉、上滑时阻力很大,几乎无法滑动 + */ +@Entry +@Component +struct refreshPullDownRatio02 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0020 - pullDownRatio为0.1测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullDownRatio: 0.1, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFFACD') + .pullToRefresh(true) + .pullDownRatio(0.1) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0020 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0020 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0020 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio02_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio03.ets new file mode 100644 index 00000000..6acd580c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio03.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0030页面 + * Refresh组件pullDownRatio为0.5测试 - 可以正常下拉、上滑 + */ +@Entry +@Component +struct refreshPullDownRatio03 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0030 - pullDownRatio为0.5测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullDownRatio: 0.5, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xDDA0DD') + .pullToRefresh(true) + .pullDownRatio(0.5) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0030 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0030 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0030 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio03_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio04.ets new file mode 100644 index 00000000..0f96f027 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio04.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0040页面 + * Refresh组件pullDownRatio为0.9测试 - 可以正常下拉、上滑 + */ +@Entry +@Component +struct refreshPullDownRatio04 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0040 - pullDownRatio为0.9测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullDownRatio: 0.9, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xF0E68C') + .pullToRefresh(true) + .pullDownRatio(0.9) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0040 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0040 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0040 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio04_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio05.ets new file mode 100644 index 00000000..fcea738d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio05.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0050页面 + * Refresh组件pullDownRatio为1测试 - 可以跟手下拉、上滑 + */ +@Entry +@Component +struct refreshPullDownRatio05 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0050 - pullDownRatio为1测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullDownRatio: 1, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xE0FFFF') + .pullToRefresh(true) + .pullDownRatio(1) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0050 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0050 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0050 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio05_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio06.ets new file mode 100644 index 00000000..a894c17e --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullDownRatio06.ets @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0180页面 + * Refresh组件默认动态下拉跟手系数测试 - 下拉距离越大,阻力越大 + */ +@Entry +@Component +struct refreshPullDownRatio06 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0180 - 默认动态下拉跟手系数测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`默认pullDownRatio: 动态系数, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 - 使用默认动态下拉跟手系数 + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0180 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0180 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0180 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullDownRatio06_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullToRefresh01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullToRefresh01.ets new file mode 100644 index 00000000..f215a652 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/other/refresh/refreshPullToRefresh01.ets @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 测试用例0010页面 + * Refresh组件pullToRefresh为false测试 - 无法下拉刷新 + */ +@Entry +@Component +struct refreshPullToRefresh01 { + @State isRefreshing: boolean = false; + @State arr: string[] = ['项目1', '项目2', '项目3', '项目4', '项目5', '项目6', '项目7', '项目8', '项目9', '项目10']; + + build() { + Column() { + // 页面标题 + Text('测试用例0010 - pullToRefresh为false测试') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`pullToRefresh: false, 刷新状态: ${this.isRefreshing ? '刷新中' : '未刷新'}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // Refresh测试区域 - pullToRefresh设置为false + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text(item) + .width('90%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + .borderRadius(10) + .margin(10) + } + }, (item: string) => item) + } + .width('100%') + .height('100%') + .scrollBar(BarState.Off) + } + .width('100%') + .height('80%') + .backgroundColor('0xFFE4E1') + .pullToRefresh(false) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('测试用例0010 Refresh onStateChange:', refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('测试用例0010 Refresh onOffsetChange:', value); + }) + .onRefreshing(() => { + console.info('测试用例0010 Refresh onRefreshing triggered'); + setTimeout(() => { + this.isRefreshing = false; + }, 2000); + }) + + // 控制按钮区域 + Button('开始刷新') + .id("refreshPullToRefresh01_01") + .width('80%') + .height(40) + .margin({ top: 10 }) + .onClick(() => { + this.isRefreshing = true; + }); + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, top: 8, bottom: 8 }); + } +} -- Gitee From 65b7926cff42776401ad3533ba046dc205a3edfd Mon Sep 17 00:00:00 2001 From: dongwei Date: Tue, 26 Aug 2025 11:19:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4ArcScrollBar=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../list_fadingEdge/ListFadingEdge.test.ets | 455 ++++++++++++++++++ .../list_fadingEdge/listFadingEdge01.ets | 102 ++++ .../list_fadingEdge/listFadingEdge02.ets | 100 ++++ .../list_fadingEdge/listFadingEdge03.ets | 163 +++++++ .../list_fadingEdge/listFadingEdge04.ets | 102 ++++ .../list_fadingEdge/listFadingEdge05.ets | 100 ++++ .../list_fadingEdge/listFadingEdge06.ets | 102 ++++ .../list_fadingEdge/listFadingEdge07.ets | 102 ++++ .../list_fadingEdge/listFadingEdge08.ets | 185 +++++++ .../list_fadingEdge/listFadingEdge09.ets | 118 +++++ .../list_fadingEdge/listFadingEdge10.ets | 102 ++++ .../list_fadingEdge/listFadingEdge11.ets | 102 ++++ 12 files changed, 1733 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_fadingEdge/ListFadingEdge.test.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge04.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge05.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge06.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge07.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge08.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge09.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge10.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge11.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_fadingEdge/ListFadingEdge.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_fadingEdge/ListFadingEdge.test.ets new file mode 100644 index 00000000..9839c1e1 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_fadingEdge/ListFadingEdge.test.ets @@ -0,0 +1,455 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON, Component } from '@kit.TestKit'; +import { BusinessError } from '@kit.BasicServicesKit' + +export default function ListFadingEdgeTest () { + + describe('ListFadingEdgeTest', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err:BusinessError) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040 + * @tc.name : List component sets fadingEdgeLength parameter to 20vp + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge01") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - List应该显示渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0040 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030 + * @tc.name : List component sets fadingEdge parameter to undefined + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge02") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - List应该没有渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察无渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察无渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0030 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100 + * @tc.name : List component with ListItemGroup sets fadingEdge effect + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge03") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ListItemGroup应该显示渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0100 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050 + * @tc.name : List component sets fadingEdgeLength parameter to greater than half of list height + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge04") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 渐隐效果长度应该是二分之一的list高 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0050 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070 + * @tc.name : List component sets fadingEdgeLength parameter to undefined + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge05") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 渐隐效果长度应该是默认值32vp + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0070 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060 + * @tc.name : List component sets fadingEdgeLength parameter to negative value + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge06") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 渐隐效果长度应该是默认值32vp + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0060 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090 + * @tc.name : List component with ListItem sets fadingEdge effect + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge07") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - ListItem应该显示渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0090 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110 + * @tc.name : List component with ListItemGroup and ListItem spacing layout sets fadingEdge effect + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge08") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 混合布局应该显示渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0110 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150 + * @tc.name : List component with modifier sets fadingEdge effect + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge09") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - modifier场景应该显示渐隐效果 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150_01') + await Utils.sleep(1000) + + // 步骤2: 滚动到顶部,观察渐隐效果 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滚动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150_02') + await Utils.sleep(1000) + + // 步骤3: 滚动到底部,观察渐隐效果 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0150 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320 + * @tc.name : List component sliding to bottom shows top edge fading and no bottom edge fading + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge10") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320_01') + await Utils.sleep(1000) + + // 步骤2: 滑动到列表底部,查看列表上下边缘的展示情况 + let scrollToBottomButton: Component = await driver.waitForComponent(ON.text('滚动到底部'), 1000); + await scrollToBottomButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0320 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330 + * @tc.name : List component initial state and sliding to top shows different edge fading effects + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330 start.`); + Settings.createWindow("testability/pages/list_fadingEdge/listFadingEdge11") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 等待页面加载完成 + await Utils.sleep(1000); + + // 步骤1: 观察初始状态 - 不滑动列表,查看列表上下边缘的展示情况 + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330_01') + await Utils.sleep(1000) + + // 步骤2: 向下滑动列表 + let scrollDownButton: Component = await driver.waitForComponent(ON.text('向下滑动'), 1000); + await scrollDownButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330_02') + await Utils.sleep(1000) + + // 步骤3: 再滑到列表顶部,查看列表上下边缘的展示情况 + let scrollToTopButton: Component = await driver.waitForComponent(ON.text('滑动到顶部'), 1000); + await scrollToTopButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LIST_TV_FADINGEDGE_0330 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge01.ets new file mode 100644 index 00000000..553b5605 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge01.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge01 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0040 - fadingEdgeLength为20vp') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 20vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('渐隐效果测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(20) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge02.ets new file mode 100644 index 00000000..8d0b6596 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge02.ets @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct listFadingEdge02 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0030 - fadingEdge为undefined') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdge: undefined, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Red) + Text('无渐隐效果') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(undefined) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge03.ets new file mode 100644 index 00000000..43f55835 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge03.ets @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge03 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + @Builder + groupHeader(text: string) { + Text(text) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .backgroundColor(0xAABBCC) + .width('100%') + .padding(10) + .textAlign(TextAlign.Center) + } + + build() { + Column() { + // 页面标题 + Text('测试用例0100 - ListItemGroup渐隐效果') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 80vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ListItemGroup({ header: this.groupHeader('第一组 - 基础项目') }) { + ForEach(this.arr.slice(0, 7), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + Text('Group 1') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + + ListItemGroup({ header: this.groupHeader('第二组 - 扩展项目') }) { + ForEach(this.arr.slice(7, 14), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Orange) + Text('Group 2') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + + ListItemGroup({ header: this.groupHeader('第三组 - 高级项目') }) { + ForEach(this.arr.slice(14), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('Group 3') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge04.ets new file mode 100644 index 00000000..af222dc1 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge04.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge04 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0050 - fadingEdgeLength大于list高的一半') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 500vp, List高度: 50%, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Brown) + Text('大渐隐效果') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(500) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('50%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge05.ets new file mode 100644 index 00000000..dbfdb4af --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge05.ets @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct listFadingEdge05 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0070 - fadingEdgeLength为undefined') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: undefined, 默认值: 32vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Pink) + Text('默认渐隐') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: undefined }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge06.ets new file mode 100644 index 00000000..b59d0529 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge06.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge06 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0060 - fadingEdgeLength为负数') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: -50vp, 默认值: 32vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Gray) + Text('负数渐隐') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(-50) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge07.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge07.ets new file mode 100644 index 00000000..c7dbe167 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge07.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge07 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0090 - ListItem渐隐效果') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 80vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Black) + Text('ListItem渐隐') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge08.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge08.ets new file mode 100644 index 00000000..8bbeba79 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge08.ets @@ -0,0 +1,185 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge08 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + @Builder + groupHeader(text: string) { + Text(text) + .fontSize(16) + .fontWeight(FontWeight.Bold) + .backgroundColor(0xAABBCC) + .width('100%') + .padding(10) + .textAlign(TextAlign.Center) + } + + build() { + Column() { + // 页面标题 + Text('测试用例0110 - ListItemGroup与ListItem间隔布局') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 80vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ListItemGroup({ header: this.groupHeader('第一组 - 基础项目') }) { + ForEach(this.arr.slice(0, 5), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + Text('Group 1') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + + ListItem() { + Text('分隔项目 - 混合布局测试') + .width('100%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFE4E1) + .fontColor(Color.Black) + } + + ListItemGroup({ header: this.groupHeader('第二组 - 扩展项目') }) { + ForEach(this.arr.slice(5, 10), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Orange) + Text('Group 2') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + + ListItem() { + Text('分隔项目 2 - 混合布局测试') + .width('100%') + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFE4E1) + .fontColor(Color.Black) + } + + ListItemGroup({ header: this.groupHeader('第三组 - 高级项目') }) { + ForEach(this.arr.slice(10, 15), (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('Group 3') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge09.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge09.ets new file mode 100644 index 00000000..886b8bf9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge09.ets @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +/** + * List自定义Modifier类 + * 用于测试用例0150 - 通过modifier设置fadingEdge属性 + */ +class ListFadingEdgeModifier implements AttributeModifier { + applyNormalAttribute(instance: ListAttribute): void { + console.info('ListFadingEdgeModifier applyNormalAttribute called') + instance.fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(80) }) + instance.scrollBar(BarState.Off) + instance.edgeEffect(EdgeEffect.Spring) + } +} + +@Entry +@Component +struct listFadingEdge09 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + // 测试用例0150的Modifier - 通过modifier设置fadingEdge + @State testModifier: AttributeModifier = new ListFadingEdgeModifier(); + + build() { + Column() { + // 页面标题 + Text('测试用例0150 - modifier场景渐隐效果') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdgeLength: 80vp, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 2000 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 - 通过modifier设置fadingEdge + List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('Modifier渐隐') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(100) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .attributeModifier(this.testModifier) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge10.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge10.ets new file mode 100644 index 00000000..98724cfe --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge10.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge10 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0320 - 滑动到底部时上边缘渐隐、下边缘无渐隐') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdge: true, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('滚动到底部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 3000 }); + }) + Button('滚动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 - 测试滑动到底部时的渐隐效果 + List({ space: 15, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + Text('边缘渐隐测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(120) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(50) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge11.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge11.ets new file mode 100644 index 00000000..192773bb --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_fadingEdge/listFadingEdge11.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct listFadingEdge11 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]; + scrollerForList: Scroller = new Scroller(); + @State currentIndex: number = 0; + + build() { + Column() { + // 页面标题 + Text('测试用例0330 - 初始状态和滑动到顶部时的边缘渐隐效果') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态信息显示 + Text(`fadingEdge: true, 当前滚动位置: ${this.currentIndex}`) + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('向下滑动') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 1500 }); + }) + Button('滑动到顶部') + .onClick(() => { + this.scrollerForList.scrollTo({ xOffset: 0, yOffset: 0 }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // List测试区域 - 测试初始状态和滑动到顶部时的渐隐效果 + List({ space: 15, initialIndex: 0, scroller: this.scrollerForList }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Row() { + Text('项目 ' + item.toString()) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Green) + Text('边缘渐隐测试') + .fontSize(14) + .fontColor(Color.Gray) + .margin({ left: 10 }) + } + .width('100%') + .height(120) + .backgroundColor(0xFFFFFF) + .borderRadius(10) + .padding(15) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + }, (item: string) => item) + } + .fadingEdge(true, { fadingEdgeLength: LengthMetrics.vp(50) }) + .onScrollIndex((start: number, end: number) => { + this.currentIndex = start; + }) + .width('100%') + .height('60%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} -- Gitee