diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusRichEditorTest.test.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusRichEditorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c53f417834cfd88acb35b2fcb53df76c47ccc9a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusRichEditorTest.test.ets @@ -0,0 +1,498 @@ +/** + * 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 { 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 } from '@kit.TestKit'; + + +export default function FocusRichEditor() { + + describe('FocusRichEditor', () => { + 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_TEXT_RICHEDITOR_textBackgroundStyle_001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : If the enableKeyboardOnFocus attribute is not set or is set to true, call the requestFocus method to make the rich text component gain focus and bind the input method. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/REtextBackgroundStyle001") + let driver:Driver = Driver.create(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_001 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_004 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_004 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : If the enableKeyboardOnFocus attribute is not set or is set to true, call the requestFocus method to make the rich text component gain focus and bind the input method. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_004', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_004 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/REtextBackgroundStyle004") + let driver:Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('在此输入文本观察效果'), 1000); + await button.inputText('随机输入一段文字'); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_textBackgroundStyle_004 finish.`); + done() + }) + + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WordBreak_HYPHENATION_00001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WordBreak_HYPHENATION_00001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : If the enableKeyboardOnFocus attribute is not set or is set to true, call the requestFocus method to make the rich text component gain focus and bind the input method. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WordBreak_HYPHENATION_00001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WordBreak_HYPHENATION_00001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/REHyphenation00001") + let driver:Driver = Driver.create(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_WordBreak_HYPHENATION_00001 finish.`); + done() + }) + + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : If the enableKeyboardOnFocus attribute is not set or is set to true, call the requestFocus method to make the rich text component gain focus and bind the input method. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorEnableKeyboard0001") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let button: Component = await driver.waitForComponent(ON.id('ReKb0001'), 1000); + await button.click(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0001 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0005 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0005 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : If the enableKeyboardOnFocus attribute is set to false, call the requestFocus method to make the rich text component gain focus and not bind the input method. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0005', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0005 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorEnableKeyboard0005") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let button: Component = await driver.waitForComponent(ON.id('ReKb0005'), 1000); + await button.click(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_ENABLEKEYBOARDFOCUS_0005 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEMETRICS_0003 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEMETRICS_0003 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : When passing parameter 1 to getLineMetrics. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEMETRICS_0003', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEMETRICS_0003 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorLineMetrics0003") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let button: Component = await driver.waitForComponent(ON.id('RElineMetrics0003'), 1000); + await button.click(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_LINEMETRICS_0003 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PREVENTDEFAULT_0001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PREVENTDEFAULT_0001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Set an onClick event for images or text, call preventDefault, and click on the images or text. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PREVENTDEFAULT_0001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PREVENTDEFAULT_0001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorPreventDefault0001") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.text('这是一段图文混合内容,后面是一张资源引用类型的图片输入。'),500); + await button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_PREVENTDEFAULT_0001 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_floatoff_0005 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_floatoff_0005 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Release after long-pressing to cancel. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_floatoff_0005', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_floatoff_0005 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorFloatOff0005") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.text('这是一段测试文本,长按后查看效果'),500); + await button.longClick(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_floatoff_0005 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0059 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0059 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : getSpans retrieves span information, where the range boundaries fall in the middle of elements with a length greater than 1. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0059', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0059 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0059") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('InterFace0059'), 1000); + await button.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0059 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0019 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0019 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : getSelection can obtain text content. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0019', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0019 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0019") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('InterFace0019'), 1000); + await button.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0019 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0014 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0014 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : updateSpanStyle can correctly update the style of text, images, or SymbolSpan. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0014', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0014 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0014") + let driver:Driver = Driver.create(); + let button1: Component = await driver.waitForComponent(ON.id('111'), 1000); + await button1.click(); + await driver.waitForIdle(1000,2000); + let button2: Component = await driver.waitForComponent(ON.id('222'), 1000); + await button2.click(); + await driver.waitForIdle(1000,2000); + let button3: Component = await driver.waitForComponent(ON.id('333'), 1000); + await button3.click(); + await driver.waitForIdle(1000,2000); + let button4: Component = await driver.waitForComponent(ON.id('444'), 1000); + await button4.click(); + await driver.waitForIdle(1000,2000); + let button5: Component = await driver.waitForComponent(ON.id('555'), 1000); + await button5.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0014 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0015 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0015 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : updateParagraphStyle can correctly update the style of the paragraph. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0015', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0015 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0015") + let driver:Driver = Driver.create(); + let button1: Component = await driver.waitForComponent(ON.id('Paragraph111'), 1000); + await button1.click(); + await driver.waitForIdle(1000,2000); + let button2: Component = await driver.waitForComponent(ON.id('Paragraph222'), 1000); + await button2.click(); + await driver.waitForIdle(1000,2000); + let button3: Component = await driver.waitForComponent(ON.id('Paragraph333'), 1000); + await button3.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0015 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_9999 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_9999 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : The RichEditor component supports an onReady callback. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_9999', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_9999 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace9999") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('InterFace9999'), 1000); + await button.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_9999 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : The RichEditor component supports an onReady callback. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0001") + let driver: Driver = Driver.create(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0001 finish.`); + done() + }) + + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0017 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0017 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : getSpans can correctly obtain the span information within the component. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0017', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0017 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorInterFace0017") + let driver: Driver = Driver.create(); + let button1: Component = await driver.waitForComponent(ON.id('001701'), 1000); + await button1.click(); + await driver.waitForIdle(1000,2000); + let button2: Component = await driver.waitForComponent(ON.id('001702'), 1000); + await button2.click(); + await driver.waitForIdle(1000,2000); + let button3: Component = await driver.waitForComponent(ON.id('001703'), 1000); + await button3.click(); + await driver.waitForIdle(1000,2000); + let button4: Component = await driver.waitForComponent(ON.id('001704'), 1000); + await button4.click(); + await driver.waitForIdle(1000,2000); + let button5: Component = await driver.waitForComponent(ON.id('001705'), 1000); + await button5.click(); + await driver.waitForIdle(1000,2000); + let button6: Component = await driver.waitForComponent(ON.id('001706'), 1000); + await button6.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_INTERFACE_0017 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0001 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0001 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Through getStyles, the extended span information stored in the attribute string of text/images can be obtained. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0001', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0001 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorStringSpan0001") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('ReSs0001'), 1000); + await button.click(); + await driver.waitForIdle(2000,3000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0001 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0004 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0004 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Specify new extended span content via setStyle. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0004', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0004 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorStringSpan0004") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('ReSets0004'), 1000); + await button.click(); + await driver.waitForIdle(500,2000); + let button2: Component = await driver.waitForComponent(ON.id('ReSs0004'), 1000); + await button2.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0004 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0016 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0016 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Insert an image attribute string at the specified position via insertString. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0016', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0016 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorStringSpan0016") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('ReSets0016'), 1000); + await button.click(); + await driver.waitForIdle(1000,2000); + let button2: Component = await driver.waitForComponent(ON.id('ReSs0016'), 1000); + await button2.click(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0016 finish.`); + done() + }) + + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0017 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0017 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + * @tc.desc : Insert an image attribute string at the specified position via insertStyledString. + */ + it('SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0017', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0017 start.`); + Settings.createWindow("testability/pages/focus_RichEditor/RichEditorStringSpan0017") + let driver: Driver = Driver.create(); + let button: Component = await driver.waitForComponent(ON.id('ReSets0017'), 1000); + await button.click(); + await driver.waitForIdle(2000,2000); + let button2: Component = await driver.waitForComponent(ON.id('ReSs0017'), 1000); + await button2.click(); + await driver.waitForIdle(2000,2000); + windowSnap.snapShot(); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_RICHEDITOR_stringspan_0017 finish.`); + done() + }) + }) +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextTimerTest.test.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextTimerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..197e470b8331f29893ed194f8143c99f3f373c20 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextTimerTest.test.ets @@ -0,0 +1,523 @@ +/** + * 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 { 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 } from '@kit.TestKit'; + +export default function FocusTextTimerTest() { + + describe('FocusTextTimerTest', () => { + 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_TEXT_TIMER_FONT_COLOR_0002 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0002 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text color 2. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0002', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0002 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontColor0002") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0002 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0003 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0003 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text color 3. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0003', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0003 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontColor0003") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0003 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0004 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0004 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text color 4. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0004', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0004 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontColor0004") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_COLOR_0004 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0002 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0002 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text size 2. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0002', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0002 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontSize0002") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0002 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0003 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0003 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text size 3. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0003', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0003 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontSize0003") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0003 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0004 + * @tc.name : SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0004 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer text size 4. + */ + it('SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0004', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0004 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtFontSize0004") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXT_TIMER_FONT_SIZE_0004 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0010 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0010 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : No Set the fontWeight values for the TextTimer component. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0010', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0010 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0010") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0010 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0012 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0012 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : No Set the fontWeight values for the TextTimer component. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0012', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0012 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0012") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0012 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0014 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0014 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : No Set the fontWeight values for the TextTimer component. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0014', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0014 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0014") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0014 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0015 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0015 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : No Set the fontWeight values for the TextTimer component. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0015', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0015 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0015") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0015 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0016 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0016 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set the fontWeight illegal values "-1", "0", "1", "450", "1000" for the TextTimer component. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0016', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0016 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0016") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0016 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0023 + * @tc.name : SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0023 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set the textShadow for the TextTimer component and set the fontWeight to FontWeight.Bolder. + */ + it('SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0023', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0023 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/CommonFontWeight0023") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_TEXTTIMER_COMMON_FONTWEIGHT_0023 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0040 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0040 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set isCountDown to false and count to 86400000 for TextTimer. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0040', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0040 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0040") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0040s'), 500); + await buttons.click(); + await driver.waitForIdle(5000,10000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0040p'), 1000); + await buttonp.click(); + await driver.waitForIdle(1500,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0040r'), 500); + await buttonr.click(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0040 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0050 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0050 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set isCountDown to false and count to 0 for TextTimer. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0050', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0050 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0050") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0050s'), 500); + await buttons.click(); + await driver.waitForIdle(1000,2000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0050p'), 1000); + await buttonp.click(); + await driver.waitForIdle(1000,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0050r'), 500); + await buttonr.click(); + await driver.waitForIdle(3000,4000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0050 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0060 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0060 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set isCountDown to false and count to -10000 for TextTimer. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0060', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0060 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0060") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0060s'), 500); + await buttons.click(); + await driver.waitForIdle(1500,2000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0060p'), 1000); + await buttonp.click(); + await driver.waitForIdle(1500,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0060r'), 500); + await buttonr.click(); + await driver.waitForIdle(3000,4000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0060 finish.`); + done() + }) + + + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0070 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0070 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set isCountDown to undefined and count to 1 for TextTimer. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0070', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0070 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0070") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0070s'), 500); + await buttons.click(); + await driver.waitForIdle(5000,10000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0070p'), 1000); + await buttonp.click(); + await driver.waitForIdle(1500,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0070r'), 500); + await buttonr.click(); + await driver.waitForIdle(1500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0070 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0080 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0080 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set isCountDown to null and count to -10000 for TextTimer. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0080', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0080 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0080") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0080s'), 500); + await buttons.click(); + await driver.waitForIdle(1500,10000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0080p'), 1000); + await buttonp.click(); + await driver.waitForIdle(1500,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0080r'), 500); + await buttonr.click(); + await driver.waitForIdle(2000,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0080 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0090 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0090 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Query the started state in the custom contentModifier. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0090', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0090 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0090") + let driver:Driver = Driver.create(); + let buttons: Component = await driver.waitForComponent(ON.id('textTimer0090s'), 500); + await buttons.click(); + await driver.waitForIdle(5000,7000); + let buttonp: Component = await driver.waitForComponent(ON.id('textTimer0090p'), 1000); + await buttonp.click(); + await driver.waitForIdle(500,2000); + let buttonr: Component = await driver.waitForComponent(ON.id('textTimer0090r'), 500); + await buttonr.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0090 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_ARKUI_TEXTTIMER_0100 + * @tc.name : SUB_ACE_UI_ARKUI_TEXTTIMER_0100 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : Set the textShadow for the TextTimer component and set the fontWeight to FontWeight.Bolder. + */ + it('SUB_ACE_UI_ARKUI_TEXTTIMER_0100', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0100 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TextTimer0100") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_TEXTTIMER_0100 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0250 + * @tc.name : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0250 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer interface: TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController }). Test for required parameters, with only one parameter: controller. + */ + it('SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0250', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0250 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtInterface0250") + let driver:Driver = Driver.create(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0250 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0280 + * @tc.name : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0280 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer interface: TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController }). Test for required parameters, with only one parameter: controller. + */ + it('SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0280', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0280 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtInterface0280") + let driver:Driver = Driver.create(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0280 finish.`); + done() + }) + + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0290 + * @tc.name : SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0290 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 2 + * @tc.desc : TextTimer interface: TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController }). Test for required parameters, with only one parameter: controller. + */ + it('SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0290', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0290 start.`); + Settings.createWindow("testability/pages/focus_TextTimer/TtInterface0290") + let driver:Driver = Driver.create(); + await driver.waitForIdle(1000,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_INFOMATION_TEXTTIMER_INTERFACE_0290 finish.`); + done() + }) + }) +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextUIall.test.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextUIall.test.ets index acde0dce8f76ff0f1ec211fd0468d52dc1b67918..04db3972bc7690b98612773da035ab38fc84bab7 100644 --- a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextUIall.test.ets +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/test/focus_TextUI/FocusTextUIall.test.ets @@ -57,6 +57,100 @@ export default function FocusTextUITest() { done() }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400 + * @tc.name : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400 start.`); + Settings.createWindow("testability/pages/focus_TextUI/FocusTextUI0400") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let buttonA: Component = await driver.waitForComponent(ON.id('changeResBtn0400'), 1000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400'); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0400 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1220 + * @tc.name : Text#TextTest#TextTest_122 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1220', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1220 start.`); + Settings.createWindow("testability/pages/focus_TextUI/FocusTextUI1220") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let buttonA: Component = await driver.waitForComponent(ON.id('paramBtn1220'), 1000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1220'); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1220 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1310 + * @tc.name : Text#TextTest#TextTest_131 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1310', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1310 start.`); + Settings.createWindow("testability/pages/focus_TextUI/FocusTextUI1310") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let buttonA: Component = await driver.waitForComponent(ON.id('testBtn1310'), 1000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1310mid') + await Utils.sleep(1000) + await buttonA.click(); + await driver.waitForIdle(500,2000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1310 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1440 + * @tc.name : Text#TextTest#TextTest_144 + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 1 + */ + it('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1440 ', Level.LEVEL1, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1440 start.`); + Settings.createWindow("testability/pages/focus_TextUI/FocusTextUI1440") + let driver:Driver = Driver.create(); + await driver.waitForIdle(500,2000); + let buttonA: Component = await driver.waitForComponent(ON.id('testBtn1440'), 1000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + await buttonA.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1440mid') + await Utils.sleep(1000) + await buttonA.click(); + await driver.waitForIdle(500,2000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_1440 finish.`); + done() + }) + + /* * @tc.number : SUB_ACE_UI_COMPONENT_TEXT_TEXT_UI_0160 * @tc.name : Text#TextTest#TextTest_016 diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REHyphenation00001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REHyphenation00001.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9d212f5a84a41a04d6f9b60e58565bd4d4192c8 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REHyphenation00001.ets @@ -0,0 +1,42 @@ +/** + * 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 Hyphenation00001 { + controller: RichEditorController = new RichEditorController() + build() { + Column() { + RichEditor({ controller: this.controller }) + .key('ParagraphSet') + .placeholder('Input words here') + .onReady(() => { + this.controller.addTextSpan("This is a long paragraph of english words to test the congratulation of the paragraphStyle, see if the paragraph breaks as set.", { + style: { + fontColor: Color.Pink + }, + paragraphStyle: { + wordBreak:WordBreak.HYPHENATION + } + }) + }) + .align(Alignment.TopStart) + .height(100) + .borderWidth(1) + .width("100%") + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle001.ets new file mode 100644 index 0000000000000000000000000000000000000000..6aa4032d0f3f06b820f67cb6912d488edb4c85e8 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle001.ets @@ -0,0 +1,40 @@ +/** + * 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 textBackgroundStyle001 { + controller: RichEditorController = new RichEditorController() + build() { + Column() { + RichEditor({ controller: this.controller }) + .onReady(()=>{ + this.controller.addTextSpan('组件文本观测',{ + style:{ + textBackgroundStyle:{ + color: Color.Red, + radius:'5vp' + } + } + }) + }) + .align(Alignment.TopStart) + .height(100) + .borderWidth(1) + .width("100%") + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle004.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle004.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1bbdec8b899cc4cb4a6eb83913b984d877df993 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/REtextBackgroundStyle004.ets @@ -0,0 +1,42 @@ +/** + * 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 textBackgroundStyle004 { + controller: RichEditorController = new RichEditorController() + build() { + Column() { + RichEditor({ controller: this.controller }) + .key('在此输入文本观察效果') + .placeholder('在此输入文本观察效果') + .onReady(()=>{ + this.controller.setTypingStyle( + { + fontWeight: 'medium', + fontColor: Color.Blue, + fontSize: 50, + fontStyle: FontStyle.Italic, + decoration: { type: TextDecorationType.Underline, color: Color.Green } + }) + }) + .align(Alignment.TopStart) + .height(100) + .borderWidth(1) + .width("100%") + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0001.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fbaf985f5bfa58c8d294d572c7b0afd21aee890 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0001.ets @@ -0,0 +1,46 @@ +/** + * 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 KeyBoard0001 { + controller: RichEditorController = new RichEditorController() + controller1: TextInputController = new TextInputController() + needFocusKey: string = 'RichEditorKeyboardTest' + @State textFlag: string = "TextFlag"; + + build() { + Column() { + RichEditor({ controller: this.controller }) + .key(this.needFocusKey) + .align(Alignment.TopStart) + .height(100) + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .onPaste((event?: PasteEvent) => { + }) + Button('点我获取焦点') + .id('ReKb0001') + .onClick((event: ClickEvent) => { + focusControl.requestFocus(this.needFocusKey) + }) + .width('100%') + .height('100%') + .padding(15) + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0005.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0005.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e8b856cd52008333f4778c3ec6d25aca5e640c7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorEnableKeyboard0005.ets @@ -0,0 +1,48 @@ +/** + * 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 { FocusController } from '@ohos.arkui.UIContext'; +import common from '@ohos.app.ability.common'; + +@Entry +@Component +struct KeyBoard0005 { + controller: RichEditorController = new RichEditorController() + controller1: TextInputController = new TextInputController() + needFocusKey: string = 'RichEditorKeyboardTest' + @State textFlag: string = "TextFlag"; + + build() { + Column() { + RichEditor({ controller: this.controller }) + .key(this.needFocusKey) + .align(Alignment.TopStart) + .height(100) + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .enableKeyboardOnFocus(false) + .onPaste((event?: PasteEvent) => { + }) + Button('点我获取焦点') + .id('ReKb0005') + .onClick((event: ClickEvent) => { + focusControl.requestFocus(this.needFocusKey) + }) + .width('100%') + .height('100%') + .padding(15) + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorFloatOff0005.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorFloatOff0005.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2572dc9a7204cbae7730ecb41d6318c0a22858d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorFloatOff0005.ets @@ -0,0 +1,51 @@ +/** + * 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 FloatOff0005 { + controller: RichEditorController = new RichEditorController() + controller1: TextInputController = new TextInputController() + options: RichEditorOptions = { controller: this.controller } + needFocusKey: string = 'RichEditorKeyboardTest' + @State lineMetrics: string = ""; // 定义lineMetrics状态变量 + + + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('这是一段测试文本,长按后查看效果', { + style: { + fontColor: Color.Black, + fontSize: 15 + }, + gesture: + { + onLongPress: (() => { + console.info('文本长按事件触发'); + }) + } + }) + }) + .width(300) + .height(100) + } + .width('100%') + .height('100%') + .padding(20) + } +} + diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0001.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a986df3f494eac342dc7389610d11a6f3194aa2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0001.ets @@ -0,0 +1,57 @@ +/** + * 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 ReIFOr0001 { + private controller: RichEditorController = new RichEditorController(); + + build() { + Column() { + // 富文本编辑器组件 + RichEditor({ controller: this.controller }) + .width('90%') + .height(200) + .backgroundColor('#F8F8F8') + .onReady(() => this.onEditorReady()) // 添加onReady回调 + .margin({ bottom: 20 }) + } + .width('100%') + .height('100%') + .padding(20) + } + + // 编辑器初始化完成回调 + private onEditorReady() { + console.log('RichEditor 初始化完成'); + + // 在回调中添加初始化文字 + this.controller.addTextSpan('这是初始化显示的文字内容,', { + style: { + fontColor: Color.Black, + fontSize: 16 + } + }); + + this.controller.addTextSpan('会在组件初始化后自动显示。', { + style: { + fontColor: Color.Blue, + fontSize: 16, + fontWeight: FontWeight.Bold + } + }); + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0014.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0014.ets new file mode 100644 index 0000000000000000000000000000000000000000..85f8e9de4ad516ba7e620fa3789db678bd921000 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0014.ets @@ -0,0 +1,165 @@ +/** + * 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 RichEditorSpan0014 { + 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 = ""; + + 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%") + + Column(){ + Row(){ + Button("0-1更新样式:加粗").id('111').onClick(() => { + this.controller.updateSpanStyle({ + start: 0, + end: 1, + textStyle: + { + fontWeight: FontWeight.Bolder + } + }) + }) + + Button("1-2更新样式:加粗").id('222').onClick(() => { + this.controller.updateSpanStyle({ + start: 1, + end: 2, + textStyle: + { + fontWeight: FontWeight.Bolder + } + }) + }) + + Button("100-101更新样式:加粗").id('333').onClick(() => { + this.controller.updateSpanStyle({ + start: 100, + end: 101, + textStyle: + { + fontWeight: FontWeight.Bolder + } + }) + }) + } + + Row(){ + Button("2-1更新样式:加粗").id('444').onClick(() => { + this.controller.updateSpanStyle({ + start: 2, + end: 1, + textStyle: + { + fontWeight: FontWeight.Bolder + } + }) + }) + + Button("-1--1更新样式:加粗").id('555').onClick(() => { + this.controller.updateSpanStyle({ + start: -1, + end: -1, + textStyle: + { + fontWeight: FontWeight.Bolder + } + }) + }) + } + } + .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("app.media.Symbolspan001"), + { + style: + { + fontSize: 30 + } + }) + this.controller.addImageSpan($r("app.media.icon"), + { + imageStyle: + { + size: ["57px", "57px"] + } + }) + 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 + "]"; + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + family: "sans-serif", + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .width("100%") + .height("30%") + } + .borderWidth(1) + .borderColor(Color.Red) + .width("100%") + .height("70%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0015.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0015.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1f2c9a4a2d6714b3b0a975496cd20cdc9d1b289 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0015.ets @@ -0,0 +1,118 @@ +/** + * 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 RichEditorSpan0015 { + 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 = ""; + + build() { + Column() { + Column(){ + Row(){ + Button("0-1段落更新样式").id('Paragraph111').onClick(() => { + this.controller.updateParagraphStyle({ + start: 0, + end: 1, + style:{ + textAlign:TextAlign.Center, + leadingMargin:10, + wordBreak:WordBreak.NORMAL, + lineBreakStrategy:LineBreakStrategy.BALANCED + } + }) + }) + + Button("1-2段落更新样式").id('Paragraph222').onClick(() => { + this.controller.updateParagraphStyle({ + start: 1, + end: 2, + style: + { + textAlign:TextAlign.Center, + leadingMargin:10, + wordBreak:WordBreak.NORMAL, + lineBreakStrategy:LineBreakStrategy.BALANCED + } + }) + }) + + Button("50-51更新样式").id('Paragraph333').onClick(() => { + this.controller.updateParagraphStyle({ + start: 50, + end: 51, + style: + { + textAlign:TextAlign.Center, + leadingMargin:10, + wordBreak:WordBreak.NORMAL, + lineBreakStrategy:LineBreakStrategy.BALANCED + } + }) + }) + } + } + .borderColor(Color.Red) + .width("100%") + + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan("01234567890这将是一段长文本显示,为了测试段落样式修改", + { + style: + { + fontColor: Color.Orange, + fontSize: 30 + } + }) + this.controller.addTextSpan("这将是一段长文本显示,为了测试段落样式修改01234567890", + { + 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 + "]"; + }) + .placeholder("input...", { + fontColor: Color.Gray, + font: { + size: 16, + weight: FontWeight.Normal, + family: "sans-serif", + style: FontStyle.Normal + } + }) + .borderWidth(1) + .borderColor(Color.Green) + .width("100%") + .height("30%") + } + .borderColor(Color.Red) + .width("100%") + .height("100%") + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0017.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0017.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4032fdb08c5d2b432e890a9dfff699a3e0b6e06 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0017.ets @@ -0,0 +1,91 @@ +/** + * 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 RichEditorSpan0017 { + private controller: RichEditorController = new RichEditorController(); + build() { + Column() { + // 预填充内容的富文本编辑器 + RichEditor({ controller: this.controller }) + .onReady(()=>{ + this.controller.addTextSpan('测试内容:文本😊符号✅,'); + this.controller.addTextSpan('简单图文混排示例'); + }) + .width('100%') + .height(200) + .backgroundColor('#F9F9F9') + .border({ width: 1, color: '#DDD' }) + .margin({ bottom: 20 }) + + // 按钮组 1 + Row() { + Button('Button1: getSpans()') + .id('001701') + .onClick(() => { + console.log('Button1 点击:', JSON.stringify(this.controller.getSpans())); + }) + Button('Button2: getSpans(0,1)') + .id('001702') + .onClick(() => { + console.log('Button2 点击:', JSON.stringify(this.controller.getSpans({start:0, end:1}))); + }) + + Text(JSON.stringify(this.controller.getSpans())) + .margin({ bottom: 20 }) + } + .width('100%') + .margin({ bottom: 10 }) + + // 按钮组 2 + Row() { + Button('Button3: getSpans(1,2)') + .id('001703') + .onClick(() => { + console.log('Button3 点击:', JSON.stringify(this.controller.getSpans({start:1, end:2}))); + }) + + Button('Button4: getSpans(100,101)') + .id('001704') + .onClick(() => { + console.log('Button4 点击:', JSON.stringify(this.controller.getSpans({start:100, end:101}))); + }) + } + .width('100%') + .margin({ bottom: 10 }) + + // 按钮组 3 + Row() { + Button('Button5: getSpans(2,1)') + .id('001705') + .onClick(() => { + console.log('Button5 点击:', JSON.stringify(this.controller.getSpans({start:2, end:1}))); + }) + + Button('Button6: getSpans(-1,-1)') + .id('001706') + .onClick(() => { + console.log('Button6 点击:', JSON.stringify(this.controller.getSpans({start:-1, end:-1}))); + }) + } + + .width('100%') + } + .width('100%') + .height('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0019.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0019.ets new file mode 100644 index 0000000000000000000000000000000000000000..a94268359bab937dd99df76f63fe1f678514fe70 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0019.ets @@ -0,0 +1,90 @@ +/** + * 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 ReIF0019 { + private controller: RichEditorController = new RichEditorController(); + @State selectionInfo: string = '未选择内容'; + + build() { + Column() { + // 富文本编辑器 + RichEditor({ controller: this.controller }) + .width('90%') + .height(200) + .backgroundColor('#F5F5F5') + .onReady(() => { + this.controller.addTextSpan('这是一段测试文本。', { + style: { + fontColor: Color.Black, + fontSize: 15 + } + }) + }) + .margin({ bottom: 20 }) + + // 获取选区按钮 + Button('获取选区信息') + .id('InterFace0019') + .onClick(() => this.handleGetSelection()) + .width('50%') + .margin({ bottom: 20 }) + + // 显示选区信息 + Text(this.selectionInfo) + .width('90%') + .backgroundColor('#F0F0F0') + .padding(10) + .textAlign(TextAlign.Start) + } + .width('100%') + .height('100%') + .padding(20) + } + + // 处理获取选区信息 + private handleGetSelection() { + try { + // 获取选区信息 + const selection = this.controller.getSelection(); + + // 打印完整的选区信息到控制台 + console.log(JSON.stringify(selection)); + + // 根据实际返回结构解析选区信息 + if (selection && Array.isArray(selection.selection) && selection.selection.length === 2) { + let start = 0; + let end = 0; + if (selection && Array.isArray(selection.selection) && selection.selection.length === 2) { + start = selection.selection[0]; + end = selection.selection[1]; + } + + if (start === end) { + this.selectionInfo = `光标位置: ${start}`; + } else { + this.selectionInfo = `选区范围: ${start} - ${end}`; + } + } else { + this.selectionInfo = '无法解析选区信息'; + console.warn('getSelection() 返回格式不符合预期:', selection); + } + } catch (error) { + this.selectionInfo = `获取选区失败: ${error.message}`; + console.error('获取选区信息失败:', error); + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0059.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0059.ets new file mode 100644 index 0000000000000000000000000000000000000000..2406e4774bf6adeebed21280f5c87784d8d0a9bb --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace0059.ets @@ -0,0 +1,90 @@ +/** + * 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 REInterFace0059 { + controller: RichEditorController = new RichEditorController(); + options: RichEditorOptions = { controller: this.controller }; + @State content: string = ""; + + build() { + Column() { + // 内容显示区域 + Column() { + Text("编辑器内容:").width("100%") + Text() { + Span(this.content) + }.width("100%") + } + .border({ width: 1, color: Color.Red }) + .width("100%") + .padding(10) + + // 操作按钮 + Button("获取全部内容") + .id('InterFace0059') + .onClick(() => this.getAllContent()) + .margin({ top: 20 }) + + // 富文本编辑器 + RichEditor(this.options) + .onReady(() => this.initContent()) + .placeholder("输入内容...") + .border({ width: 1, color: Color.Green }) + .width("100%") + .height(200) + .margin({ top: 20 }) + } + .width("100%") + .height("100%") + .padding(20) + } + + // 初始化编辑内容 + private initContent() { + this.controller.addTextSpan('测试文本 '); + this.controller.addTextSpan('😄', { style: { fontSize: 24 } }); // Emoji + this.controller.addSymbolSpan($r("app.media.Symbolspan001")); // 符号 + this.controller.addTextSpan(' 更多文本 '); + this.controller.addTextSpan('🎉', { style: { fontSize: 24 } }); // Emoji + } + + // 获取全部内容(从开始到结尾) + private getAllContent() { + this.content = ""; + + try { + // 获取整个编辑器的Span信息(使用足够大的end值) + const spans = this.controller.getSpans({ + start: 0, + end: 9999 // 使用一个足够大的值代替getTotalLength + }); + + spans.forEach(item => { + // 直接通过属性判断类型 + if (item['imageStyle']) { + this.content += `[图片: ${item['valueResourceStr']}]\n`; + } else if (item['symbolType']) { + this.content += `[符号: ${item['symbolType']}]\n`; + } else { + this.content += `${item['value'] || '未知内容'}\n`; + } + }); + } catch (error) { + this.content = `获取内容失败: ${error.message}`; + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace9999.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace9999.ets new file mode 100644 index 0000000000000000000000000000000000000000..26756cdc3bc40b7954f04b02babd0477fc7d7490 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorInterFace9999.ets @@ -0,0 +1,95 @@ +/** + * 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 BuilderObject { + content: string; + imageUri?: string; + type: string; + id?: string; + + constructor(content: string, type: string, imageUri?: string, id?: string) { + this.content = content; + this.imageUri = imageUri; + this.type = type; + this.id = id || `builder_${Date.now()}`; + } +} + +@Entry +@Component +struct Index { + controller: RichEditorController = new RichEditorController(); + option: RichEditorOptions = { controller: this.controller }; + @State builderId: number = 0; + + // 保留核心Builder定义 + @Builder + chipBuilder(builder: BuilderObject) { + Row() { + Text(builder.content) + .fontSize(14) + .fontWeight(FontWeight.Medium) + + SymbolGlyph($r('app.media.Symbolspan001')) + .width(16) + .height(16) + } + .height(28) + .backgroundColor('#E0E0E0') + .borderRadius(14) + .padding(8) + } + + build() { + Column() { + // 简化UI布局 + RichEditor(this.option) + .width('100%') + .height(180) + .onReady(() => { + this.controller.addTextSpan('点击下方按钮添加BuilderSpan'); + }) + .border({ width: 1, color: '#DDD' }) + + // 仅保留添加BuilderSpan的按钮 + Button('添加ChipBuilder') + .id('InterFace9999') + .onClick(() => this.addBuilderSpan()) + .width('80%') + .margin({ top: 20 }) + } + .width('100%') + .height('100%') + .padding(20) + } + + // 核心添加逻辑 + private addBuilderSpan() { + const builder = new BuilderObject( + '测试BuilderSpan ' + this.builderId, + 'chipBuilder' + ); + + this.controller.addBuilderSpan(() => { + this.chipBuilder(builder); + }, { + offset: this.controller.getCaretOffset() + }); + + this.builderId++; + console.info('BuilderSpan添加成功,ID:', builder.id); + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorLineMetrics0003.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorLineMetrics0003.ets new file mode 100644 index 0000000000000000000000000000000000000000..eda0453b9865db1bb565efc602b8b021c8f63416 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorLineMetrics0003.ets @@ -0,0 +1,68 @@ +/** + * 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 LineMetrics0003 { + controller: RichEditorController = new RichEditorController() + controller1: TextInputController = new TextInputController() + options: RichEditorOptions = { controller: this.controller } + needFocusKey: string = 'RichEditorKeyboardTest' + @State lineMetrics: string = ""; // 定义lineMetrics状态变量 + + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('这是一段图文混合内容,后面是一张资源引用类型的图片输入。\n', { + style: { + fontColor: Color.Black, + fontSize: 15, + } + }) + this.controller.addImageSpan($r("app.media.img2"), { + imageStyle: { + size: ["57px", "57px"] + } + }) + }) + + .width(300) + .height(100) + Text('lineMetrics') + .fontSize(9).fontColor(0xCCCCCC).width('90%').padding(10) + Button('调取行信息') + .id('RElineMetrics0003') + .onClick(() => { + let layoutManager: LayoutManager = this.controller.getLayoutManager() + let lineMetrics: LineMetrics = layoutManager.getLineMetrics(1); + this.lineMetrics = "lineMetrics is" + JSON.stringify(lineMetrics) + '\n\n' + if (lineMetrics.runMetrics) { + lineMetrics.runMetrics.forEach((value, key) => { + this.lineMetrics += "runMetrics key is " + key + " " + JSON.stringify(value) + "\n\n"; + }); + } + }) + .margin({ bottom:20,top :10}) + Text(this.lineMetrics) + .width('90%') + .margin({ left: 10 }) + } + .width('100%') + .height('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorPreventDefault0001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorPreventDefault0001.ets new file mode 100644 index 0000000000000000000000000000000000000000..b271b9d1c8d2632d14033b58aa2773c9316bbacf --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorPreventDefault0001.ets @@ -0,0 +1,65 @@ +/** + * 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 PreventDefault0001 { + controller: RichEditorController = new RichEditorController() + controller1: TextInputController = new TextInputController() + options: RichEditorOptions = { controller: this.controller } + needFocusKey: string = 'RichEditorKeyboardTest' + @State lineMetrics: string = ""; // 定义lineMetrics状态变量 + + + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.addTextSpan('这是一段图文混合内容,后面是一张资源引用类型的图片输入。', { + style: { + fontColor: Color.Black, + fontSize: 15 + }, + gesture: + { + onClick: ((event) => { + event.preventDefault(); // 阻止默认点击行为 + console.info('文本点击事件触发'); + }) + + } + }) + this.controller.addImageSpan($r("app.media.img2"), { + imageStyle: { + size: ["57px", "57px"] + }, + gesture: + { + onClick: ((event) => { + event.preventDefault(); // 阻止默认点击行为 + }) + } + }) + }) + .width(300) + .height(100) + + } + .width('100%') + .height('100%') + .padding(20) + } + } + diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0001.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0001.ets new file mode 100644 index 0000000000000000000000000000000000000000..f65c4cf1227b6574055608a0219f48c36808d3e9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0001.ets @@ -0,0 +1,65 @@ +/** + * 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 MyUserDateSpan0001 extends UserDataSpan { + constructor(name: string, age: number) { + super(); + this.name = name; + this.age = age; + } + + name: string; + age: number; +} + +@Entry +@Component +struct RichESS0001 { + @State fontStyle: FontStyle = FontStyle.Italic; + styleString: MutableStyledString = new MutableStyledString("hello world", [{ + start: 0, + length: 11, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0001("hello", 21) + }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { + controller: this.controller + }; + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.styleString); + }) + .width(300) + .height(100) + .backgroundColor("#F9F9F9") + .border({ width: 1, color: "#DDD" }) + + Row() { + Button("GetStyles调用") + .id('ReSs0001') + .onClick(() => { + console.log('GetStyles调用日志' + JSON.stringify(this.styleString.getStyles(0,this.styleString.length))); + }) + } + .width("100%") + .margin({ bottom: 20 }) + } + .width('100%') + .height('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0004.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0004.ets new file mode 100644 index 0000000000000000000000000000000000000000..37494b5934242228a8f1b4caa9036fc5a2594344 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0004.ets @@ -0,0 +1,78 @@ +/** + * 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 MyUserDateSpan0004 extends UserDataSpan { + constructor(name: string, age: number) { + super(); + this.name = name; + this.age = age; + } + + name: string; + age: number; +} + +@Entry +@Component +struct RichESS0004 { + @State fontStyle: FontStyle = FontStyle.Italic; + styleString: MutableStyledString = new MutableStyledString("hello world", [{ + start: 0, + length: 11, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0004("hello", 21) + }]); + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { + controller: this.controller + }; + mutableStyledString1: MutableStyledString = new MutableStyledString("属性字符串", [{ + start: 0, + length: 6, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0004('Zhang ',23) +}]); + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.styleString); + }) + .width(300) + .height(100) + .backgroundColor("#F9F9F9") + .border({ width: 1, color: "#DDD" }) + + Row() { + Button("SetStyles调用") + .id('ReSets0004') + .onClick(() => { + console.log('GetStyles初始日志' + JSON.stringify(this.styleString.getStyles(0,this.styleString.length))); + this.controller.setStyledString(this.mutableStyledString1); + }) + + Button("GetStyles调用") + .id('ReSs0004') + .onClick(() => { + console.log('SetStyles调用日志' + JSON.stringify(this.mutableStyledString1.getStyles(0,this.mutableStyledString1.length))); + }) + } + .width("100%") + .margin({ bottom: 20 }) + } + .width('100%') + .height('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0016.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0016.ets new file mode 100644 index 0000000000000000000000000000000000000000..97b0a37621ee9d784c71f50c76263c14b6cf6ef3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0016.ets @@ -0,0 +1,74 @@ +/** + * 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 MyUserDateSpan0016 extends UserDataSpan { + constructor(name: string, age: number) { + super(); + this.name = name; + this.age = age; + } + + name: string; + age: number; +} + +@Entry +@Component +struct RichESS0016 { + @State fontStyle: FontStyle = FontStyle.Italic; + + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { + controller: this.controller + }; + mutableStyledString1: MutableStyledString = new MutableStyledString("属性字符串", [{ + start: 0, + length: 6, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0016('Zhang ',23) + }]); + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.mutableStyledString1); + }) + .width(300) + .height(100) + .backgroundColor("#F9F9F9") + .border({ width: 1, color: "#DDD" }) + + Row() { + Button("insertString调用") + .id('ReSets0016') + .onClick(() => { + console.log('GetStyles调用日志' + JSON.stringify(this.mutableStyledString1.getStyles(0,this.mutableStyledString1.length))); + this.mutableStyledString1.insertString(0,"Damon") + this.controller.setStyledString(this.mutableStyledString1); + }) + + Button("GetStyles调用") + .id('ReSs0016') + .onClick(() => { + console.log('insertString调用日志' + JSON.stringify(this.mutableStyledString1.getStyles(0,this.mutableStyledString1.length))); + }) + } + .width("100%") + .margin({ bottom: 20 }) + } + .width('100%') + .height('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0017.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0017.ets new file mode 100644 index 0000000000000000000000000000000000000000..953d0a59846c56c4d39ce65a43771f1597423011 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_RichEditor/RichEditorStringSpan0017.ets @@ -0,0 +1,82 @@ +/** + * 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 MyUserDateSpan0017 extends UserDataSpan { + constructor(name: string, age: number) { + super(); + this.name = name; + this.age = age; + } + name: string; + age: number; +} + +@Entry +@Component +struct RichESS0017 { + @State fontStyle: FontStyle = FontStyle.Italic; + + controller: RichEditorStyledStringController = new RichEditorStyledStringController(); + options: RichEditorStyledStringOptions = { + controller: this.controller + }; + mutableStyledString1: MutableStyledString = new MutableStyledString("属性字符串", [{ + start: 0, + length: 6, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0017('Zhang ',23) + }]); + + mutableStyledString2: MutableStyledString = new MutableStyledString("insertStyledString", [{ + start: 0, + length: 6, + styledKey: StyledStringKey.USER_DATA, + styledValue: new MyUserDateSpan0017('Tian yi ',23) + }]); + build() { + Column() { + RichEditor(this.options) + .onReady(() => { + this.controller.setStyledString(this.mutableStyledString1); + }) + .width(300) + .height(100) + .backgroundColor("#F9F9F9") + .border({ width: 1, color: "#DDD" }) + + Row() { + Button("insertStyledString调用") + .id('ReSets0017') + .onClick(() => { + console.log('GetStyles调用日志' + JSON.stringify(this.mutableStyledString1.getStyles(0,this.mutableStyledString1.length))); + this.mutableStyledString1.insertStyledString(5,this.mutableStyledString2) + this.controller.setStyledString(this.mutableStyledString1); + }) + + Button("GetStyles调用") + .id('ReSs0017') + .onClick(() => { + console.log('insertString调用日志' + JSON.stringify(this.mutableStyledString1.getStyles(0,this.mutableStyledString1.length))); + }) + } + .width("100%") + .margin({ bottom: 20 }) + + } + .width('100%') + .height('100%') + .padding(20) + + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0010.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f3defd7a3f809fe5bbf80f55da8a71f5b5815f2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0010.ets @@ -0,0 +1,30 @@ +/** + * 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 TextTimerExample0010 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0012.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0012.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe9641fbaa252d0ed9e6027c864676fd7f17c8ab --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0012.ets @@ -0,0 +1,31 @@ +/** + * 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 TextTimerExample0012 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(900) + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0014.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0014.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e4f4d483959ddeea169028ae04acb57da78ada4 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0014.ets @@ -0,0 +1,37 @@ +/** + * 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 TextTimerExample0014 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(-1) + .fontSize(50) + + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(1000) + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0015.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0015.ets new file mode 100644 index 0000000000000000000000000000000000000000..9274b4f91d0019980cdaf8cefc1c47cdc4abdb9d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0015.ets @@ -0,0 +1,31 @@ +/** + * 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 TextTimerExample0015 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight("400") + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0016.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0016.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3ac0adc2c94d783b38e861c1c5e4a08c75f0a5f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0016.ets @@ -0,0 +1,37 @@ +/** + * 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 TextTimerExample0016 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight('-1') + .fontSize(50) + + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight('1000') + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0023.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0023.ets new file mode 100644 index 0000000000000000000000000000000000000000..f30dbaeb31fb20c03ee2452e5a12caf157e72329 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/CommonFontWeight0023.ets @@ -0,0 +1,34 @@ +/** + * 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 TextTimerExample0023 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + @State textShadows : ShadowOptions | Array = [{ radius: 10, color: Color.Red, offsetX: 10, offsetY: 0 },{ radius: 10, color: Color.Black, offsetX: 20, offsetY: 0 }, + { radius: 10, color: Color.Brown, offsetX: 30, offsetY: 0 },{ radius: 10, color: Color.Green, offsetX: 40, offsetY: 0 }, + { radius: 10, color: Color.Yellow, offsetX: 100, offsetY: 0 }] + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bolder) + .fontSize(50) + .textShadow(this.textShadows) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0040.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d52ad405ced2f94df526c57dec893317ba1dbf5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0040.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0040 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0040); + } +} +@Builder +function buildTextTimer0040(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0040 { + @State count: number = 86400000; + @State myTimerModifier: MyTextTimerModifier0040 = new MyTextTimerModifier0040(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: false, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0040s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0040p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0040r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0050.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..14a7269466576cfb0694876d623c97e1fc44709b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0050.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0050 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0050); + } +} +@Builder +function buildTextTimer0050(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0050 { + @State count: number = 0; + @State myTimerModifier: MyTextTimerModifier0050 = new MyTextTimerModifier0050(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: false, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0050s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0050p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0050r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0060.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a5331cb9921c078bf7fc44d0e8eeacdb27281f6 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0060.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0060 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0060); + } +} +@Builder +function buildTextTimer0060(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0060 { + @State count: number = -10000; + @State myTimerModifier: MyTextTimerModifier0060 = new MyTextTimerModifier0060(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: false, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0060s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0060p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0060r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0070.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d757939b552ae8c3aee8e50b1a733ba9facf764 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0070.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0070 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0070); + } +} +@Builder +function buildTextTimer0070(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0070 { + @State count: number = 1; + @State myTimerModifier: MyTextTimerModifier0070 = new MyTextTimerModifier0070(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: undefined, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0070s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0070p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0070r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0080.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..7264c3022deadf7aaa174fcdc41a5686c6fffeba --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0080.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0080 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0080); + } +} +@Builder +function buildTextTimer0080(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0080 { + @State count: number = -10000; + @State myTimerModifier: MyTextTimerModifier0080 = new MyTextTimerModifier0080(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: null, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0080s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0080p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0080r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0090.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..44aabd26811cf1fed150e496cd2e3d29441a97b1 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0090.ets @@ -0,0 +1,79 @@ +/** + * 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 MyTextTimerModifier0090 implements ContentModifier { + constructor() { + } + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0090); + } +} + +@Builder +function buildTextTimer0090(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.started ? 'Started:true': 'Started:false').fontColor(Color.White) + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0090 { + @State count: number = 3600; + @State myTimerModifier: MyTextTimerModifier0090 = new MyTextTimerModifier0090(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: null, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").id('textTimer0090s').onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").id('textTimer0090p').onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").id('textTimer0090r').onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0100.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a8d33a250dae27d94faa7abb34c3531cc5158c2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TextTimer0100.ets @@ -0,0 +1,78 @@ +/** + * 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 MyTextTimerModifier0100 implements ContentModifier { + constructor() { + } + + applyContent(): WrappedBuilder<[TextTimerConfiguration]> { + return wrapBuilder(buildTextTimer0100); + } +} +@Builder +function buildTextTimer0100(config: TextTimerConfiguration) { + Column() { + Stack({ alignContent: Alignment.Center }) { + Circle({ width: 150, height: 150 }) + .fill(config.started ? (config.isCountDown ? 0xFF232323 : 0xFF717171) : 0xFF929292) + Column() { + Text(config.isCountDown ? "倒计时" : "正计时").fontColor(Color.White) + Text( + (config.isCountDown ? "剩余" : "已经过去了") + (config.isCountDown ? + (Math.max(config.count / 1000 - config.elapsedTime / 100, 0)).toFixed(1) + "/" + + (config.count / 1000).toFixed(0) + : ((config.elapsedTime / 100).toFixed(0)) + ) + "秒" + ).fontColor(Color.White) + } + } + } +} + +@Entry +@Component +struct TextTimer0100 { + @State count: number = 86400000; + @State myTimerModifier: MyTextTimerModifier0100 = new MyTextTimerModifier0100(); + countDownTextTimerController: TextTimerController = new TextTimerController(); + countUpTextTimerController: TextTimerController = new TextTimerController(); + + + build() { + Row() { + Column() { + TextTimer({ isCountDown: false, controller: this.countUpTextTimerController }) + .contentModifier(this.myTimerModifier) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer onTimer utc is:' + utc + ', elapsedTime: ' + elapsedTime); + }) + Row() { + Button("start").onClick(() => { + this.countDownTextTimerController.start(); + this.countUpTextTimerController.start(); + }).margin(10) + Button("pause").onClick(() => { + this.countDownTextTimerController.pause(); + this.countUpTextTimerController.pause(); + }).margin(10) + Button("reset").onClick(() => { + this.countDownTextTimerController.reset(); + this.countUpTextTimerController.reset(); + }).margin(10) + }.margin(20) + }.width('100%') + }.height('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0002.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0002.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab643d46fe675d0f88c111ff9bfab4f96ae61b9e --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0002.ets @@ -0,0 +1,29 @@ +/** + * 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 TextTimerColor0002 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(0xffff00) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0003.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0003.ets new file mode 100644 index 0000000000000000000000000000000000000000..d952a4ed842e216d30c6c941d6ec0089e878175a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0003.ets @@ -0,0 +1,29 @@ +/** + * 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 TextTimerColor0003 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor('rgb(0,0,255)') + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0004.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0004.ets new file mode 100644 index 0000000000000000000000000000000000000000..891855a86a762be8d1cbf61551ddedcf23757a9a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontColor0004.ets @@ -0,0 +1,28 @@ +/** + * 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 TextTimerColor0004 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0002.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0002.ets new file mode 100644 index 0000000000000000000000000000000000000000..a24e80a14a171d0dabdac3f514b3b2e5eedd0367 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0002.ets @@ -0,0 +1,30 @@ +/** + * 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 TextTimerSize0002 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontSize('30vp') + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0003.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0003.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7b1cda6be7d9ededd472c02b782d55c86818ba5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0003.ets @@ -0,0 +1,30 @@ +/** + * 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 TextTimerSize0003 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontSize('30px') + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0004.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0004.ets new file mode 100644 index 0000000000000000000000000000000000000000..120142b160e2ef215e961c95496516e23c5fc6ad --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtFontSize0004.ets @@ -0,0 +1,29 @@ +/** + * 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 TextTimerSize0004 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0250.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..83691da74ced973648f4fad4f029093668ce64f9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0250.ets @@ -0,0 +1,26 @@ +/** + * 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 TextTimerInterface0250 { + textTimerController: TextTimerController = new TextTimerController() + + build() { + Column() { + TextTimer({ controller: this.textTimerController }) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0280.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0280.ets new file mode 100644 index 0000000000000000000000000000000000000000..1397f57f4958dce231dbcd170d9e3dc6fc56f171 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0280.ets @@ -0,0 +1,31 @@ +/** + * 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 TextTimerInterface0280 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ count: 30000, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(-1) + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0290.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0290.ets new file mode 100644 index 0000000000000000000000000000000000000000..43707fdc7d9a535894f4307da64c1abb0ff4fbc5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextTimer/TtInterface0290.ets @@ -0,0 +1,31 @@ +/** + * 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 TextTimerInterface0290 { + textTimerController: TextTimerController = new TextTimerController() + @State format: string = 'mm:ss.SS' + + build() { + Column() { + TextTimer({ isCountDown: true, controller: this.textTimerController }) + .format(this.format) + .fontColor(Color.Black) + .fontWeight(-1) + .fontSize(50) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI0400.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI0400.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e2c000b9aa7a1e603dd92155fb6e176e9231005 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI0400.ets @@ -0,0 +1,32 @@ +/** + * 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 FocusTextUI0400 { + @State fontSizes: Resource = $r('app.integer.integer_value_20'); // 字体大小资源引用 + + build() { + Column() { + Text('这是一段测试文本,用于验证fontSize通过动态资源引用的效果。') + .fontSize(this.fontSizes) + .id('changeResBtn0400') + .onClick(() => { + this.fontSizes = $r('app.integer.integer_value_10'); + }) + } + .width('100%') + .padding(20) + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1220.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1220.ets new file mode 100644 index 0000000000000000000000000000000000000000..cedd6f316db41c031086e29d1a6d51f274e1cdb9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1220.ets @@ -0,0 +1,49 @@ +/** + * 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 FocusTextUI1220 { + @State maxFont: number = 40; // 初始最大字号 + @State minSize: number = 10; + @State maxLine: number = 2; // 初始最大行数 + + build() { + Column() { + Text('静态参数测试文本:这是一段用于验证的长文本,用于验证maxFontSize和maxLines的效果') + .maxLines(-100)// 负数时不限制行数 + .fontSize(30) + .padding(20) + + Text('动态参数测试文本:这是一段用于测试的长文本,用于验证maxFontSize和maxLines的效果') + .fontSize(30) + .maxFontSize(this.maxFont) + .minFontSize(this.minSize) + .maxLines(this.maxLine)// 负数时不限制行数 + .width('90%') + .id('paramBtn1220') + .onClick(() => { + this.minSize = 10; + this.maxFont = 20; + this.maxLine = -100; + }) + .padding(20) + + Text('静态参数测试文本:这是一段用于验证的长文本,用于验证maxFontSize和maxLines的效果') + .maxLines(-100)// 负数时不限制行数 + .fontSize(20) + .padding(20) + } +} +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1310.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1310.ets new file mode 100644 index 0000000000000000000000000000000000000000..f15b968a15b08cc09fa07b0fdfbec30e02d57356 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1310.ets @@ -0,0 +1,51 @@ +/** + * 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 FocusTextUI1310 { + @State minSize: number = 10; // 最小字号资源(10fp) + @State maxSize: number = 15; // 最大字号初始值(16fp) + @State maxLines: number = -100; // 最大行数 + @State currentSize: number = 12; // 当前字号,初始为minSize + @State testStep: number = 0; // 测试步骤标记 + + build() { + Column() { + Text('这是一段对比文本,用于对比验证当设置minFontSize=20fp, maxFontSize=30fp时,文本字号是否被限制在20-30fp之间。') + .fontSize(20) + .padding(20) + + Text('这是一段测试文本,用于动态验证当设置minFontSize=20fp, maxFontSize=30fp时,文本字号是否被限制在20-30fp之间。') + .minFontSize(this.minSize) + .maxFontSize(this.maxSize) + .maxLines(this.maxLines) + .fontSize(this.currentSize) + .id('testBtn1310') + .onClick(() => { + this.minSize = 20; + this.maxSize = 30; + }) + .padding(20) + + Text('这是一段对比文本,用于对比验证当设置minFontSize=20fp, maxFontSize=30fp时,文本字号是否被限制在20-30fp之间。') + .fontSize(30) + .padding(20) + } + .width('100%') + .height('100%') + .padding(20) + } + +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1440.ets b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1440.ets new file mode 100644 index 0000000000000000000000000000000000000000..789d0bf8987a961100c1944921c765891855d6e1 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_08/uiTEXTcompare01/entry/src/ohosTest/ets/testability/pages/focus_TextUI/FocusTextUI1440.ets @@ -0,0 +1,68 @@ +/** + * 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 FocusTextUI1440 { + @State minSize: ResourceStr = $r('app.float.float_value_5'); // 最小字号(10fp) + @State maxSize: ResourceStr = $r('app.float.float_value_10'); // 最大字号(20fp) + @State maxLines: number = 2; // 最大行数 + @State lineHeight: number = 10; // 行高,初始有效值 + @State currentSize: string = '8fp'; // 当前测试字号 + @State testStep: number = 1; // 测试步骤 + + build() { + Column() { + Text('这是一段静态对比文本,验证文本字号是否仍被限制在minFontSize和maxFontSize之间。') + .fontSize('15fp') + .padding(20) + + Text('这是一段动态测试文本,验证文本字号是否仍被限制在minFontSize和maxFontSize之间。') + .minFontSize(this.minSize) + .maxFontSize(this.maxSize) + .fontSize(this.currentSize) + .maxLines(this.maxLines) + .lineHeight(this.lineHeight) + .id('testBtn1440') + .onClick(() => { + this.maxSize = $r('app.float.float_value_20'); + this.minSize = $r('app.float.float_value_10') + this.lineHeight = -100; + this.maxLines = 5; + this.testStep++; + this.updateParams(); + }) + .padding(20) + + Text('这是一段静态对比文本,验证文本字号是否仍被限制在minFontSize和maxFontSize之间。') + .fontSize('20fp') + .padding(20) + } + .width('100%') + .padding(20) + } + + // 更新测试参数 + private updateParams(): void { + switch (this.testStep) { + case 2: // 步骤3: 负行高,fontSize超过maxSize + this.currentSize = '15fp'; + break; + case 3: // 步骤3: 负行高,fontSize超过maxSize + this.currentSize = '25fp'; + this.testStep = 1; + break; + } + } +} \ No newline at end of file