diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/toast_promptAction/ToastPromptAction.test.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/toast_promptAction/ToastPromptAction.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..57fce87b84a9b1f729a956133ad023b44c49a88f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/test/toast_promptAction/ToastPromptAction.test.ets @@ -0,0 +1,1315 @@ +/** + * 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'; +import { BusinessError } from '@kit.BasicServicesKit' + +export default function ToastPromptActionTest () { + + describe('ToastPromptActionTest', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err:BusinessError) => { + 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_POPUPBOX_PROMPT_PROMPTACTION_0040 + * @tc.name : Multiple Toast components with Default/Top_Most/SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction04") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 先查找所有按钮,确保页面完全加载 + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_04'), 1000); + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_04'), 1000); + + // 依次启动多个Toast + await toast1Button.click(); + await driver.waitForIdle(500,2000); + console.log('ToastPromptActionTest Toast1.click success') + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040_01') + await Utils.sleep(1000) + + await toast2Button.click(); + console.log('ToastPromptActionTest Toast2.click success1') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040_02') + await Utils.sleep(2500) + + await driver.waitForIdle(500,2000); + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_04'), 1000); + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_04'), 1000); + + // 依次关闭Toast + await close2Button.click(); + console.log('ToastPromptActionTest Close2.click success') + await driver.waitForIdle(500,2000); + + await close1Button.click(); + console.log('ToastPromptActionTest Close1.click success') + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0040 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020 + * @tc.name : Single Toast component with TOP_MOST showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction02") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 打开Toast + let openButton1: Component = await driver.waitForComponent(ON.id('open_toast_button_02'), 1000); + await openButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020_01') + await Utils.sleep(2500) + + await driver.waitForIdle(1500,2500); + // 关闭Toast + let closeButton1: Component = await driver.waitForComponent(ON.id('close_toast_button_02'), 1000); + await closeButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020_02') + await Utils.sleep(1000) + + // 多次打开关闭 + // 打开Toast + let openButton2: Component = await driver.waitForComponent(ON.id('open_toast_button_02'), 1000); + await openButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500); + + // 关闭Toast + let closeButton2: Component = await driver.waitForComponent(ON.id('close_toast_button_02'), 1000); + await closeButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + // 打开Toast + let openButton3: Component = await driver.waitForComponent(ON.id('open_toast_button_02'), 1000); + await openButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500); + + // 关闭Toast + let closeButton3: Component = await driver.waitForComponent(ON.id('close_toast_button_02'), 1000); + await closeButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0020 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010 + * @tc.name : Multiple Toast components with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction01") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_01'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_01'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0010 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090 + * @tc.name : Multiple Toast components with Default/Top_Most/SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction09") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_09'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_09'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0090 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0070 + * @tc.name : Single Toast component with TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0070', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0070 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction07") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_07'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0070_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0070 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0080 + * @tc.name : Single Toast component with TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0080', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0080 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction08") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_08'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0080_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0080 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060 + * @tc.name : Single Toast component with Default showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction06") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_06'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060_01') + await Utils.sleep(1000) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_06'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060_02') + await Utils.sleep(1000) + + // 连续多次操作 + for (let i = 0; i < 2; i++) { + await openButton.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + await closeButton.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + } + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0060 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction10") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + + // 先查找所有按钮,确保页面完全加载 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_10'), 1000); + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_10'), 1000); + + // 验证按钮是否可见 + await driver.assertComponentExist(ON.id('open_toast_button_10')); + await driver.assertComponentExist(ON.id('close_toast_button_10')); + + // 打开Toast + await openButton.click(); + console.log('ToastPromptActionTest open_toast_button_10.click success') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100_01') + await Utils.sleep(2500) + + // 重新查找关闭按钮,确保它仍然可用 + closeButton = await driver.waitForComponent(ON.id('close_toast_button_10'), 1000); + + // 关闭Toast + await closeButton.click(); + console.log('close_toast_button_10 close_toast_button_10.click success') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0100 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050 + * @tc.name : Multiple Toast components with Default/Top_Most/SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction05") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_05'), 1000); + await toast1Button.click(); + console.log('toastLog toast1_button_05 click success') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_05'), 1000); + await toast2Button.click(); + console.log('toastLog toast2_button_05 click success') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050_02') + await Utils.sleep(2500) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_05'), 1000); + await close1Button.click(); + console.log('toastLog close1_button_05 click success') + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_05'), 1000); + await close2Button.click(); + console.log('toastLog close2_button_05 click success') + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0050 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030 + * @tc.name : Single Toast component with DEFAULT showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction03") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_03'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030_01') + await Utils.sleep(1000) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_03'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0030 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120 + * @tc.name : Multiple Toast components with Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction12") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_12'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_12'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120_02') + await Utils.sleep(2500) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_12'), 1000); + await close1Button.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_12'), 1000); + await close2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0120 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110 + * @tc.name : Multiple Toast components with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction11") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_11'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_11'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110_02') + await Utils.sleep(1000) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_11'), 1000); + await close1Button.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_11'), 1000); + await close2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0110 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0160 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0160', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0160 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction16") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_16'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0160_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0160 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140 + * @tc.name : Single Toast component with Default showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction14") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton1: Component = await driver.waitForComponent(ON.id('open_toast_button_14'), 1000); + await openButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140_01') + await Utils.sleep(1000) + + // 关闭Toast + let closeButton1: Component = await driver.waitForComponent(ON.id('close_toast_button_14'), 1000); + await closeButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140_02') + await Utils.sleep(1000) + + // 多次打开关闭 + // 打开Toast + let openButton2: Component = await driver.waitForComponent(ON.id('open_toast_button_14'), 1000); + await openButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + // 关闭Toast + let closeButton2: Component = await driver.waitForComponent(ON.id('close_toast_button_14'), 1000); + await closeButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + // 打开Toast + let openButton3: Component = await driver.waitForComponent(ON.id('open_toast_button_14'), 1000); + await openButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + // 关闭Toast + let closeButton3: Component = await driver.waitForComponent(ON.id('close_toast_button_14'), 1000); + await closeButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0140 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150 + * @tc.name : Multiple Toast components with Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction15") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_15'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_15'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0150 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130 + * @tc.name : Single Toast component with TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction13") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_13'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_13'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0130 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction17") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton1: Component = await driver.waitForComponent(ON.id('open_toast_button_17'), 1000); + await openButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton1: Component = await driver.waitForComponent(ON.id('close_toast_button_17'), 1000); + await closeButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170_02') + await Utils.sleep(1000) + + // 多次打开关闭 + // 打开Toast + let openButton2: Component = await driver.waitForComponent(ON.id('open_toast_button_17'), 1000); + await openButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500) + + // 关闭Toast + let closeButton2: Component = await driver.waitForComponent(ON.id('close_toast_button_17'), 1000); + await closeButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000) + + // 打开Toast + let openButton3: Component = await driver.waitForComponent(ON.id('open_toast_button_17'), 1000); + await openButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500) + + // 关闭Toast + let closeButton3: Component = await driver.waitForComponent(ON.id('close_toast_button_17'), 1000); + await closeButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0170 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180 + * @tc.name : Multiple Toast components with SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction18") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_18'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_18'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0180 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200 + * @tc.name : Multiple Toast components with SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction20") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_20'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_20'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0200 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190 + * @tc.name : Multiple Toast components with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction19") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_19'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_19'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190_02') + await Utils.sleep(2500) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_19'), 1000); + await close1Button.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_19'), 1000); + await close2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0190 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210 + * @tc.name : Multiple Toast components with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction21") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_21'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_21'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0210 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0250 + * @tc.name : Single Toast component with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0250', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0250 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction25") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_25'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0250_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0250 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240 + * @tc.name : Multiple Toast components with Default/Top_Most/SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction24") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_24'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240_01') + await Utils.sleep(1000) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_24'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0240 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230 + * @tc.name : Single Toast component with DEFAULT showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction23") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_23'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230_01') + await Utils.sleep(1000) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_23'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0230 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270 + * @tc.name : Multiple Toast components with Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction27") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_27'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_27'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270_02') + await Utils.sleep(2500) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0270 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300 + * @tc.name : Single Toast component with TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction30") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_30'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_30'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0300 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0310 + * @tc.name : Single Toast component with Default showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0310', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0310 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction31") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_31'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0310_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0310 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0220 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0220', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0220 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction22") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast并截图验证 + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_22'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0220_01') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0220 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction26") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton1: Component = await driver.waitForComponent(ON.id('open_toast_button_26'), 1000); + await openButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton1: Component = await driver.waitForComponent(ON.id('close_toast_button_26'), 1000); + await closeButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260_02') + await Utils.sleep(1000) + + // 多次打开关闭 + // 打开Toast + let openButton2: Component = await driver.waitForComponent(ON.id('open_toast_button_26'), 1000); + await openButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500) + + // 关闭Toast + let closeButton2: Component = await driver.waitForComponent(ON.id('close_toast_button_26'), 1000); + await closeButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000) + + // 打开Toast + let openButton3: Component = await driver.waitForComponent(ON.id('open_toast_button_26'), 1000); + await openButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500) + + // 关闭Toast + let closeButton3: Component = await driver.waitForComponent(ON.id('close_toast_button_26'), 1000); + await closeButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0260 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290 + * @tc.name : Multiple Toast components with SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction29") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_29'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_29'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290_02') + await Utils.sleep(2500) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_29'), 1000); + await close1Button.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_29'), 1000); + await close2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0290 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320 + * @tc.name : Multiple Toast components with Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction32") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_32'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_32'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320_02') + await Utils.sleep(2500) + + // 依次关闭Toast + let close1Button: Component = await driver.waitForComponent(ON.id('close1_button_32'), 1000); + await close1Button.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(500); + + let close2Button: Component = await driver.waitForComponent(ON.id('close2_button_32'), 1000); + await close2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320_03') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0320 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280 + * @tc.name : Multiple Toast components with SYSTEM_Top_Most showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction28") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 依次启动多个Toast + let toast1Button: Component = await driver.waitForComponent(ON.id('toast1_button_28'), 1000); + await toast1Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280_01') + await Utils.sleep(2500) + + let toast2Button: Component = await driver.waitForComponent(ON.id('toast2_button_28'), 1000); + await toast2Button.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0280 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330 + * @tc.name : Single Toast component with TOP_MOST showMode, continuous open/close + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction33") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton1: Component = await driver.waitForComponent(ON.id('open_toast_button_33'), 1000); + await openButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton1: Component = await driver.waitForComponent(ON.id('close_toast_button_33'), 1000); + await closeButton1.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330_02') + await Utils.sleep(1000) + + // 多次打开关闭 + // 打开Toast + let openButton2: Component = await driver.waitForComponent(ON.id('open_toast_button_33'), 1000); + await openButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500); + + // 关闭Toast + let closeButton2: Component = await driver.waitForComponent(ON.id('close_toast_button_33'), 1000); + await closeButton2.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + // 打开Toast + let openButton3: Component = await driver.waitForComponent(ON.id('open_toast_button_33'), 1000); + await openButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(2500); + + // 关闭Toast + let closeButton3: Component = await driver.waitForComponent(ON.id('close_toast_button_33'), 1000); + await closeButton3.click(); + await driver.waitForIdle(500,2000); + await Utils.sleep(1000); + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0330 finish.`); + done() + }) + + /* + * @tc.number : SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340 + * @tc.name : Single Toast component with SYSTEM_TOP_MOST showMode + * @tc.type : Function + * @tc.size : MediumTest + * @tc.level : 3 + */ + it('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340', Level.LEVEL3, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340 start.`); + Settings.createWindow("testability/pages/toast_promptAction/toastPromptAction34") + let driver:Driver = Driver.create(); + await driver.waitForIdle(200,500); + await Utils.sleep(1000); + + // 打开Toast + let openButton: Component = await driver.waitForComponent(ON.id('open_toast_button_34'), 1000); + await openButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340_01') + await Utils.sleep(2500) + + // 关闭Toast + let closeButton: Component = await driver.waitForComponent(ON.id('close_toast_button_34'), 1000); + await closeButton.click(); + await driver.waitForIdle(500,2000); + windowSnap.snapShot('SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340_02') + await Utils.sleep(1000) + + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_POPUPBOX_PROMPT_PROMPTACTION_0340 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction01.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction01.ets new file mode 100644 index 0000000000000000000000000000000000000000..17fe2c8d1bc95d9273b9530b98712c03b1274cbc --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction01.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction01 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0010 - 多个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_01') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_01') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Toast1显示第一个Toast,然后点击Toast2显示第二个Toast,观察第一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:第二个Toast显示时,第一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction02.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction02.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb782554de808e4345f611613061e02152c37002 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction02.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction02 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0020 - 单个Toast组件TOP_MOST showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_02') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_02') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction03.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction03.ets new file mode 100644 index 0000000000000000000000000000000000000000..6358c1e02a62cffe25463139dba972e4111de7b9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction03.ets @@ -0,0 +1,137 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction03 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0030 - 单个Toast组件DEFAULT showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: DEFAULT - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_03') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_03') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction04.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction04.ets new file mode 100644 index 0000000000000000000000000000000000000000..657ee852cebd2c263f9cc040ead8cc0a364b549d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction04.ets @@ -0,0 +1,179 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction04 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0040 - 多个Toast组件Default/Top_Most/SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default/Top_Most/SYSTEM_Top_Most - 同一类型的Toast只能打开一个') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_04') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_04') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_04') + .zIndex(9999999) + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_04') + .zIndex(9999999) + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:同一类型的Toast只能打开一个') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction05.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction05.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a89225ae5596a37e9c9b1269243112eda9196c0 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction05.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction05 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0050 - 多个Toast组件Default/Top_Most/SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default/Top_Most/SYSTEM_Top_Most - 同一类型的Toast只能打开一个') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_05') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_05') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_05') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_05') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:同一类型的Toast只能打开一个') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction06.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction06.ets new file mode 100644 index 0000000000000000000000000000000000000000..e76ac3fa1b14dff59a263985f96ad55889bc30af --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction06.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction06 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0060 - 单个Toast组件Default showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_06') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_06') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction07.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction07.ets new file mode 100644 index 0000000000000000000000000000000000000000..3523b800d2f83375137be06adfc6819044fe6907 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction07.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction07 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0070 - 单个Toast组件TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_07') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction08.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction08.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b28dc6671a555b6dc4a4f2cb5ebf6f8ea027e1c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction08.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction08 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0080 - 单个Toast组件TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_08') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction09.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction09.ets new file mode 100644 index 0000000000000000000000000000000000000000..15eb91d93e99df45216e966ed83eaba70aa23451 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction09.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction09 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0090 - 多个Toast组件Default/Top_Most/SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default/Top_Most/SYSTEM_Top_Most - 同一类型的Toast只能打开一个') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_09') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_09') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_09') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_09') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:同一类型的Toast只能打开一个') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction10.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction10.ets new file mode 100644 index 0000000000000000000000000000000000000000..943de2c0dc9dbbaf53497ce52c33378195914703 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction10.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction10 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0100 - 单个Toast组件TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_10') + .type(ButtonType.Capsule) + .height(100) + .width(120) + .backgroundColor(Color.Green) + .fontColor(Color.White) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 100, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_10') + .type(ButtonType.Capsule) + .height(100) + .width(120) + .backgroundColor(Color.Blue) + .fontColor(Color.White) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction11.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction11.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff98c4539400f14a214db0dd41220793241b2af5 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction11.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction11 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0110 - 多个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_11') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_11') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_11') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_11') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction12.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction12.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5369064c220a3ad8f6277357d2f26bef90cc0b6 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction12.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction12 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0120 - 多个Toast组件Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_12') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_12') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_12') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_12') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction13.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction13.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4c0d9732082293e0f87125c48a6e1726af6762b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction13.ets @@ -0,0 +1,137 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction13 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0130 - 单个Toast组件TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_13') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_13') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction14.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction14.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae436887138c16a3a212687c4eba9454e51e7dec --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction14.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction14 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0140 - 单个Toast组件Default showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_14') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_14') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction15.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction15.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8ce7aa20e85fee8b4b17bce093950e0a2952cc9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction15.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction15 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0150 - 多个Toast组件Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_15') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_15') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction16.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction16.ets new file mode 100644 index 0000000000000000000000000000000000000000..3bb8b073acc9965551749962234941f4da77bc2f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction16.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction16 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0160 - 单个Toast组件SYSTEM_TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_TOP_MOST - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_16') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction17.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction17.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b2694dd0fdb8154d974b8266564e400952154ad --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction17.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction17 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0170 - 单个Toast组件SYSTEM_TOP_MOST showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_TOP_MOST - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_17') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_17') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction18.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction18.ets new file mode 100644 index 0000000000000000000000000000000000000000..870a2e627ee8196d765d8a4f8f2a3da11aca885a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction18.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction18 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0180 - 多个Toast组件SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_18') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_18') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction19.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction19.ets new file mode 100644 index 0000000000000000000000000000000000000000..200993bb383830e0efb0a6ba7fb4a467d413ed31 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction19.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction19 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0190 - 多个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_19') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_19') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_19') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_19') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction20.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction20.ets new file mode 100644 index 0000000000000000000000000000000000000000..8743742a8f28c244bf8b36510a27d6b9536b5632 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction20.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction20 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0200 - 多个Toast组件SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_20') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_20') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction21.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction21.ets new file mode 100644 index 0000000000000000000000000000000000000000..1642577c5b378ce3e274a48a7f4e529ab8877697 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction21.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction21 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0210 - 多个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_21') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_21') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction22.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction22.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad6987168448a8dabe2a8452ff212b24f639345c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction22.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction22 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0220 - 单个Toast组件SYSTEM_TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_TOP_MOST - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_22') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction23.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction23.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1028710f50dd85a2638a1e8c244a1aaa5013318 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction23.ets @@ -0,0 +1,137 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction23 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0230 - 单个Toast组件DEFAULT showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: DEFAULT - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_23') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_23') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction24.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction24.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1c4f604e25b26f427258c26d89be6c13f450a61 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction24.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction24 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0240 - 多个Toast组件Default/Top_Most/SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default/Top_Most/SYSTEM_Top_Most - 同一类型的Toast只能打开一个') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_24') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_24') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察同一类型的Toast只能打开一个') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:同一类型的Toast只能打开一个') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction25.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction25.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ad92f2e7ea732ca229f0e3ba085b66e38d0397d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction25.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction25 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0250 - 单个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_25') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction26.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction26.ets new file mode 100644 index 0000000000000000000000000000000000000000..e53a34ffda4bd0cd492c19d9330a8bd87ca9da24 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction26.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction26 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0260 - 单个Toast组件SYSTEM_TOP_MOST showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_TOP_MOST - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_26') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_26') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction27.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction27.ets new file mode 100644 index 0000000000000000000000000000000000000000..852a9f69009a970e64544e5a31a75fc3ae9c464d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction27.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction27 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0270 - 多个Toast组件Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_27') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_27') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction28.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction28.ets new file mode 100644 index 0000000000000000000000000000000000000000..ada54d1122d3c255aabafd59592c02c9699cc1a7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction28.ets @@ -0,0 +1,144 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction28 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0280 - 多个Toast组件SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_28') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_28') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,观察后面一个Toast打开后,前一个Toast是否自动关闭') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1按钮显示第一个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Toast2按钮显示第二个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction29.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction29.ets new file mode 100644 index 0000000000000000000000000000000000000000..84173411b68097e9a718f9001053465349b71e46 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction29.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction29 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0290 - 多个Toast组件SYSTEM_Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_29') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_29') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_29') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_29') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction30.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction30.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa7aa08f6e1764ff853779364c4e7f47379dc401 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction30.ets @@ -0,0 +1,137 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction30 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0300 - 单个Toast组件TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_30') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_30') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction31.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction31.ets new file mode 100644 index 0000000000000000000000000000000000000000..55090629b57ff91ae538d1eb07eee4c3afabf735 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction31.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. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction31 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0310 - 单个Toast组件Default showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Default - 测试Toast正常显示') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_31') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是DEFAULT模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.DEFAULT + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,观察Toast正常显示') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 预期效果:Toast正常显示') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction32.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction32.ets new file mode 100644 index 0000000000000000000000000000000000000000..863ec9adcbdfe02db6ffa364bc6f5f987004ef0e --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction32.ets @@ -0,0 +1,177 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction32 { + @State toastId1: number = 0; + @State toastId2: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0320 - 多个Toast组件Top_Most showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: Top_Most - 后面一个Toast打开后,前一个Toast自动关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Toast1') + .id('toast1_button_32') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第一个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId1 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Toast2') + .id('toast2_button_32') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是第二个Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId2 = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 关闭按钮 + Row({ space: 10 }) { + Button('Close1') + .id('close1_button_32') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId1); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + Button('Close2') + .id('close2_button_32') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId2); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('依次启动多个Toast,然后依次关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Toast1和Toast2依次启动多个Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close1和Close2依次关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:后面一个Toast打开后,前一个Toast自动关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction33.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction33.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bd0f365590634eb0e121352d965fbf876fb9e83 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction33.ets @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction33 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0330 - 单个Toast组件TOP_MOST showMode连续操作') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: TOP_MOST - 测试连续打开/关闭Toast') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_33') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_33') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast,测试连续操作') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 连续多次执行打开/关闭操作') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('4. 预期效果:Toast连续打开/关闭正常') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +} diff --git a/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction34.ets b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction34.ets new file mode 100644 index 0000000000000000000000000000000000000000..59f8da538bfea0fae91a882e148c2a16dc0357e2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_01/entry/src/ohosTest/ets/testability/pages/toast_promptAction/toastPromptAction34.ets @@ -0,0 +1,137 @@ +/** + * 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 { promptAction, LengthMetrics, PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct toastPromptAction34 { + @State toastId: number = 0; + private uiContext: UIContext = this.getUIContext(); + private promptAction: PromptAction = this.uiContext.getPromptAction(); + + build() { + Column() { + // 页面标题 + Text('测试用例0340 - 单个Toast组件SYSTEM_TOP_MOST showMode') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 8, bottom: 8 }); + + // 状态说明 + Text('showMode: SYSTEM_TOP_MOST - 测试Toast正常显示和关闭') + .height(35) + .fontSize(12) + .textAlign(TextAlign.Center) + .fontColor(Color.Black) + .width('100%') + .border({ width: 1 }) + .lineHeight(16) + .fontWeight(300) + .margin({ bottom: 8 }); + + // 操作按钮 + Row({ space: 10 }) { + Button('Open Toast') + .id('open_toast_button_34') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.openToast({ + message: '这是SYSTEM_TOP_MOST模式的Toast消息', + duration: 1500, + showMode: promptAction.ToastShowMode.SYSTEM_TOP_MOST + }).then((toastId: number) => { + this.toastId = toastId; + }); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenToast error code is ${code}, message is ${message}`); + } + }) + Button('Close Toast') + .id('close_toast_button_34') + .type(ButtonType.Capsule) + .height(100) + .onClick(() => { + try { + this.promptAction.closeToast(this.toastId); + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseToast error code is ${code}, message is ${message}`); + } + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .margin({ bottom: 10 }); + + // 说明文字 + Text('点击Open Toast显示Toast,点击Close Toast关闭Toast') + .fontSize(14) + .fontColor(Color.Gray) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: 20 }); + + // 测试区域 + Column({ space: 20 }) { + Text('测试说明:') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Blue) + .width('100%') + .textAlign(TextAlign.Center); + + Text('1. 点击Open Toast按钮显示Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('2. 点击Close Toast按钮关闭Toast') + .fontSize(14) + .fontColor(Color.Black) + .width('100%') + .textAlign(TextAlign.Start); + + Text('3. 预期效果:Toast正常显示和关闭') + .fontSize(14) + .fontColor(Color.Green) + .width('100%') + .textAlign(TextAlign.Start); + } + .width('90%') + .padding(15) + .backgroundColor(0xF5F5F5) + .borderRadius(10) + .margin({ top: 20 }); + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5, left: 10, right: 10 }) + } +}