diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test.ets index ccf64109a71855014aa23478caa9812a07ba94e9..70f0ce3550dacab566d75b24747087fc7e6a6cc2 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test.ets @@ -41,6 +41,21 @@ export default function ComponentTextRicheditorAITests() { describe('ComponentTextRicheditorAITests', () => { + 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() + }) /** * NO.SUB_ACE_UI_RICHEDITOR_AI_0010 *des:1、点击“开启AI分析”按钮(设置 @@ -49,9 +64,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0010', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0010 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0010"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0010')); await rich.click(); @@ -75,9 +90,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0020 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0020"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0020')); await rich.click(); @@ -100,9 +115,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0030', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0030 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0030"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0030')); await rich.click(); @@ -138,9 +153,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0040', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0040 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0040"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0040')); await rich.click(); @@ -182,9 +197,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0050', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0050 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0050"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0050')); await rich.click(); @@ -216,9 +231,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0060', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0060 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0060"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0060')); await rich.click(); @@ -248,9 +263,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0070', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0070 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0070"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0070')); await rich.click(); @@ -278,9 +293,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0080', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0080 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0080"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0080')); await rich.click(); @@ -301,7 +316,6 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0090', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0090 start.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0090"); await Utils.sleep(2000); windowSnap.snapShot(); @@ -319,9 +333,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0100', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0100 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0100"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0100')); await rich.click(); @@ -347,9 +361,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0110', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0110 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0110"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0110')); await rich.click(); @@ -375,9 +389,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0120', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0120 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0120"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0120')); await rich.click(); @@ -403,9 +417,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0130', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0130 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0130"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0130')); await rich.click(); @@ -431,9 +445,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0140', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0140 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0140"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0140')); await rich.click(); @@ -459,9 +473,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0150', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0150 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0150"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0150')); await rich.click(); @@ -491,9 +505,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0160', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0160 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0160"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0160')); await rich.click(); @@ -524,9 +538,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0170', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0170 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0170"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0170')); await rich.click(); @@ -557,9 +571,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0180', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0180 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0180"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0180')); await rich.click(); @@ -591,9 +605,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0190', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0190 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0190"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0190')); await rich.click(); @@ -621,9 +635,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0200', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0200 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0200"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0200')); await rich.click(); @@ -651,9 +665,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0210', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0210 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0210"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0210')); let AI = await driver.findComponent(ON.id('AI')); @@ -675,9 +689,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0220', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0220 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0220"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0220')); let AI = await driver.findComponent(ON.id('AI')); @@ -737,9 +751,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0230', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0230 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0230"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0230')); let AI = await driver.findComponent(ON.id('AI')); @@ -763,9 +777,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0240', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0240 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0240"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0240')); let AI = await driver.findComponent(ON.id('AI')); @@ -787,9 +801,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0250', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0250 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0250"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0250')); await Utils.sleep(1000); @@ -810,9 +824,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0260', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0260 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0260"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0260')); await rich.click(); @@ -843,9 +857,9 @@ export default function ComponentTextRicheditorAITests() { */ it('SUB_ACE_UI_RICHEDITOR_AI_0270', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_AI_0270 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorAITest/ComponentTextRicheditorAI0270"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorAI0270')); await rich.click(); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidanceTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidanceTests.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab3c625dfed5765ec7563017b73fc4bbd5559c51 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidanceTests.test.ets @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { afterEach, describe, it } 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, On } from '@ohos.UiTest' +import { KeyCode } from '@kit.InputKit' + +/* + * SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0001:Avoidance相关用例 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function ComponentTextRicheditorAvoidanceTests() { + + describe('ComponentTextRicheditorAvoidanceTests', () => { + 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() + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0001 + *des:1、添加RichEditor组件 + 2、双击或者长按选中文本\image内容,左右手柄均可见 + 3、选择组件内比较靠下的内容,调整左右手柄并往下骨动,满 + 足顶部避让,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0001', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0001 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0001"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0001")); + await richeditor.longClick(); + await Utils.sleep(1000); + let richeditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0001")); + await richeditor1.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(1000); + let richeditor2 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0001")); + await richeditor2.click(); + await Utils.sleep(1000); + let select2 = await driver.findComponent(ON.id('select2')); + await select2.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0001.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0002 + *des:1、添加RichEditor组件 + 2、双击或者长按选中文本\image内容,左右手柄均可见 + 3、调整左右手柄,满足顶部避让失败底部避让成功,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0002', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0002 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0002"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0002")); + await richeditor.longClick(); + await Utils.sleep(1000); + let richeditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0002")); + await richeditor1.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(1000); + let richeditor2 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0002")); + await richeditor2.click(); + await Utils.sleep(1000); + let select2 = await driver.findComponent(ON.id('select2')); + await select2.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0002.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0003 + *des:1、添加RichEditor组件 + 2、双击或者长按选中文本\image内容,左右手柄均可见 + 3、调整左右手柄,满足顶部避让失败底部避让失败,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0003', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0003 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0003"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0003")); + await richeditor.click(); + await Utils.sleep(1000); + let select2 = await driver.findComponent(ON.id('select2')); + await select2.click(); + await Utils.sleep(100); + let richeditor2 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0003")); + await richeditor2.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(1000); + let richeditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0003")); + await richeditor1.click(); + await Utils.sleep(100); + await richeditor1.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0003.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0004 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0004', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0004 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0004"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0004")); + await richeditor.click(); + await Utils.sleep(1000); + await richeditor.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0004.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0005 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0005', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0005 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0005"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0005")); + await richeditor.doubleClick(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0005.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0006 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0006', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0006 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0006"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0006")); + await richeditor.doubleClick(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0006.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0007 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0007', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0007 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0007"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0007")); + await richeditor.doubleClick(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0007.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0008 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0008', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0008 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0008"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0008")); + await richeditor.doubleClick(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0008.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0009 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0009', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0009 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0009"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0009")); + await richeditor.doubleClick(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0009.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0010 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0010', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0010 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0010"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0010")); + await richeditor.click(); + await Utils.sleep(1000); + await richeditor.click(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0010.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0011 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0011', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0011 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0011"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0011")); + await richeditor.click(); + await Utils.sleep(1000); + await richeditor.click(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0011.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0012 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0012', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0012 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0012"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0012")); + await richeditor.click(); + await Utils.sleep(1000); + await richeditor.click(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0012.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0013 + *des:Avoidance + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0013', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0013 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0013"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorAvoidance0013")); + await richeditor.click(); + await Utils.sleep(1000); + await richeditor.click(); + await Utils.sleep(1000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_Avoidance_0013.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColors.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColors.test.ets index 52d51ef5aff767d6f265a10c68cc7dffa6e3376d..033b1e8af7a44bfbf54ef3fa7f82aef731385ccb 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColors.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColors.test.ets @@ -41,6 +41,21 @@ export default function ComponentTextRicheditorCustomColors() { describe('ComponentTextRicheditorCustomColors', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0001 *des:1、添加RichEditor组件,不设置光标、手柄、文本选中背景颜色 @@ -48,10 +63,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0001', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0001 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0001"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0001") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0001")); await richeditor.click(); await Utils.sleep(2000); @@ -81,10 +96,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0002', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0002 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0002"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0002") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0002")); await richeditor.click(); await Utils.sleep(2000); @@ -114,10 +129,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0003', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0003 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0003"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0003") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0003")); await richeditor.click(); await Utils.sleep(2000); @@ -147,10 +162,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0004', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0004 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0004"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0004") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0004")); await richeditor.click(); await Utils.sleep(2000); @@ -180,10 +195,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0005', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0005 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0005"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0005") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0005")); await richeditor.click(); await Utils.sleep(2000); @@ -213,10 +228,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0006', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0006 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0006"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0006") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0006")); await richeditor.click(); await Utils.sleep(2000); @@ -246,10 +261,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0007', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0007 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0007"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0007") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0007")); await richeditor.click(); await Utils.sleep(2000); @@ -279,10 +294,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0008', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0008 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0008"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0008") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0008")); await richeditor.click(); await Utils.sleep(2000); @@ -312,10 +327,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0009', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0009 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0009"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0009") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0009")); await richeditor.click(); await Utils.sleep(2000); @@ -346,10 +361,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0010', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0010 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0010"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0010") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0010")); await richeditor.click(); await Utils.sleep(2000); @@ -379,10 +394,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0011', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0011 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0011"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0011") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0011")); await richeditor.click(); await Utils.sleep(2000); @@ -412,10 +427,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0012', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0012 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0012"); + await Utils.sleep(2000); let driver = Driver.create(); - await Utils.sleep(1000) - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0012") - await Utils.sleep(1000) + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0012")); await richeditor.click(); await Utils.sleep(2000) @@ -445,10 +460,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0013', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0013 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0013"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0013") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0013")); await richeditor.click(); await Utils.sleep(2000); @@ -478,10 +493,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0014', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0014 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0014"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0014") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0014")); await richeditor.click(); await Utils.sleep(2000); @@ -511,10 +526,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0015', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0015 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0015"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0015") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0015")); await richeditor.click(); await Utils.sleep(2000); @@ -545,10 +560,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0016', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0016 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0016"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0016") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0016")); await richeditor.click(); await Utils.sleep(2000); @@ -579,10 +594,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0017', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0017 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0017"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0017") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0017")); await richeditor.click(); await Utils.sleep(2000); @@ -612,10 +627,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0018', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0018 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0018"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0018") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0018")); await richeditor.click(); await Utils.sleep(2000); @@ -636,10 +651,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0019', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0019 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0019"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0019") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0019")); await richeditor.click(); await Utils.sleep(2000); @@ -660,10 +675,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0020 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0020"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0020") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0020")); await richeditor.click(); await Utils.sleep(2000); @@ -694,10 +709,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0021', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0021 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0021"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0021") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0021")); await richeditor.click(); await Utils.sleep(2000); @@ -728,10 +743,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0022', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0022 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0022"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0022") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0022")); await richeditor.click(); await Utils.sleep(2000); @@ -762,10 +777,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0023', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0020 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0023"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0023") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0023")); await richeditor.click(); await Utils.sleep(2000); @@ -798,10 +813,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0025', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0025 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0025")); await richeditor.click(); await Utils.sleep(2000); @@ -820,6 +835,9 @@ export default function ComponentTextRicheditorCustomColors() { await Utils.sleep(2000); windowSnap.snapShot(); await Utils.sleep(1000); + let change = await driver.findComponent(ON.id('change')); + await change.click(); + await Utils.sleep(1000); Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0025finish.`); done(); }) @@ -831,10 +849,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0026', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0026 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0026"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0026") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0026")); await richeditor.click(); await Utils.sleep(2000); @@ -862,10 +880,10 @@ export default function ComponentTextRicheditorCustomColors() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0028', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOB_CUSTOMCOLORS_0028 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0028"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0028") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomColor0028")); await richeditor.click(); await Utils.sleep(2000); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayoutTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayoutTests.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c31c18f04e155bed86a03285682a91328a16a3d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayoutTests.test.ets @@ -0,0 +1,583 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { afterEach, describe, it } 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, MouseButton, ON, On } from '@ohos.UiTest' +import { KeyCode } from '@kit.InputKit' + +/* + * SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0010:CUSTOMLAYOUT相关用例 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function ComponentTextRicheditorCustomLayoutTests() { + + describe('ComponentTextRicheditorCustomLayoutTests', () => { + 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() + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0010 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、通过placeholderSpanOption设置offset索引为0 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0010', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0010 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0010"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0010')); + await rich.click(); + await Utils.sleep(1000); + let addBtn = await driver.findComponent(ON.id('addSpan')); + await addBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0010.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0020 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、通过placeholderSpanOption设置offset索引为2 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0020', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0020 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0020"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0020')); + await rich.click(); + await Utils.sleep(1000); + let addBtn = await driver.findComponent(ON.id('addSpan')); + await addBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0020.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0030 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、通过placeholderSpanOption设置offset索引为-2 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0030', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0030 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0030"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0030')); + await rich.click(); + await Utils.sleep(1000); + let addBtn = await driver.findComponent(ON.id('addSpan')); + await addBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0030.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0040 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、通过placeholderSpanOption设置offset索引大于存在的索引 + 范围 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0040', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0040 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0040"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0040')); + await rich.click(); + await Utils.sleep(1000); + let addBtn = await driver.findComponent(ON.id('addSpan')); + await addBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0040.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0050 + *des:1、创健RichEditor组件内布局自定义builder组件 + 2、编译安装 + 3、动态修改offset素引值,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0050 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0050"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0050')); + await rich.click(); + await Utils.sleep(1000); + let addBtn = await driver.findComponent(ON.id('addSpan')); + await addBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0050.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0060"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0060')); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060 start.`+rich); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0070 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、编译安装 + 3、删除组件,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0070', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0060 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0070"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout070')); + await rich.click(); + await Utils.sleep(1000); + let delSpan = await driver.findComponent(ON.id('delSpan')); + await delSpan.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0070.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0080 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、编译安装 + 3、手指鼠标夏制粘贴,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0080', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0080 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0080") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout080')); + await rich.longClick(); + await Utils.sleep(1000); + let copy = await driver.findComponent(ON.text('复制')); + await copy?.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + let paste = await driver.findComponent(ON.text('粘贴')); + await paste?.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0080.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0090 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、编译安装 + 3、手指长按选中,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0090', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0090 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0090") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout090')); + await rich.longClick(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0090.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0100 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、编译安装 + 3、剪切组件,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0100', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0100 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0100") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0100')); + await rich.longClick(); + await Utils.sleep(1000); + let cut = await driver.findComponent(ON.text('剪切')); + await cut?.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0100.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0120 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、设置RichEditor自身属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0120', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0120 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0120") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0120')); + await rich.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0120.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0130 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、设置点击事件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0130', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0130 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0130") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0130')); + await rich.click(); + await Utils.sleep(1000); + let text = await driver.findComponent(ON.id('text')); + await text.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0130.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0150 + *des:1、创建自定义builder组件设置百分比布局 + 2、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0150', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0150 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0150") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0150.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0160 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、builder内组件设置Size属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0160', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0160 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0160") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0160.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0170 + *des:1、创健RichEditor组件内布局自定义builder组件 + 2、builder内组件设置padding属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0170', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0170 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0170") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0170.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0180 + *des:1、创建RichEditor组件内布局自定义builder组件 + 2、builder内组件设置margin属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0180', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0180 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0180") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0180.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0190 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内布局Row子组件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0190', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0190 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0190") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0190.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0200 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内布局Row子组件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0200 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0200") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0200.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0210 + *des:1、创健RichEditor组件内布局自定义builder + 2、Builder内布局Text子组件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0210 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0210") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0210.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0220 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内布局Flex子组件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0220', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0220 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0220") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0220.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0230 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内布局image子组件 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0230', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0230 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0230") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0230.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0240 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内布局Row组件不设置大小 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0240', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0240 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0240") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0240.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0250 + *des:1、创健RichEditor组件内布局自定义builder + 2、Builder内布局Row组件设置aspectRatio属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0250', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0250 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0250") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0250.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0260 + *des:1、创建RichFditor组件内布局自定义builder + 2、Builder内布局Column内布局Text组件,Text组件设置 + borderStyle、borderWidth、borderColor、borderRadius属性 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0260', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0260 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0260") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0260.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0270 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内设置Text组件设置opacity属性正常值 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0270', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0270 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0270") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0270.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0280 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内设置Text组件设置blur属性为1 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0280', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0280 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0280") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0280.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0290 + *des:1、创健RichEditor组件内布局自定义builder + 2、Builder内设置Text组件设置backdropBlur属性为3 + 3、编译安装,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0290', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0290 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0290") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0290.`); + done(); + }) + /** + * NO.SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0300 + *des:1、创建RichEditor组件内布局自定义builder + 2、Builder内设置Text组件 + 3、编译安装 + 4、在RichEditor内输入文字观察验证,验证效果 + */ + it('SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0300', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0300 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0300") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorCustomLayout0300')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_CONFONENT_TEXT_RICHEDITOR_CUSTOMLAYOUT_0300.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnceTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnceTests.test.ets index b2d84b04a8397d09b63bff3a0dcb5dde53ac5934..120f5cfee029801c870905a3ff132e8cb8cd896d 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnceTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnceTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { describe('ComponentTextRicheditorCustomkeyBoardAvoidAnceTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0001 *des:1、添加RichEditor组件位于页面底部 @@ -48,10 +62,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0001', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0001 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0001"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0001") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0001")); await richeditor.click(); windowSnap.snapShot(); @@ -67,10 +81,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0002', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0002 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0002"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0002") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0002")); await richeditor.click(); windowSnap.snapShot(); @@ -87,10 +101,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0003', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0003 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0003"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0003") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0003")); await richeditor.click(); windowSnap.snapShot(); @@ -107,10 +121,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0004', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0004 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0004"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0004") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0004")); await richeditor.click(); windowSnap.snapShot(); @@ -128,10 +142,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0005', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0005 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0005"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0005") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0005")); await richeditor.click(); windowSnap.snapShot(); @@ -149,10 +163,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0006', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0006 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0006"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0006") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0006")); await richeditor.click(); windowSnap.snapShot(); @@ -170,10 +184,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0007', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0007 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0007"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0007") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0007")); await richeditor.click(); windowSnap.snapShot(); @@ -191,10 +205,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0008', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0008 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0008"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0008") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0008")); await richeditor.click(); windowSnap.snapShot(); @@ -209,10 +223,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0009', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0009 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0009"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0009") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0009")); await richeditor.click(); windowSnap.snapShot(); @@ -230,10 +244,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0010', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0010 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0010"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0010") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0010")); await richeditor.click(); windowSnap.snapShot(); @@ -251,10 +265,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0011', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0011 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0011"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0011") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0011")); await richeditor.click(); windowSnap.snapShot(); @@ -272,10 +286,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0012', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0012 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0012"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0012") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0012")); await richeditor.click(); await Utils.sleep(1000); @@ -297,10 +311,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0013', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0013 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0013"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0013") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0013")); await richeditor.click(); await Utils.sleep(1000); @@ -322,10 +336,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0016', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0016 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0016")); let change = await driver.findComponent(ON.id("changeScreen")); await change.click(); @@ -335,6 +349,9 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { await Utils.sleep(2000); windowSnap.snapShot(); await Utils.sleep(1000); + let changes = await driver.findComponent(ON.id('change')); + await changes.click(); + await Utils.sleep(1000); Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0016.`); done(); }) @@ -348,10 +365,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0017', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0017 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0017")); await Utils.sleep(1000); let change = await driver.findComponent(ON.id("changeScreen")); @@ -362,6 +379,9 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { await Utils.sleep(2000); windowSnap.snapShot(); await Utils.sleep(1000); + let changes = await driver.findComponent(ON.id('change')); + await changes.click(); + await Utils.sleep(1000); Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0017.`); done(); }) @@ -374,10 +394,10 @@ export default function ComponentTextRicheditorCustomkeyBoardAvoidAnceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0019', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_CUSTOMKEYBOARDAVOIDANCE_0019 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0019"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0019") - await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorCustomkeyBoardAvoidAnce0019")); await richeditor.click(); await Utils.sleep(1000); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeatures.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeatures.test.ets index 43a5f58645bb47dee6b5c60aaf5e40835b81ad5d..7857e6829ce81cf88e394faba9420870ca19831a 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeatures.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeatures.test.ets @@ -1,4 +1,4 @@ - /* +/* * Copyright (C) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. @@ -41,7 +41,21 @@ import { MouseButton } from '@kit.TestKit' export default function ComponentTextRicheditorFontfeatures() { describe('ComponentTextRicheditorFontfeatures', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0001 *des:设置fontStyle 属性为FontStyle.Normal,验证效果 @@ -516,10 +530,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0037', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0037 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0037") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richEditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature003701")); await richEditor1?.click() await Utils.sleep(1000) @@ -550,10 +564,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0038', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0038 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0038") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richEditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature003801")); await richEditor1?.click() await Utils.sleep(1000) @@ -597,10 +611,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0042', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0042 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0042") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richEditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0042")); await richEditor?.click() await Utils.sleep(1000) @@ -617,10 +631,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0043', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0043 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0043") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richEditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0043")); await richEditor?.click() await Utils.sleep(1000) @@ -652,10 +666,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0045', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0045 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0045") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richEditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0045")); await richEditor1?.click() await Utils.sleep(1000) @@ -673,10 +687,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0046', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0046 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0046") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let select = await driver.findComponent(ON.id("getspans")); await select?.click() await Utils.sleep(1000) @@ -691,10 +705,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0047', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0047 start.`); - let driver = Driver.create(); - await Utils.sleep(1000) Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0047") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let select = await driver.findComponent(ON.id("getselection")); await select?.click() await Utils.sleep(1000) @@ -709,9 +723,9 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0048', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0048 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0048") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richEditor1 = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0048")); await richEditor1.click(); @@ -834,9 +848,9 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0057', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0057 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0057") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0057")); await Utils.sleep(1000); @@ -854,9 +868,9 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0058', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0058 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0058") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0058")); await Utils.sleep(1000); @@ -874,9 +888,9 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0059', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0059 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0059") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0059")); await Utils.sleep(1000); @@ -894,9 +908,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0039', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0039 start.`); - let driver = Driver.create(); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0039") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0039")); let textArea = await driver.findComponent(ON.id('TextArea')); await textArea.click() @@ -919,9 +934,10 @@ export default function ComponentTextRicheditorFontfeatures() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0040', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_FONTFEATURE_0040 start.`); - let driver = Driver.create(); Settings.createWindow("testability/pages/ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeature0040") - await Utils.sleep(1000) + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorFontfeature0040")); let textArea = await driver.findComponent(ON.id('TextArea')); await textArea.click() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorInterface/ComponentTextRicheditorInterfaceTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorInterface/ComponentTextRicheditorInterfaceTests.test.ets index 3cc60c244088d674b1f01f95400fb97fcaf1deec..44306c851dedc8092f70330988fa702edddff30f 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorInterface/ComponentTextRicheditorInterfaceTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorInterface/ComponentTextRicheditorInterfaceTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorInterfaceTests() { describe('ComponentTextRicheditorInterfaceTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0340 *des:1、启动应用 @@ -48,7 +62,6 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0340', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0340.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0340"); await Utils.sleep(2000); windowSnap.snapShot(); @@ -64,7 +77,6 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0350', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0350.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0350"); await Utils.sleep(2000); windowSnap.snapShot(); @@ -80,7 +92,6 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0360', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0360.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0360"); await Utils.sleep(2000); windowSnap.snapShot(); @@ -96,9 +107,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0410', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0410.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0410"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0410')); await rich.click(); @@ -132,9 +143,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0420', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0420.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0420"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0420')); await rich.click(); @@ -167,9 +178,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0430', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0430.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0430"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0430')); await rich.click(); @@ -204,9 +215,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0440', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0440.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0440"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0440')); await rich.click(); @@ -243,9 +254,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0450', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0450.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0450"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0450')); await rich.click(); @@ -281,9 +292,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0460', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0460.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0460"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0460')); await rich.click(); @@ -310,9 +321,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0470', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0470.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0470"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0470')); await rich.click(); @@ -337,9 +348,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0480', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0480.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0480"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0480')); await rich.click(); @@ -374,9 +385,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0490', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0490.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0490"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0490')); await rich.click(); @@ -410,9 +421,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0500', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0500.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0500"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0500')); await rich.click(); @@ -448,9 +459,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0510', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0510.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0510"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0510')); await rich.click(); @@ -484,9 +495,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0520', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0520.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0520"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0520')); await rich.click(); @@ -519,9 +530,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0530', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0530.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0530"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0530')); await rich.click(); @@ -556,9 +567,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0540', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0540.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0540"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0540')); await rich.click(); @@ -592,9 +603,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0550', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0550.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0550"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0550')); await rich.click(); @@ -630,9 +641,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0560', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0560.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0560"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0560')); await rich.click(); @@ -666,9 +677,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0570', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0570.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0570"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0570')); await rich.click(); @@ -701,9 +712,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0580', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0580.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0580"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0580')); await rich.click(); @@ -738,9 +749,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0590', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0590.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0590"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0590')); await rich.click(); @@ -774,9 +785,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0600', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0600.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0600"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0600')); await rich.click(); @@ -812,9 +823,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0610', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0610.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0610"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0610')); await rich.click(); @@ -848,9 +859,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0620', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0620.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0620"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0620')); await rich.click(); @@ -883,9 +894,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0630', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0630.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0630"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0630')); await rich.click(); @@ -920,9 +931,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0640', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0640.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0640"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0640')); await rich.click(); @@ -956,9 +967,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0650', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0650.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0650"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0650')); await rich.click(); @@ -994,9 +1005,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0660', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0660.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0660"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0660')); await rich.click(); @@ -1030,9 +1041,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0670', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0670.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0670"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0670')); await rich.click(); @@ -1065,9 +1076,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0680', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0680.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0680"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0680')); await rich.click(); @@ -1102,9 +1113,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0690', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0690.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0690"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0690')); await rich.click(); @@ -1138,9 +1149,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0700', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0700.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0700"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0700')); await rich.click(); @@ -1176,9 +1187,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0710', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0710.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0710"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0710')); await rich.click(); @@ -1214,9 +1225,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0720', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0720.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0720"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0720')); await rich.click(); @@ -1250,9 +1261,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0730', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0730.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0730"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0730')); await rich.click(); @@ -1285,9 +1296,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0740', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0740.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0740"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0740')); await rich.click(); @@ -1322,9 +1333,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0750', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0750.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0750"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0750')); await rich.click(); @@ -1360,9 +1371,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0760', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0760.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0760"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0760')); await rich.click(); @@ -1398,9 +1409,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0770', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0770.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0770"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0770')); await rich.click(); @@ -1434,9 +1445,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0780', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0780.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0780"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0780')); await rich.click(); @@ -1469,9 +1480,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0790', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0790.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0790"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0790')); await rich.click(); @@ -1506,9 +1517,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0800', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0800.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0800"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0800')); await rich.click(); @@ -1542,9 +1553,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0810', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0810.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0810"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0810')); await rich.click(); @@ -1580,9 +1591,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0820', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0820.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0820"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0820')); await rich.click(); @@ -1616,9 +1627,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0830', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0830.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0830"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0830')); await rich.click(); @@ -1651,9 +1662,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0840', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0840.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0840"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0840')); await rich.click(); @@ -1688,9 +1699,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0850', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0850.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0850"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0850')); await rich.click(); @@ -1724,9 +1735,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0860', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0860.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0860"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0860')); await rich.click(); @@ -1760,9 +1771,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0870', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0870.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0870"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0870')); await rich.click(); @@ -1795,9 +1806,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0880', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0880.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0880"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0880')); await rich.click(); @@ -1832,9 +1843,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0890', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0890.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0890"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0890')); await rich.click(); @@ -1868,9 +1879,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0900', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0900.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0900"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0900')); await rich.click(); @@ -1906,9 +1917,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0910', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0910.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0910"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0910')); await rich.click(); @@ -1942,9 +1953,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0920', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0920.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0920"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0920')); await rich.click(); @@ -1977,9 +1988,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0930', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0930.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0930"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0930')); await rich.click(); @@ -2014,9 +2025,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0940', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0940.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0940"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0940')); await rich.click(); @@ -2050,9 +2061,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0950', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0950.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0950"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0950')); await rich.click(); @@ -2088,9 +2099,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0960', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0960.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0960"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0960')); await rich.click(); @@ -2124,9 +2135,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0970', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0970.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0970"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0970')); await rich.click(); @@ -2159,9 +2170,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0980', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0980.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0980"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0980')); await rich.click(); @@ -2196,9 +2207,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0990', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0990.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface0990"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface0990')); await rich.click(); @@ -2232,9 +2243,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1000', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1000.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1000"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1000')); await rich.click(); @@ -2270,9 +2281,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1010', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1010.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1010"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1010')); await rich.click(); @@ -2306,9 +2317,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1020.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1020"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1020')); await rich.click(); @@ -2341,9 +2352,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1030', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1030.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1030"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1030')); await rich.click(); @@ -2378,9 +2389,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1040', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1040.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1040"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1040')); await rich.click(); @@ -2414,9 +2425,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1050', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1050.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1050"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1050')); await rich.click(); @@ -2452,9 +2463,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1060', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1060.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1060"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1060')); await rich.click(); @@ -2488,9 +2499,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1070', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1070.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1070"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1070')); await rich.click(); @@ -2523,9 +2534,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1080', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1080.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1080"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1080')); await rich.click(); @@ -2560,9 +2571,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1090', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1090.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1090"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1090')); await rich.click(); @@ -2596,9 +2607,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1100', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1100.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1100"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1100')); await rich.click(); @@ -2634,9 +2645,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1110', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1110.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1110"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1110')); await rich.click(); @@ -2670,9 +2681,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1120', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1120.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1120"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1120')); await rich.click(); @@ -2705,9 +2716,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1130', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1130.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1130"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1130')); await rich.click(); @@ -2742,9 +2753,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1140', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1140.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1140"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1140')); await rich.click(); @@ -2778,9 +2789,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1150', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1150.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1150"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1150')); await rich.click(); @@ -2816,9 +2827,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1160', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1160.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1160"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1160')); await rich.click(); @@ -2852,9 +2863,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1170', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1170.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1170"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1170')); await rich.click(); @@ -2887,9 +2898,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1180', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1180.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1180"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1180')); await rich.click(); @@ -2924,9 +2935,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1190', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1190.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1190"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1190')); await rich.click(); @@ -2960,9 +2971,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1200', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1200.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1200"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1200')); await rich.click(); @@ -2998,9 +3009,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1210', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1210.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1210"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1210')); await rich.click(); @@ -3034,9 +3045,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1220', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1220.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1220"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1220')); await rich.click(); @@ -3069,9 +3080,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1230', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1230.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1230"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1230')); await rich.click(); @@ -3106,9 +3117,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1240', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1240.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1240"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1240')); await rich.click(); @@ -3142,9 +3153,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1250', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1250.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1250"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1250')); await rich.click(); @@ -3180,9 +3191,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1260', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1260.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1260"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1260')); await rich.click(); @@ -3216,9 +3227,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1270', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1270.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1270"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1270')); await rich.click(); @@ -3251,9 +3262,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1280', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1280.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1280"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1280')); await rich.click(); @@ -3288,9 +3299,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1290', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1290.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1290"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1290')); await rich.click(); @@ -3324,9 +3335,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1300', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1300.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1300"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1300')); await rich.click(); @@ -3362,9 +3373,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1310', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1310.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1310"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1310')); await rich.click(); @@ -3398,9 +3409,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1320', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1320.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1320"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1320')); await rich.click(); @@ -3433,9 +3444,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1330', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1330.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1330"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1330')); await rich.click(); @@ -3470,9 +3481,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1340', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1340.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1340"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1340')); await rich.click(); @@ -3506,9 +3517,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1350', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1350.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1350"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1350')); await rich.click(); @@ -3544,9 +3555,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1360', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1360.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1360"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1360')); await rich.longClick(); @@ -3564,9 +3575,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1380', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1380.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1380"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1380')); await rich.longClick(); @@ -3584,9 +3595,9 @@ export default function ComponentTextRicheditorInterfaceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1400', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_1400.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorInterface/ComponentTextRicheditorInterface1400"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorInterface1400')); await rich.click(); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcingTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcingTests.test.ets index 297c9628d07fb448acb33a87463ff4e5c0973cfb..c0deecde5f21c4ebb5b1ab95db3a56eab16ad768 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcingTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcingTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorKeyboardReinForcingTests() { describe('ComponentTextRicheditorKeyboardReinForcingTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0001 *des:1、点击RichEditor组件,激活软键盘 @@ -48,9 +62,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0001', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0001 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0001") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0001')); await rich.click() @@ -67,9 +81,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0002', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0002 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0002") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0002')); await rich.click() @@ -86,9 +100,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0003', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0003 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0003") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0003')); await rich.click() @@ -105,9 +119,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0004', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0004 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0004") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0004')); await rich.click() @@ -126,9 +140,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0012', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0012 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0012") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0012')); await rich.click(); @@ -156,9 +170,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0013', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0013 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0013") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0013')); await rich.click(); @@ -184,9 +198,9 @@ export default function ComponentTextRicheditorKeyboardReinForcingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0015', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_KEYBOARDREINFORCING_0015start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0015") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorKeyboardReinForcing0015')); await rich.click(); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyleTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyleTests.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f20082386967547ed8ae6613837b09d457454841 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyleTests.test.ets @@ -0,0 +1,592 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { afterEach, describe, it } 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, On } from '@ohos.UiTest' +import { KeyCode } from '@kit.InputKit' + +/* + * SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0010:LAYOUTSTYLE相关用例 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function ComponentTextRicheditorLayoutStyleTests() { + + describe('ComponentTextRicheditorLayoutStyleTests', () => { + 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() + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0010 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为30vp,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0010', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0010 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0010") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0010.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0020 + *des:1、添加RichEditor组件 + 2、addImsgeSpan设置margin值为10px,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0020', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0020 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0020") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0020.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0030 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为10lpx,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0030', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0030 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0030") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0030.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0040 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为10fp,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0040', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0040 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0040") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0040.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0050 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为10,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0050 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0050") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0050.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0060 + *des:1、添加RichEditor组件 + 2、addImageSpan设置aarcin值为$r(app.string 30fp'),验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0060', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0060 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0060") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0060.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0070 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为2%,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0070', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0070 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0070") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0070.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0080 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为-10,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0080', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0080 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0080") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0080.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0110 + *des:1、添加RichEditor组件 + 2、addImageSpan设置margin值为1000,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0110', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0110 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0110") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0110.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0120 + *des:1、添加RichEditor组件 + 2、addImageSpan设置Margin值为 + {left:10,top:20px,right:10,botton:20px),验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0120', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0120 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0120") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0120.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0140 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为2%,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0140', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0140 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0140") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0140.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0150 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svgsgif + 3、addImageSpam设置borderRadius值为10rp,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0150', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0150 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0150") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0150.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0160 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、if + 3、addImazeSpam设置borderRadius值为10px,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0160', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0160 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0160") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0160.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0170 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bap、svg、gif + 3、addInageSpan设置borderRadius值为10lpx,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0170', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0170 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0170") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0170.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0180 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、zif + 3、addImageSpan设置borderRadius值为10fp,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0180', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0180 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0180") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0180.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0190 + *des:添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置berderRadius值为10,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0190', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0190 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0190") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0190.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0200 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpam设置berderRadius值为$r(app string 30fp),验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0200 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0200") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0200.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0210 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为-10,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0210 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0210") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0210.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0220 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、 + svg、gif + 3、addImageSpan不设置borderRadius,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0220', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0220 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0220") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0220.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0230 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bap、svg、gif + 3、addInageSpan设置borderRadius值为1000,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0230', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0230 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0230") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0230.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0240 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、if + 3、addImareSpan设置borderRadius值为undefined,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0240', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0240 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0240") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0240.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0250 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImsgeSpan设置borderRadius值为{topLeft:20px},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0250', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0250 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0250") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0250.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0260 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为{topRight:20},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0260', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0260 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0260") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0260.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0270 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为 + {bottomLeft $r(app string 30fp)},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0270', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0270 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0270") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0270.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0280 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为{bottomRi ght:20},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0280', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0280 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0280") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0280.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0290 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svgs gif + 3、addImageSpan设置borderRadius值为 + {topLeft:20,topRight:10,bottonRi ght:30,bottomLeft:50},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0290', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0290 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0290") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0290.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0300 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为 + {topLeft:20,topRight:1000},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0300', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0300 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0300") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0300.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0310 + *des:1、添加RichEditor组件 + 2、图片格式分别为设置为png、jpg、bmp、svg、gif + 3、addImageSpan设置borderRadius值为 + {bottonLeft:undefined,bottomRight:0},验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0310', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0310 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0310") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0310.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0320 + *des:1、启动应用 + 2、切换横屏,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0320', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0320 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0320") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorLayoutStyle0320')); + await rich.click(); + await Utils.sleep(1000); + let switchBtn = await driver.findComponent(ON.id('switch')); + await switchBtn.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + let change = await driver.findComponent(ON.id('change')); + await change.click(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0320.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0330 + *des:1、启动应用 + 2、选中图片后剪切,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0330', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0330 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0330") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorLayoutStyle0330')); + await rich.longClick(); + await Utils.sleep(1000); + let cut = await driver.findComponent(ON.text('剪切')); + await cut.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0330.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0340 + *des:1、启动应用 + 2、点击按钮设置ImageSpanAligment值为TOP,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0340', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0340 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0340") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0340.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0350 + *des:1、启动应用 + 2、点击按扭设置ImageSpanAligment值为CENTER,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0350', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0350 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0350") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0350.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0360 + *des:1、启动应用 + 2、点击按扭设置ImageSpanAligment值为CENTER,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0360', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0360 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0360") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0360.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0370 + *des:1、启动应用 + 2、点击按扭设置ImageSpanAligment值为CENTER,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0370', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0370 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0370") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0370.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0400 + *des:1、启动应用 + 2、点击按扭设置ImageSpanAligment值为CENTER,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0400', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0400 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0400") + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LAYOUTSTYLE_0400.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacingTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacingTests.test.ets index 140efa8e6d2156cc717c4d2f7fb4847ae47d681d..213ba59c148514ffaab19d2f95b942f5ef885465 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacingTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacingTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { describe('ComponentTextRicheditorLineHeightLetterSpacingTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0014 *des:1、添加RichEditor组件 @@ -49,7 +63,6 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0014', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0014 start.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0014") await Utils.sleep(2000); windowSnap.snapShot(); @@ -57,6 +70,72 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0014.`); done(); }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0015 + *des:1、添加RichEditor组件 + 2、设置lineHeigzht值为100、letter-spacing值为100,输入文 + 本内容 + 3、从其他组件拖拽过来一段lineHeizht值为-10、letter- + spacing值为-10的文本内睿,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0015', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0015 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0015"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0015")); + let textArea = await driver.findComponent(ON.id('TextArea')); + await textArea.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_MOVE_END); + await Utils.sleep(500); + await textArea.click(); + await Utils.sleep(1000); + let selectAll = await driver.findComponent(ON.text('全选')) + await selectAll?.click(); + await Utils.sleep(1000); + await textArea.dragTo(richeditor) + await Utils.sleep(1000); + await textArea.click(); + await Utils.sleep(3000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0015.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0016 + *des:1、添加RichEditor组件 + 2、设置lineHeight值为0b1010、letter-spacing值为0b1010, + 输入文本内容 + 3、从其他组件拖拽过来一段linaHeight值为0b1010、latter- + spacing值为0b1010的文本内容,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0016', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0016 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0016"); + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0016")); + let textArea = await driver.findComponent(ON.id('TextArea')); + await textArea.click(); + await Utils.sleep(1000); + await textArea.click(); + await Utils.sleep(1000); + await textArea.click(); + await Utils.sleep(1000); + let selectAll = await driver.findComponent(ON.text('全选')) + await selectAll?.click(); + await Utils.sleep(1000); + await textArea.dragTo(richeditor) + await Utils.sleep(3000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0016.`); + done(); + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0014 *des:1、添加RichEditor组件 @@ -67,10 +146,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0019', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0014 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0019") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0019")); await richeditor.click(); await Utils.sleep(1000); @@ -91,10 +170,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0020 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0020") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0020")); await richeditor.click(); await Utils.sleep(1000); @@ -119,10 +198,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0021', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0021 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0021") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0021")); await richeditor.longClick(); await Utils.sleep(2000); @@ -141,10 +220,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0022', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0022 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0022") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0022")); await richeditor.click(); await Utils.sleep(1000); @@ -166,10 +245,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0023', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0023 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0023") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0023")); await richeditor.click(); await Utils.sleep(1000); @@ -191,10 +270,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0024', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0024 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0024") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0024")); await richeditor.click(); await Utils.sleep(1000); @@ -216,10 +295,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0025', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0025 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0025") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0025")); await richeditor.click(); await Utils.sleep(1000); @@ -241,10 +320,10 @@ export default function ComponentTextRicheditorLineHeightLetterSpacingTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHTLETTERSPACING_0026', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEHEIGHT&LETTERSPACING_0026 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0026") await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLineHeightLetterSpacing0026")); await richeditor.click(); await Utils.sleep(1000); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectalls.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectalls.test.ets index af1feae37182093bb11d04726e795ea938199fcf..16c12152a0cb08f16c50db31175320bf5500b7b9 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectalls.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectalls.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorLongPresstoselectalls() { describe('ComponentTextRicheditorLongPresstoselectalls', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0001 *des:1、设置onLongPress回调函数里setSelection(1,2,{menuPolicy: MenuPolicy.SHOW }) @@ -48,9 +62,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0001', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0001 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0001") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0001")); await richeditor.click(); @@ -70,9 +84,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0002', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0002 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0002") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0002")); await richeditor.click(); @@ -92,9 +106,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0003', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0003 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0003") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0003")); await richeditor.click(); @@ -114,9 +128,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0004', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0004 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0004") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0004")); await richeditor.click(); @@ -135,9 +149,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0005', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0005 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0005") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0005")); await richeditor.click(); @@ -156,9 +170,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0006', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0006 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0006") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0006")); await richeditor.click(); @@ -177,9 +191,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0007', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0006 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0007") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0007")); await richeditor.click(); @@ -198,9 +212,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0008', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0008 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0008") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0008")); await richeditor.click(); @@ -220,9 +234,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0009', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0009 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0009") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0009")); await richeditor.click(); @@ -242,9 +256,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0010', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0010 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0010") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0010")); await richeditor.click(); @@ -264,9 +278,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0011', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0011 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0011") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0011")); await richeditor.click(); @@ -285,9 +299,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0012', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0012 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0012") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0012")); await richeditor.click(); @@ -308,9 +322,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0013', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0013 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0013") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0013")); await richeditor.click(); @@ -333,9 +347,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0014', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0014 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0014") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0014")); await richeditor.click(); @@ -358,9 +372,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0015', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0015 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0015") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0015")); await richeditor.click(); @@ -381,9 +395,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0016', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0016 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0016") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0016")); await richeditor.click(); @@ -404,9 +418,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0017', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0017 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0017") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0017")); await richeditor.click(); @@ -427,9 +441,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0017_157', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0017_157 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0017_157") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0017_157")); await richeditor.click(); @@ -451,9 +465,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0017_157_029', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0017_157_029 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0017_157_029") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0017_157_029")); await richeditor.click(); @@ -473,9 +487,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0017_429', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0017_429 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0017_429") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0017_429")); await richeditor.click(); @@ -498,9 +512,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0017_429_005', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0017_429_005 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0017_429_005") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0017_429_005")); await richeditor.click(); @@ -520,9 +534,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0018', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0018 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0018") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0018")); await richeditor.click(); @@ -543,9 +557,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0019', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0019 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0019") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0019")); await richeditor.click(); @@ -566,9 +580,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0020', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0020 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0020") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0020")); await richeditor.click(); @@ -592,9 +606,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0021', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0021 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0021") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0021")); await richeditor.click(); @@ -623,9 +637,9 @@ export default function ComponentTextRicheditorLongPresstoselectalls() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LONGPRESSTOSELECTAIL_0022', 0, async (done: Function) => { Logger.info('TEST', `ComponentTextRicheditorLongPresstoselectall0022 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectall0022") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorLongPresstoselectall0022")); await richeditor.click(); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test.ets index f592251066066f69a70c309e3db37bf3a5f675ec..7790e09b7a454e8169821f5ccf4bd151a691c9c5 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test.ets @@ -40,16 +40,30 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorOnWillChangeTests() { describe('ComponentTextRicheditorOnWillChangeTests', () => { + 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() + }) /** * NO.SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0001 *des:2、富文本组件输入框无法输入, onWillChange回调中的replacedSpans中的值正常, onDidChang无回调值|,验证效果 */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0001', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0001 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0001") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0001")); await richeditor.click(); @@ -71,9 +85,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0002', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0002 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0002") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0002")); let textArea = await driver.findComponent(ON.id('TextArea')); @@ -98,9 +112,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0003', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0003 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0003") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0003")); let changeBtn = await driver.findComponent(ON.id("changeFeature")); @@ -118,9 +132,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0004', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0004 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0004") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0004")); Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0004.`+richeditor); @@ -142,9 +156,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0005', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0005start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0005") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0005")); Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0005.`+richeditor); @@ -166,9 +180,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0006', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0006start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0006") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0006")); Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0006.`+richeditor); @@ -197,9 +211,9 @@ export default function ComponentTextRicheditorOnWillChangeTests() { */ it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0007', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0007start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0007") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0007")); Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0007.`+richeditor); @@ -232,5 +246,76 @@ export default function ComponentTextRicheditorOnWillChangeTests() { Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0007.`); done(); }) + /** + * NO.SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0025 + *des:1.onwillchange返回值设置为true 2.软硬键盘输入文本内容3.组件内拖放文本\image\symbol内容,看预期效果 + */ + it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0025', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0025start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0025") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0025")); + await richeditor.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_MOVE_END); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id("select")); + await select.click(); + await Utils.sleep(500); + await richeditor.dragTo(richeditor); + await Utils.sleep(3000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0025.`); + done(); + }) + /** + * NO.SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0026 + *des:1.onwillchange返回值设置为true 2.软硬键盘输入文本内容3.从其他组件拖拽文本内容到富文本组件的段首\段中\段尾,看预期效果 + */ + it('SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0026', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0026start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0026") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorOnWillChange0026")); + await richeditor.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_MOVE_END); + await Utils.sleep(500); + let textArea = await driver.findComponent(ON.id('TextArea')); + await textArea.click(); + await Utils.sleep(500); + await textArea.click() + await Utils.sleep(500); + let selectAll = await driver.findComponent(ON.text('全选')) + await selectAll?.click(); + await Utils.sleep(1000); + await textArea.dragTo(richeditor); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UT_COMPONENT_TEXT_RICHEDITOR_ONWILLCHANGE_0026.`); + done(); + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenuTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenuTests.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7a2ebb24d096ac2734bcaaa1f87a0d78f0e24ee --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenuTests.test.ets @@ -0,0 +1,747 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { afterEach, describe, it } 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, On } from '@ohos.UiTest' +import { KeyCode } from '@kit.InputKit' + +/* + * SUB ACE_UI_PC_MENU_0020:PC_MENU相关用例 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function ComponentTextRicheditorPCMenuTests() { + + describe('ComponentTextRicheditorPCMenuTests', () => { + 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() + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0020 + *des:1、添加RichEditor组件 + 2、设置多行文本 + 3、设置: + .bindselectionMenu(RichEditorSpanType.TEXT + this MyMenu2,RichEdi torResponseType.LONG PRESS),验证效果 + */ + it('SUB_ACE_UI_PC_MENU_0020', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0020 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0020") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0020')); + await rich.longClick(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0020.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0030 + *des:1、添加RichEditor组件 + 2、设舌多行文本 + 3、设置:.bindselectionMenu(RichEditorSpanType.TEXT + this.JyMenu2,RichEdi torResponseType.SELECI),验证效果 + */ + it('SUB_ACE_UI_PC_MENU_0030', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0030 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0030") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0030')); + await rich.longClick(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0030.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0050 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0050 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0050") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0050')); + await rich.longClick(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0050.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0060 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0060', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0060 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0060") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0060')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0060.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0070 + *des:1、添加RichEditor组件 + 2、设置多行文本 + 3、添加Selectionllenu,设置EditorlMenuOptions的builder类型,验证效果 + */ + it('SUB_ACE_UI_PC_MENU_0070', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0070 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0070") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0070')); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0070.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0090 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0090', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0090 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0090") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0090')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0090.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0100 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0100', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0100 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0100") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0100')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0100.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0110 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0110', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0110 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0110") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0110')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0110.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0120 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0120', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0120 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0120") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0120')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0120.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0130 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0130', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0130 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0130") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0130')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0130.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0140 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0140', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0140 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0140") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0140')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0140.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0150 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0150', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0150 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0150") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0150')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0150.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0160 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0160', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0160 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0160") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0160')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0160.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0170 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0170', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0170 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0170") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0170')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0170.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0180 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0180', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0180 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0180") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0180')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0180.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0190 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0190', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0190 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0190") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0190')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0190.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0200 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0200 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0200") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0200')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0200.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0210 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0210 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0210") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0210')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0210.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0220 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0220', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0220 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0220") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0220')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0220.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0230 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0230', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0230 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0230") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0230')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0230.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0240 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0240', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0240 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0240") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0240')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0240.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0250 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0250', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0250 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0250") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0250')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0250.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0260 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0260', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0260 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0260") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0260')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0260.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0270 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0270', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0270 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0270") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0270')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0270.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0280 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0280', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0280 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0280") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0280')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0280.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0290 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0290', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0290 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0290") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0290')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0290.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0310 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0310', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0310 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0310") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0310')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0310.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0320 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0320', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0320 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0320") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0320')); + await rich.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id('select')); + await select.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0320.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0330 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0330', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0330 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0330") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0330')); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + let all = await driver.findComponent(ON.text('全选')); + await all.click(); + await Utils.sleep(1000); + let copy = await driver.findComponent(ON.text('复制')); + await copy.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0330.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0340 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0340', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0340 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0340") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0340')); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + let all = await driver.findComponent(ON.text('全选')); + await all.click(); + await Utils.sleep(1000); + let cute = await driver.findComponent(ON.text('剪切')); + await cute.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0340.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0350 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0350', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0350 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0350") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0350')); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + let all = await driver.findComponent(ON.text('全选')); + await all.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0350.`); + done(); + }) + /** + * NO.SUB_ACE_UI_PC_MENU_0360 + *des:menu + */ + it('SUB_ACE_UI_PC_MENU_0360', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0360 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0360") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPCMenu0360')); + await rich.click(); + await Utils.sleep(1000); + await rich.click(); + await Utils.sleep(1000); + let all = await driver.findComponent(ON.text('全选')); + await all.click(); + await Utils.sleep(1000); + let past = await driver.findComponent(ON.text('粘贴')); + await past.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_PC_MENU_0360.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholderTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholderTests.test.ets index 18c12f98f608bc25d1eae78f9f40ac7b86ff55d2..10215fa7eee2584cd334d38b5454ff556f7e1aea 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholderTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholderTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorPlaceholderTests() { describe('ComponentTextRicheditorPlaceholderTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0001 *des:1、添加RichEditor组件. @@ -1235,9 +1249,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0079', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0079 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0079"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0079')) await Utils.sleep(1000); @@ -1259,9 +1273,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0079_932', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0079 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0079_932"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0079_932')) await Utils.sleep(1000); @@ -1285,9 +1299,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0080', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0080 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0080"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0080')) await Utils.sleep(1000); @@ -1325,9 +1339,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0082', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0082 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0082"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0082')); await Utils.sleep(1000); @@ -1362,10 +1376,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0083', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0083 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0083"); - await Utils.sleep(1000); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0083')); await Utils.sleep(1000); @@ -1401,10 +1414,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0084', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0084 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0084"); - await Utils.sleep(1000); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0084')); await Utils.sleep(1000); @@ -1436,9 +1448,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0085', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0085 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0085"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0085')); let changeText = await driver.findComponent(ON.id('change')); @@ -1481,9 +1493,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0086', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0086 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0086"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0086')); let changeText = await driver.findComponent(ON.id('change')); @@ -1516,9 +1528,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0087', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0087 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0087"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeText = await driver.findComponent(ON.id('change')); await changeText.click(); @@ -1558,9 +1570,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0088', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0088 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0088"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeText = await driver.findComponent(ON.id('change')); await changeText.click(); @@ -1601,9 +1613,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0089', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0089 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0089"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich1 = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0089')); let ponit = await rich1.getBoundsCenter(); @@ -1623,9 +1635,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0090', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0090 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0090"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich1 = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0090')); let ponit = await rich1.getBoundsCenter(); @@ -1665,9 +1677,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0092', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0092 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0092"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0092')); let ponit = await rich.getBoundsCenter(); @@ -1702,9 +1714,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0093', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0093 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0093"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let deleteBtn = await driver.findComponent(ON.id('delete')); await deleteBtn.click(); @@ -1724,9 +1736,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0094', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0094 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0094"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let addBtn = await driver.findComponent(ON.id('add')); await addBtn.click(); @@ -1748,15 +1760,18 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0095', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0095 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0095"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let addBtn = await driver.findComponent(ON.id('setContent')); await addBtn.click(); await Utils.sleep(1000); windowSnap.snapShot(); await Utils.sleep(1000); + let change = await driver.findComponent(ON.id('change')); + await change.click(); + await Utils.sleep(1000); Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0095`); done(); }) @@ -1770,9 +1785,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0097', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0097 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0097"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0097')); await rich.click(); @@ -1804,7 +1819,6 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0098', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0098 start.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0098"); await Utils.sleep(1000); windowSnap.snapShot(); @@ -1822,9 +1836,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0099', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_0099 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0099"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder0099')); await rich.click(); @@ -1863,9 +1877,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00100', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00100 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00100"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeBtn = await driver.findComponent(ON.id('changeFeature')); await changeBtn.click(); @@ -1884,9 +1898,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00101', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00101 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00101"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeBtn = await driver.findComponent(ON.id('changeFeature')); await changeBtn.click(); @@ -1905,9 +1919,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00102', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00102 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00102"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeBtn = await driver.findComponent(ON.id('changeFeature')); await changeBtn.click(); @@ -1927,9 +1941,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00103"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeBtn = await driver.findComponent(ON.id('changeFeature')); await changeBtn.click(); @@ -1948,9 +1962,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00104', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00104 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00104"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let changeBtn = await driver.findComponent(ON.id('changeFeature')); await changeBtn.click(); @@ -1972,9 +1986,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00105', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00105 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00105"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder00105')); await rich.click(); @@ -1997,9 +2011,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103_040', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103_040 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00103_040"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder00103_040')); await rich.click(); @@ -2026,9 +2040,9 @@ export default function ComponentTextRicheditorPlaceholderTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103_040_934', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PLACEHOLDER_00103_040_934 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00103_040_934"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorPlaceholder00103_040_934')); let textArea = await driver.findComponent(ON.id('TextArea')); @@ -2039,7 +2053,7 @@ export default function ComponentTextRicheditorPlaceholderTests() { let selectAll = await driver.findComponent(ON.text('全选')) await selectAll?.click(); await Utils.sleep(1000); - await textArea.dragTo(textArea) + await textArea.dragTo(rich); await Utils.sleep(1000); await rich.click(); await Utils.sleep(1000); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledStringTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledStringTests.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce88c0780c02ffc8de3684dcafc1ccb610c90e23 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledStringTests.test.ets @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { afterEach, describe, it } 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, On } from '@ohos.UiTest' +import { KeyCode } from '@kit.InputKit' + +/* + * RichEditorSetStyledString001:属性字符串相关用例 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function ComponentTextRicheditorSetStyledStringTests() { + + describe('ComponentTextRicheditorSetStyledStringTests', () => { + 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() + }) + /** + * NO.RichEditorSetStyledString001 + *des:1、调用addTextSpan添加一段文本, 设定装饰 + 线颜色不设定字体颜色,验证效果 + */ + it('RichEditorSetStyledString001', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString001 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString001") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString001")); + await richeditor.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(1000); + let center = await driver.findComponent(ON.id("image_center")); + await center.click(); + await Utils.sleep(1000); + let bottom = await driver.findComponent(ON.id("image_bottom")); + await bottom.click(); + await Utils.sleep(1000); + let beside = await driver.findComponent(ON.id("image_baseline")); + await beside.click(); + await Utils.sleep(1000); + let addString = await driver.findComponent(ON.id("add_text")); + await addString.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString001.`); + done(); + }) + /** + * NO.RichEditorSetStyledString002 + *des:1、生成属性字符串,设定图片大小,使用百分比字符串 + 2、使用setStyledString接口,使富文本展示属性字符串 + 3、观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString002', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString002 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString002") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString002")); + await richeditor.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString002.`); + done(); + }) + /** + * NO.RichEditorSetStyledString003 + *des:1、生成属性字符串,设定图片大小,使用百分比字符串 + 2、使用setStyledString接口,使富文本展示属性字符串 + 3、观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString003', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString003 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString003") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString003")); + await richeditor.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString003.`); + done(); + }) + /** + * NO.RichEditorSetStyledString004 + *des:1、生成属性字符串,设置图片外边距/内边距/圆角 + 2、使用setStyledString接口,使富文本展示属性字符串 + 3、观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString004', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString004 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString004") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString004")); + await richeditor.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString004.`); + done(); + }) + /** + * NO.RichEditorSetStyledString005 + *des:1、生成属性字符串,分别设定图片缩放方式为 + ImageFit.Contain、ImageFit.Cover、ImageFit.Auto + ImagePit.Fill、ImageFit.ScaleDown、ImageFit.None + 2、使用setStyledString接口,使富文本展示属性字符串 + 3、观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString005', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString005 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString005") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString005")); + await richeditor.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(1000); + let center = await driver.findComponent(ON.id("image_center")); + await center.click(); + await Utils.sleep(1000); + let bottom = await driver.findComponent(ON.id("image_bottom")); + await bottom.click(); + await Utils.sleep(1000); + let beside = await driver.findComponent(ON.id("image_baseline")); + await beside.click(); + await Utils.sleep(1000); + let down = await driver.findComponent(ON.id("image_down")); + await down.click(); + await Utils.sleep(1000); + let none = await driver.findComponent(ON.id("image_none")); + await none.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString005.`); + done(); + }) + /** + * NO.RichEditorSetStyledString008 + *des:1、生成属性字符串 + 2、设置replaceStyle的key为image,length长度必须为1 + 3、点击替换后,观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString008', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString008 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString008") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString008")); + await richeditor.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id("select")); + await select.click(); + await Utils.sleep(2000); + await driver.triggerKey(KeyCode.KEYCODE_DEL); + await Utils.sleep(100); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString008.`); + done(); + }) + /** + * NO.RichEditorSetStyledString009 + *des:1、生成带一张图片或者多张图片的属性字符串 + 2、设置replaceString将图片或者图文混合内容替换为字符串 + (要考成文字在图片前还是图片后的不同情况:length要覆盖到 + 图片) + 3、点击替换后,观察富文本组件内容显示效果,验证效果 + */ + it('RichEditorSetStyledString009', 0, async (done: Function) => { + Logger.info('TEST', `RichEditorSetStyledString009 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString009") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorSetStyledString009")); + await richeditor.click(); + await Utils.sleep(1000); + let image = await driver.findComponent(ON.id("image")); + await image.click(); + await Utils.sleep(1000); + let select = await driver.findComponent(ON.id("select")); + await select.click(); + await Utils.sleep(1000); + let top = await driver.findComponent(ON.id("image_top")); + await top.click(); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_DEL); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `RichEditorSetStyledString009.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeysTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeysTests.test.ets index 5adf8f6929a886e52cbfcda19fc26c82cf02dc78..e2261019a3998f0e8c0a61f45f6dd68cd16b8c58 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeysTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeysTests.test.ets @@ -41,7 +41,21 @@ import { MouseButton } from '@kit.TestKit' export default function ComponentTextRicheditorShortKcutKeysTests() { describe('ComponentTextRicheditorShortKcutKeysTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0010 *des:1、第一个输入框中输入长文本,设置字体样式为红色、料体、较粗;使用快捷键ctrl+c复制ctrl+v粘贴到另一个输入框中 @@ -49,9 +63,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0010', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0010 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0010") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0010')); await rich.click(); @@ -77,9 +91,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0020 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0020") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0020')); await rich.click(); @@ -105,9 +119,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0030', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0030 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0030") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0030')); await rich.longClick(); @@ -131,9 +145,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0040', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0040 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0040") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0040')); await rich.click(); @@ -177,9 +191,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0050', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0050 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0050") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0050')); await rich.click(); @@ -212,9 +226,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0060', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0060 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0060") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0060')); await rich.longClick(); @@ -239,9 +253,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0070', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0070 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0070") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0070')); await rich.click(); @@ -269,9 +283,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0080', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0080 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0080") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0080')); await rich.click(); @@ -304,9 +318,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0090', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0090 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0090") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0090')); await rich.click(); @@ -332,9 +346,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0100', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0100 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0100") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0100')); await rich.longClick(); @@ -358,9 +372,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0110', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0110 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0110") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0110')); await rich.click(); @@ -391,9 +405,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0120', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0120 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0120") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0120')); await rich.click(); @@ -424,9 +438,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0130', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0130 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0130") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0130')); await rich.click(); @@ -455,9 +469,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0140', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0140 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0140") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0140')); await rich.click(); @@ -484,9 +498,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0150', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0150 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0150") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0150')); await rich.longClick(); @@ -515,9 +529,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0160', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0160 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0160") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0160')); await rich.longClick(); @@ -548,9 +562,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0170', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0170 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0170") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0170')); await rich.click(); @@ -578,9 +592,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0180', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0180 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0180") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0180')); await rich.longClick(); @@ -605,9 +619,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0190', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0190 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0190") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0190')); await rich.longClick(); @@ -636,9 +650,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0200', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0200 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0200") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0200')); await rich.click(); @@ -673,9 +687,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0210', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0210 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0210") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0210')); await rich.click(); @@ -710,9 +724,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0220', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0220 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0220") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0220')); await rich.longClick(); @@ -737,9 +751,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0230', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0230 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0230") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0230')); await rich.click(); @@ -770,9 +784,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0240', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0240 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0240") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0240')); await rich.longClick(); @@ -796,9 +810,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0260', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0260 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0260") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0260')); await rich.longClick(); @@ -826,9 +840,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0270', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0270 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0270") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0270')); await rich.longClick(); @@ -855,9 +869,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0280', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0280 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0280") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0280')); await rich.click(); @@ -890,9 +904,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0290', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0290 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0290") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0290')); await rich.click(); @@ -918,9 +932,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0300', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0300 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0300") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0300')); await rich.click(); @@ -949,9 +963,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0310', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0310 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0310") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0310')); await rich.longClick(); @@ -977,9 +991,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0320', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0320 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0320") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0320')); await rich.click(); @@ -1009,9 +1023,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0330', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0330 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0330") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0330')); await rich.click(); @@ -1037,9 +1051,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0340', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0340 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0340") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0340')); await rich.click(); @@ -1063,9 +1077,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0350', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0350 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0350") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0350')); await rich.click(); @@ -1090,9 +1104,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0360', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0360 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0360") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0360')); await rich.click(); @@ -1115,9 +1129,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0370', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0370 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0370") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0370')); await rich.click(); @@ -1140,9 +1154,9 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0380', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0380 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0380") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0380')); await rich.click(); @@ -1158,5 +1172,320 @@ export default function ComponentTextRicheditorShortKcutKeysTests() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0380.`); done(); }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0390 + *des:"1、输入长文本,光标位于自然段段中 + 2、按Ctrl+end",验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0390', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0390 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0390") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0390')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_RIGHT,KeyCode.KEYCODE_MOVE_END); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0390.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0400 + *des:1、输入长文本,光标位于自然段段中 + 2、按Shift+↑,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0400', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0400 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0400") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0400')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_SHIFT_LEFT,KeyCode.KEYCODE_DPAD_UP); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0400.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0410 + *des:1、输入长文本,光标位于自然段段中 + 2、按Shift+↓,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0410', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0410 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0410") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0410')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_SHIFT_LEFT,KeyCode.KEYCODE_DPAD_DOWN); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0410.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0420 + *des:1、输入长文本,光标位于自然段段中 + 2、按Shift+↓,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0420', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0420 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0420") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0420')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_SHIFT_LEFT,KeyCode.KEYCODE_DPAD_RIGHT); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0420.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0430 + *des:1、输入长文本,光标位于自然段段中 + 2、按Shift+↓,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0430', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0430 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0430") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0430')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerKey( KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_SHIFT_LEFT,KeyCode.KEYCODE_DPAD_LEFT); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0430.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0440 + *des:1、输入长文本,按Ctrl+A,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0440', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0440 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0440") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0440')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_A); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0440.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0450 + *des:1、输入长文本,按Ctrl+A,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0450', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0450 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0450") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0450')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_A); + await Utils.sleep(200); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_C); + await Utils.sleep(200); + let rich1 = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0450_01')); + await rich1.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_V); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0450.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0460 + *des:1、输入长文本 + 2、设置copyOptions参数为InApp + 3、对一段文本内容,ctrl+c其制 + 4、在第二个输入框中ctrl+v粘贴文本,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0460', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0460 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0460") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0460')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_A); + await Utils.sleep(200); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_C); + await Utils.sleep(200); + let rich1 = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0460_01')); + await rich1.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_V); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0460.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0470 + *des:1、输入长文本 + 2、设置copyOptions参数为LocalDevice + 3、对一段文本内容,ctrl+c复制 + 4、在第二个输入框中ctrl+v粘贴文本,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0470', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0470 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0470") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0470')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_A); + await Utils.sleep(200); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_C); + await Utils.sleep(200); + let rich1 = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0470_01')); + await rich1.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_V); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0470.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0480 + *des:1、打开demo,点击ctrl+z + 2、查看预设文本显示,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0480', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0480 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0480") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0480')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0480.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0490 + *des:1、输入文本 + 2、多次点击ctrl+z + 3、多此点击ctrlty + 4、再次点击ctrl+z,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0490', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0490 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0490") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0490')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Y); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Y); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0490.`); + done(); + }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0500 + *des:1、输入文本 + 2、多次点击ctrl+z,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0500', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0500 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0500") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let rich = await driver.findComponent(ON.id('ComponentTextRicheditorShortKcutKeys0500')); + await rich.click(); + await Utils.sleep(1000); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerKey(KeyCode.KEYCODE_F); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(100); + await driver.triggerCombineKeys(KeyCode.KEYCODE_CTRL_LEFT,KeyCode.KEYCODE_Z); + await Utils.sleep(2000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDIT0R_SHORTKCUTKEYS_0500.`); + done(); + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformanceTests.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformanceTests.test.ets index c33d01b5f19061279baa229c523d05297559db91..b5593d5420b5a105a6146be1e3c70198a19f0005 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformanceTests.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformanceTests.test.ets @@ -40,7 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorUxConformanceTests() { describe('ComponentTextRicheditorUxConformanceTests', () => { + 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() + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0006 *des:1、调用addTextSpan添加一段文本, 设定装饰 @@ -48,7 +62,6 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0006', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0006 start.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0006") await Utils.sleep(2000); windowSnap.snapShot(); @@ -63,7 +76,6 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0007', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0007 start.`); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0007") await Utils.sleep(2000); windowSnap.snapShot(); @@ -71,6 +83,33 @@ export default function ComponentTextRicheditorUxConformanceTests() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0007.`); done(); }) + /** + * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0009 + *des:1、从其他组件拖入一段文本到RiohEditor组件 + 2、调用getSpans获取span信息,验证效果 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0009', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0009 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0009") + await Utils.sleep(2000); + let driver = Driver.create(); + await Utils.sleep(1000); + let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorUxConformance0009")); + let textArea = await driver.findComponent(ON.id('TextArea')); + await textArea.click(); + await Utils.sleep(1000); + await textArea.click(); + await Utils.sleep(1000); + let selectAll = await driver.findComponent(ON.text('全选')) + await selectAll?.click(); + await Utils.sleep(1000); + await textArea.dragTo(richeditor) + await Utils.sleep(3000); + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0009.`); + done(); + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0011 *des:1、点击多张图片中间位置,将光标放至任意一张图片后 @@ -79,9 +118,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0011', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0011 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0011") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0011')); await rich.click(); @@ -106,9 +145,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0012', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0012 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0012") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0012')); await rich.click(); @@ -135,9 +174,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0013', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0013 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0013") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0013')); await rich.click(); @@ -163,9 +202,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0014', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0014 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0014") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0014')); await rich.click(); @@ -187,9 +226,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0015', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0015 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0015") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0015')); await rich.click(); @@ -211,9 +250,9 @@ export default function ComponentTextRicheditorUxConformanceTests() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0016', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_UXCONFORMANCE_0016 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0016") + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let rich = await driver.findComponent(ON.id('ComponentTextRicheditorUxConformance0016')); await rich.click(); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreaks.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreaks.test.ets index 747d60888c73b40d62ebaa983fd15794b3343990..6c1cbd523153b6c2acca6641a8a653bd83b00b8c 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreaks.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreaks.test.ets @@ -40,6 +40,21 @@ import { KeyCode } from '@kit.InputKit' export default function ComponentTextRicheditorWordbreaks() { describe('ComponentTextRicheditorWordbreaks', () => { + 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(); + }) /** * NO.SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0001 *des:wordBreak不设置属性,验证效果 @@ -85,9 +100,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0004', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0004 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0004"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0004")); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -104,9 +119,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0005', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0005 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0005"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0005")); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -123,9 +138,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0006', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0006 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0006"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0006")); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -220,9 +235,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0012', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0012 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0012"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0012")); await richeditor.click(); @@ -240,7 +255,7 @@ export default function ComponentTextRicheditorWordbreaks() { await driver.triggerKey(KeyCode.KEYCODE_V); await Utils.sleep(1000); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); - Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0012 finish.` + justBtn); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0012 finish.`+justBtn); await justBtn.click(); await Utils.sleep(1000); windowSnap.snapShot(); @@ -256,9 +271,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0013', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0013 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0013"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0013")); await richeditor.click(); @@ -292,9 +307,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0014', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0014 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0014"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0014")); await richeditor.click(); @@ -335,9 +350,10 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0015', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0015 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0015"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0015"); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0015")); await Utils.sleep(1000); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -356,9 +372,10 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0016', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0016 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0016"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0016"); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0016")); await Utils.sleep(1000); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -377,9 +394,10 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0017', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0017 start.`); + Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0017"); + await Utils.sleep(2000); let driver = Driver.create(); await Utils.sleep(1000); - Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0017"); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0017")); await Utils.sleep(1000); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); @@ -398,12 +416,12 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0018', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0018 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0018"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0018")); - Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0018 start.` + richeditor); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0018 start.`+richeditor); await richeditor.click(); await Utils.sleep(1000); await driver.triggerKey(KeyCode.KEYCODE_DEL); @@ -459,12 +477,12 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0019"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0019")); - Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 start.` + richeditor); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 start.`+richeditor); await richeditor.click(); await Utils.sleep(2000); await driver.triggerKey(KeyCode.KEYCODE_DEL); @@ -498,8 +516,7 @@ export default function ComponentTextRicheditorWordbreaks() { await driver.triggerKey(KeyCode.KEYCODE_7); await Utils.sleep(1000); windowSnap.snapShot(); - await Utils.sleep(1000); - ; + await Utils.sleep(1000);; Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 finish.`); done(); }) @@ -511,12 +528,12 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0020', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0020 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0020"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0020")); - Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 start.` + richeditor); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0019 start.`+richeditor); await richeditor.click(); let justBtn = await driver.findComponent(ON.id("updateParagraphStyle")); await justBtn.click(); @@ -554,12 +571,12 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0021', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0021 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0021"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0021")); - Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0021 start.` + richeditor); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0021 start.`+richeditor); await richeditor.longClick(); await Utils.sleep(2000); let paste = await driver.findComponent(ON.text('粘贴')); @@ -578,9 +595,9 @@ export default function ComponentTextRicheditorWordbreaks() { */ it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0022', 0, async (done: Function) => { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WORDBREAK_0022 start.`); - let driver = Driver.create(); - await Utils.sleep(1000); Settings.createWindow("testability/pages/ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreak0022"); + await Utils.sleep(2000); + let driver = Driver.create(); await Utils.sleep(1000); let richeditor = await driver.findComponent(ON.id("ComponentTextRicheditorWordbreak0022")); let textArea = await driver.findComponent(ON.id('TextArea')); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets index 0860e1238b7d5125d3247205585c174e61e3e827..65d361faa72c91e753ca4c6c10c28d932b188fc3 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets @@ -35,6 +35,20 @@ import ComponentTextRicheditorUxConformanceTests import ComponentTextRicheditorAITests from './ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test'; import ComponentTextRicheditorOnWillChangeTests from './ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test'; + + +import ComponentTextRicheditorFontfeatures from './ComponentTextRicheditorFontfeatureTest/ComponentTextRicheditorFontfeatures.test'; +import ComponentTextRicheditorCustomColors from './ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColors.test'; +import ComponentTextRicheditorWordbreaks from './ComponentTextRicheditorWordbreakTest/ComponentTextRicheditorWordbreaks.test'; +import ComponentTextRicheditorLongPresstoselectalls from './ComponentTextRicheditorLongPresstoselectallTest/ComponentTextRicheditorLongPresstoselectalls.test'; +import ComponentTextRicheditorPlaceholderTests from './ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholderTests.test'; + +import ComponentTextRicheditorCustomkeyBoardAvoidAnceTests from './ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnceTests.test'; +import ComponentTextRicheditorKeyboardReinForcingTests from './ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcingTests.test'; +import ComponentTextRicheditorLineHeightLetterSpacingTests from './ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacingTests.test'; +import ComponentTextRicheditorUxConformanceTests from './ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformanceTests.test'; +import ComponentTextRicheditorAITests from './ComponentTextRicheditorAITest/ComponentTextRicheditorAITests.test'; +import ComponentTextRicheditorOnWillChangeTests from './ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChangeTests.test'; import ComponentTextRicheditorInterfaceTests from './ComponentTextRicheditorInterface/ComponentTextRicheditorInterfaceTests.test'; import ComponentTextRicheditorShortKcutKeysTests @@ -149,6 +163,16 @@ import UIComponentPopupBoxToastStyleInterface001 from './UIComponentPopupBoxToastStyleInterfaceTest/UIComponentPopupBoxToastStyleInterface001.test'; import UIComponentPopupBoxFullDialogInterface001 from './UIComponentPopupBoxFullDialogInterfaceTest/UIComponentPopupBoxFullDialogInterface001.test'; +import ComponentTextRicheditorCustomLayoutTests + from './ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayoutTests.test'; +import ComponentTextRicheditorPCMenuTests + from './ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenuTests.test'; +import ComponentTextRicheditorLayoutStyleTests + from './ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyleTests.test'; +import ComponentTextRicheditorSetStyledStringTests + from './ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledStringTests.test'; +import ComponentTextRicheditorAvoidanceTests + from './ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidanceTests.test'; export default function testsuite() { ComponentTextRicheditorFontfeatures(); @@ -239,6 +263,11 @@ export default function testsuite() { UIComponentPopupBoxAttribute(); UIComponentPopupBoxPromptToastSequence(); UIComponentPopupBoxSpecificationsPopup(); + ComponentTextRicheditorCustomLayoutTests(); + ComponentTextRicheditorPCMenuTests(); + ComponentTextRicheditorLayoutStyleTests(); + ComponentTextRicheditorSetStyledStringTests(); + ComponentTextRicheditorAvoidanceTests(); } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/model/Settings.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/model/Settings.ets index c74ae272407cbf707ddcfaaacf42c1e132d5452d..602ec9fc615e9b7f665cf8de72d274d39dfacf17 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/model/Settings.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/model/Settings.ets @@ -23,6 +23,7 @@ import common from '@ohos.app.ability.common'; import { i18n } from '@kit.LocalizationKit'; import { router } from '@kit.ArkUI'; import { systemDateTime } from '@kit.BasicServicesKit'; +import { router, uiAppearance } from '@kit.ArkUI'; const TAG: string = '[TEST]'; @@ -36,14 +37,14 @@ async function sleep(time: number): Promise { } class Settings { - isPhone: boolean = true; + isPhone: boolean = false; windowClass: window.Window | undefined = undefined windowCreateType: string = "changeWindow"; private static DEFAULT_WIDTH: number = 720; - private static DEFAULT_HEIGHT: number = 1280; + private static DEFAULT_HEIGHT: number = 1412; private static DEFAULT_DPI: number = 240; - private static DEFAULT_OFFSET_X: number = 0; - private static DEFAULT_OFFSET_Y: number = 60; + private static DEFAULT_OFFSET_X: number = 100; + private static DEFAULT_OFFSET_Y: number = 132; private portrait: boolean = true changeWindowPosition(windowClass: window.Window, X: number | undefined, Y: number | undefined) { @@ -155,8 +156,7 @@ class Settings { * width,height:窗口宽高,默认width=600,height=1250 可配置范围:[0,2560],单位为vp * dpi:像素密度,默认dpi=330,可配置范围:80-640 * */ - - createWindow(pageURI: string, X?: number | undefined, Y?: number | undefined, width?: number | undefined, + async createWindow(pageURI: string, X?: number | undefined, Y?: number | undefined, width?: number | undefined, height?: number | undefined, dpi?: number | undefined) { if (!this.isPhone) { this.windowCreateType = "createWindow" @@ -245,6 +245,21 @@ class Settings { console.log(`Switch Locales,appPreferredLanguage2=${appPreferredLanguage2}`); } + /** + * @param locale:(zh-Hans-CN(简体中文),zh-Hant-CN(繁体中文),en-Latn-CN(英文),ug-CN(维语),bo-CN(藏语)) + */ + switchCusLocales(locale: string) { + try { + i18n.System.setAppPreferredLanguage(locale); // 设置系统当前Locale为 "zh-CN" + } catch (error) { + let err: BusinessError = error as BusinessError; + console.error(`call System.setAppPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`); + } + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); // 获取应用偏好语言 + console.log(`Switch Locales,appPreferredLanguage2=${appPreferredLanguage2}`); + console.log(`Switch CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + } + /** * 切换应用内部语言 */ @@ -265,19 +280,15 @@ class Settings { console.log(`Switch Locales,appPreferredLanguage2=${appPreferredLanguage2}`); } - /** - * 切换应用内部语言 - * @param locale:(zh-Hans-CN(简体中文),zh-Hant-CN(繁体中文),en-Latn-CN(英文),ug-CN(维语),bo-CN(藏语)) - */ - switchCusLocales(locale: string) { - try { - i18n.System.setAppPreferredLanguage(locale); // 设置系统当前Locale为 "zh-CN" - } catch (error) { - let err: BusinessError = error as BusinessError; - console.error(`call System.setAppPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`); - } - let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); // 获取应用偏好语言 - console.log(`Switch CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + async setOrientationToPortrait() { + let context = getContext() + let promise = await Window.getLastWindow(context); + let orientation = Window.Orientation.PORTRAIT; + await promise.setPreferredOrientation(orientation); + } + + async setUiAppearance() { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT); } changeOrientation(object?: Object) { diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/TestAbility.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/TestAbility.ets index 5b2992dcb24394039f4c71907479c34895c1a73a..956959276850fafb640ee420bd6cad3d971d7f05 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/TestAbility.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -59,13 +59,29 @@ export default class TestAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); GlobalThis.getInstance().setContext("context", this.context) - windowStage.loadContent('testability/pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; + // + let atManager = abilityAccessCtrl.createAtManager(); + let appFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION; + let permissionFlags = 0; + bundleManager.getBundleInfoForSelf(appFlags, (err, data) => { + if (err) { + Logger.error(TAG, 'getAllApplicationInfo failed: %{public}s', err.message); + console.error("") } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - }); + let tokenID = + data.appInfo.accessTokenId; //系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取 + atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.READ_MEDIA', permissionFlags, (err, data) => { + if (err) { + Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`) + } + }) + atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.WRITE_MEDIA', permissionFlags, (err, data) => { + if (err) { + Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`) + } + }) + }) + } onWindowStageDestroy() { diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0001.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0001.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0a1a401cdcda26b1222db23656b9e0c6f288b1f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0001.ets @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0001 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + Button('select1') + .id('select1') + .width(100) + .height(60) + .onClick(()=>{ + this.controller.setSelection(-1,2); + }); + Button('select2') + .id('select2') + .width(100) + .height(60) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + this.controller.addTextSpan('我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + }) + .width(100) + .height(300) + .id('ComponentTextRicheditorAvoidance0001') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0002.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0002.ets new file mode 100644 index 0000000000000000000000000000000000000000..041ede9d91c9d3a2d29d95d4c1bed2030d6fa7c0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0002.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0002 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + Button('select2') + .id('select2') + .width(100) + .height(60) + .onClick(()=>{ + this.controller.setSelection(-1,5); + }); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0002') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0003.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0003.ets new file mode 100644 index 0000000000000000000000000000000000000000..c012f4d6674cd73d5cdf8eb32a6a5d3bb27c4ebd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0003.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0003 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + Button('select2') + .id('select2') + .width(100) + .height(60) + .onClick(()=>{ + this.controller.setSelection(-1,5); + }); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0003') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0004.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0004.ets new file mode 100644 index 0000000000000000000000000000000000000000..1183be8a2581b2f9b883b71df44b7f5ecc356d17 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0004.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0004 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0004') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0005.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0005.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4046de7d32512c3a1d31580481154ea34cb0955 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0005.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0005 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0005') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0006.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0006.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8f7b47eb3d92c6f94130df58c50a3371c36aa66 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0006.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0006 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0006') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0007.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0007.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a5daa21f4362e77f37500f57727df3a6a041be8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0007.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0007 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0007') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0008.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0008.ets new file mode 100644 index 0000000000000000000000000000000000000000..a10408673789639ac81f623ea5f8dc541eacaa7c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0008.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0008 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0008') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0009.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0009.ets new file mode 100644 index 0000000000000000000000000000000000000000..7af8a415c1cfa560ca27d1deceaab3615bfa44ce --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0009.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0009 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0009') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea1526da13ce952a88eb1422d1e8ee295c3dfa30 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0010.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0010 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 20, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0010') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0011.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0011.ets new file mode 100644 index 0000000000000000000000000000000000000000..404b457ae0cbe7756e9820d30d59fab81a51221e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0011.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0011 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(('cat.jpg'), { + imageStyle: { + size: ["80px", "80px"] + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0011') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0012.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0012.ets new file mode 100644 index 0000000000000000000000000000000000000000..f255b307ca363092ec2c1e2bb6281abfd691a063 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0012.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0012 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), + { + style: + { + fontSize: 30 + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0012') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0013.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0013.ets new file mode 100644 index 0000000000000000000000000000000000000000..6677253181d3a67b2d5bd95228b07fdbfcaef721 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0013.ets @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorAvoidance0013 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人我是中国人', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 40, + } + }); + + }) + .width(300) + .height(300) + .id('ComponentTextRicheditorAvoidance0013') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025.ets index 455ef11ce8792e42cf687b34ea420fc578089ad5..b8586c16c5efbef4249a8392cd10a4f386771609 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomColorsTest/ComponentTextRicheditorCustomColor0025.ets @@ -43,6 +43,29 @@ struct ComponentTextRicheditorCustomColor0025 { } ; } + setOrientation1() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.PORTRAIT; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } build() { Row() { Column() { @@ -70,6 +93,13 @@ struct ComponentTextRicheditorCustomColor0025 { this.controller.setSelection( -1,-1); this.setOrientation(); }) + Button('change') + .id('change') + .width(100) + .height(30) + .onClick(() => { + this.setOrientation1(); + }) } .width('100%') .height('100%') diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..182f8c7a757aba4ae4be3ce3e327036d09778e15 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0010.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0010 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('addSpan') + .id('addSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: 0 }); + }) + RichEditor(this.options) + .onReady(() => { + }) + .id('ComponentTextRicheditorCustomLayout0010') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a0b89938ce95e94d316f7688d18f2556c292683 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0020.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0020 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('addSpan') + .id('addSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: 2 }); + }) + RichEditor(this.options) + .onReady(() => { + }) + .id('ComponentTextRicheditorCustomLayout0020') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..2bcb444ed142faec1411b2e35dcab002cd3096e1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0030.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0030 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('addSpan') + .id('addSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -2 }); + }) + RichEditor(this.options) + .onReady(() => { + }) + .id('ComponentTextRicheditorCustomLayout0030') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ee4506328adecf0cc47557a8d3f73eea9e8d8c8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0040.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0040 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('addSpan') + .id('addSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + RichEditor(this.options) + .onReady(() => { + }) + .id('ComponentTextRicheditorCustomLayout0040') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..df985e52fcdad6f7f5b4a483fbb2cd295e52ba74 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0050.ets @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0050 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('addSpan') + .id('addSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0050') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..6cb10de96e78e3ed6742d38e2a7c31e7839f1561 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0060.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0060 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column({ space: 1 }) { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .focusOnTouch(true) + .id('ComponentTextRicheditorCustomLayout060') + } + .tabIndex(1) + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..3966eac3ff2e68ead4476bcf93a94aa0982cc20e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0070.ets @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0070 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + Button('delSpan') + .id('delSpan') + .width(100) + .height(60) + .onClick(() => { + this.controller.deleteSpans(); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout070') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..3abaf8636c52dc742687b042883974596d9160db --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0080.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0080 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout080') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..fafd33b06baeb5623212d9a5ebc848e9025785f5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0090.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0090 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout090') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9d9c1f67f69337ed5789eb1f0384727b02f0ae2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0100.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0100 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0100') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8c9f658855781ceabbcd4e229d9e589d89e7682 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0120.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0120 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0120') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c5de25f35a28e872a664f379290034a50073554 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0130.ets @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0130 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + .onClick(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -2 }); + }); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0130') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d7a3e5b15de3210e573cc4d89fbd01ed2dee6bc --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0150.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0150 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height('30%') + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0150') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..8691ec61d498432480a67b9e96634e2f3352b190 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0160.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0160 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .size({ width: '30%', height: 110 }) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0160') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..020d7550296f7f388eedf3ed0c1119e481817445 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0170.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0170 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0170') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..8de7701b7cd55a3d21779876029530d24549d768 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0180.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0180 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .margin(20) + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0180') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..b88a0e7c7d038367d26f035f0a058cb53d413b1f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0190.ets @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0190 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Row(){ + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .margin(20) + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + .width(200) + .height(50) + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0190') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d11423e618624712eb49ab736586157212faddc --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0200.ets @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0200 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Column(){ + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .margin(20) + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + .width(200) + .height(50) + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0200') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a88a53ac123e769ef369c24db24ee52124d0b3f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0210.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0210 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .width('20%') + .margin(20) + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange) + .focusable(true) + .id('text') + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0210') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..fcc946ac699f25c91cfa47dc0d2db4ebea28a1e8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0220.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0220 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Flex() { + Text('flexGrow(2)') + .flexGrow(2) + .height(100) + .backgroundColor(0xF5DEB3) + .textAlign(TextAlign.Center) + Text('flexGrow(1)') + .flexGrow(1) + .height(100) + .backgroundColor(0xD2B48C) + .textAlign(TextAlign.Center) + }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) + + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0220') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5d945b517d91c30146dacb6886fc02ec96fbdfe --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0230.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0230 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Row() { + // 加载png格式图片 + Image(("cat.jpg")) + .width(110).height(110).margin(15) + .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + } + } + }.height(320).width(360).padding({ right: 10, top: 10 }) + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0230') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..38f543c1d41ae6dc0fd36bb3230476b880912562 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0240.ets @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0240 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Column() { + Row() { + // 加载png格式图片 + Image(("cat.jpg")) + .width(110).height(110).margin(15) + .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + } + } + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0240') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0732a8580d20ac29ffec5134cf15118e2d51b9b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0250.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0250 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Column() { + Row() { + // 加载png格式图片 + Image(("cat.jpg")) + .width(110).height(110).margin(15) + .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + } + .aspectRatio(2) + } + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0250') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0260.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0260.ets new file mode 100644 index 0000000000000000000000000000000000000000..b10e11040c5807acfae443fc0af408e652be61c1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0260.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0260 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Column() { + Text("hello") + .padding('20') + .borderWidth(1) + .borderRadius(5) + .borderStyle(BorderStyle.Dashed) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + }.height(320).width(360).padding({ right: 10, top: 10 }) + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0260') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d04e0f7d19c759f708d965369e24950faee1871 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0270.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0270 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .borderRadius(5) + .opacity(5) + .borderStyle(BorderStyle.Dashed) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0270') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0280.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0280.ets new file mode 100644 index 0000000000000000000000000000000000000000..b26e88240e7678e83860e7c9fad15279cebad9d7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0280.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0280 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .borderRadius(5) + .opacity(5) + .borderStyle(BorderStyle.Dashed) + .width('20%') + .blur(1) + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0280') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0290.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0290.ets new file mode 100644 index 0000000000000000000000000000000000000000..768d7fef5a57707332e923fd6fc8f67c41e72167 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0290.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0290 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .borderRadius(5) + .opacity(5) + .borderStyle(BorderStyle.Dashed) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .backdropBlur(3) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0290') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0300.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0300.ets new file mode 100644 index 0000000000000000000000000000000000000000..94f4410ee46980b62e54adacbaa37ff341bcdc67 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0300.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorCustomLayout0300 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + placeholderBuilder3() { + Text("hello") + .padding('20') + .borderWidth(1) + .borderRadius(5) + .opacity(5) + .borderStyle(BorderStyle.Dashed) + .width('20%') + .backgroundColor(Color.Pink) + .height(60) + .borderColor(Color.Orange); + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addBuilderSpan(() => { + this.placeholderBuilder3(); + }, { offset: -10000000000000000 }); + }) + .id('ComponentTextRicheditorCustomLayout0300') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016.ets index 4c99ee1854cf0490f00fa4c94b6f4a10762f6b02..d6aaec2994f3578efc4eb35410d02146edeba559 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0016.ets @@ -43,6 +43,29 @@ struct ComponentTextRicheditorCustomkeyBoardAvoidAnce0016 { } ; } + setOrientation1() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.PORTRAIT; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } // 自定义键盘组件 @Builder CustomKeyboardBuilder() { @@ -93,6 +116,13 @@ struct ComponentTextRicheditorCustomkeyBoardAvoidAnce0016 { .customKeyboard(this.CustomKeyboardBuilder(),{ supportAvoidance: true }) .border({ width: 1 }) .id('ComponentTextRicheditorCustomkeyBoardAvoidAnce0016'); + Button('change') + .id('change') + .width(100) + .height(30) + .onClick(() => { + this.setOrientation1(); + }) } .width('50%') .height('80%') diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017.ets index b88564c46b7cd71380af9e45d191b929100d0c4b..c25d67ac1c6488d8009d1fe3e25447c12cae2e05 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017.ets @@ -43,6 +43,29 @@ struct ComponentTextRicheditorCustomkeyBoardAvoidAnce0017 { } ; } + setOrientation1() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.PORTRAIT; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } // 自定义键盘组件 @Builder CustomKeyboardBuilder() { @@ -93,6 +116,13 @@ struct ComponentTextRicheditorCustomkeyBoardAvoidAnce0017 { .customKeyboard(this.CustomKeyboardBuilder(),{ supportAvoidance: true }) .border({ width: 1 }) .id('ComponentTextRicheditorCustomkeyBoardAvoidAnce0017'); + Button('change') + .id('change') + .width(100) + .height(30) + .onClick(() => { + this.setOrientation1(); + }) } .width('50%') .height('80%') diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ac7bf500318c5f68951009bf12a58f150d114bd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0010.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0010 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0010') + .margin('30vp') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..d25c22807c53d6e7d0f15eb05f79b174cfc80681 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0020.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0020 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0020') + .margin('10px') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c6c151a07adc4b746367161a1a252043a1f7409 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0030.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0030 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0030') + .margin('10lpx') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdc56e42c845452a06a8765fbd4512ad19e9ee81 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0040.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0040 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0040') + .margin('10fp') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..623130cba61a0fec0e159229b39f35327951abc4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0050.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0050 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0050') + .margin(10) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1393bc1bd07d31dd572ae37b8364a149d8b545c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0060.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0060 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0060') + .margin(getContext().resourceManager.getStringSync($r('app.string.size_30fp'))) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..d8e79f53ac3ccc7c68c24a2e81dc1951c8545af6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0070.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0070 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0070') + .margin('2%') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..d28ff066cc198e826743393041e27455f1b70e01 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0080.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0080 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0080') + .margin(-10) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c4137c79243d0c0968a5c2522d6683e388ab192 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0110.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0110 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0110') + .margin(1000) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d495dbb7538b5481d8f68837f0032163a41729a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0120.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0120 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0120') + .margin({left:10,top:'20px',right:10,bottom:'20px'}) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..c585da68152b0dc4f534bc174dae71d4796736c6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0140.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0140 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '2%', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '2%', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '2%', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '2%', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '2%', + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0140') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..caba3b278aae1292619d244343842bf890bbc15b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0150.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0150 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10vp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10vp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10vp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10vp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10vp', + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0150') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..d73ace8569d5ffc5d2d63ca3b2446f4efc551f44 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0160.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0160 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10px', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10px', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10px', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10px', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10px', + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0160') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..b650b2efd2524b314b1554cb1c5b764bdfcd8ab8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0170.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0170 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10lpx', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10lpx', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10lpx', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10lpx', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10lpx', + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0170') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..eef321f956c4f71e787f3201041471dd4f32921f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0180.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0180 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: '10fp', + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0180') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..32f5ea8c2b720f6f55458e021392bd972faac190 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0190.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0190 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 10, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0190') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2f1658a6bea5ed0c4f99ccb30f4e40196b4ce3e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0200.ets @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0200 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + radius: BorderRadiuses | Dimension = { + topLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + topRight: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + bottomRight: getContext().resourceManager.getStringSync($r('app.string.size_30fp')) + }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: this.radius, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: this.radius, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: this.radius, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: this.radius, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: this.radius, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0200') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..020d94ca03cd84fdb8e14616f57191ffd228b1d3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0210.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0210 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: -10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: -10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: -10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: -10, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: -10, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0210') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..a240a6526ce0ba6f1af6d0629d6f95035f224fc8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0220.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0220 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0220') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..e683c4fc76e0308df918672f33b828c80ab24401 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0230.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0230 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 1000, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 1000, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 1000, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 1000, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: 1000, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0230') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..12406881ac1866bbe1d3af68057f71e8a47e8b63 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0240.ets @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0240 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + radius: BorderRadiuses | Dimension = { + topLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + topRight: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp')), + bottomRight: getContext().resourceManager.getStringSync($r('app.string.size_30fp')) + }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: undefined, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: undefined, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: undefined, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: undefined, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: undefined, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0240') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c372474e55ca5918c914223d3824e4cf3deb57b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0250.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0250 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topLeft:'20px'}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topLeft:'20px'}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topLeft:'20px'}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topLeft:'20px'}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topLeft:'20px'}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0250') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0260.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0260.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9cd61f56a4d62b70c23ff23359a69ff45474a6d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0260.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0260 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius:{topRight:20}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0260') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..422128e35d415e30132004f476319597036c0ac5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0270.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0270 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp'))}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp'))}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp'))}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp'))}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft: getContext().resourceManager.getStringSync($r('app.string.size_30fp'))}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0270') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0280.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0280.ets new file mode 100644 index 0000000000000000000000000000000000000000..a82cd45feb90283f4403995669543ee4972edbca --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0280.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0280 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomRight:20}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomRight:20}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0280') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0290.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0290.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ec5d3f6bdaa0a3283be196830d84311f813a407 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0290.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0290 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:10,bottomRight:30,bottomLeft:50}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:10,bottomRight:30,bottomLeft:50}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:10,bottomRight:30,bottomLeft:50}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:10,bottomRight:30,bottomLeft:50}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:10,bottomRight:30,bottomLeft:50}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0290') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0300.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0300.ets new file mode 100644 index 0000000000000000000000000000000000000000..485bf549dbc9daf080b7e515808499c34bfb5cac --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0300.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0300 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:1000}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:1000}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:1000}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:1000}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {topLeft:20,topRight:1000}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0300') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0310.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0310.ets new file mode 100644 index 0000000000000000000000000000000000000000..431de70f6d1d74bef23b1cd2bcc2fcc2d56780c5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0310.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0310 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft:undefined,bottomRight:0}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft:undefined,bottomRight:0}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.bird_people')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft:undefined,bottomRight:0}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fan')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft:undefined,bottomRight:0}, + } + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.fly')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + borderRadius: {bottomLeft:undefined,bottomRight:0}, + } + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0310') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0320.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0320.ets new file mode 100644 index 0000000000000000000000000000000000000000..7666d1203d0cdb01c28d80131f3c57d514f4178c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0320.ets @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; +import { window } from '@kit.ArkUI'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0320 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + setOrientation() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.LANDSCAPE; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } + setOrientation1() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.PORTRAIT; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + Button('switch') + .id('switch') + .width(100) + .height(30) + .onClick(() => { + this.controller.stopEditing(); + this.setOrientation(); + }) + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0320') + Button('change') + .id('change') + .width(100) + .height(30) + .onClick(() => { + this.setOrientation1(); + }) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0330.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0330.ets new file mode 100644 index 0000000000000000000000000000000000000000..623714063fa48d740270d2da1b8be990862a00d9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0330.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { image } from '@kit.ImageKit'; + + +@Entry +@Component +struct ComponentTextRicheditorLayoutStyle0330 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }); + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)); + let createPixelMap: image.PixelMap = await imageSource.createPixelMap(); + await imageSource.release(); + return createPixelMap; + } + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + this.controller.addImageSpan(await this.getPixmapFromMedia($r('app.media.img')).then(), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0330') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0340.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0340.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae2261f26a0080b3982373e25ba04dcb176dd11e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0340.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0340 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + verticalAlign: ImageSpanAlignment.TOP + } + }); + this.controller.addTextSpan('我是中国人', {}); + }) + .id('ComponentTextRicheditorLayoutStyle0340') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0350.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0350.ets new file mode 100644 index 0000000000000000000000000000000000000000..1aca1be76e98c61777b5535a6d945261fbfa8208 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0350.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0350 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + verticalAlign: ImageSpanAlignment.CENTER + } + }); + this.controller.addTextSpan('我是中国人', {}); + }) + .id('ComponentTextRicheditorLayoutStyle0350') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0360.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0360.ets new file mode 100644 index 0000000000000000000000000000000000000000..4168ce26d4ddb399ba9365c5297212f846a9ea0f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0360.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0360 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + verticalAlign: ImageSpanAlignment.BOTTOM + } + }); + this.controller.addTextSpan('我是中国人', {}); + }) + .id('ComponentTextRicheditorLayoutStyle0360') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0370.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0370.ets new file mode 100644 index 0000000000000000000000000000000000000000..25856691fc60ead2d52b2cccc10a68d92188e60d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0370.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0370 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + verticalAlign: ImageSpanAlignment.BASELINE + } + }); + this.controller.addTextSpan('我是中国人', {}); + }) + .id('ComponentTextRicheditorLayoutStyle0370') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0400.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0400.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7f250ad8db1e3e8b8ce5f65dfc302b5eb6fe252 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0400.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLayoutStyle0400 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .onReady(async () => { + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + layoutStyle: { + margin: 10, + } + } + }); + this.controller.addTextSpan('我是中国人', {}); + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + } + }); + }) + .id('ComponentTextRicheditorLayoutStyle0400') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0015.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0015.ets new file mode 100644 index 0000000000000000000000000000000000000000..26b52b6e5a22a3d011ddbeae4e792d8b3e190e3f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0015.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLineHeightLetterSpacing0015 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + TextArea({text:"我是TextArea"}).draggable(true).width(500).height(100).id('TextArea').lineHeight(-10).letterSpacing(-10); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('abcde', { + style: { + lineHeight:100, + letterSpacing:100 + } + }); + }) + .width('100%') + .id('ComponentTextRicheditorLineHeightLetterSpacing0015') + .draggable(true) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0016.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0016.ets new file mode 100644 index 0000000000000000000000000000000000000000..1726bbe653352d140599ed77fc12344db8cb76f7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0016.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorLineHeightLetterSpacing0016 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + build() { + Row() { + Column() { + TextArea({text:"我是TextArea"}).draggable(true).width(100).height(50).id('TextArea').lineHeight(0b1010).letterSpacing(0b1010); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('abcde', { + style: { + lineHeight:0b1010, + letterSpacing:0b1010 + } + }); + }) + .id('ComponentTextRicheditorLineHeightLetterSpacing0016') + .draggable(true) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0025.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0025.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9c6df2700ea10c60a2fb53a6de17d0b953dfffa --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0025.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorOnWillChange0025 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State replacedSpansValue: string = ''; + @State rangeBefore: string = ''; + @State rangeAfter: string = ''; + + build() { + Row() { + Column() { + Button('select') + .id('select') + .width(100) + .height(60) + .onClick(()=>{ + this.controller.setSelection(5,-1); + }); + Text('replacedSpans value====' + this.replacedSpansValue).borderColor(Color.Red); + Text('rangeBefore value=====' + this.rangeBefore + 'rangeAfter value=====' + this.rangeAfter) + .borderColor(Color.Green); + RichEditor(this.options) + .id('ComponentTextRicheditorOnWillChange0025') + .borderColor(Color.Orange) + .onReady(() => { + this.controller.addTextSpan('111', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }); + this.controller.addImageSpan(("cat.jpg"), + { + imageStyle: + { + size: ["57px", "57px"], + verticalAlign: ImageSpanAlignment.BASELINE + } + }); + }) + .borderWidth(1) + .draggable(true) + .onWillChange((value: RichEditorChangeValue) => { + this.replacedSpansValue = JSON.stringify(value.replacedSpans); + return true; + }) + .onDidChange((rangeBefore: TextRange, rangeAfter: TextRange) => { + this.rangeAfter = JSON.stringify(rangeAfter); + this.rangeBefore = JSON.stringify(rangeBefore); + }) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0026.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0026.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b469c49e57a1ee497fbeb767e064a82e53ff614 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0026.ets @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorOnWillChange0026 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State replacedSpansValue: string = ''; + @State rangeBefore: string = ''; + @State rangeAfter: string = ''; + + build() { + Row() { + Column() { + Text('replacedSpans value====' + this.replacedSpansValue).borderColor(Color.Red); + Text('rangeBefore value=====' + this.rangeBefore + 'rangeAfter value=====' + this.rangeAfter) + .borderColor(Color.Green); + TextArea({text:"我是TextArea"}).draggable(true).width(100).height(50).id('TextArea'); + RichEditor(this.options) + .id('ComponentTextRicheditorOnWillChange0026') + .borderColor(Color.Orange) + .onReady(() => { + this.controller.addTextSpan('111', { + style: { + fontStyle: FontStyle.Normal, + fontColor: Color.Black, + fontSize: 15, + } + }) + }) + .draggable(true) + .borderWidth(1) + .onWillChange((value: RichEditorChangeValue) => { + this.replacedSpansValue = JSON.stringify(value.replacedSpans); + return true; + }) + .onDidChange((rangeBefore: TextRange, rangeAfter: TextRange) => { + this.rangeAfter = JSON.stringify(rangeAfter); + this.rangeBefore = JSON.stringify(rangeBefore); + }) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..14663f64f2471d94b6d7d9685039945da9b79a51 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0020.ets @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0020 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + LongPressImageCustomMenu() { + Column() { + Menu() { + MenuItemGroup() { + MenuItem({ + startIcon: ("cat.jpg"), + content: 'Menu', + labelInfo: '' + }) + .onClick(() => { + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 2', labelInfo: '' }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 3', labelInfo: '' }) + } + } + .radius($r('sys.float.ohos_id_corner_radius_card')) + .clip(true) + .backgroundColor('#F0F0F0') + } + } + + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.LongPressImageCustomMenu, RichEditorResponseType.LONG_PRESS, { + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0020') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..801fd9d6ccb893b9482a02d5ec5aa7b4797991e5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0030.ets @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0030 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + LongPressImageCustomMenu() { + Column() { + Menu() { + MenuItemGroup() { + MenuItem({ + startIcon: ("cat.jpg"), + content: 'Menu', + labelInfo: '' + }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 2', labelInfo: '' }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 3', labelInfo: '' }) + } + } + .radius($r('sys.float.ohos_id_corner_radius_card')) + .clip(true) + .backgroundColor('#F0F0F0') + } + } + + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.LongPressImageCustomMenu, RichEditorResponseType.LONG_PRESS, { + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.LongPressImageCustomMenu, RichEditorResponseType.SELECT) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0030') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..072188cb1dcf8ab5c09f67561ab225980ca1ff89 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0050.ets @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0050 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + + @Builder + LongPressImageCustomMenu() { + Column() { + Menu() { + MenuItemGroup() { + MenuItem({ + startIcon: ("cat.jpg"), + content: 'Menu', + labelInfo: '' + }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 2', labelInfo: '' }) + MenuItem({ startIcon: ("cat.jpg"), content: 'Select Mixed Menu 3', labelInfo: '' }) + } + } + .radius($r('sys.float.ohos_id_corner_radius_card')) + .clip(true) + .backgroundColor('#F0F0F0') + } + } + + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.LongPressImageCustomMenu, RichEditorResponseType.SELECT) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0050') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5c97c56ae742db56ff7155145ab9e072b93bd7d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0060.ets @@ -0,0 +1,541 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0060 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State message: string = 'Hello World'; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0060') + .onReady(() => { + this.controller.addTextSpan(this.message, { style: { fontColor: Color.Orange, fontSize: 30 } }); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "搜索", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..3979ff494c23719ce0a75c27c8ec4ced03ec15da --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0070.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0070 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + onCreateMenu(menuItems: Array) { + console.log('menuItems size=' + menuItems.length); + menuItems.forEach((value, index) => { + console.log('menuItem' + index + ', id=' + JSON.stringify(value)); + }) + let extensionMenuItems: Array = [ + { + content: 'RichEditor扩展1', icon: ("cat.jpg"), id: TextMenuItemId.of('extension1') + }, + { + content: 'RichEditor扩展2', icon: ("cat.jpg"), id: TextMenuItemId.of('extension2') + }, + { + content: 'RichEditor扩展3', icon: ("cat.jpg"), id: TextMenuItemId.of('extension3') + }, + { + content: 'RichEditor扩展4', icon: ("cat.jpg"), id: TextMenuItemId.of('extension4') + } + ] + return menuItems.concat(extensionMenuItems) + } + onMenuItemClicked(menuItem: TextMenuItem, textRange: TextRange) { + if (menuItem.id.equals(TextMenuItemId.of('extension1'))) { + console.log('click' + menuItem.content + ', textRange=' + JSON.stringify(textRange)) + return true; + } + return false; + } + + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0070') + .editMenuOptions({ + onCreateMenu: (menuItems: Array) => { + return this.onCreateMenu(menuItems); + }, + onMenuItemClick: (menuItem: TextMenuItem, textRange: TextRange) => { + return this.onMenuItemClicked(menuItem, textRange); + } + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..b671001b4824705fd6b7d0e9c057f02c723ccf07 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0090.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0090 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0090') + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "搜索", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..83b280f8551b0692f94f6881cb7efb350f29daa2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0100.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0100 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0100') + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f4e4c9fdf49746b3ff16f40f7b0ac5823b84b04 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0110.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0110 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0110') + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..cba97ec1cf4811512e2631977349d8ae5f04b3fe --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0120.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0120 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0120') + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3b308f8f9c71e4a96475f6804b91ddaed9d8012 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0130.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0130 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0130') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccce8977a7e3c775dc85c6fe56c784fa15f52690 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0140.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0140 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0140') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..21b2f6960168e2f6a461dd3dcc5e77177d6e09d3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0150.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0150 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0150') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..505855aa93eb22202fbbf35afe34df6e476d4af6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0160.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0160 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(0,5); + }) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0160') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..80834844499bf0c9e6f46bd143c599b9d21b5a4a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0170.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorPCMenu0170 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(0,5); + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + this.msg = (item as RichEditorTextSpanResult).value; + }); + }) + Text(this.msg) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0170') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..f611009202d373d9fcba872808e652d9803cf7f8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0180.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { JSON } from '@kit.ArkTS'; + + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0180 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + @State msg1 : string = ''; + build() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,-1); + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + this.msg = JSON.stringify((item as RichEditorImageSpanResult).valueResourceStr); + }else{ + this.msg1 = (item as RichEditorTextSpanResult).value; + } + }); + }) + Text(this.msg + this.msg1) + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + this.controller.addImageSpan(('cat.jpg'), { + imageStyle: { + size: ["80px", "80px"] + } + }); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0180') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..82ab17c8db3e916d9d7399d1ad9ae5512b916e99 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0190.ets @@ -0,0 +1,545 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0190 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0190') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + this.controller.addImageSpan(('cat.jpg'), { + imageStyle: { + size: ["80px", "80px"] + } + }); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..36b360b60110c6e0ad0ce44598d3b4fa0512549e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0200.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0200 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0200') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb51e13f5dcf0311af11566d95abfe9f963a0124 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0210.ets @@ -0,0 +1,540 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0210 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0210') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .onSelect((value: RichEditorSelection) => { + if (value.selection[0] == -1 && value.selection[1] == -1) { + return; + } + this.start = value.selection[0]; + this.end = value.selection[1]; + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.LongPress, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .bindSelectionMenu(RichEditorSpanType.TEXT, this.panel, ResponseType.RightClick, { + onDisappear: () => { + this.sliderShow = false; + } + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..de4582ddc1a54de20f36b7e1d03a45db70da7bd7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0220.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0220 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0220') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc94a96275bfcb23b328df55000ce51b03e74f5d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0230.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0230 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0230') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..626bf350cdb7ba4b626b358a994267a4a4bd064e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0240.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0240 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0240') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..606096f68f9dfd779f7079c02e06ca85bd125781 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0250.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0250 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0250') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0260.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0260.ets new file mode 100644 index 0000000000000000000000000000000000000000..c01ca064ca4820a37d2857a68155f956c0606764 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0260.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0260 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0260') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..e14bcbe6d1d9fde1bce10d97c69b9b2ff6747ba4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0270.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0270 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0270') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0280.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0280.ets new file mode 100644 index 0000000000000000000000000000000000000000..a74b929c4782a8fdfaff644a89e6fce9c3eb068b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0280.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0280 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0280') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0290.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0290.ets new file mode 100644 index 0000000000000000000000000000000000000000..c00d52638574b645c91b6da7ba01c13ec723b5ca --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0290.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0290 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0290') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0310.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0310.ets new file mode 100644 index 0000000000000000000000000000000000000000..aed08e37dbb49e422fe739ca94da3030fc36e286 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0310.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0310 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0310') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0320.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0320.ets new file mode 100644 index 0000000000000000000000000000000000000000..f59b42ab31e30f6ffd02bb08263789cedd9784cd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0320.ets @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { BusinessError, pasteboard } from '@kit.BasicServicesKit'; + +export interface SelectionMenuTheme { + imageSize: number; + buttonSize: number; + menuSpacing: number; + editorOptionMargin: number; + expandedOptionPadding: number; + defaultMenuWidth: number; + imageFillColor: Resource; + backGroundColor: Resource; + iconBorderRadius: Resource; + containerBorderRadius: Resource; + cutIcon: Resource; + copyIcon: Resource; + pasteIcon: Resource; + selectAllIcon: Resource; + shareIcon: Resource; + translateIcon: Resource; + searchIcon: Resource; + arrowDownIcon: Resource; + iconPanelShadowStyle: ShadowStyle; + iconFocusBorderColor: Resource; +} + +export const defaultTheme: SelectionMenuTheme = { + imageSize: 24, + buttonSize: 48, + menuSpacing: 8, + editorOptionMargin: 1, + expandedOptionPadding: 3, + defaultMenuWidth: 256, + imageFillColor: $r('sys.color.ohos_id_color_primary'), + backGroundColor: $r('sys.color.ohos_id_color_dialog_bg'), + iconBorderRadius: $r('sys.float.ohos_id_corner_radius_default_m'), + containerBorderRadius: $r('sys.float.ohos_id_corner_radius_card'), + cutIcon: $r("sys.media.ohos_ic_public_cut"), + copyIcon: $r("sys.media.ohos_ic_public_copy"), + pasteIcon: $r("sys.media.ohos_ic_public_paste"), + selectAllIcon: $r("sys.media.ohos_ic_public_select_all"), + shareIcon: $r("sys.media.ohos_ic_public_share"), + translateIcon: $r("sys.media.ohos_ic_public_translate_c2e"), + searchIcon: $r("sys.media.ohos_ic_public_search_filled"), + arrowDownIcon: $r("sys.media.ohos_ic_public_arrow_down"), + iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD, + iconFocusBorderColor: $r('sys.color.ohos_id_color_focused_outline'), +} + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0320 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State textSize: number = 40; + @State sliderShow: boolean = false; + @State start: number = -1; + @State end: number = -1; + @State colorTransparent: Color = Color.Transparent; + private iconArr: Array = + [$r('app.media.icon'), $r("app.media.icon"), $r('app.media.icon'), + $r("app.media.icon"), $r('app.media.icon')]; + @State iconBgColor: ResourceColor[] = new Array(this.iconArr.length).fill(this.colorTransparent); + @State pasteEnable: boolean = false; + @State visibilityValue: Visibility = Visibility.Visible; + @State textStyle: RichEditorTextStyle = {}; + private fontWeightTable: string[] = + ["100", "200", "300", "400", "500", "600", "700", "800", "900", "bold", "normal", "bolder", "lighter", "medium", + "regular"]; + private theme: SelectionMenuTheme = defaultTheme; + + aboutToAppear() { + if (this.controller) { + let richEditorSelection = this.controller.getSelection(); + if (richEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + } + } + let sysBoard = pasteboard.getSystemPasteboard(); + if (sysBoard && sysBoard.hasDataSync()) { + this.pasteEnable = true; + } else { + this.pasteEnable = false; + } + } + + build() { + Column() { + Column() { + Button('select') + .id('select') + .height(60) + .width(100) + .onClick(()=>{ + this.controller.setSelection(-1,6); + }) + RichEditor(this.options) + .id('ComponentTextRicheditorPCMenu0320') + .onReady(() => { + this.controller.addTextSpan('我是中国我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + }.width('100%').backgroundColor(Color.White) + }.height('100%') + } + + PushDataToPasteboard(richEditorSelection: RichEditorSelection) { + let sysBoard = pasteboard.getSystemPasteboard(); + let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, ''); + if (richEditorSelection.spans && richEditorSelection.spans.length > 0) { + let count = richEditorSelection.spans.length; + for (let i = count - 1; i >= 0; i--) { + let item = richEditorSelection.spans[i] + if ((item as RichEditorTextSpanResult)?.textStyle) { + let span = item as RichEditorTextSpanResult; + let style = span.textStyle; + let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, + span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1])) + let prop = pasteData.getProperty() + let temp: Record = { + 'color': style.fontColor, + 'size': style.fontSize, + 'style': style.fontStyle, + 'weight': this.fontWeightTable[style.fontWeight], + 'fontFamily': style.fontFamily, + 'decorationType': style.decoration.type, + 'decorationColor': style.decoration.color + } + prop.additions[i] = temp; + pasteData.addRecord(data); + pasteData.setProperty(prop); + } + } + } + sysBoard.clearData(); + sysBoard.setData(pasteData).then(() => { + console.info('SelectionMenu copy option, Succeeded in setting PasteData.'); + this.pasteEnable = true; + }).catch((err: BusinessError) => { + console.error('SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message); + }) + } + + PopDataFromPasteboard(richEditorSelection: RichEditorSelection) { + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start == end && this.controller) { + start = this.controller.getCaretOffset(); + end = this.controller.getCaretOffset(); + } + let moveOffset = 0; + let sysBoard = pasteboard.getSystemPasteboard(); + sysBoard.getData((err, data) => { + if (err) { + return; + } + let count = data.getRecordCount() + for (let i = 0; i < count; i++) { + const element = data.getRecord(i);; + let tex: RichEditorTextStyle = { + fontSize: 16, + fontColor: Color.Black, + fontWeight: FontWeight.Normal, + fontFamily: "HarmonyOS Sans", + fontStyle: FontStyle.Normal, + decoration: { type: TextDecorationType.None, color: "#FF000000", style: TextDecorationStyle.SOLID } + } + if (data.getProperty() && data.getProperty().additions[i]) { + const tmp = data.getProperty().additions[i] as Record; + if (tmp.color) { + tex.fontColor = tmp.color as ResourceColor; + } + if (tmp.size) { + tex.fontSize = tmp.size as Length | number; + } + if (tmp.style) { + tex.fontStyle = tmp.style as FontStyle; + } + if (tmp.weight) { + tex.fontWeight = tmp.weight as number | FontWeight | string; + } + if (tmp.fontFamily) { + tex.fontFamily = tmp.fontFamily as ResourceStr; + } + if (tmp.decorationType && tex.decoration) { + tex.decoration.type = tmp.decorationType as TextDecorationType; + } + if (tmp.decorationColor && tex.decoration) { + tex.decoration.color = tmp.decorationColor as ResourceColor; + } + if (tex.decoration) { + tex.decoration = { type: tex.decoration.type, color: tex.decoration.color }; + } + } + if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) { + this.controller.addTextSpan(element.plainText, + { + style: tex, + offset: start + moveOffset + } + ) + moveOffset += element.plainText.length + } + } + if (this.controller) { + this.controller.setCaretOffset(start + moveOffset); + this.controller.closeSelectionMenu(); + } + if (start != end && this.controller) { + this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset }); + } + }) + } + + @Builder + panel() { + Column() { + this.iconPanel(); + if (!this.sliderShow) { + this.SystemMenu(); + } else { + this.sliderPanel(); + } + }.width(256) + } + + @Builder + iconPanel() { + Column() { + Row({ space: 2 }) { + ForEach(this.iconArr, (item: Resource, index ?: number) => { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image(item) + .fillColor(this.theme.imageFillColor) + .width(24) + .height(24) + .focusable(true) + .draggable(false) + } + .borderRadius(this.theme.iconBorderRadius) + .width(this.theme.buttonSize) + .height(this.theme.buttonSize) + .onClick(() => { + if (index as number == 0) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontWeight != 11) { + this.textStyle.fontWeight = FontWeight.Bolder; + } else { + this.textStyle.fontWeight = FontWeight.Normal; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 1) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontStyle == FontStyle.Italic) { + this.textStyle.fontStyle = FontStyle.Normal; + } else { + this.textStyle.fontStyle = FontStyle.Italic; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 2) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.decoration) { + if (this.textStyle.decoration.type == TextDecorationType.Underline) { + this.textStyle.decoration.type = TextDecorationType.None; + } else { + this.textStyle.decoration.type = TextDecorationType.Underline; + } + } else { + this.textStyle.decoration = + { type: TextDecorationType.Underline, color: Color.Black, style: TextDecorationStyle.SOLID }; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } else if (index as number == 3) { + this.sliderShow = !this.sliderShow; + } else if (index as number == 4) { + this.sliderShow = false; + if (this.controller) { + let selection = this.controller.getSelection(); + let spans = selection.spans; + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + let span = item as RichEditorTextSpanResult; + this.textStyle = span.textStyle; + let start = span.offsetInSpan[0]; + let end = span.offsetInSpan[1]; + let offset = span.spanPosition.spanRange[0]; + if (this.textStyle.fontColor == Color.Orange || this.textStyle.fontColor == '#FFFFA500') { + this.textStyle.fontColor = Color.Black; + } else { + this.textStyle.fontColor = Color.Orange; + } + this.controller.updateSpanStyle({ + start: offset + start, + end: offset + end, + textStyle: this.textStyle + }) + } + }) + } + } + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event != undefined) { + if (event.type === TouchType.Down) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_click_effect'); + } + if (event.type === TouchType.Up) { + this.iconBgColor[index as number] = this.colorTransparent; + } + } + }) + .onHover((isHover?: boolean, event?: HoverEvent) => { + this.iconBgColor.forEach((icon: ResourceColor, index1) => { + this.iconBgColor[index1] = this.colorTransparent; + }) + if (isHover != undefined) { + this.iconBgColor[index as number] = $r('sys.color.ohos_id_color_hover'); + } + }) + .backgroundColor(this.iconBgColor[index as number]) + }) + } + } + .clip(true) + .width(this.theme.defaultMenuWidth) + .padding(this.theme.expandedOptionPadding) + .borderRadius(this.theme.containerBorderRadius) + .margin({ bottom: this.theme.menuSpacing }) + .backgroundColor(this.theme.backGroundColor) + .shadow(this.theme.iconPanelShadowStyle) + } + + @Builder + SystemMenu() { + Column() { + Menu() { + if (this.controller) { + MenuItemGroup() { + MenuItem({ startIcon: this.theme.cutIcon, content: "剪切", labelInfo: "Ctrl+X" }) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection() + this.PushDataToPasteboard(richEditorSelection); + this.controller.deleteSpans({ + start: richEditorSelection.selection[0], + end: richEditorSelection.selection[1] + }) + }) + MenuItem({ startIcon: this.theme.copyIcon, content: "复制", labelInfo: "Ctrl+C" }) + .onClick(() => { + if (!this.controller) { + return + } + let richEditorSelection = this.controller.getSelection(); + this.PushDataToPasteboard(richEditorSelection); + this.controller.closeSelectionMenu(); + }) + MenuItem({ startIcon: this.theme.pasteIcon, content: "粘贴", labelInfo: "Ctrl+V" }) + .enabled(this.pasteEnable) + .onClick(() => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + this.PopDataFromPasteboard(richEditorSelection); + }) + MenuItem({ startIcon: this.theme.selectAllIcon, content: "全选", labelInfo: "Ctrl+A" }) + .visibility(this.visibilityValue) + .onClick(() => { + if (!this.controller) { + return; + } + this.controller.setSelection(-1, -1); + this.visibilityValue = Visibility.None; + }) + MenuItem({ startIcon: this.theme.shareIcon, content: "有道词典", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.translateIcon, content: "翻译", labelInfo: "" }) + .enabled(false); + MenuItem({ startIcon: this.theme.searchIcon, content: "更多", labelInfo: "" }) + .enabled(false); + } + } + } + .onVisibleAreaChange([0.0, 1.0], () => { + if (!this.controller) { + return; + } + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.selection[0]; + let end = richEditorSelection.selection[1]; + if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) { + this.visibilityValue = Visibility.None; + } else { + this.visibilityValue = Visibility.Visible; + } + }) + .radius(this.theme.containerBorderRadius) + .clip(true) + .backgroundColor(Color.White) + .width(this.theme.defaultMenuWidth) + } + .width(this.theme.defaultMenuWidth) + } + + @Builder + sliderPanel() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text('A').fontSize(15) + Slider({ value: this.textSize, step: 10, style: SliderStyle.InSet }) + .width(210) + .onChange((value: number, mode: SliderChangeMode) => { + if (this.controller) { + let selection = this.controller.getSelection(); + if (mode == SliderChangeMode.End) { + if (this.textSize == undefined) { + this.textSize = 0; + } + let spans = selection.spans + spans.forEach((item: RichEditorTextSpanResult | RichEditorImageSpanResult, index) => { + if (typeof (item as RichEditorTextSpanResult)['textStyle'] != 'undefined') { + this.textSize = Math.max(this.textSize, (item as RichEditorTextSpanResult).textStyle.fontSize) + } + }) + } + if (mode == SliderChangeMode.Moving || mode == SliderChangeMode.Click) { + this.start = selection.selection[0]; + this.end = selection.selection[1]; + this.textSize = value; + this.controller.updateSpanStyle({ + start: this.start, + end: this.end, + textStyle: { fontSize: this.textSize } + }) + } + } + }) + Text('A').fontSize(20).fontWeight(FontWeight.Medium) + }.borderRadius(this.theme.containerBorderRadius) + } + .shadow(ShadowStyle.OUTER_DEFAULT_MD) + .backgroundColor(Color.White) + .borderRadius(this.theme.containerBorderRadius) + .padding(15) + .height(48) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0330.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0330.ets new file mode 100644 index 0000000000000000000000000000000000000000..34fa38389989e6d11cb6af3000d2e60d800fc7ed --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0330.ets @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { JSON } from '@kit.ArkTS'; + + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0330 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + @State msg1 : string = ''; + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0330') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0340.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0340.ets new file mode 100644 index 0000000000000000000000000000000000000000..8996efc66d9bf73154eed68eb0f20472f716b3ff --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0340.ets @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { JSON } from '@kit.ArkTS'; + + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0340 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + @State msg1 : string = ''; + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0340') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0350.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0350.ets new file mode 100644 index 0000000000000000000000000000000000000000..b173dab43f5ff9399bef8804c34dac58933d8216 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0350.ets @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { JSON } from '@kit.ArkTS'; + + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0350 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + @State msg1 : string = ''; + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0350') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0360.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0360.ets new file mode 100644 index 0000000000000000000000000000000000000000..914934cb765e519a416fabf6e93c89e34809d434 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0360.ets @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Huawei Device 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 { JSON } from '@kit.ArkTS'; + + +@Entry +@Component +struct ComponentTextRicheditorPCMenu0360 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : string = ''; + @State msg1 : string = ''; + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('我是中国' + '\n' + '我是中国' + '\n' + '我是中国', {}); + }) + .borderWidth(1) + .borderColor(Color.Red) + .width(200) + .height(200) + .id('ComponentTextRicheditorPCMenu0360') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0095.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0095.ets index e6310626999448d3aca3d9685000f61659028564..2d2ebb48aade9223172b9076216083696e208308 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0095.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0095.ets @@ -45,6 +45,29 @@ struct ComponentTextRicheditorPlaceholder0095 { } ; } + setOrientation1() { + try { + window.getLastWindow(getContext(this), (err, data) => { // 获取window实例 + if (err.code) { + return; + } + let windowClass = data; + + let orientation = window.Orientation.PORTRAIT; // 设置窗口方向为传感器自动旋转模式。 + try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + return; + } + }); + } catch (exception) { + } + ; + }); + } catch (exception) { + } + ; + } build() { Row() { @@ -64,6 +87,13 @@ struct ComponentTextRicheditorPlaceholder0095 { this.tips = 'zhognguoahjdoha dnao oadjiafnofofnoasdfofaonafsnfudsfofdccvc v vccv mdfsj'; this.setOrientation(); }) + Button('change') + .id('change') + .width(100) + .height(30) + .onClick(() => { + this.setOrientation1(); + }) } .width('100%') .height('100%') diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString001.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString001.ets new file mode 100644 index 0000000000000000000000000000000000000000..22595333f9fbbba882eeb60cd49c2bd5b86c9a0a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString001.ets @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; +@Entry +@Component +struct ComponentTextRicheditorSetStyledString001 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle1 }]); + styledString: StyledString = new StyledString("属性字符串", + [{ start: 2, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle2 }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = {controller: this.controller}; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + + build() { + Column() { + Button("image Top").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + Button("image Center").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_center') + Button("image Bottom").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BOTTOM, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_bottom') + + Button("image Baseline").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_baseline') + RichEditor(this.options) + .onReady(() => { + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black).id('ComponentTextRicheditorSetStyledString001') + + Column() { + Row() { + Button("add text").onClick(() => { + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(this.styledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + }).id('add_text') + } + + } + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString002.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString002.ets new file mode 100644 index 0000000000000000000000000000000000000000..96e2b8bd151273212628aaefc698ee30335372b8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString002.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; +@Entry +@Component +struct ComponentTextRicheditorSetStyledString002 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle1 }]); + styledString: StyledString = new StyledString("属性字符串", + [{ start: 2, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle2 }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = {controller: this.controller}; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + + build() { + Column() { + Button("百分比").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + RichEditor(this.options) + .onReady(() => { + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black).id('ComponentTextRicheditorSetStyledString002') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString003.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString003.ets new file mode 100644 index 0000000000000000000000000000000000000000..c66cefbdb747d59d1a6a31c5c0e79a8da97d89db --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString003.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; +@Entry +@Component +struct ComponentTextRicheditorSetStyledString003 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle1 }]); + styledString: StyledString = new StyledString("属性字符串", + [{ start: 2, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle2 }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = {controller: this.controller}; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + + build() { + Column() { + Button("设定图片大小").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: '57px', height: '57px' }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + RichEditor(this.options) + .onReady(() => { + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black).id('ComponentTextRicheditorSetStyledString003') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString004.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString004.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4010b806b3411ea1b950f9bdc9eb7d7ebf98dc0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString004.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; +@Entry +@Component +struct ComponentTextRicheditorSetStyledString004 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle1 }]); + styledString: StyledString = new StyledString("属性字符串", + [{ start: 2, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle2 }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = {controller: this.controller}; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + + build() { + Column() { + Button("设定图片大小").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: '57px', height: '57px' }, + layoutStyle: { borderRadius: LengthMetrics.vp(10),margin:LengthMetrics.vp(10),padding:LengthMetrics.vp(10)}, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain, + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + RichEditor(this.options) + .onReady(() => { + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black).id('ComponentTextRicheditorSetStyledString004') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString005.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString005.ets new file mode 100644 index 0000000000000000000000000000000000000000..8491f3adefcdcf084af082946bed72aaff6d0ab6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString005.ets @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; +@Entry +@Component +struct ComponentTextRicheditorSetStyledString005 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle1 }]); + styledString: StyledString = new StyledString("属性字符串", + [{ start: 2, length: 5, styledKey: StyledStringKey.FONT, styledValue: this.fontStyle2 }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = {controller: this.controller}; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + + build() { + Column() { + Button("ImageFit.Contain").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + Button("ImageFit.Fill").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit: ImageFit.Fill + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_center') + Button("ImageFit.Cover").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BOTTOM, + objectFit: ImageFit.Cover + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_bottom') + + Button("ImageFit.Auto").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit: ImageFit.Auto + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_baseline') + Button("ImageFit.ScaleDown").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit: ImageFit.ScaleDown + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_down') + Button("ImageFit.None").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit: ImageFit.None + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_none') + RichEditor(this.options) + .onReady(() => { + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black).id('ComponentTextRicheditorSetStyledString005') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString008.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString008.ets new file mode 100644 index 0000000000000000000000000000000000000000..60ec53e0c204599d0ee9a959b19a1ddd827c3ae2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString008.ets @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; + +@Entry +@Component +struct ComponentTextRicheditorSetStyledString008 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ + start: 0, + length: 5, + styledKey: StyledStringKey.FONT, + styledValue: this.fontStyle1 + }]); + styledString: StyledString = new StyledString("属性字符串", + [{ + start: 2, + length: 5, + styledKey: StyledStringKey.FONT, + styledValue: this.fontStyle2 + }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { controller: this.controller }; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + build() { + Column() { + Button("replace").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image_top') + Button("select").onClick(() => { + this.controller.setSelection(-1,-1); + }).id('select') + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.mutableStyledString); + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black) + .id('ComponentTextRicheditorSetStyledString008') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString009.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString009.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad3c0ae51635ff525a0d19606172634179aada5b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString009.ets @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2024 Huawei Device 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'; +import { image } from '@kit.ImageKit'; + +@Entry +@Component +struct ComponentTextRicheditorSetStyledString009 { + stringLength: number = 0; + imagePixelMap: image.PixelMap | undefined = undefined; + @State selection: string = ""; + @State content: string = ""; + @State range: string = ""; + @State replaceString: string = ""; + @State rangeBefore: string = ""; + @State rangeAfter: string = ""; + richEditorStyledString: MutableStyledString = new MutableStyledString(""); + textStyle: TextStyle = new TextStyle({ + fontWeight: FontWeight.Lighter, + fontFamily: 'HarmonyOS Sans', + fontColor: Color.Green, + fontSize: LengthMetrics.vp(30), + fontStyle: FontStyle.Normal + }) + fontStyle1: TextStyle = new TextStyle({ fontColor: Color.Blue }); + fontStyle2: TextStyle = new TextStyle({ + fontWeight: FontWeight.Bolder, + fontFamily: 'Arial', + fontColor: Color.Orange, + fontSize: LengthMetrics.vp(50), + fontStyle: FontStyle.Italic + }) + // 创建属性字符串对象 + mutableStyledString: MutableStyledString = new MutableStyledString("init属性", + [{ + start: 0, + length: 5, + styledKey: StyledStringKey.FONT, + styledValue: this.fontStyle1 + }]); + styledString: StyledString = new StyledString("属性字符串", + [{ + start: 2, + length: 5, + styledKey: StyledStringKey.FONT, + styledValue: this.fontStyle2 + }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { controller: this.controller }; + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ + bundleName: resource.bundleName, + moduleName: resource.moduleName, + id: resource.id + }) + let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) + let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ + desiredPixelFormat: image.PixelMapFormat.RGBA_8888 + }) + await imageSource.release() + return createPixelMap + } + + build() { + Column() { + Button("image").onClick(() => { + if (this.imagePixelMap !== undefined) { + let imageStyledString = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 20, height: 20 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit: ImageFit.Contain + })) + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.appendStyledString(imageStyledString); + this.controller.setStyledString(this.richEditorStyledString); + this.controller.setCaretOffset(this.richEditorStyledString.length); + } + }).id('image') + Button("replace").onClick(() => { + let richEditorSelection = this.controller.getSelection(); + let start = richEditorSelection.start ? richEditorSelection.start : 0; + let end = richEditorSelection.end ? richEditorSelection.end : 0; + this.richEditorStyledString = this.controller.getStyledString(); + this.richEditorStyledString.setStyle({ + start: start, + length: end - start, + styledKey: StyledStringKey.FONT, + styledValue: this.textStyle + }) + this.controller.setStyledString(this.richEditorStyledString); + }).id('image_top') + Button("select").onClick(() => { + this.controller.setSelection(-1,-1); + }).id('select') + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.mutableStyledString); + }) + .height("20%") + .width("100%") + .borderWidth(1) + .borderColor(Color.Black) + .id('ComponentTextRicheditorSetStyledString009') + .width("100%") + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0390.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0390.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b3b67f01c5f1400f8472967d7b5a7c65ece37f2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0390.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0390 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是国人', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0390') + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0390_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0400.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0400.ets new file mode 100644 index 0000000000000000000000000000000000000000..82b377fa9580bf2b38ab53e60349288656d16952 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0400.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0400 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0400') + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0400_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0410.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0410.ets new file mode 100644 index 0000000000000000000000000000000000000000..76c5232f50a0481d3d4a4f11430d44cabd09bb3a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0410.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0410 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0410') + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0410_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0420.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0420.ets new file mode 100644 index 0000000000000000000000000000000000000000..80b585041db1224ae30f22098f6f3364503d0ad0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0420.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0420 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0420') + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0420_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0430.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0430.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ea3b8a50f25a204d85a0620b5bacde94f2a25ab --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0430.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0430 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0430') + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0430_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0440.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0440.ets new file mode 100644 index 0000000000000000000000000000000000000000..829d3085d8cde7d5db1a774638b4899ab25a40f1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0440.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0440 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0440') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0450.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0450.ets new file mode 100644 index 0000000000000000000000000000000000000000..acd399b4a9589864f808eb87f4a72e2fbd15ccd4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0450.ets @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0450 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0450') + .copyOptions(CopyOptions.None) + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0450_01') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0460.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0460.ets new file mode 100644 index 0000000000000000000000000000000000000000..33c637de5edde9a8ccb4118a302d3eafed4319bc --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0460.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0460 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0460') + .copyOptions(CopyOptions.InApp) + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0460_01') + .onPaste(() => { + this.controller1.stopEditing(); + }) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0470.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0470.ets new file mode 100644 index 0000000000000000000000000000000000000000..538436ad90cc72d64741e6ea2e0b12070c4dd5e8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0470.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0470 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国'+'\n'+'我是中国'+'\n'+'我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0470') + .copyOptions(CopyOptions.LocalDevice) + + RichEditor(this.options1) + .width('100%') + .height('50%') + .borderWidth(2) + .borderColor(Color.Red) + .margin({top:20}) + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0470_01') + .onPaste(() => { + this.controller1.stopEditing(); + }) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0480.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0480.ets new file mode 100644 index 0000000000000000000000000000000000000000..48c4b4b88a7f80571a04e20f4a42c1ceefd64992 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0480.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0480 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + this.controller.addTextSpan('我是中国', { + }); + }) + .id('ComponentTextRicheditorShortKcutKeys0480') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0490.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0490.ets new file mode 100644 index 0000000000000000000000000000000000000000..092fd8b9ba316dee7be273a15272432b88ee1ec5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0490.ets @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0490 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0490') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0500.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0500.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5f361f9e04ff54aadd9205fd80f250b6cbd0358 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0500.ets @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorShortKcutKeys0500 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + controller1: RichEditorController = new RichEditorController(); + options1: RichEditorOptions = { controller: this.controller1 }; + + build() { + Row() { + Column() { + RichEditor(this.options) + .borderWidth(2) + .borderColor(Color.Blue) + .width('100%') + .height('30%') + .onReady(() => { + }) + .id('ComponentTextRicheditorShortKcutKeys0500') + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0009.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0009.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6eb6ddd92422394993e38e0d9e8ede95f744c5f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0009.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device 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 ComponentTextRicheditorUxConformance0009 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State msg : String = ''; + build() { + Row() { + Column() { + Text('span value=====' + this.msg) + TextArea({text:"我是TextArea"}).draggable(true).width(100).height(50).id('TextArea'); + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('abcde', { + }); + }) + .onDragEnd(()=>{ + this.msg = JSON.stringify(this.controller.getSpans()); + console.log('msg===='+this.msg); + }) + .onIMEInputComplete(()=>{ + this.msg = JSON.stringify(this.controller.getSpans()); + console.log('msg===='+this.msg); + }) + .onDidChange(()=>{ + this.msg = JSON.stringify(this.controller.getSpans()); + console.log('msg===='+this.msg); + }) + .id('ComponentTextRicheditorUxConformance0009') + .draggable(true) + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/module.json5 b/function/ui_compare_rh/uicompare/entry/src/ohosTest/module.json5 index e58bd507f3ecff51931c351ebcabf6603cd5c40c..69a54527634afae2627d4bc0b82bbae2b69ab6eb 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/module.json5 +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/module.json5 @@ -12,20 +12,33 @@ "installationFree": false, "pages": "$profile:test_pages", "requestPermissions": [ + { + "name":"ohos.permission.INTERNET" + "name": "ohos.permission.SYSTEM_FLOAT_WINDOW", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, { "name": "ohos.permission.WRITE_MEDIA" }, { - "name": "ohos.permission.READ_MEDIA" + "name": "ohos.permission.INTERNET" }, { - "name":"ohos.permission.UPDATE_CONFIGURATION" + "name": "ohos.permission.READ_MEDIA" }, { - "name":"ohos.permission.RUNNING_LOCK" + "name": "ohos.permission.CAPTURE_SCREEN" }, { - "name":"ohos.permission.INTERNET" + "name": "ohos.permission.ACCESS_SCREEN_LOCK_INNER" } ], "abilities": [ diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/element/string.json b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/element/string.json index ce65c09bf1f31a1214be8ab75ed207896afea2d3..b426d7959db6da0b118ebd8e9de9600097da4091 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/element/string.json +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/element/string.json @@ -243,6 +243,10 @@ { "name": "20string", "value": "20" + }, + { + "name": "size_30fp", + "value": "30fp" } ] } \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json index 5cc05ce92cff61b76d701a3fe495c11c73638078..03926cc9d070f49865bc2d945c6395aaa0336d86 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -141,6 +141,8 @@ "testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0005", "testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0006", "testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0007", + "testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0025", + "testability/pages/ComponentTextRicheditorOnWillChangeTest/ComponentTextRicheditorOnWillChange0026", "testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0001", "testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0002", "testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0003", @@ -158,6 +160,8 @@ "testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0017", "testability/pages/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest/ComponentTextRicheditorCustomkeyBoardAvoidAnce0019", "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0014", + "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0015", + "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0016", "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0019", "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0020", "testability/pages/ComponentTextRicheditorLineHeightLetterSpacing/ComponentTextRicheditorLineHeightLetterSpacing0021", @@ -175,6 +179,7 @@ "testability/pages/ComponentTextRicheditorKeyboardReinForcingTest/ComponentTextRicheditorKeyboardReinForcing0015", "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0006", "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0007", + "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0009", "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0011", "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0012", "testability/pages/ComponentTextRicheditorUxConformanceTest/ComponentTextRicheditorUxConformance0013", @@ -346,6 +351,133 @@ "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0360", "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0370", "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0380", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0390", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0400", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0410", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0420", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0430", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0440", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0450", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0460", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0470", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0480", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0490", + "testability/pages/ComponentTextRicheditorShortKcutKeys/ComponentTextRicheditorShortKcutKeys0500", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0010", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0020", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0030", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0040", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0050", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0060", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0070", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0080", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0090", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0100", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0120", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0130", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0150", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0160", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0170", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0180", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0190", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0200", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0210", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0220", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0230", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0240", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0250", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0260", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0270", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0280", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0290", + "testability/pages/ComponentTextRicheditorCustomLayout/ComponentTextRicheditorCustomLayout0300", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0020", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0030", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0050", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0060", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0070", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0090", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0100", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0110", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0120", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0130", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0140", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0150", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0160", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0170", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0180", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0190", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0200", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0210", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0220", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0230", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0240", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0250", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0260", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0270", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0280", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0290", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0310", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0320", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0330", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0340", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0350", + "testability/pages/ComponentTextRicheditorPCMenu/ComponentTextRicheditorPCMenu0360", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0010", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0020", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0030", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0040", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0050", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0060", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0070", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0080", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0110", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0120", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0140", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0150", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0160", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0170", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0180", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0190", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0200", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0210", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0220", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0230", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0240", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0250", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0260", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0270", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0280", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0290", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0300", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0310", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0320", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0330", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0340", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0350", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0360", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0370", + "testability/pages/ComponentTextRicheditorLayoutStyle/ComponentTextRicheditorLayoutStyle0400", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString001", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString002", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString003", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString004", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString005", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString008", + "testability/pages/ComponentTextRicheditorSetStyledString/ComponentTextRicheditorSetStyledString009", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0001", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0002", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0003", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0004", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0005", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0006", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0007", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0008", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0009", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0010", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0011", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0012", + "testability/pages/ComponentTextRicheditorAvoidance/ComponentTextRicheditorAvoidance0013", "testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0001", "testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0002", "testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder0003", @@ -1801,6 +1933,7 @@ "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface007", "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface008", "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface009", - "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface0010" + "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface0010", + "testability/pages/ComponentTextRicheditorPlaceholderTest/ComponentTextRicheditorPlaceholder00105" ] } diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorAITest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorAITest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..cd22fd7a32935892b430b18fdd64c4a2fc919819 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorAITest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomColorsTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomColorsTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0ed4fdf3517f971c51d6909414bce80f0486c94a Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomColorsTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..dc9e38de4fce70e200c01b29fbf281e500fac6b6 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorCustomkeyBoardAvoidAnceTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorFontfeatureTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorFontfeatureTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..074274f47ccd5c92a616590aa2ca6bbf480ed3b7 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorFontfeatureTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorInterface.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorInterface.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..b1b471a0013c40407bc9c3a7878dca31c24df550 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorInterface.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorKeyboardReinForcingTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorKeyboardReinForcingTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..1521d00fb511a47c5c621227bad4f857db81d6ad Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorKeyboardReinForcingTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLineHeightLetterSpacing.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLineHeightLetterSpacing.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..73b20451f9a7b94b8e3d8b2559207640969a777d Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLineHeightLetterSpacing.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLongPresstoselectallTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLongPresstoselectallTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..3c97a98f87b6358a807ad7b829f543662a910d50 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorLongPresstoselectallTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorPlaceholderTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorPlaceholderTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..048fdef61f5ac29f785822b70828bc71fb7d1601 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorPlaceholderTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorShortKcutKeys.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorShortKcutKeys.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..8889b70e43778417da1ea8d5deb1909148caa3d2 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorShortKcutKeys.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorUxConformanceTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorUxConformanceTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..01d7da9f5dd9cc7b9c668f7cf5106d0c19099bd9 Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorUxConformanceTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorWordbreakTest.xlsx b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorWordbreakTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..908b977ee271713babb808c07f38753955ca94fb Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/ComponentTextRicheditorWordbreakTest.xlsx differ diff --git a/function/ui_compare_rh/uicompare_tools/excel/richeditor1.xlsx b/function/ui_compare_rh/uicompare_tools/excel/richeditor1.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..205f386a6b4cf609aaaf632b0baa3535ad2e36dc Binary files /dev/null and b/function/ui_compare_rh/uicompare_tools/excel/richeditor1.xlsx differ