From 2675a09964b71eecd5ca2f3cc4a60a868b2d1c73 Mon Sep 17 00:00:00 2001 From: phx1986 Date: Fri, 6 Sep 2024 15:17:15 +0800 Subject: [PATCH] 'color' Signed-off-by: phx1986 --- .../UIComponentCreateColor.test.ets | 78 ++++++++++--------- .../UIFontFeatureTest/UIFontFeature.test.ets | 2 +- .../UIComponentCreateColor005.ets | 43 +++++----- .../UIComponentCreateColor010.ets | 33 ++++---- .../UIComponentCreateColor014.ets | 37 ++++----- ...onentTextCommonAffineTransformation020.ets | 2 +- ...onentTextCommonAffineTransformation021.ets | 2 +- 7 files changed, 93 insertions(+), 104 deletions(-) diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIComponentCreateColorTest/UIComponentCreateColor.test.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIComponentCreateColorTest/UIComponentCreateColor.test.ets index ca7e6dcc..5e7c8235 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIComponentCreateColorTest/UIComponentCreateColor.test.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIComponentCreateColorTest/UIComponentCreateColor.test.ets @@ -47,27 +47,28 @@ export default function UIComponentCreateColor() { Settings.createWindow("testability/pages/UIComponentCreateColor/UIComponentCreateColor005") await Utils.sleep(1000) let driver : Driver = Driver.create(); - await driver.delayMs(1000) - await Utils.sleep(1000) - let button1:Component = await driver.findComponent(ON.id('caretColor')); await driver.delayMs(100) await Utils.sleep(100) + let ch1:Component = await driver.findComponent(ON.id('colorstr005')); + await driver.delayMs(100) + await ch1.click() + let button1:Component = await driver.findComponent(ON.id('caretColor005')); + await driver.delayMs(100) await button1.click() + await ch1.click() await Utils.sleep(100) - let ch2:Component = await driver.findComponent(ON.id('colorstr')); + let btn:Component = await driver.findComponent(ON.id('setTextSelection005')); await driver.delayMs(100) - await ch2.click() + await btn.click() await Utils.sleep(100) - await button1.click() + await ch1.click() await Utils.sleep(100) await button1.click() await Utils.sleep(100) - let btn:Component = await driver.findComponent(ON.id('setTextSelection')); - await driver.delayMs(100) - await btn.click() + await ch1.click() + await Utils.sleep(100) + await button1.click() await Utils.sleep(100) - let ch1:Component = await driver.findComponent(ON.id('rgb')); - await driver.delayMs(100) await ch1.click() await Utils.sleep(100) windowSnap.snapShot() @@ -85,27 +86,28 @@ export default function UIComponentCreateColor() { Settings.createWindow("testability/pages/UIComponentCreateColor/UIComponentCreateColor010") await Utils.sleep(1000) let driver : Driver = Driver.create(); - await driver.delayMs(1000) - await Utils.sleep(1000) - let button1:Component = await driver.findComponent(ON.id('caretColor')); await driver.delayMs(100) await Utils.sleep(100) + let ch1:Component = await driver.findComponent(ON.id('colorstr010')); + await driver.delayMs(100) + await ch1.click() + let button1:Component = await driver.findComponent(ON.id('caretColor010')); + await driver.delayMs(100) await button1.click() + await ch1.click() await Utils.sleep(100) - let ch2:Component = await driver.findComponent(ON.id('colorstr')); + let btn:Component = await driver.findComponent(ON.id('setTextSelection010')); await driver.delayMs(100) - await ch2.click() + await btn.click() await Utils.sleep(100) - await button1.click() + await ch1.click() await Utils.sleep(100) await button1.click() await Utils.sleep(100) - let btn:Component = await driver.findComponent(ON.id('setTextSelection')); - await driver.delayMs(100) - await btn.click() + await ch1.click() + await Utils.sleep(100) + await button1.click() await Utils.sleep(100) - let ch1:Component = await driver.findComponent(ON.id('rgb')); - await driver.delayMs(100) await ch1.click() await Utils.sleep(100) windowSnap.snapShot() @@ -123,27 +125,29 @@ export default function UIComponentCreateColor() { Settings.createWindow("testability/pages/UIComponentCreateColor/UIComponentCreateColor014") await Utils.sleep(1000) let driver : Driver = Driver.create(); - await driver.delayMs(1000) - await Utils.sleep(1000) - let button1:Component = await driver.findComponent(ON.id('caretColor')); - await driver.delayMs(1000) + await driver.delayMs(100) await Utils.sleep(100) - let ch2:Component = await driver.findComponent(ON.id('colorstr')); - await driver.delayMs(1000) - await ch2.click() - await Utils.sleep(1000) - await button1.click() - await Utils.sleep(1500) - await button1.click() - await Utils.sleep(1500) + let ch1:Component = await driver.findComponent(ON.id('colorstr014')); + await driver.delayMs(100) + await ch1.click() + await ch1.inputText('rgbcolor rgb text14') + let button1:Component = await driver.findComponent(ON.id('caretColor014')); + await driver.delayMs(100) await button1.click() + await ch1.click() await Utils.sleep(100) - let btn:Component = await driver.findComponent(ON.id('setTextSelection')); + let btn:Component = await driver.findComponent(ON.id('setTextSelection014')); await driver.delayMs(100) await btn.click() await Utils.sleep(100) - let ch1:Component = await driver.findComponent(ON.id('rgb')); - await driver.delayMs(100) + await ch1.click() + await Utils.sleep(100) + await button1.click() + await Utils.sleep(100) + await ch1.click() + await Utils.sleep(100) + await button1.click() + await Utils.sleep(100) await ch1.click() await Utils.sleep(100) windowSnap.snapShot() diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIFontFeatureTest/UIFontFeature.test.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIFontFeatureTest/UIFontFeature.test.ets index b9b1f01e..b4bd9ff6 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIFontFeatureTest/UIFontFeature.test.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIFontFeatureTest/UIFontFeature.test.ets @@ -21,7 +21,7 @@ import { Component, Driver ,ON } from '@ohos.UiTest' export default function UIFontFeature() { - describe('TestCase', () => { + describe('UIFontFeature', () => { afterEach(async (done: Function) => { if (Settings.windowClass == undefined) { return diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor005.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor005.ets index cb7df429..91367e56 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor005.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor005.ets @@ -16,10 +16,11 @@ @Entry @Component struct UIComponentCreateColor005 { - @State booltext:boolean = false @State caretcolorIndex: number = 0; @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] + @State selectionStart: number = 0 + @State selectionEnd: number = 0 controller:TextInputController = new TextInputController() build() { @@ -27,45 +28,39 @@ struct UIComponentCreateColor005 { //change selection Button('setTextSelection') .width('90%') + .height('10%') .margin({top:20}) - .id('setTextSelection') + .id('setTextSelection005') .onClick(()=>{ - this.booltext=true + this.selectionStart=0 + this.selectionEnd=5 }) //change caret color Button('caretColor') .width('90%') + .height('10%') .margin(20) - .id('caretColor') + .id('caretColor005') .onClick(()=>{ - this.caretcolorIndex++ - if (this.caretcolorIndex > (this.caretcolorStr.length - 1)) { - this.caretcolorIndex = 0 - } + this.caretcolorIndex++ + if (this.caretcolorIndex > (this.caretcolorStr.length - 1)) { + this.caretcolorIndex = 0 + } }) - //setTextSelection - if(this.booltext){ - TextInput({ - text: 'rgbcolorrgb', - controller: this.controller - }) - .caretColor('#007DFF') - .width(300) - .defaultFocus(true) - .onFocus(() => { - this.controller.setTextSelection(0, 5) - }) - .id('rgb') - } //caretcolor TextInput({ - text: this.caretcolorStr[this.caretcolorIndex], + text: 'rgbcolor rgb text', controller: this.controller }) .caretColor(this.caretcolor[this.caretcolorIndex]) .width(300) + .height('20%') .margin(20) - .id('colorstr') + .defaultFocus(true) + .onClick(() => { + this.controller.setTextSelection(this.selectionStart, this.selectionEnd) + }) + .id('colorstr005') } .width('100%') .height('100%') diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor010.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor010.ets index 94207854..38bcceea 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor010.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor010.ets @@ -16,7 +16,8 @@ @Entry @Component struct UIComponentCreateColor010 { - @State booltext:boolean = false + @State selectionStart: number = 0 + @State selectionEnd: number = 0 @State caretcolorIndex: number = 0; @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] @@ -27,36 +28,25 @@ struct UIComponentCreateColor010 { //change selection Button('setTextSelection') .width('90%') + .height('10%') .margin(20) - .id('setTextSelection') + .id('setTextSelection010') .onClick(()=>{ - this.booltext=true + this.selectionStart=0 + this.selectionEnd=5 }) //change caretcolor Button('caretColor') .width('90%') + .height('10%') .margin(20) - .id('caretColor') + .id('caretColor010') .onClick(()=>{ this.caretcolorIndex++ if (this.caretcolorIndex > (this.caretcolorStr.length - 1)) { this.caretcolorIndex = 0 } }) - //select(0,5) - if(this.booltext){ - TextArea({ - text: 'rgbcolorrgb', - controller: this.controller - }) - .caretColor('#007DFF') - .width(300) - .defaultFocus(true) - .id('rgb') - .onFocus(() => { - this.controller.setTextSelection(0, 5) - }) - } //caretcolor TextArea({ text: this.caretcolorStr[this.caretcolorIndex], @@ -64,8 +54,13 @@ struct UIComponentCreateColor010 { }) .caretColor(this.caretcolor[this.caretcolorIndex]) .width(300) + .height('20%') .margin(20) - .id('colorstr') + .defaultFocus(true) + .onClick(() => { + this.controller.setTextSelection(this.selectionStart, this.selectionEnd) + }) + .id('colorstr010') } .width('100%') .height('100%') diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor014.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor014.ets index 66cd5463..c64bd9b3 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor014.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor014.ets @@ -19,7 +19,8 @@ import prompt from '@system.prompt'; @Component struct UIComponentCreateColor014 { - @State booltext:boolean = false + @State selectionStart: number = 0 + @State selectionEnd: number = 0 @State caretcolorIndex: number = 0; @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] @@ -30,45 +31,39 @@ struct UIComponentCreateColor014 { //change selection Button('setTextSelection') .width('90%') - .margin(50) - .id('setTextSelection') + .height('10%') + .margin(20) + .id('setTextSelection014') .onClick(()=>{ - this.booltext=true + this.selectionStart=0 + this.selectionEnd=5 }) //change caretcolor Button('caretColor') .width('90%') - .margin(50) + .height('10%') + .margin(20) .backgroundColor(Color.Orange) - .id('caretColor') + .id('caretColor014') .onClick(()=>{ this.caretcolorIndex++ if (this.caretcolorIndex > (this.caretcolorStr.length - 1)) { this.caretcolorIndex = 0 } }) - //select(0,5) - if(this.booltext){ - Search({ - value: 'rgbcolorrgb', - controller: this.controller - }) - .caretStyle({color:'#007DFF'}) - .width(300) - .defaultFocus(true) - .onFocus(() => { - this.controller.setTextSelection(0, 5) - }) - .id('rgb') - } //caretcolor Search({ controller: this.controller }) .caretStyle({color:this.caretcolor[this.caretcolorIndex]}) .width(300) + .height('20%') .margin(20) - .id('colorstr') + .defaultFocus(true) + .onClick(() => { + this.controller.setTextSelection(this.selectionStart, this.selectionEnd) + }) + .id('colorstr014') } .width('100%') .height('100%') diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation020.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation020.ets index a248904b..6d05f744 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation020.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation020.ets @@ -76,7 +76,7 @@ struct UiComponentTextCommonAffineTransformation020 { build() { Column() { Button('sizechange') - .margin(5) + .margin(10) .width('90%') .height(15) .fontSize(12) diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation021.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation021.ets index 6f95367b..66979e3b 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation021.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UiComponentTextCommonAffineTransformation/UiComponentTextCommonAffineTransformation021.ets @@ -76,7 +76,7 @@ struct UiComponentTextCommonAffineTransformation021 { build() { Column() { Button('sizechange') - .margin(5) + .margin(10) .width('90%') .height(15) .fontSize(12) -- Gitee