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 0000000000000000000000000000000000000000..70e97b086e29b966a2f83e4e24a2a40d9adecf9f --- /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 0000000000000000000000000000000000000000..a2d0b20cd4e6985b5e80eb97e24393a72828855f --- /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() + }) + + }) +} 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 0000000000000000000000000000000000000000..24bc0c4a4226b856190f212ad91216743299fe47 --- /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 0000000000000000000000000000000000000000..d4c917f8eed758844ac19517b5e52161472c7cfd --- /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 0000000000000000000000000000000000000000..03391b646a104e2b268aa3c40ef6ea0d6fcf0062 --- /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 0000000000000000000000000000000000000000..f656e5e75ffb57376c724076c14a73d9acd75b9b --- /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 0000000000000000000000000000000000000000..1647d8b4361f004b74d97f86902ecce323f4fff6 --- /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 0000000000000000000000000000000000000000..a861dc95c8bd96f31f0fa3677921adf7c044ad3b --- /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 0000000000000000000000000000000000000000..8a6f648b4620d66ba683dc6df5766cd76db89f24 --- /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 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 0000000000000000000000000000000000000000..9dfe8d0fb1eb7f98912dd7c2b077d5f4dcc2bbcb --- /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 0000000000000000000000000000000000000000..968d8bdcd87fa3dd69f2a4a7f1a545533743bfea --- /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 0000000000000000000000000000000000000000..c8efd0d81cbf2a4dcbfddb5a12f0eef53a55056d --- /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 0000000000000000000000000000000000000000..7e783ad54d8613d7ccad797f0fb351b949537e71 --- /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 0000000000000000000000000000000000000000..0b28752163ed168fb9e907d4391463e8b9e23b83 --- /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 0000000000000000000000000000000000000000..6278f5c880bdfcccb904ea4e5a6d0bb9c2afaab6 --- /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 0000000000000000000000000000000000000000..132366c39cfd4b6c0fdf358a625bdbd6eb22ab0c --- /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 0000000000000000000000000000000000000000..3ec54dc39f71cdae9ad89424dad98dfe998457f4 --- /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 0000000000000000000000000000000000000000..9e766b46649abd7020517dfdace364d201e465e0 --- /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%") + } + } +}