From 3e417f567309a6c4ad11491eb66912bef6feba16 Mon Sep 17 00:00:00 2001 From: dongwei Date: Mon, 8 Sep 2025 15:42:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?list=E7=BB=84=E4=BB=B6=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../ListScrollbarHover.test.ets | 374 ++++++++++++++++++ .../listScrollbarHover01.ets | 94 +++++ .../listScrollbarHover02.ets | 89 +++++ .../listScrollbarHover03.ets | 110 ++++++ .../listScrollbarHover04.ets | 94 +++++ .../listScrollbarHover05.ets | 88 +++++ .../listScrollbarHover06.ets | 107 +++++ .../listScrollbarHover07.ets | 89 +++++ .../listScrollbarHover08.ets | 90 +++++ .../listScrollbarHover09.ets | 93 +++++ .../listScrollbarHover10.ets | 92 +++++ 11 files changed, 1320 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_scrollbar_hover/ListScrollbarHover.test.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover04.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover05.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover06.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover07.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover08.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover09.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover10.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_scrollbar_hover/ListScrollbarHover.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_scrollbar_hover/ListScrollbarHover.test.ets new file mode 100644 index 00000000..fa0fc59f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/list_scrollbar_hover/ListScrollbarHover.test.ets @@ -0,0 +1,374 @@ +/** + * 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 ListScrollbarHoverTest () { + + describe('ListScrollbarHoverTest', () => { + 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_SACROLLBAR_HOVER_0030 + * @tc.name : List scrollbar hover test - change color + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0030', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0030 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover01") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0030')); + await windowSnap.snapShot('ListScrollbarHover0030_1'); + await Utils.sleep(1000); + + // 点击改变滚动条颜色按钮 + let colorButton: Component = await driver.waitForComponent(ON.id('change_color_button_03'), 1000); + await colorButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0030_2'); + await Utils.sleep(1000); + + // 再次点击改变颜色 + await colorButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0030_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0030 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0050 + * @tc.name : List scrollbar hover test - change layout direction + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0050', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0050 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover02") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0050')); + await windowSnap.snapShot('ListScrollbarHover0050_1'); + await Utils.sleep(1000); + + // 点击改变布局方向按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_05'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0050_2'); + await Utils.sleep(1000); + + // 再次点击改变方向 + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0050_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0050 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0100 + * @tc.name : List scrollbar hover test - Image component state change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0100', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0100 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover03") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0100')); + await windowSnap.snapShot('ListScrollbarHover0100_1'); + await Utils.sleep(1000); + + // 点击改变滚动条状态按钮 + let stateButton: Component = await driver.waitForComponent(ON.id('change_state_button_10'), 1000); + await stateButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0100_2'); + await Utils.sleep(1000); + + // 再次点击改变状态 + await stateButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0100_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0100 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0040 + * @tc.name : List scrollbar hover test - change width + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0040', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0040 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover04") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0040')); + await windowSnap.snapShot('ListScrollbarHover0040_1'); + await Utils.sleep(1000); + + // 点击改变滚动条宽度按钮 + let widthButton: Component = await driver.waitForComponent(ON.id('change_width_button_04'), 1000); + await widthButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0040_2'); + await Utils.sleep(1000); + + // 再次点击改变宽度 + await widthButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0040_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0040 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0060 + * @tc.name : List scrollbar hover test - change direction + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0060', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0060 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover05") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0060')); + await windowSnap.snapShot('ListScrollbarHover0060_1'); + await Utils.sleep(1000); + + // 点击改变direction按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_06'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0060_2'); + await Utils.sleep(1000); + + // 再次点击改变direction + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0060_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0060 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0080 + * @tc.name : List scrollbar hover test - Text component state change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0080', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0080 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover06") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0080')); + await windowSnap.snapShot('ListScrollbarHover0080_1'); + await Utils.sleep(1000); + + // 点击改变滚动条状态按钮 + let stateButton: Component = await driver.waitForComponent(ON.id('change_state_button_08'), 1000); + await stateButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0080_2'); + await Utils.sleep(1000); + + // 再次点击改变状态 + await stateButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0080_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0080 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0130 + * @tc.name : List scrollbar hover test - Text component direction change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0130', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0130 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover07") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0130')); + await windowSnap.snapShot('ListScrollbarHover0130_1'); + await Utils.sleep(1000); + + // 点击改变direction按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_13'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0130_2'); + await Utils.sleep(1000); + + // 再次点击改变direction + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0130_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0130 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0110 + * @tc.name : List scrollbar hover test - Text component layout direction change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0110', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0110 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover08") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0110')); + await windowSnap.snapShot('ListScrollbarHover0110_1'); + await Utils.sleep(1000); + + // 点击改变布局方向按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_11'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0110_2'); + await Utils.sleep(1000); + + // 再次点击改变方向 + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0110_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0110 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0120 + * @tc.name : List scrollbar hover test - Image component layout direction change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0120', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0120 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover09") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0120')); + await windowSnap.snapShot('ListScrollbarHover0120_1'); + await Utils.sleep(1000); + + // 点击改变布局方向按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_12'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0120_2'); + await Utils.sleep(1000); + + // 再次点击改变方向 + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0120_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0120 end'); + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0140 + * @tc.name : List scrollbar hover test - Image component direction change + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0140', Level.LEVEL3, async (done: Function) => { + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0140 start'); + Settings.createWindow("testability/pages/list_scrollbar_hover/listScrollbarHover10") + let driver: Driver = Driver.create(); + await driver.waitForIdle(200, 500); + await driver.assertComponentExist(ON.text('List滚动条悬浮测试0140')); + await windowSnap.snapShot('ListScrollbarHover0140_1'); + await Utils.sleep(1000); + + // 点击改变direction按钮 + let directionButton: Component = await driver.waitForComponent(ON.id('change_direction_button_14'), 1000); + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0140_2'); + await Utils.sleep(1000); + + // 再次点击改变direction + await directionButton.click(); + await driver.waitForIdle(500, 2000); + await windowSnap.snapShot('ListScrollbarHover0140_3'); + await Utils.sleep(1000); + + console.log('SUB_ACE_UI_COMPONENT_LIST_SACROLLBAR_HOVER_0140 end'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover01.ets new file mode 100644 index 00000000..4741d68c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover01.ets @@ -0,0 +1,94 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover01 { + @State scrollBarColor: string | number | Color = Color.Blue; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0030') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('滚动条状态: Auto, 动态改变滚动条颜色') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前颜色: ${this.scrollBarColor}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变滚动条颜色') + .id('change_color_button_03') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + if (this.scrollBarColor === Color.Blue) { + this.scrollBarColor = Color.Red; + } else if (this.scrollBarColor === Color.Red) { + this.scrollBarColor = Color.Green; + } else { + this.scrollBarColor = Color.Blue; + } + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .scrollBarColor(this.scrollBarColor) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover02.ets new file mode 100644 index 00000000..36b7cc7f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover02.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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover02 { + @State listDirection: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0050') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('滚动条状态: Auto, 动态改变布局方向') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listDirection === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变布局方向') + .id('change_direction_button_05') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listDirection = this.listDirection === Axis.Vertical ? + Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listDirection) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover03.ets new file mode 100644 index 00000000..e9813a71 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover03.ets @@ -0,0 +1,110 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover03 { + @State scrollBarState: BarState = BarState.Auto; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0100') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Image, 滚动条状态异常值与正常值切换') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前滚动条状态: ${this.getScrollBarStateText()}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变滚动条状态') + .id('change_state_button_10') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + if (this.scrollBarState === BarState.Auto) { + this.scrollBarState = BarState.On; + } else if (this.scrollBarState === BarState.On) { + this.scrollBarState = BarState.Off; + } else { + this.scrollBarState = BarState.Auto; + } + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Image($r('app.media.icon')) + .width(40) + .height(40) + .margin({ right: 10 }) + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(this.scrollBarState) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } + + private getScrollBarStateText(): string { + switch (this.scrollBarState) { + case BarState.Auto: + return 'Auto'; + case BarState.On: + return 'On'; + case BarState.Off: + return 'Off'; + default: + return 'Unknown'; + } + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover04.ets new file mode 100644 index 00000000..52cd85dd --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover04.ets @@ -0,0 +1,94 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover04 { + @State scrollBarWidth: number = 8; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0040') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('滚动条状态: Auto, 动态改变滚动条宽度') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前滚动条宽度: ${this.scrollBarWidth}px`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变滚动条宽度') + .id('change_width_button_04') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + if (this.scrollBarWidth === 8) { + this.scrollBarWidth = 12; + } else if (this.scrollBarWidth === 12) { + this.scrollBarWidth = 16; + } else { + this.scrollBarWidth = 8; + } + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .scrollBarWidth(this.scrollBarWidth) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover05.ets new file mode 100644 index 00000000..a960ccfd --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover05.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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover05 { + @State listAxis: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0060') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('滚动条状态: Auto, 改变direction') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listAxis === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变direction') + .id('change_direction_button_06') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listAxis = this.listAxis === Axis.Vertical ? Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listAxis) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover06.ets new file mode 100644 index 00000000..1b7ac0de --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover06.ets @@ -0,0 +1,107 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover06 { + @State scrollBarState: BarState = BarState.Auto; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0080') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Text, 滚动条状态异常值与正常值切换') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前滚动条状态: ${this.getScrollBarStateText()}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变滚动条状态') + .id('change_state_button_08') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + if (this.scrollBarState === BarState.Auto) { + this.scrollBarState = BarState.On; + } else if (this.scrollBarState === BarState.On) { + this.scrollBarState = BarState.Off; + } else { + this.scrollBarState = BarState.Auto; + } + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(this.scrollBarState) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } + + private getScrollBarStateText(): string { + switch (this.scrollBarState) { + case BarState.Auto: + return 'Auto'; + case BarState.On: + return 'On'; + case BarState.Off: + return 'Off'; + default: + return 'Unknown'; + } + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover07.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover07.ets new file mode 100644 index 00000000..ef9fbd90 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover07.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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover07 { + @State listAxis: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0130') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Text, 滚动条状态: Auto, 改变direction') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listAxis === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变direction') + .id('change_direction_button_13') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listAxis = this.listAxis === Axis.Vertical ? Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listAxis) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover08.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover08.ets new file mode 100644 index 00000000..885f2cf3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover08.ets @@ -0,0 +1,90 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover08 { + @State listDirection: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0110') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Text, 动态改变布局方向') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listDirection === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变布局方向') + .id('change_direction_button_11') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listDirection = this.listDirection === Axis.Vertical ? + Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listDirection) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover09.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover09.ets new file mode 100644 index 00000000..29f9ece6 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover09.ets @@ -0,0 +1,93 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover09 { + @State listDirection: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0120') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Image, 动态改变布局方向') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listDirection === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变布局方向') + .id('change_direction_button_12') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listDirection = this.listDirection === Axis.Vertical ? + Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Image($r('app.media.icon')) + .width(40) + .height(40) + .margin({ right: 10 }) + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listDirection) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover10.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover10.ets new file mode 100644 index 00000000..1bf05302 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/list_scrollbar_hover/listScrollbarHover10.ets @@ -0,0 +1,92 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct listScrollbarHover10 { + @State listAxis: Axis = Axis.Vertical; + @State currentIndex: number = 0; + private scroller: Scroller = new Scroller(); + private dataArray: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9', 'Item 10']; + + build() { + Column() { + Text('List滚动条悬浮测试0140') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, bottom: 10 }) + + Text('外置滚动条子组件: Image, 滚动条状态: Auto, 改变direction') + .fontSize(16) + .margin({ bottom: 10 }) + + Text(`当前列表方向: ${this.listAxis === Axis.Vertical ? 'Vertical' : 'Horizontal'}`) + .fontSize(14) + .margin({ bottom: 10 }) + + Button('改变direction') + .id('change_direction_button_14') + .type(ButtonType.Capsule) + .height(50) + .onClick(() => { + this.listAxis = this.listAxis === Axis.Vertical ? Axis.Horizontal : Axis.Vertical; + }) + + List({ scroller: this.scroller }) { + ForEach(this.dataArray, (item: string, index: number) => { + ListItem() { + Row() { + Image($r('app.media.icon')) + .width(40) + .height(40) + .margin({ right: 10 }) + Text(item) + .fontSize(16) + .fontColor(Color.Black) + Blank() + Text(`Index: ${index}`) + .fontSize(14) + .fontColor(Color.Gray) + } + .width('100%') + .height(60) + .padding({ left: 20, right: 20 }) + .backgroundColor(index % 2 === 0 ? Color.White : Color.Gray) + .borderRadius(8) + .margin({ bottom: 5 }) + } + }, (item: string) => item) + } + .width('100%') + .height(400) + .scrollBar(BarState.Auto) + .listDirection(this.listAxis) + .onScrollIndex((firstIndex: number) => { + this.currentIndex = firstIndex; + }) + + Text(`当前滚动位置: ${this.currentIndex}`) + .fontSize(14) + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + .backgroundColor(0xF5F5F5) + .padding(20) + } +} -- Gitee From 6a7c8bb59d619e146b15f323fc7b335e6d7d60b1 Mon Sep 17 00:00:00 2001 From: dongwei Date: Tue, 9 Sep 2025 14:38:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?textPicker=E7=BB=84=E4=BB=B6=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../textPicker_wear/TextPickerWear.test.ets | 870 ++++++++++++++++++ .../textPicker_wear/textPickerWear01.ets | 76 ++ .../textPicker_wear/textPickerWear02.ets | 76 ++ .../textPicker_wear/textPickerWear03.ets | 76 ++ .../textPicker_wear/textPickerWear04.ets | 79 ++ .../textPicker_wear/textPickerWear05.ets | 76 ++ .../textPicker_wear/textPickerWear06.ets | 79 ++ .../textPicker_wear/textPickerWear07.ets | 76 ++ .../textPicker_wear/textPickerWear08.ets | 79 ++ .../textPicker_wear/textPickerWear09.ets | 79 ++ .../textPicker_wear/textPickerWear10.ets | 76 ++ 11 files changed, 1642 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/textPicker_wear/TextPickerWear.test.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear01.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear02.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear03.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear04.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear05.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear06.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear07.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear08.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear09.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear10.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/textPicker_wear/TextPickerWear.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/textPicker_wear/TextPickerWear.test.ets new file mode 100644 index 00000000..d2904cbc --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/textPicker_wear/TextPickerWear.test.ets @@ -0,0 +1,870 @@ +/** + * 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 TextPickerWearTest() { + describe('TextPickerWearTest', () => { + beforeAll(() => { + console.info('TextPickerWearTest beforeAll'); + }); + + beforeEach(() => { + console.info('TextPickerWearTest beforeEach'); + }); + + 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() + }) + + afterAll(() => { + console.info('TextPickerWearTest afterAll'); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0450 + * @tc.name : TextPicker wearable single column focus display test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0450', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear01"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker更改选中项观察焦点显示 + let textPicker: Component = await driver.waitForComponent(ON.id('text_picker_01'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项字体,颜色等 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0450'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0440 + * @tc.name : TextPicker wearable single column scroll up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0440', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear02"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向上滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.8; + let endY = rect.top + height * 0.2; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0440'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0400 + * @tc.name : TextPicker wearable single column fling up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0400', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear03"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向上抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY - 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0400'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0380 + * @tc.name : TextPicker wearable multi column click upper option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0380', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear04"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker点击上面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0380'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0430 + * @tc.name : TextPicker wearable single column fling down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0430', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear05"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向下抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向下抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY + 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0430'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0370 + * @tc.name : TextPicker wearable multi column scroll up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0370', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear06"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向上滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用swipe方法模拟向上滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.8; + let endY = rect.top + height * 0.2; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0370'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0460 + * @tc.name : TextPicker wearable single column fling up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0460', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear07"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向上抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY - 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0460'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0390 + * @tc.name : TextPicker wearable multi column click lower option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0390', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear08"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker点击下面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0390'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0510 + * @tc.name : TextPicker wearable multi column click lower option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0510', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear09"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker点击下面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0510'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0490 + * @tc.name : TextPicker wearable single column click lower option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0490', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear10"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker点击下面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0490'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0520 + * @tc.name : TextPicker wearable multi column scroll down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0520', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear11"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向下滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用swipe方法模拟向下滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.2; + let endY = rect.top + height * 0.8; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0520'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0470 + * @tc.name : TextPicker wearable single column fling down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0470', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear12"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向下抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向下抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY + 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0470'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0550 + * @tc.name : TextPicker wearable multi column fling down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0550', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear13"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向下抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用正确的fling方法,从中心点向下抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY + 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0550'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0530 + * @tc.name : TextPicker wearable multi column click upper option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0530', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear14"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker点击上面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0530'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0540 + * @tc.name : TextPicker wearable single column focus display test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0540', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear15"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker更改选中项观察焦点显示 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项字体,颜色等 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0540'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0570 + * @tc.name : TextPicker wearable single column click upper option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0570', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear16"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker点击上面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0570'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0560 + * @tc.name : TextPicker wearable single column fling up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0560', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear17"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向上抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY - 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0560'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0630 + * @tc.name : TextPicker wearable single column click upper option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0630', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear18"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker点击上面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0630'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0640 + * @tc.name : TextPicker wearable multi column scroll down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0640', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear19"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向下滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用swipe方法模拟向下滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.2; + let endY = rect.top + height * 0.8; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0640'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0580 + * @tc.name : TextPicker wearable multi column multi finger operation test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0580', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear20"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker多指操作同时滑动多列 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0580'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0620 + * @tc.name : TextPicker wearable single column drag up down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0620', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear21"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上/向下拖动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向上拖动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.6; + let endY = rect.top + height * 0.4; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + // 使用swipe方法模拟向下拖动 + await driver.swipe(centerX, endY, centerX, startY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0620'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0610 + * @tc.name : TextPicker wearable single column scroll down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0610', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear22"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向下滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向下滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.2; + let endY = rect.top + height * 0.8; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0610'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0600 + * @tc.name : TextPicker wearable single column fling down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0600', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear23"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向下抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用正确的fling方法,从中心点向下抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY + 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0600'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0660 + * @tc.name : TextPicker wearable single column drag up down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0660', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear24"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上/向下拖动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向上拖动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.6; + let endY = rect.top + height * 0.4; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + // 使用swipe方法模拟向下拖动 + await driver.swipe(centerX, endY, centerX, startY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0660'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0650 + * @tc.name : TextPicker wearable multi column fling up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0650', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear25"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向上抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用正确的fling方法,从中心点向上抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY - 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0650'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0680 + * @tc.name : TextPicker wearable multi column fling up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0680', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear26"); + await driver.waitForIdle(500, 2000); + + // 1、多列TextPicker向上抛滑 + let textPicker: Component = await driver.waitForComponent(ON.id('multi_text_picker'), 1000); + // 使用正确的fling方法,从中心点向上抛滑 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let centerY = rect.top + (rect.bottom - rect.top) / 2; + await driver.fling({x: centerX, y: centerY}, {x: centerX, y: centerY - 200}, 5, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0680'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0670 + * @tc.name : TextPicker wearable single column click lower option test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0670', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear27"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker点击下面备选项 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0670'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0720 + * @tc.name : TextPicker wearable single column focus display test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0720', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear28"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker更改选中项观察焦点显示 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + await textPicker.click(); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项字体,颜色等 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0720'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0700 + * @tc.name : TextPicker wearable single column scroll up test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0700', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear29"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向上滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向上滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.8; + let endY = rect.top + height * 0.2; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0700'); + await Utils.sleep(1000); + + done(); + }); + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0710 + * @tc.name : TextPicker wearable single column scroll down test + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0710', Level.LEVEL3, async (done: Function) => { + let driver: Driver = Driver.create(); + Settings.createWindow("testability/pages/textPicker_wear/textPickerWear30"); + await driver.waitForIdle(500, 2000); + + // 1、单列TextPicker向下滑动 + let textPicker: Component = await driver.waitForComponent(ON.id('single_text_picker'), 1000); + // 使用swipe方法模拟向下滑动 + let rect = await textPicker.getBounds(); + let centerX = rect.left + (rect.right - rect.left) / 2; + let height = rect.bottom - rect.top; + let startY = rect.top + height * 0.2; + let endY = rect.top + height * 0.8; + await driver.swipe(centerX, startY, centerX, endY, 1000); + await driver.waitForIdle(500, 2000); + + // 2、观察选中项变化 + await windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PICKER_WEAR_0710'); + await Utils.sleep(1000); + + done(); + }); + }); +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear01.ets new file mode 100644 index 00000000..f17d8c16 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear01.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear01 { + @State selectedIndex: number = 2; + private range: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker焦点显示测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.range[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 20 }) + + TextPicker({ + range: this.range, + selected: this.selectedIndex, + value: this.range[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('text_picker_01') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 20, weight: FontWeight.Bold } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 观察选中项的焦点显示效果') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear02.ets new file mode 100644 index 00000000..b5c9d32b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear02.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear02 { + @State selectedIndex: number = 5; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向上滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Red, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear03.ets new file mode 100644 index 00000000..28c3b951 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear03.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear03 { + @State selectedIndex: number = 3; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向上抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Green, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear04.ets new file mode 100644 index 00000000..38e664a5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear04.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear04 { + @State selectedIndex: number[] = [2, 1]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker点击上面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Orange, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击上面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear05.ets new file mode 100644 index 00000000..1f639bbe --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear05.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear05 { + @State selectedIndex: number = 4; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向下抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear06.ets new file mode 100644 index 00000000..48605705 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear06.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear06 { + @State selectedIndex: number[] = [1, 3]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向上滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Brown, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear07.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear07.ets new file mode 100644 index 00000000..736fd728 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear07.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear07 { + @State selectedIndex: number = 6; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向上抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Pink, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear08.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear08.ets new file mode 100644 index 00000000..bb037f30 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear08.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear08 { + @State selectedIndex: number[] = [3, 2]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker点击下面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击下面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear09.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear09.ets new file mode 100644 index 00000000..5a519bb3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear09.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear09 { + @State selectedIndex: number[] = [4, 1]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker点击下面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Red, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击下面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear10.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear10.ets new file mode 100644 index 00000000..1b32b1b9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear10.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear10 { + @State selectedIndex: number = 7; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker点击下面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Yellow, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击下面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file -- Gitee From f14fc3beb82c3464ff4a102e139cf99231e5ee59 Mon Sep 17 00:00:00 2001 From: dongwei Date: Tue, 9 Sep 2025 14:39:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?textPicker=E7=BB=84=E4=BB=B6=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- .../textPicker_wear/textPickerWear11.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear12.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear13.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear14.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear15.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear16.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear17.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear18.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear19.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear20.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear21.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear22.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear23.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear24.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear25.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear26.ets | 79 +++++++++++++++++++ .../textPicker_wear/textPickerWear27.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear28.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear29.ets | 76 ++++++++++++++++++ .../textPicker_wear/textPickerWear30.ets | 76 ++++++++++++++++++ 20 files changed, 1541 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear11.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear12.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear13.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear14.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear15.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear16.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear17.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear18.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear19.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear20.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear21.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear22.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear23.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear24.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear25.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear26.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear27.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear28.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear29.ets create mode 100644 sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear30.ets diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear11.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear11.ets new file mode 100644 index 00000000..eb160336 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear11.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear11 { + @State selectedIndex: number[] = [2, 4]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向下滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear12.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear12.ets new file mode 100644 index 00000000..fd781ccf --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear12.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear12 { + @State selectedIndex: number = 8; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向下抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Green, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear13.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear13.ets new file mode 100644 index 00000000..18cfe46a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear13.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear13 { + @State selectedIndex: number[] = [1, 3]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向下抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Green, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear14.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear14.ets new file mode 100644 index 00000000..c293dd40 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear14.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear14 { + @State selectedIndex: number[] = [4, 2]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker点击上面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Yellow, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击上面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear15.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear15.ets new file mode 100644 index 00000000..904dbf53 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear15.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear15 { + @State selectedIndex: number = 9; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker焦点显示测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 20, weight: FontWeight.Bold } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 观察选中项的焦点显示效果') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear16.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear16.ets new file mode 100644 index 00000000..3b2f938a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear16.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear16 { + @State selectedIndex: number = 0; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker点击上面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Green, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击上面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear17.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear17.ets new file mode 100644 index 00000000..283c43b3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear17.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear17 { + @State selectedIndex: number = 1; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向上抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Red, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear18.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear18.ets new file mode 100644 index 00000000..587f7098 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear18.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear18 { + @State selectedIndex: number = 2; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker点击上面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Gray, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击上面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear19.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear19.ets new file mode 100644 index 00000000..be1b8d82 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear19.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear19 { + @State selectedIndex: number[] = [3, 1]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向下滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Red, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear20.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear20.ets new file mode 100644 index 00000000..9a070754 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear20.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear20 { + @State selectedIndex: number[] = [2, 2]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker多指操作测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 多指操作同时滑动多列观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear21.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear21.ets new file mode 100644 index 00000000..acb7a419 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear21.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear21 { + @State selectedIndex: number = 4; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker拖动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Yellow, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上/向下拖动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear22.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear22.ets new file mode 100644 index 00000000..a59b83f9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear22.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear22 { + @State selectedIndex: number = 5; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向下滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.White, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear23.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear23.ets new file mode 100644 index 00000000..f1a10fbc --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear23.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear23 { + @State selectedIndex: number = 6; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向下抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear24.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear24.ets new file mode 100644 index 00000000..99166b7d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear24.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear24 { + @State selectedIndex: number = 7; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker拖动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Gray, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上/向下拖动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear25.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear25.ets new file mode 100644 index 00000000..ad4d995f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear25.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear25 { + @State selectedIndex: number[] = [1, 4]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向上抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Red, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear26.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear26.ets new file mode 100644 index 00000000..da13d94d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear26.ets @@ -0,0 +1,79 @@ +/** + * 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 textPickerWear26 { + @State selectedIndex: number[] = [3, 3]; + private multiOptions: string[][] = [ + ['选项1', '选项2', '选项3', '选项4', '选项5'], + ['子选项1', '子选项2', '子选项3', '子选项4', '子选项5'] + ]; + private multipleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(50), + LengthMetrics.percent(50) + ]; + + build() { + Column() { + Text('多列TextPicker向上抛滑测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.multiOptions[0][this.selectedIndex[0]] + ' - ' + this.multiOptions[1][this.selectedIndex[1]]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.multiOptions, + selected: this.selectedIndex, + columnWidths: this.multipleColumnWidths + }) + .id('multi_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 14, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 16, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number[]; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onScrollStop ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker 多列:onEnterSelectedArea ' + JSON.stringify(value) + ', ' + 'index: ' + JSON.stringify(index)); + }) + .width('90%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上抛滑观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear27.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear27.ets new file mode 100644 index 00000000..a5abd7ee --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear27.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear27 { + @State selectedIndex: number = 8; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker点击下面备选项测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Green, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 点击下面备选项观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear28.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear28.ets new file mode 100644 index 00000000..ddcce5d9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear28.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear28 { + @State selectedIndex: number = 9; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker焦点显示测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Orange, font: { size: 20, weight: FontWeight.Bold } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 观察选中项的焦点显示效果') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear29.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear29.ets new file mode 100644 index 00000000..b37725f7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear29.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear29 { + @State selectedIndex: number = 0; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向上滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Blue, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向上滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear30.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear30.ets new file mode 100644 index 00000000..bf5f2319 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/textPicker_wear/textPickerWear30.ets @@ -0,0 +1,76 @@ +/** + * 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 textPickerWear30 { + @State selectedIndex: number = 1; + private singleOptions: string[] = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7', '选项8', '选项9', '选项10']; + private singleColumnWidths: LengthMetrics[] = [ + LengthMetrics.percent(100) + ]; + + build() { + Column() { + Text('单列TextPicker向下滑动测试') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20 }) + + Text('当前选中: ' + this.singleOptions[this.selectedIndex]) + .fontSize(16) + .margin({ bottom: 10 }) + + TextPicker({ + range: this.singleOptions, + selected: this.selectedIndex, + value: this.singleOptions[this.selectedIndex], + columnWidths: this.singleColumnWidths + }) + .id('single_text_picker') + .disappearTextStyle({ color: Color.Gray, font: { size: 15, weight: FontWeight.Lighter } }) + .textStyle({ color: Color.Black, font: { size: 18, weight: FontWeight.Normal } }) + .selectedTextStyle({ color: Color.Pink, font: { size: 18, weight: FontWeight.Medium } }) + .defaultPickerItemHeight(50) + .canLoop(false) + .onChange((value: string | string[], index: number | number[]) => { + this.selectedIndex = index as number; + }) + .onScrollStop((value: string | string[], index: number | number[]) => { + console.info('TextPicker scroll stopped, value: ' + value + ', index: ' + index); + }) + .onEnterSelectedArea((value: string | string[], index: number | number[]) => { + console.info('TextPicker item enter selected area, value: ' + value + ', index: ' + index); + }) + .width('80%') + .height(200) + .backgroundColor(Color.White) + .borderRadius(10) + .margin({ bottom: 20 }) + + Text('测试说明: 向下滑动观察选中项变化') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5') + .padding(20) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file -- Gitee