diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/List.test.ets b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/List.test.ets index 2646f9a826a0ec6458a4b0a8b4591f5aba16573d..3d3898097658956b5dfa0deb968cad401b86168a 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/List.test.ets +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/List.test.ets @@ -31,6 +31,7 @@ import UiComponentTextCommonTextstyle from './UiComponentTextCommonTextstyleTest import UiComponentTextTextareaInterface from './UiComponentTextTextareaInterfaceTest/UiComponentTextTextareaInterface.test' import UIAttributePositionSizeLayoutTest from './UIAttributePositionSizeLayoutTest/UIAttributePositionSizeLayoutTest.test' import UIAttributePositionInterfaceTest from './UIAttributePositionInterfaceTest/UIAttributePositionInterfaceTest.test' +import UIComponentCreateColor from './UIComponentCreateColorTest/UIComponentCreateColor.test' export default function testsuite() { demoTest(); UIAttributeFontInterface001(); @@ -50,4 +51,5 @@ export default function testsuite() { UiComponentTextTextareaInterface(); UIAttributePositionSizeLayoutTest(); UIAttributePositionInterfaceTest(); + UIComponentCreateColor(); } \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..ca7e6dcc66ccd012cb9c101160dcbf81375c4751 --- /dev/null +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/test/UIComponentCreateColorTest/UIComponentCreateColor.test.ets @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024 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 } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' + +export default function UIComponentCreateColor() { + + describe('UIComponentCreateColor', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + 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_CREATE_COLOR_0050 + * @tc.name SUB_ACE_UI_COMPONENT_CREATE_COLOR_0050 + * @tc.desc switch the color and set background color to the default color-textinput + */ + it('SUB_ACE_UI_COMPONENT_CREATE_COLOR_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0050 start.`); + 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) + await button1.click() + await Utils.sleep(100) + let ch2:Component = await driver.findComponent(ON.id('colorstr')); + await driver.delayMs(100) + await ch2.click() + await Utils.sleep(100) + await button1.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 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() + await Utils.sleep(100) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0050 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_CREATE_COLOR_0100 + * @tc.name SUB_ACE_UI_COMPONENT_CREATE_COLOR_0100 + * @tc.desc switch the color and set background color to the default color-textarea + */ + it('SUB_ACE_UI_COMPONENT_CREATE_COLOR_0100', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0100 start.`); + 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) + await button1.click() + await Utils.sleep(100) + let ch2:Component = await driver.findComponent(ON.id('colorstr')); + await driver.delayMs(100) + await ch2.click() + await Utils.sleep(100) + await button1.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 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() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0100 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_CREATE_COLOR_0140 + * @tc.name SUB_ACE_UI_COMPONENT_CREATE_COLOR_0140 + * @tc.desc switch the color and set background color to the default color-search + */ + it('SUB_ACE_UI_COMPONENT_CREATE_COLOR_0140', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0140 start.`); + 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 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) + await button1.click() + await Utils.sleep(100) + let btn:Component = await driver.findComponent(ON.id('setTextSelection')); + 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) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_CREATE_COLOR_0140 finish.`); + done() + }) + }) +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..cb7df4293fe2c2bc12bfc3977b9f406611ce2625 --- /dev/null +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor005.ets @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentCreateColor005 { + @State booltext:boolean = false + @State caretcolorIndex: number = 0; + @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] + @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] + controller:TextInputController = new TextInputController() + + build() { + Column() { + //change selection + Button('setTextSelection') + .width('90%') + .margin({top:20}) + .id('setTextSelection') + .onClick(()=>{ + this.booltext=true + }) + //change caret color + Button('caretColor') + .width('90%') + .margin(20) + .id('caretColor') + .onClick(()=>{ + 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], + controller: this.controller + }) + .caretColor(this.caretcolor[this.caretcolorIndex]) + .width(300) + .margin(20) + .id('colorstr') + } + .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 new file mode 100644 index 0000000000000000000000000000000000000000..94207854bd348aea544f3e8ae550e48e0a9268d3 --- /dev/null +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor010.ets @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentCreateColor010 { + @State booltext:boolean = false + @State caretcolorIndex: number = 0; + @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] + @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] + controller:TextAreaController = new TextAreaController() + + build() { + Column() { + //change selection + Button('setTextSelection') + .width('90%') + .margin(20) + .id('setTextSelection') + .onClick(()=>{ + this.booltext=true + }) + //change caretcolor + Button('caretColor') + .width('90%') + .margin(20) + .id('caretColor') + .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], + controller: this.controller + }) + .caretColor(this.caretcolor[this.caretcolorIndex]) + .width(300) + .margin(20) + .id('colorstr') + } + .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 new file mode 100644 index 0000000000000000000000000000000000000000..66cd54635cb53f92f024770d436d660789490124 --- /dev/null +++ b/function/ui_compare/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentCreateColor/UIComponentCreateColor014.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 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 prompt from '@system.prompt'; + +@Entry +@Component + +struct UIComponentCreateColor014 { + @State booltext:boolean = false + @State caretcolorIndex: number = 0; + @State caretcolor: Color[] = [Color.Red, Color.Green, Color.Blue] + @State caretcolorStr: string[] = ['Red', 'Green', 'Blue'] + controller:SearchController = new SearchController() + + build() { + Column() { + //change selection + Button('setTextSelection') + .width('90%') + .margin(50) + .id('setTextSelection') + .onClick(()=>{ + this.booltext=true + }) + //change caretcolor + Button('caretColor') + .width('90%') + .margin(50) + .backgroundColor(Color.Orange) + .id('caretColor') + .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) + .margin(20) + .id('colorstr') + } + .width('100%') + .height('100%') + } +} diff --git a/function/ui_compare/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json b/function/ui_compare/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json index 42f75e417f60159d61aa2693e569f54400d13665..25455cc6729252554825315478f67cd2296e8768 100644 --- a/function/ui_compare/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/function/ui_compare/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -251,6 +251,9 @@ "testability/pages/UIAttributePositionInterface/UIAttributePositionInterface003", "testability/pages/UIAttributePositionInterface/UIAttributePositionInterface004", "testability/pages/UIAttributePositionInterface/UIAttributePositionInterface005", - "testability/pages/UIAttributePositionInterface/UIAttributePositionInterface006" + "testability/pages/UIAttributePositionInterface/UIAttributePositionInterface006", + "testability/pages/UIComponentCreateColor/UIComponentCreateColor005", + "testability/pages/UIComponentCreateColor/UIComponentCreateColor010", + "testability/pages/UIComponentCreateColor/UIComponentCreateColor014" ] }