From 933213133563d2cf177b2cee2b7619cbc636120d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Fri, 18 Jul 2025 15:50:39 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiRichEditorScroll=E7=AD=8928=E6=9D=A1case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- ...mponentImageAttachmentColorFilter.test.ets | 341 ++++++++++++++++++ .../UiComponentTextInputSymbolGlyph.test.ets | 239 ++++++++++++ .../UiRichEditorScroll.test.ets | 299 +++++++++++++++ 3 files changed, 879 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter.test.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph.test.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiRichEditorScroll/UiRichEditorScroll.test.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter.test.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter.test.ets new file mode 100644 index 00000000..3d03fe00 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter.test.ets @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON,Component ,MouseButton } from '@ohos.UiTest' +/* + * SUB_ACE_UI_ATTRIBUTES_FONT_INTERFACE_0010:设置文本颜色 + * + * 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 UiComponentImageAttachmentColorFilter() { + + describe('UiComponentImageAttachmentColorFilter', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_IMPORT_COMPONENTCONTENT_0080 + * @tc.name Set the ImageAttachment property string to add an image, and set colorFilter and objectFit at the same time + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_IMPORT_COMPONENTCONTENT_0080', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_IMPORT_COMPONENTCONTENT_0080 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter01") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter01_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter01_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_IMPORT_COMPONENTCONTENT_0080 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0090 + * @tc.name Set the ImageAttachment property string to add an image, and set colorFilter and layoutStyle at the same time + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0090', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0090 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter02") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter02_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter02_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0090 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0070 + * @tc.name Set the ImageAttachment property string to add an image, and set colorFilter and verticalAlign at the same time + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0070', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0070 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter03") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter03_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter03_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0070 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0060 + * @tc.name Set the ImageAttachment property string to add an image, and set colorFilter and size at the same time + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0060', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0060 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter04") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter04_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter04_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0060 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0030 + * @tc.name Set the ImageAttachment property string to add an image, and set the colorFilter to 19 bits + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0030', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0030 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter05") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter05_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter05_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0030 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0020 + * @tc.name Set the ImageAttachment property string to add an image, and set the colorFilter to 20 bits + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0020', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0020 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter06") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter06_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter06_02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0020 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0100 + * @tc.name Set the ImageAttachment property string to add an image, set a colorFilter, and use replaceString to replace the image with text + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0100', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0100 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter07") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter07_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter07_02'),1000); + let button03: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter07_03'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button03.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0100 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0110 + * @tc.name Set the ImageAttachment property string to add an image, set the colorFilter, and use insertString to insert text before and after the image + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0110', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0110 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter08") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter08_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter08_02'),1000); + let button03: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter08_03'),1000); + let button04: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter08_04'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button04.click() + await driver.waitForIdle(500,2000) + await button03.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0200 + * @tc.name Set the ImageAttachment property string to add an image, set the colorFilter, and use appendStyledString to insert a new image + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0200', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0200 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter09") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter09_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter09_02'),1000); + let button03: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter09_03'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button03.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0200 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0190 + * @tc.name Set the ImageAttachment property string to add an image, set the colorFilter, and use insertStyledString to insert a new image + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0190', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0190 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter10") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter10_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter10_02'),1000); + let button03: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter10_03'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + await button03.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0190 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0180 + * @tc.name Set the ImageAttachment property string to add an image, set the colorFilter, and use replaceStyledString to insert a new image + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 3 + */ + it('SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0180', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0180 start.`); + Settings.createWindow("testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter11") + let driver:Driver=Driver.create(); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter11_01'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter11_02'),1000); + let button03: Component = await driver.waitForComponent(ON.id('UiComponentImageAttachmentColorFilter11_03'),1000); + await button01.click() + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await button03.click() + await driver.waitForIdle(500,2000) + await button02.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_IMAGEATTACHMENT_COLORFILTER_0180 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph.test.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph.test.ets new file mode 100644 index 00000000..70e97b08 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph.test.ets @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON,Component ,MouseButton } from '@ohos.UiTest' +/* + * SUB_ACE_UI_ATTRIBUTES_FONT_INTERFACE_0010:设置文本颜色 + * + * 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 UiComponentTextInputSymbolGlyph() { + + describe('UiComponentTextInputSymbolGlyph', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0050 + * @tc.name TextInput component, set cancelButton{CancelButtonStyle.CONSTANT,SymbolGlyphModifier}, and dynamically switch fontsize + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0050', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0050 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph01") + let driver:Driver=Driver.create(); + let textinput: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph01_01'),1000); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph01_02'),1000); + let point = await textinput.getBounds() + await driver.mouseClick({x:point.right-10,y:point.top-(point.top-point.bottom)/2},MouseButton.MOUSE_BUTTON_LEFT) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await textinput.inputText('11') + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await button01.click(); + await textinput.inputText('11') + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0050 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0040 + * @tc.name TextInput component, set cancelButton{CancelButtonStyle.CONSTANT,SymbolGlyphModifier}, and dynamically switch fontColor + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0040', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0040 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph02") + let driver:Driver=Driver.create(); + let textinput: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph02_01'),1000); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph02_02'),1000); + let point = await textinput.getBounds() + await driver.mouseClick({x:point.right-10,y:point.top-(point.top-point.bottom)/2},MouseButton.MOUSE_BUTTON_LEFT) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await textinput.inputText('11') + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await button01.click(); + await textinput.inputText('11') + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0040 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0060 + * @tc.name TextInput component, set cancelButton{CancelButtonStyle.CONSTANT,SymbolGlyphModifier}, and dynamically switch fontweight + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0060', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0060 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph03") + let driver:Driver=Driver.create(); + let textinput: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph03_01'),1000); + let button01: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph03_02'),1000); + let point = await textinput.getBounds() + await driver.mouseClick({x:point.right-10,y:point.top-(point.top-point.bottom)/2},MouseButton.MOUSE_BUTTON_LEFT) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await textinput.inputText('11') + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await button01.click(); + await textinput.inputText('11') + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0060 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0150 + * @tc.name TextInput component, set cancelButton{CancelButtonStyle.CONSTANT,SymbolGlyphModifier}, and enter extra-long text + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0150', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0150 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph04") + let driver:Driver=Driver.create(); + let textinput: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph04_01'),1000); + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await textinput.inputText('111111111111111111111111111111111') + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0150 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0110 + * @tc.name TextInput component, set the input box type to password/NEW_PASSWORD/NUMBER_PASSWORD, and change the system font size + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0110', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0110 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph05") + let driver:Driver=Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph05_02'),1000); + for(let i=0;i<4;++i) + { + await button.click(); + windowSnap.snapShot(); + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0120 + * @tc.name TextInput component, set the input box type to password/NEW_PASSWORD/NUMBER_PASSWORD, and change the system font size to fp + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0120', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0120 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph06") + let driver:Driver=Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph06_02'),1000); + for(let i=0;i<4;++i) + { + await button.click(); + windowSnap.snapShot(); + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0120 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0220 + * @tc.name System dark and light color test + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0220', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0220 start.`); + Settings.createWindow("testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph07") + let driver:Driver=Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph07_02'),1000); + let button02: Component = await driver.waitForComponent(ON.id('UiComponentTextInputSymbolGlyph07_03'),1000); + await button.click(); + windowSnap.snapShot(); + await driver.waitForIdle(500,2000) + await button02.click(); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXTINPUT_SYMBOLGLYPH_0220 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiRichEditorScroll/UiRichEditorScroll.test.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiRichEditorScroll/UiRichEditorScroll.test.ets new file mode 100644 index 00000000..a2d0b20c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiRichEditorScroll/UiRichEditorScroll.test.ets @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON,Component ,MouseButton } from '@ohos.UiTest' +/* + * SUB_ACE_UI_ATTRIBUTES_FONT_INTERFACE_0010:设置文本颜色 + * + * 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 UiRichEditorScroll() { + + describe('UiRichEditorScroll', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0120 + * @tc.name RichEditor, multi-line text is displayed in the content area, and the height is dynamically changed + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0120', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0120 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll01") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button01: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll01'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0120 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0150 + * @tc.name RichEditor, multi-line text, delete content + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0150', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0150 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll02") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button01: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll02'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0150 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0110 + * @tc.name RichEditor, multi-line text is displayed in the content area, and the width is dynamically changed + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0110', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0110 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll03") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button01: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll03'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0210 + * @tc.name RichEditor, multi-line text, padding settings + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0210', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0210 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll04") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button01: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll04'),1000); + await button01.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0210 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0230 + * @tc.name RichEditor, multi-line text, set clip + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0230', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0230 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll05") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let richeditor: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll05'),1000); + let point =await richeditor.getBoundsCenter(); + await driver.mouseScroll({x:point.x, y:point.y}, true, 30) + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0230 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0130 + * @tc.name RichEditor, multi-line text, select all text Scroll up and down to select all without disappearing + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0130', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0130 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll06") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll06_01'),1000); + let richeditor: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll06_02'),1000); + let point =await richeditor.getBoundsCenter(); + await richeditor.click(); + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await driver.mouseScroll({x:point.x, y:point.y}, false, 30) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0130 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0250 + * @tc.name RichEditor, multi-line text, select all text Scroll up and down to select all without disappearing + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0250', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0250 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll07") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let button: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll07_01'),1000); + let richeditor: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll07_02'),1000); + let point =await richeditor.getBoundsCenter(); + await driver.mouseScroll({x:point.x, y:point.y}, true, 2) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await richeditor.click(); + await button.click(); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0250 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0270 + * @tc.name RichEditor, multi-line text, click to truncate text + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0270', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0270 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll08") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot(); + let richeditor: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll08_02'),1000); + let point =await richeditor.getBoundsCenter(); + await driver.mouseScroll({x:point.x, y:point.y}, true, 2) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await richeditor.click(); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0270 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0220 + * @tc.name RichEditor, multi-line text, set text indentation + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0220', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0220 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll09") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0220 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_RICHEDITOR_SCROLL_0140 + * @tc.name RichEditor, multi-line text, select part of the text + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_RICHEDITOR_SCROLL_0140', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0140 start.`); + Settings.createWindow("testability/pages/UiRichEditorScroll/UiRichEditorScroll10") + let driver:Driver=Driver.create(); + let richeditor: Component = await driver.waitForComponent(ON.id('UiRichEditorScroll10'),1000); + let point = await richeditor.getBoundsCenter(); + await richeditor.click(); + await driver.longClick(point.x,point.y) + await Utils.sleep(1500) + await driver.mouseDrag({x:point.x+10, y:point.y+20},{x:point.x, y:point.y+100},600); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_RICHEDITOR_SCROLL_0140 finish.`); + done() + }) + + }) +} -- Gitee From 6640d87d5d1ba71bb78546987819215993233916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Fri, 18 Jul 2025 15:51:04 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiRichEditorScroll=E7=AD=8928=E6=9D=A1case2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- .../UiComponentTextInputSymbolGlyph01.ets | 85 +++++++++++++++ .../UiComponentTextInputSymbolGlyph02.ets | 86 +++++++++++++++ .../UiComponentTextInputSymbolGlyph03.ets | 87 +++++++++++++++ .../UiComponentTextInputSymbolGlyph04.ets | 76 +++++++++++++ .../UiComponentTextInputSymbolGlyph05.ets | 86 +++++++++++++++ .../UiComponentTextInputSymbolGlyph06.ets | 86 +++++++++++++++ .../UiComponentTextInputSymbolGlyph07.ets | 102 ++++++++++++++++++ 7 files changed, 608 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph01.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph02.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph03.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph04.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph05.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph06.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph07.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph01.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph01.ets new file mode 100644 index 00000000..24bc0c4a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph01.ets @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph01 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically switch fontsize'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontsize : number =10 + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .fontSize(this.fontsize) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph01_01') + Button('change fontsize') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .onClick(()=>{ + this.fontsize+=10 + }) + .id('UiComponentTextInputSymbolGlyph01_02') + } + .width('100%') + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph02.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph02.ets new file mode 100644 index 00000000..d4c917f8 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph02.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph02 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically switch fontcolor'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontcolor : Color =Color.Blue + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .fontSize(10) + .fontColor(this.fontcolor) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph02_01') + Button('change fontcolor') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .onClick(()=>{ + this.fontcolor=Color.Red + }) + .id('UiComponentTextInputSymbolGlyph02_02') + } + .width('100%') + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph03.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph03.ets new file mode 100644 index 00000000..03391b64 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph03.ets @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph03 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically switch fontweight'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontweight : number =100 + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .fontSize(10) + .fontColor(Color.Blue) + .fontWeight(this.fontweight) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph03_01') + Button('change fontweight') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .onClick(()=>{ + this.fontweight+=400 + }) + .id('UiComponentTextInputSymbolGlyph03_02') + } + .width('100%') + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph04.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph04.ets new file mode 100644 index 00000000..f656e5e7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph04.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class MyTextInputAttribute implements AttributeModifier { + public isDark: boolean = false; + + applyNormalAttribute(instance: TextInputAttribute): void { + instance.cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + } +} + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph04 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'modifier set cancelbutton'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontweight : number =10 + @State modifier3: MyTextInputAttribute = new MyTextInputAttribute(); + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .defaultFocus(true) + .fontSize(10) + .fontColor(Color.Blue) + .fontWeight(this.fontweight) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .attributeModifier(this.modifier3) + .id('UiComponentTextInputSymbolGlyph04_01') + } + .width('100%') + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph05.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph05.ets new file mode 100644 index 00000000..1647d8b4 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph05.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiAppearance } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph05 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically change the system Font size'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontweight : number =100 + @State fontscale : number = 1; + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .minFontScale(1) + .maxFontScale(3.2) + .fontSize(10) + .fontColor(Color.Blue) + .fontWeight(this.fontweight) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph05_01') + Button('set fontscale').onClick(()=>{ + try { + uiAppearance.setFontScale(this.fontscale).then(() => { + console.info('Set fontScale successfully.'); + }).catch((error:Error) => { + console.error('Set fontScale failed, ' + error.message); + }); + } catch (error) { + let message = (error as BusinessError).message; + console.error('Set fontScale failed, ' + message); + } + this.fontscale+=0.15; + }) + .id('UiComponentTextInputSymbolGlyph05_02') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph06.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph06.ets new file mode 100644 index 00000000..a861dc95 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph06.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics, uiAppearance } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph06 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically change the system Font size and The unit is FP'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontweight : number =100 + @State fontscale : number = 1; + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: "10fp", + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .minFontScale(1) + .maxFontScale(3.2) + .fontSize(10) + .fontColor(Color.Blue) + .fontWeight(this.fontweight) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph06_01') + Button('set fontscale').onClick(()=>{ + try { + uiAppearance.setFontScale(this.fontscale).then(() => { + console.info('Set fontScale successfully.'); + }).catch((error:Error) => { + console.error('Set fontScale failed, ' + error.message); + }); + } catch (error) { + let message = (error as BusinessError).message; + console.error('Set fontScale failed, ' + message); + } + this.fontscale+=0.5; + }) + .id('UiComponentTextInputSymbolGlyph06_02') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph07.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph07.ets new file mode 100644 index 00000000..8a6f648b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentTextInputSymbolGlyph/UiComponentTextInputSymbolGlyph07.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics, uiAppearance } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct UiComponentTextInputSymbolGlyph07 { + textAreaController: TextAreaController = new TextAreaController(); + textinputController: TextInputController = new TextInputController(); + searchController: SearchController = new SearchController(); + @State startIndex: number = 0 + @State endIndex: number = 0 + @State text: string = ''; + @State text2: string = 'Dynamically change the system Font size and The unit is FP'; + @State changeValue: string = '' + @State submitValue: string = '' + @State fontweight : number =100 + @State fontscale : number = 1; + + build() { + Column({ space: 3 }) { + Text(this.text2) + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + TextInput({ text: this.text, controller: this.textinputController }) + .width('95%') + .height(100) + .cancelButton({ + style: CancelButtonStyle.CONSTANT, + icon: { + size: 45, + src: $r('app.media.app_icon'), + color: Color.Blue + } + }) + .defaultFocus(true) + .minFontScale(1) + .maxFontScale(3.2) + .fontSize(10) + .fontColor(Color.Blue) + .fontWeight(this.fontweight) + .enableKeyboardOnFocus(true) + .style(TextInputStyle.Inline) + .type(InputType.Password) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + this.startIndex = selectionStart + this.endIndex = selectionEnd + }) + .id('UiComponentTextInputSymbolGlyph07_01') + Button('set DarkMode dark').onClick(()=>{ + try { + uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (error) => { + if (error) { + console.error('Set dark-mode failed, ' + error.message); + } else { + console.info('Set dark-mode successfully.'); + } + }) + } catch (error) { + let message = (error as BusinessError).message; + console.error('Set dark-mode failed, ' + message); + } + }) + .id('UiComponentTextInputSymbolGlyph07_02') + Button('set DarkMode light').onClick(()=>{ + try { + uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT, (error) => { + if (error) { + console.error('Set dark-mode failed, ' + error.message); + } else { + console.info('Set dark-mode successfully.'); + } + }) + } catch (error) { + let message = (error as BusinessError).message; + console.error('Set dark-mode failed, ' + message); + } + }) + .id('UiComponentTextInputSymbolGlyph07_03') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file -- Gitee From a7a4ca61274f2d265fe6bd34d09ce86b52f437f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Fri, 18 Jul 2025 15:51:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiRichEditorScroll=E7=AD=8928=E6=9D=A1case3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- ...iComponentImageAttachmentColorFilter01.ets | 124 ++++++++++++++ ...iComponentImageAttachmentColorFilter02.ets | 124 ++++++++++++++ ...iComponentImageAttachmentColorFilter03.ets | 123 ++++++++++++++ ...iComponentImageAttachmentColorFilter04.ets | 124 ++++++++++++++ ...iComponentImageAttachmentColorFilter05.ets | 125 ++++++++++++++ ...iComponentImageAttachmentColorFilter06.ets | 125 ++++++++++++++ ...iComponentImageAttachmentColorFilter07.ets | 138 ++++++++++++++++ ...iComponentImageAttachmentColorFilter08.ets | 143 ++++++++++++++++ ...iComponentImageAttachmentColorFilter09.ets | 152 ++++++++++++++++++ ...iComponentImageAttachmentColorFilter10.ets | 152 ++++++++++++++++++ ...iComponentImageAttachmentColorFilter11.ets | 152 ++++++++++++++++++ 11 files changed, 1482 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter01.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter02.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter03.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter04.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter05.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter06.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter07.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter08.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter09.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter10.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter11.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter01.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter01.ets new file mode 100644 index 00000000..b42590af --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter01.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter01 { + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-set colorFilter、objectFit') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter01_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter、objectFit') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter01_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter02.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter02.ets new file mode 100644 index 00000000..ffbdfc92 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter02.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter02 { + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-set colorFilter、layoutStyle') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter02_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter、layoutStyle') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter02_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + verticalAlign: ImageSpanAlignment.BASELINE, + objectFit:ImageFit.Fill, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter03.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter03.ets new file mode 100644 index 00000000..f85f12d3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter03.ets @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter03 { + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-set colorFilter、verticalAlign') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.TOP, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter03_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter、verticalAlign') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter03_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + objectFit:ImageFit.Fill, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter04.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter04.ets new file mode 100644 index 00000000..d796b1d5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter04.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter04{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-set colorFilter、size') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter04_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter、size') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter04_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter05.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter05.ets new file mode 100644 index 00000000..5a8d7ccd --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter05.ets @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter05{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-Set colorFilter to 19 bits') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter05_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter05_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter06.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter06.ets new file mode 100644 index 00000000..51d560fa --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter06.ets @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter06{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-Set colorFilter to 20 bits') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter06_01') + Text(undefined, { controller: this.controller2 }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-not set colorFilter') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .id('UiComponentImageAttachmentColorFilter06_02') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + })); + this.controller2.setStyledString(this.mutableStr); + } + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter07.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter07.ets new file mode 100644 index 00000000..49015349 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter07.ets @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter07{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + @State colorfit : ColorFilterType|undefined = '' + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-Set colorFilter to 20 bits') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter07_01') + Button('Image之Get') + .onClick(() => { + let imageArray = this.mutableStr.getStyles(0, 1, StyledStringKey.IMAGE); + for (let i = 0; i < imageArray.length; ++i) { + console.info('mutableStr start ' + imageArray[i].start + ' length ' + imageArray[i].length + ' type ' + + imageArray[i].styledKey); + if (imageArray[i].styledKey === 300) { + let attachment = imageArray[i].styledValue as ImageAttachment; + this.imagePixelMap3 = attachment.value; + console.info('mutableStr value ' + JSON.stringify(attachment.value)); + if (attachment.size !== undefined) { + console.info('mutableStr size width ' + attachment.size.width + ' height ' + attachment.size.height); + } + console.info('mutableStr vertical ' + attachment.verticalAlign); + console.info('mutableStr fit ' + attachment.objectFit); + console.info('mutableStr colorFilter ' + attachment.colorFilter); + this.colorfit=attachment.colorFilter + if (attachment.layoutStyle !== undefined) { + let radius = attachment.layoutStyle.borderRadius as BorderRadiuses; + console.info('mutableStr radius ' + JSON.stringify(radius)); + } + } + } + }) + .id('UiComponentImageAttachmentColorFilter07_02') + Text('colorFilter='+this.colorfit) + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Red) + .fontSize(5) + Button('Image之replace') + .onClick(() => { + this.mutableStr.replaceString(0, 1, "789"); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter07_03') + } + .width('100%') + } + .height('100%') + } +} + diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter08.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter08.ets new file mode 100644 index 00000000..aeac4d75 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter08.ets @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter08{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + @State colorfit : ColorFilterType|undefined = '' + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('设置图片-Set colorFilter to 20 bits') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter08_01') + Button('Image之Get') + .onClick(() => { + let imageArray = this.mutableStr.getStyles(0, 1, StyledStringKey.IMAGE); + for (let i = 0; i < imageArray.length; ++i) { + console.info('mutableStr start ' + imageArray[i].start + ' length ' + imageArray[i].length + ' type ' + + imageArray[i].styledKey); + if (imageArray[i].styledKey === 300) { + let attachment = imageArray[i].styledValue as ImageAttachment; + this.imagePixelMap3 = attachment.value; + console.info('mutableStr value ' + JSON.stringify(attachment.value)); + if (attachment.size !== undefined) { + console.info('mutableStr size width ' + attachment.size.width + ' height ' + attachment.size.height); + } + console.info('mutableStr vertical ' + attachment.verticalAlign); + console.info('mutableStr fit ' + attachment.objectFit); + console.info('mutableStr colorFilter ' + attachment.colorFilter); + this.colorfit=attachment.colorFilter + if (attachment.layoutStyle !== undefined) { + let radius = attachment.layoutStyle.borderRadius as BorderRadiuses; + console.info('mutableStr radius ' + JSON.stringify(radius)); + } + } + } + }) + .id('UiComponentImageAttachmentColorFilter08_02') + Text('colorFilter='+this.colorfit) + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Red) + .fontSize(5) + Button('Image之Insert 前') + .onClick(() => { + this.mutableStr.insertString(0, '123'); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter08_03') + Button('Image之Insert 后') + .onClick(() => { + this.mutableStr.insertString(1, '123'); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter08_04') + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter09.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter09.ets new file mode 100644 index 00000000..65f628b4 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter09.ets @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter09{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + @State colorfit : ColorFilterType|undefined = '' + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('Use appendStyledString to insert a new image') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter09_01') + Button('Image之Get') + .onClick(() => { + let imageArray = this.mutableStr.getStyles(1, 1, StyledStringKey.IMAGE); + for (let i = 0; i < imageArray.length; ++i) { + console.info('mutableStr start ' + imageArray[i].start + ' length ' + imageArray[i].length + ' type ' + + imageArray[i].styledKey); + if (imageArray[i].styledKey === 300) { + let attachment = imageArray[i].styledValue as ImageAttachment; + this.imagePixelMap3 = attachment.value; + console.info('mutableStr value ' + JSON.stringify(attachment.value)); + if (attachment.size !== undefined) { + console.info('mutableStr size width ' + attachment.size.width + ' height ' + attachment.size.height); + } + console.info('mutableStr vertical ' + attachment.verticalAlign); + console.info('mutableStr fit ' + attachment.objectFit); + console.info('mutableStr colorFilter ' + attachment.colorFilter); + this.colorfit=attachment.colorFilter + if (attachment.layoutStyle !== undefined) { + let radius = attachment.layoutStyle.borderRadius as BorderRadiuses; + console.info('mutableStr radius ' + JSON.stringify(radius)); + } + } + } + }) + .id('UiComponentImageAttachmentColorFilter09_02') + Text('colorFilter='+this.colorfit) + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Red) + .fontSize(5) + Button('Image之Append') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr2 = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 + ] + })); + } + this.mutableStr.appendStyledString(this.mutableStr2); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter09_03') + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter10.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter10.ets new file mode 100644 index 00000000..3c3ff4c9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter10.ets @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter10{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + @State colorfit : ColorFilterType|undefined = '' + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('Use insertStyledString to insert a new image') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter10_01') + Button('Image之Get') + .onClick(() => { + let imageArray = this.mutableStr.getStyles(1, 1, StyledStringKey.IMAGE); + for (let i = 0; i < imageArray.length; ++i) { + console.info('mutableStr start ' + imageArray[i].start + ' length ' + imageArray[i].length + ' type ' + + imageArray[i].styledKey); + if (imageArray[i].styledKey === 300) { + let attachment = imageArray[i].styledValue as ImageAttachment; + this.imagePixelMap3 = attachment.value; + console.info('mutableStr value ' + JSON.stringify(attachment.value)); + if (attachment.size !== undefined) { + console.info('mutableStr size width ' + attachment.size.width + ' height ' + attachment.size.height); + } + console.info('mutableStr vertical ' + attachment.verticalAlign); + console.info('mutableStr fit ' + attachment.objectFit); + console.info('mutableStr colorFilter ' + attachment.colorFilter); + this.colorfit=attachment.colorFilter + if (attachment.layoutStyle !== undefined) { + let radius = attachment.layoutStyle.borderRadius as BorderRadiuses; + console.info('mutableStr radius ' + JSON.stringify(radius)); + } + } + } + }) + .id('UiComponentImageAttachmentColorFilter10_02') + Text('colorFilter='+this.colorfit) + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Red) + .fontSize(5) + Button('Image之insertStyledString') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr2 = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 + ] + })); + } + this.mutableStr.insertStyledString(1,this.mutableStr2); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter10_03') + } + .width('100%') + } + .height('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter11.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter11.ets new file mode 100644 index 00000000..0a2e397d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentImageAttachmentColorFilter/UiComponentImageAttachmentColorFilter11.ets @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { image } from '@kit.ImageKit'; +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct UiComponentImageAttachmentColorFilter11{ + @State message: string = 'Hello World'; + imagePixelMap: image.PixelMap | undefined = undefined; + @State imagePixelMap3: image.PixelMap | undefined = undefined; + @State colorfit : ColorFilterType|undefined = '' + mutableStr: MutableStyledString = new MutableStyledString('123'); + controller: TextController = new TextController(); + controller2: TextController = new TextController(); + private uiContext: UIContext = this.getUIContext(); + mutableStr2: MutableStyledString = new MutableStyledString('This is set decoration line style to the mutableStr2', [{ + start: 0, + length: 15, + styledKey: StyledStringKey.DECORATION, + styledValue: new DecorationStyle({ + type: TextDecorationType.Overline, + color: Color.Orange, + style: TextDecorationStyle.DOUBLE + }) + }]); + + async aboutToAppear() { + console.info("aboutToAppear initial imagePixelMap"); + this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')); + } + + private async getPixmapFromMedia(resource: Resource) { + let unit8Array = await this.uiContext.getHostContext()?.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() { + Row() { + Column({ space: 5 }) { + Text(undefined, { controller: this.controller }) + .copyOption(CopyOptions.InApp) + .draggable(true) + .fontSize(30) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + Button('Use insertStyledString to insert a new image') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 0.50, 0.09, 0.62, 0.58, 0.39, + 0.31, 0.54, 0.21, 0.22, 0.09, + 0.10, 0.40, 0.90, 0.11, 0.43, + 0.11, 0.05, 0.08, 1.00, 0.12 + ] + })); + this.controller.setStyledString(this.mutableStr); + } + }) + .id('UiComponentImageAttachmentColorFilter11_01') + Button('Image之Get') + .onClick(() => { + let imageArray = this.mutableStr.getStyles(0, 1, StyledStringKey.IMAGE); + for (let i = 0; i < imageArray.length; ++i) { + console.info('mutableStr start ' + imageArray[i].start + ' length ' + imageArray[i].length + ' type ' + + imageArray[i].styledKey); + if (imageArray[i].styledKey === 300) { + let attachment = imageArray[i].styledValue as ImageAttachment; + this.imagePixelMap3 = attachment.value; + console.info('mutableStr value ' + JSON.stringify(attachment.value)); + if (attachment.size !== undefined) { + console.info('mutableStr size width ' + attachment.size.width + ' height ' + attachment.size.height); + } + console.info('mutableStr vertical ' + attachment.verticalAlign); + console.info('mutableStr fit ' + attachment.objectFit); + console.info('mutableStr colorFilter ' + attachment.colorFilter); + this.colorfit=attachment.colorFilter + if (attachment.layoutStyle !== undefined) { + let radius = attachment.layoutStyle.borderRadius as BorderRadiuses; + console.info('mutableStr radius ' + JSON.stringify(radius)); + } + } + } + }) + .id('UiComponentImageAttachmentColorFilter11_02') + Text('colorFilter='+this.colorfit) + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Red) + .fontSize(5) + Button('Image之replaceStyle') + .onClick(() => { + if (this.imagePixelMap !== undefined) { + this.mutableStr2 = new MutableStyledString(new ImageAttachment({ + value: this.imagePixelMap, + size: { width: 50, height: 50 }, + layoutStyle: { borderRadius: LengthMetrics.vp(10) }, + verticalAlign: ImageSpanAlignment.CENTER, + objectFit:ImageFit.Fill, + colorFilter:[ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 + ] + })); + } + this.mutableStr.replaceStyledString(0,1,this.mutableStr2); + this.controller.setStyledString(this.mutableStr); + }) + .id('UiComponentImageAttachmentColorFilter11_03') + } + .width('100%') + } + .height('100%') + } +} -- Gitee From cb043695ffdcecf7ba432a6c17aa2233134d50af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Fri, 18 Jul 2025 15:51:26 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiRichEditorScroll=E7=AD=8928=E6=9D=A1case4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- .../UiRichEditorScroll01.ets | 175 ++++++++++++++++++ .../UiRichEditorScroll02.ets | 168 +++++++++++++++++ .../UiRichEditorScroll03.ets | 168 +++++++++++++++++ .../UiRichEditorScroll04.ets | 169 +++++++++++++++++ .../UiRichEditorScroll05.ets | 162 ++++++++++++++++ .../UiRichEditorScroll06.ets | 171 +++++++++++++++++ .../UiRichEditorScroll07.ets | 174 +++++++++++++++++ .../UiRichEditorScroll08.ets | 175 ++++++++++++++++++ .../UiRichEditorScroll09.ets | 167 +++++++++++++++++ .../UiRichEditorScroll10.ets | 150 +++++++++++++++ 10 files changed, 1679 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll01.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll02.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll03.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll04.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll05.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll06.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll07.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll08.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll09.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll01.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll01.ets new file mode 100644 index 00000000..9dfe8d0f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll01.ets @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll01 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myheight : number =120 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + }.width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("change height") + .onClick(() => { + this.myheight-=50; + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll01') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan("012345", + { + style: + { + fontColor: Color.Orange, + fontSize: 30 + } + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), + { + style: + { + fontSize: 30 + } + }) + this.controller.addTextSpan("56789", + { + style: + { + fontColor: Color.Black, + fontSize: 30 + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .width("100%") + .height(this.myheight) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll02.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll02.ets new file mode 100644 index 00000000..968d8bdc --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll02.ets @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll02 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myheight : number =70 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + }.width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("delete text") + .onClick(() => { + this.controller.deleteSpans({start:0,end:5}) + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll02') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .barState(BarState.On) + .onReady(() => { + this.controller.addTextSpan("11111111111012345", + { + style: + { + fontColor: Color.Orange, + } + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .width("100%") + .height(60) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll03.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll03.ets new file mode 100644 index 00000000..c8efd0d8 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll03.ets @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll03 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State mywidth : number =300 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + }.width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("change width") + .onClick(() => { + this.mywidth-=100; + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll03') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .barState(BarState.On) + .onReady(() => { + this.controller.addTextSpan("112345", + { + style: + { + fontColor: Color.Orange, + } + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .width(this.mywidth) + .height(60) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll04.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll04.ets new file mode 100644 index 00000000..7e783ad5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll04.ets @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll04 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State mypadding : number =10 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + }.width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("set padding") + .onClick(() => { + this.mypadding+=10; + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll04') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .padding(this.mypadding) + .barState(BarState.On) + .onReady(() => { + this.controller.addTextSpan("111111111112345", + { + style: + { + fontColor: Color.Orange, + } + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(60) + .width(170) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll05.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll05.ets new file mode 100644 index 00000000..0b287521 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll05.ets @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll05 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =0 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + }.width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + Text('set clip to true') + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + RichEditor(this.options) + .barState(BarState.On) + .id('UiRichEditorScroll05') + .clip(true) + .onReady(() => { + this.controller.addTextSpan("112111111111111345", + { + style: + { + fontColor: Color.Orange, + }, + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll06.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll06.ets new file mode 100644 index 00000000..6278f5c8 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll06.ets @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll06 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =0 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + } + .width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button('set selection') + .onClick(()=>{ + this.controller.setSelection(-1, -1) + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll06_01') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .barState(BarState.On) + .id('UiRichEditorScroll06_02') + .clip(true) + .onReady(() => { + this.controller.addTextSpan("112111111111111345", + { + style: + { + fontColor: Color.Orange, + }, + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll07.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll07.ets new file mode 100644 index 00000000..132366c3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll07.ets @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll07 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =0 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + } + .width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button('set selection') + .onClick(()=>{ + this.controller.setSelection(-1, -1) + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll07_01') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .copyOptions(CopyOptions.LocalDevice) + .draggable(true) + .barState(BarState.On) + .id('UiRichEditorScroll07_02') + .clip(true) + .onReady(() => { + this.controller.addTextSpan("112112111211121112111211"+ + '112112111211121112111211112112111211121112111211', + { + style: + { + fontColor: Color.Orange, + }, + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll08.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll08.ets new file mode 100644 index 00000000..3ec54dc3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll08.ets @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll08 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =0 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + } + .width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button('set selection') + .onClick(()=>{ + this.controller.setSelection(-1, -1) + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiRichEditorScroll08_01') + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .copyOptions(CopyOptions.LocalDevice) + .draggable(true) + .barState(BarState.On) + .id('UiRichEditorScroll08_02') + .clip(true) + .onReady(() => { + this.controller.addTextSpan("112112111211121112111211"+ + '112112111211121112111211112112111211121112111211', + { + style: + { + fontSize:40, + fontColor: Color.Orange, + }, + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll09.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll09.ets new file mode 100644 index 00000000..9e766b46 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll09.ets @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll09 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =20 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + } + .width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + Text('set leadingMargin') + .fontSize(10) + .fontColor(0xCCCCCC) + .width('90%') + .border({ width: 1 }) + .lineHeight(20) + .margin(30) + .padding(10) + RichEditor(this.options) + .copyOptions(CopyOptions.LocalDevice) + .draggable(true) + .barState(BarState.On) + .clip(true) + .onReady(() => { + this.controller.addTextSpan("111", + { + paragraphStyle: { + leadingMargin: 100 + }, + style: + { + fontColor: Color.Orange, + }, + }) + this.controller.addSymbolSpan($r("sys.symbol.ohos_trash"), {}) + this.controller.addTextSpan("567891", + { + style: + { + fontColor: Color.Black, + } + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets new file mode 100644 index 00000000..7e647269 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UiRichEditorScroll10 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + private start: number = -1; + private end: number = -1; + @State message: string = "[-1, -1]" + @State content: string = "" + @State myleadingMargin : number =20 + + build() { + Column() { + Column() { + Text("selection range:") + .width("100%") + Text() { + Span(this.message) + } + .width("100%") + Text("selection content:") + .width("100%") + Text() { + Span(this.content) + } + .width("100%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("20%") + + Row() { + Button("获取选择内容").onClick(() => { + this.content = ""; + this.controller.getSpans({ + start: this.start, + end: this.end + }).forEach(item => { + if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ + this.content += (item as RichEditorImageSpanResult).valueResourceStr; + this.content += "\n" + } else { + if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { + this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; + this.content += "\n" + }else { + this.content += (item as RichEditorTextSpanResult).value; + this.content += "\n" + } + } + }) + }) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("10%") + + Column() { + RichEditor(this.options) + .id('UiRichEditorScroll10') + .copyOptions(CopyOptions.LocalDevice) + .draggable(true) + .barState(BarState.On) + .clip(true) + .onReady(() => { + this.controller.addTextSpan("111111111111111111111"+ + '111111111111111111111111111111111111111111', + { + style: + { + fontColor: Color.Orange, + }, + }) + }) + .onSelect((value: RichEditorSelection) => { + this.start = value.selection[0]; + this.end = value.selection[1]; + this.message = "[" + this.start + ", " + this.end + "]" + }) + .aboutToIMEInput((value: RichEditorInsertValue) => { + console.log("---------------------- aboutToIMEInput ----------------------") + console.log("insertOffset:" + value.insertOffset) + console.log("insertValue:" + value.insertValue) + return true; + }) + .onIMEInputComplete((value: RichEditorTextSpanResult) => { + console.log("---------------------- onIMEInputComplete ---------------------") + console.log("spanIndex:" + value.spanPosition.spanIndex) + console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") + console.log("value:" + value.value) + }) + .aboutToDelete((value: RichEditorDeleteValue) => { + console.log("---------------------- aboutToDelete --------------------------") + console.log("offset:" + value.offset) + console.log("direction:" + value.direction) + console.log("length:" + value.length) + value.richEditorDeleteSpans.forEach(item => { + console.log("---------------------- item --------------------------") + console.log("spanIndex:" + item.spanPosition.spanIndex) + console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") + console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") + if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { + console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) + } else { + console.log("text:" + (item as RichEditorTextSpanResult).value) + } + }) + return true; + }) + .onDeleteComplete(() => { + console.log("---------------------- onDeleteComplete ------------------------") + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .height(100) + .width(200) + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} -- Gitee From 3fe924f189f5bac62a6d792d3f77083099c4b85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Wed, 6 Aug 2025 15:55:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- .../UiRichEditorScroll10.ets | 150 ------------------ 1 file changed, 150 deletions(-) delete mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets deleted file mode 100644 index 7e647269..00000000 --- a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiRichEditorScroll/UiRichEditorScroll10.ets +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Entry -@Component -struct UiRichEditorScroll10 { - controller: RichEditorController = new RichEditorController(); - options: RichEditorOptions = { controller: this.controller }; - private start: number = -1; - private end: number = -1; - @State message: string = "[-1, -1]" - @State content: string = "" - @State myleadingMargin : number =20 - - build() { - Column() { - Column() { - Text("selection range:") - .width("100%") - Text() { - Span(this.message) - } - .width("100%") - Text("selection content:") - .width("100%") - Text() { - Span(this.content) - } - .width("100%") - } - .borderWidth(1) - .borderColor(Color.Red) - .width("100%") - .height("20%") - - Row() { - Button("获取选择内容").onClick(() => { - this.content = ""; - this.controller.getSpans({ - start: this.start, - end: this.end - }).forEach(item => { - if(typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined'){ - this.content += (item as RichEditorImageSpanResult).valueResourceStr; - this.content += "\n" - } else { - if(typeof(item as RichEditorTextSpanResult)['symbolSpanStyle'] != 'undefined') { - this.content += (item as RichEditorTextSpanResult).symbolSpanStyle?.fontSize; - this.content += "\n" - }else { - this.content += (item as RichEditorTextSpanResult).value; - this.content += "\n" - } - } - }) - }) - } - .borderWidth(1) - .borderColor(Color.Red) - .width("100%") - .height("10%") - - Column() { - RichEditor(this.options) - .id('UiRichEditorScroll10') - .copyOptions(CopyOptions.LocalDevice) - .draggable(true) - .barState(BarState.On) - .clip(true) - .onReady(() => { - this.controller.addTextSpan("111111111111111111111"+ - '111111111111111111111111111111111111111111', - { - style: - { - fontColor: Color.Orange, - }, - }) - }) - .onSelect((value: RichEditorSelection) => { - this.start = value.selection[0]; - this.end = value.selection[1]; - this.message = "[" + this.start + ", " + this.end + "]" - }) - .aboutToIMEInput((value: RichEditorInsertValue) => { - console.log("---------------------- aboutToIMEInput ----------------------") - console.log("insertOffset:" + value.insertOffset) - console.log("insertValue:" + value.insertValue) - return true; - }) - .onIMEInputComplete((value: RichEditorTextSpanResult) => { - console.log("---------------------- onIMEInputComplete ---------------------") - console.log("spanIndex:" + value.spanPosition.spanIndex) - console.log("spanRange:[" + value.spanPosition.spanRange[0] + "," + value.spanPosition.spanRange[1] + "]") - console.log("offsetInSpan:[" + value.offsetInSpan[0] + "," + value.offsetInSpan[1] + "]") - console.log("value:" + value.value) - }) - .aboutToDelete((value: RichEditorDeleteValue) => { - console.log("---------------------- aboutToDelete --------------------------") - console.log("offset:" + value.offset) - console.log("direction:" + value.direction) - console.log("length:" + value.length) - value.richEditorDeleteSpans.forEach(item => { - console.log("---------------------- item --------------------------") - console.log("spanIndex:" + item.spanPosition.spanIndex) - console.log("spanRange:[" + item.spanPosition.spanRange[0] + "," + item.spanPosition.spanRange[1] + "]") - console.log("offsetInSpan:[" + item.offsetInSpan[0] + "," + item.offsetInSpan[1] + "]") - if (typeof(item as RichEditorImageSpanResult)['imageStyle'] != 'undefined') { - console.log("image:" + (item as RichEditorImageSpanResult).valueResourceStr) - } else { - console.log("text:" + (item as RichEditorTextSpanResult).value) - } - }) - return true; - }) - .onDeleteComplete(() => { - console.log("---------------------- onDeleteComplete ------------------------") - }) - .placeholder("input...", { - fontColor: Color.Gray, - font: { - size: 16, - weight: FontWeight.Normal, - style: FontStyle.Normal - } - }) - .borderWidth(1) - .borderColor(Color.Green) - .height(100) - .width(200) - } - .borderWidth(1) - .borderColor(Color.Red) - .width("100%") - .height("70%") - } - } -} -- Gitee