diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUIAnimatedResponseTest/ArkUIAnimatedResponse.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUIAnimatedResponseTest/ArkUIAnimatedResponse.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ee7c5219c9d76f4a368a62f9fa7eef38f291e8d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUIAnimatedResponseTest/ArkUIAnimatedResponse.test.ets @@ -0,0 +1,554 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function ArkUIAnimatedResponse() { + + describe('ArkUIAnimatedResponse', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0050 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0050 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0050 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0050") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0050 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0080 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0080 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0080', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0080 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0080") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0080 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0110 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0110 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0110', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0110 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0110") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(500) + await tab7.click() + await Utils.sleep(1000) + + let tab9:Component = await driver.findComponent(ON.id('tab9')); + await Utils.sleep(500) + await tab9.click() + await Utils.sleep(1000) + + let tab8:Component = await driver.findComponent(ON.id('tab8')); + await Utils.sleep(500) + await tab8.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0100 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0100 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0100', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0100 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0100") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0100 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0070 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0070 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0070', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0070 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0070") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0070 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0060 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0060 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0060', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0060 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0060") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0060 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0090 + * @tc.name SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0090 + * @tc.desc nav width + */ + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0090', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0090 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0090") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0090 finish.`); + done() + }) + + + it('SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0040', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0040 start.`); + Settings.createWindow("testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0040") + await Utils.sleep(300) + + let driver : Driver = Driver.create(); + await driver.delayMs(300) + + let tab3:Component = await driver.findComponent(ON.id('tab3')); + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + let tab4:Component = await driver.findComponent(ON.id('tab4')); + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + let tab5:Component = await driver.findComponent(ON.id('tab5')); + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + let tab6:Component = await driver.findComponent(ON.id('tab6')); + await Utils.sleep(300) + await tab6.click() + await Utils.sleep(300) + let tab7:Component = await driver.findComponent(ON.id('tab7')); + await Utils.sleep(300) + await tab7.click() + await Utils.sleep(300) + + await tab6.click() + await Utils.sleep(300) + await tab5.click() + await Utils.sleep(300) + await tab4.click() + await Utils.sleep(300) + await tab3.click() + await Utils.sleep(300) + + let tab2:Component = await driver.findComponent(ON.id('tab2')); + await Utils.sleep(300) + await tab2.click() + await Utils.sleep(300) + + let tab1:Component = await driver.findComponent(ON.id('tab1')); + await Utils.sleep(300) + await tab1.click() + await Utils.sleep(300) + + let tab0:Component = await driver.findComponent(ON.id('tab0')); + await Utils.sleep(300) + await tab0.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_ARKUI_ANIMATED_RESPONSE_0040 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabScrollableTest/ArkUITabScrollable.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabScrollableTest/ArkUITabScrollable.test.ets index 11de16ebb3a3e455b798f2cddc14af0bb33dd4dc..a8aeeaa53ac5904bc855cf3e4ddb8732cfc4e9ce 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabScrollableTest/ArkUITabScrollable.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabScrollableTest/ArkUITabScrollable.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,58 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabScrollable() { describe('ArkUITabScrollable', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -43,7 +91,7 @@ export default function ArkUITabScrollable() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_scrollable_001 finish.`); done() @@ -68,7 +116,7 @@ export default function ArkUITabScrollable() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_scrollable_002 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleSelectedColorTest/ArkUITabsIconStyleSelectedColor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleSelectedColorTest/ArkUITabsIconStyleSelectedColor.test.ets index 8c54c62e50087aef0663c201d92e3872ec5d61b6..eb2e97fb05299feda9f4796a50ba8ee8449a9c0e 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleSelectedColorTest/ArkUITabsIconStyleSelectedColor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleSelectedColorTest/ArkUITabsIconStyleSelectedColor.test.ets @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsIconStyleSelectedColor() { describe('ArkUITabsIconStyleSelectedColor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_027 * @tc.name ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_027 @@ -32,7 +78,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_027 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor027") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_027 finish.`); done() @@ -46,7 +92,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_029 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor029") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_029 finish.`); done() @@ -60,7 +106,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_028 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor028") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_028 finish.`); done() @@ -74,7 +120,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_024 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor024") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_024 finish.`); done() @@ -88,7 +134,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_026 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor026") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_026 finish.`); done() @@ -102,7 +148,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_025 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor025") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_025 finish.`); done() @@ -116,7 +162,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_014 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor014") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_014 finish.`); done() @@ -130,7 +176,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_013 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor013") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_013 finish.`); done() @@ -144,7 +190,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_001 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor001") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_001 finish.`); done() @@ -158,7 +204,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_004 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor004") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_004 finish.`); done() @@ -172,7 +218,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_008 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor008") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_008 finish.`); done() @@ -186,7 +232,7 @@ export default function ArkUITabsIconStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_022 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleSelectedColor/ArkUITabsIconStyleSelectedColor022") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_SELECTEDCOLOR_022$ finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleUnselectedColorTest/ArkUITabsIconStyleUnselectedColor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleUnselectedColorTest/ArkUITabsIconStyleUnselectedColor.test.ets index 5df21352c8310e8a539de155a98c44ffa69edaa4..013457135affbbaf651caabaec9f67944a06a2aa 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleUnselectedColorTest/ArkUITabsIconStyleUnselectedColor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsIconStyleUnselectedColorTest/ArkUITabsIconStyleUnselectedColor.test.ets @@ -19,10 +19,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsIconStyleUnselectedColor() { describe('ArkUITabsIconStyleUnselectedColor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_026 * @tc.name ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_026 @@ -32,7 +79,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_026 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor026") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_026 finish.`); done() @@ -46,7 +93,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_028 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor028") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_028 finish.`); done() @@ -60,7 +107,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_027 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor027") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_027 finish.`); done() @@ -74,7 +121,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_021 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor021") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_021 finish.`); done() @@ -88,7 +135,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_022 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor022") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_022 finish.`); done() @@ -102,7 +149,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_024 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor024") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_024 finish.`); done() @@ -116,7 +163,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_014 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor014") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_014 finish.`); done() @@ -130,7 +177,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_016 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor016") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_016 finish.`); done() @@ -144,7 +191,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_029 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor029") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_029 finish.`); done() @@ -158,7 +205,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_002 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor002") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_002 finish.`); done() @@ -172,7 +219,7 @@ export default function ArkUITabsIconStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_005 start.`); Settings.createWindow("testability/pages/ArkUITabsIconStyleUnselectedColor/ArkUITabsIconStyleUnselectedColor005") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_ICONSTYLE_UNSELECTEDCOLOR_005 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleSelectedColorTest/ArkUITabsLabelStyleSelectedColor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleSelectedColorTest/ArkUITabsLabelStyleSelectedColor.test.ets index 39aa137013fb9b01355f0d53bc35741995205ece..1be7c86ea04751fec388b4e02254e2a564dd4cbe 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleSelectedColorTest/ArkUITabsLabelStyleSelectedColor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleSelectedColorTest/ArkUITabsLabelStyleSelectedColor.test.ets @@ -18,10 +18,58 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsLabelStyleSelectedColor() { describe('ArkUITabsLabelStyleSelectedColor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -43,7 +91,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_027 finish.`); done() @@ -68,7 +116,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_029 finish.`); done() @@ -93,7 +141,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_013 finish.`); done() @@ -118,7 +166,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_017 finish.`); done() @@ -142,7 +190,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_019 finish.`); done() @@ -167,7 +215,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_001 finish.`); done() @@ -192,7 +240,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_003 finish.`); done() @@ -216,7 +264,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_005 finish.`); done() @@ -240,7 +288,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_007 finish.`); done() @@ -265,7 +313,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_011 finish.`); done() @@ -290,7 +338,7 @@ export default function ArkUITabsLabelStyleSelectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_selectedColor_009 finish.`); done() @@ -304,14 +352,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_028 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor028") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor028_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_028 finish.`); done() @@ -325,14 +373,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_021 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor021") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor021_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_021 finish.`); done() @@ -346,14 +394,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_023 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor023") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor023_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_023 finish.`); done() @@ -367,14 +415,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_024 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor024") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor024_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_024 finish.`); done() @@ -388,14 +436,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_026 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor026") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor026_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_026 finish.`); done() @@ -409,14 +457,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_025 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor025") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor025_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_025 finish.`); done() @@ -430,14 +478,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_012 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor012") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor012_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_012 finish.`); done() @@ -451,14 +499,14 @@ export default function ArkUITabsLabelStyleSelectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_015 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleSelectedColor/ArkUITabsLabelStyleSelectedColor015") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleSelectedcolor015_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_SELECTEDCOLOR_015 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleUnselectedColorTest/ArkUITabsLabelStyleUnselectedColor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleUnselectedColorTest/ArkUITabsLabelStyleUnselectedColor.test.ets index d7dd0377579ace102aa8506ceea577bf63d48457..dfdbad3a40898615e1000a313b5e8fb143f5db66 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleUnselectedColorTest/ArkUITabsLabelStyleUnselectedColor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStyleUnselectedColorTest/ArkUITabsLabelStyleUnselectedColor.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,58 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsLabelStyleUnselectedColor() { describe('ArkUITabsLabelStyleUnselectedColor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* * @tc.number ArkUI_Tabs_LabelStyle_unselectedColor_026 @@ -42,7 +90,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_026 finish.`); done() @@ -67,7 +115,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_028 finish.`); done() @@ -92,7 +140,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_027 finish.`); done() @@ -117,7 +165,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_021 finish.`); done() @@ -142,7 +190,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_022 finish.`); done() @@ -167,7 +215,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_025 finish.`); done() @@ -192,7 +240,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_011 finish.`); done() @@ -217,7 +265,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_012 finish.`); done() @@ -242,7 +290,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_017 finish.`); done() @@ -267,7 +315,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_001 finish.`); done() @@ -292,7 +340,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_005 finish.`); done() @@ -317,7 +365,7 @@ export default function ArkUITabsLabelStyleUnselectedColor() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_unselectedColor_008 finish.`); done() @@ -331,14 +379,14 @@ export default function ArkUITabsLabelStyleUnselectedColor() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_UNSELECTEDCOLOR_024 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStyleUnselectedColor/ArkUITabsLabelStyleUnselectedColor024") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleUnselectedcolor024_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_UNSELECTEDCOLOR_024 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStylefontTest/ArkUITabsLabelStylefont.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStylefontTest/ArkUITabsLabelStylefont.test.ets index 1279dfa79c2cf91afd023b941364d0ad5a29eda1..3d952c9dc85853224e49cfadcebca26fa1706c35 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStylefontTest/ArkUITabsLabelStylefont.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsLabelStylefontTest/ArkUITabsLabelStylefont.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsLabelStylefont() { describe('ArkUITabsLabelStylefont', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -42,7 +89,7 @@ export default function ArkUITabsLabelStylefont() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_005 finish.`); done() @@ -67,7 +114,7 @@ export default function ArkUITabsLabelStylefont() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_016 finish.`); done() @@ -92,7 +139,7 @@ export default function ArkUITabsLabelStylefont() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_015 finish.`); done() @@ -109,7 +156,7 @@ export default function ArkUITabsLabelStylefont() { Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_011 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont011") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_011 finish.`); done() @@ -126,7 +173,7 @@ export default function ArkUITabsLabelStylefont() { Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_007 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont007") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_007 finish.`); done() @@ -143,7 +190,7 @@ export default function ArkUITabsLabelStylefont() { Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_010 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont010") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_010 finish.`); done() @@ -160,7 +207,7 @@ export default function ArkUITabsLabelStylefont() { Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_008 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont008") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_008 finish.`); done() @@ -177,7 +224,7 @@ export default function ArkUITabsLabelStylefont() { Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_009 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont009") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_009 finish.`); done() @@ -202,7 +249,7 @@ export default function ArkUITabsLabelStylefont() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.error('TEST', `ArkUI_Tabs_LabelStyle_font_020 finish.`); done() @@ -216,7 +263,7 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_006 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont006") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_006 finish.`); done() @@ -230,7 +277,7 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_019 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont019") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_019 finish.`); done() @@ -244,14 +291,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_001 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont001") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont001_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_001 finish.`); done() @@ -265,14 +312,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_003 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont003") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont003_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_003 finish.`); done() @@ -286,14 +333,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_004 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont004") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont004_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_004 finish.`); done() @@ -307,14 +354,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_018 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont018") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont018_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_018 finish.`); done() @@ -328,14 +375,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_017 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont017") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont017_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_017 finish.`); done() @@ -349,14 +396,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_013 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont013") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont013_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_013 finish.`); done() @@ -370,14 +417,14 @@ export default function ArkUITabsLabelStylefont() { Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_012 start.`); Settings.createWindow("testability/pages/ArkUITabsLabelStylefont/ArkUITabsLabelStylefont012") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) let driver: Driver = Driver.create() let button: Component = await driver.findComponent(ON.id('ArkUITabsLabelstyleFont012_001')) await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ARKUI_TABS_LABELSTYLE_FONT_012 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleSelectedcolorTest/ArkUITabsSingleSelectedcolor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleSelectedcolorTest/ArkUITabsSingleSelectedcolor.test.ets index 50df4505f457169bd9cb023f924b37aae115f956..2fa3d701769104877443ddc860cc7f21865c7f2a 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleSelectedcolorTest/ArkUITabsSingleSelectedcolor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleSelectedcolorTest/ArkUITabsSingleSelectedcolor.test.ets @@ -19,10 +19,58 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver, ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsSingleSelectedcolor() { describe('ArkUITabsSingleSelectedcolor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number ARKUI_TABS_SINGLE_SELECTEDCOLOR_011 * @tc.name ARKUI_TABS_SINGLE_SELECTEDCOLOR_011 @@ -33,7 +81,7 @@ export default function ArkUITabsSingleSelectedcolor() { Settings.createWindow("testability/pages/ArkUITabsSingleSelectedcolor/ArkUITabsSingleSelectedcolor011") await Utils.sleep(2000) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `ARKUI_TABS_SINGLE_SELECTEDCOLOR_011 finish.`); done() @@ -48,7 +96,7 @@ export default function ArkUITabsSingleSelectedcolor() { Settings.createWindow("testability/pages/ArkUITabsSingleSelectedcolor/ArkUITabsSingleSelectedcolor002") await Utils.sleep(2000) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `ARKUI_TABS_SINGLE_SELECTEDCOLOR_002 finish.`); done() @@ -63,7 +111,7 @@ export default function ArkUITabsSingleSelectedcolor() { Settings.createWindow("testability/pages/ArkUITabsSingleSelectedcolor/ArkUITabsSingleSelectedcolor005") await Utils.sleep(2000) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `ARKUI_TABS_SINGLE_SELECTEDCOLOR_005 finish.`); done() @@ -77,7 +125,7 @@ export default function ArkUITabsSingleSelectedcolor() { Settings.createWindow("testability/pages/ArkUITabsSingleSelectedcolor/ArkUITabsSingleSelectedcolor008") await Utils.sleep(2000) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `ARKUI_TABS_SINGLE_SELECTEDCOLOR_008 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleUnselectedcolorTest/ArkUITabsSingleUnselectedcolor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleUnselectedcolorTest/ArkUITabsSingleUnselectedcolor.test.ets index cb90a868a6f555e5f0c2f8ac4310ce9d9eb771ff..81db8af33db3e388221bbb5110d51461ce78606c 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleUnselectedcolorTest/ArkUITabsSingleUnselectedcolor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsSingleUnselectedcolorTest/ArkUITabsSingleUnselectedcolor.test.ets @@ -19,10 +19,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver, ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsSingleUnselectedcolor() { describe('ArkUITabsSingleUnselectedcolor', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number ARKUI_TABS_SINGLE_UNSELECTEDCOLOR_003 * @tc.name ARKUI_TABS_SINGLE_UNSELECTEDCOLOR_003 @@ -33,7 +80,7 @@ export default function ArkUITabsSingleUnselectedcolor() { Settings.createWindow("testability/pages/ArkUITabsSingleUnselectedcolor/ArkUITabsSingleUnselectedcolor003") await Utils.sleep(2000) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `ARKUI_TABS_SINGLE_UNSELECTEDCOLOR_003 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsVerticalTest/ArkUITabsVertical.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsVerticalTest/ArkUITabsVertical.test.ets index 60afbf12b9eabdc4f3d0fe3375a6ec0824d79360..eaa79205ada1cafa89fba5cca6d2a3d3b6698b30 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsVerticalTest/ArkUITabsVertical.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/ArkUITabsVerticalTest/ArkUITabsVertical.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function ArkUITabsVertical() { describe('ArkUITabsVertical', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number ArkUI_Tabs_vertical_001 @@ -42,7 +89,7 @@ export default function ArkUITabsVertical() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `ArkUI_Tabs_vertical_001 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/FunctionJichuWaterFlowTest/FunctionJichuWaterFlow.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/FunctionJichuWaterFlowTest/FunctionJichuWaterFlow.test.ets index e2b67bdc172852aa4e57d4a08a69a6c80abed03b..48a8d3730250db2ad814d640129d3769d456d2f6 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/FunctionJichuWaterFlowTest/FunctionJichuWaterFlow.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/FunctionJichuWaterFlowTest/FunctionJichuWaterFlow.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -17,11 +17,58 @@ import Settings from '../model/Settings' import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' -import { Component, Driver ,ON } from '@ohos.UiTest' - +import { Component, Driver, ON, PointerMatrix } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function FunctionJichuWaterFlow() { describe('FunctionJichuWaterFlow', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -34,7 +81,7 @@ export default function FunctionJichuWaterFlow() { Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350 start.`); Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350 finish.`); done() @@ -50,21 +97,116 @@ export default function FunctionJichuWaterFlow() { Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_001806 start.`); Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow001806") await Utils.sleep(1000) - let driver : Driver = Driver.create(); + let driver: Driver = Driver.create(); await driver.delayMs(100) - let refreshListItem0 :Component = await driver.findComponent(ON.id('FunctionJichuWaterFlow001806_001')) + let refreshListItem0: Component = await driver.findComponent(ON.id('FunctionJichuWaterFlow001806_001')) await Utils.sleep(200) let pos = await refreshListItem0.getBoundsCenter() await Utils.sleep(100) - await driver.swipe(pos.x,pos.y,pos.x,pos.y-400) + await driver.swipe(pos.x, pos.y, pos.x, pos.y - 400) await Utils.sleep(1000) - await driver.swipe(pos.x,pos.y,pos.x,pos.y-400) + await driver.swipe(pos.x, pos.y, pos.x, pos.y - 400) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_001806 finish.`); done() }) + /* +* @tc.number SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737 +* @tc.name SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737 +* @tc.desc 1、添加Waterflow组件 + 2、设置Waterflow的参数:设置参数footer +*/ + it('SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737 start.`); + Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737") + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737142 +* @tc.name SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737142 +* @tc.desc 1、添加Waterflow组件 + 2、设置Waterflow的参数:设置参数footer +*/ + it('SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737142', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737142 start.`); + Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737142") + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0350737142 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_1 + * @tc.name SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_1 + * @tc.desc + */ + it('SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_1 start.`); + Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')) + await Utils.sleep(1000) + let center = await water.getBoundsCenter(); + await driver.fling({ + x: center.x, y: center.y + 400 + }, { + x: center.x, y: center.y + }, 5, 40000); + await Utils.sleep(3000) + let button: Component = await driver.findComponent(ON.id('FunctionJichuWaterFlow0380_002')) + await button.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_2 + * @tc.name SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_2 + * @tc.desc + */ + it('SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_2 start.`); + Settings.createWindow("testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('FunctionJichuWaterFlow0380_001')) + await button.click(); + await Utils.sleep(1000); + let water = await driver.findComponent(ON.type('WaterFlow')) + await Utils.sleep(1000); + let center = await water.getBoundsCenter(); + let pointers: PointerMatrix = PointerMatrix.create(1, 3); + pointers.setPoint(0, 0, { + x: center.x, y: center.y + 50 + }); + pointers.setPoint(0, 1, { + x: center.x, y: center.y + 20 + }); + pointers.setPoint(0, 2, { + x: center.x, y: center.y + }); + await Utils.sleep(3000) + await driver.injectMultiPointerAction(pointers); + let button2: Component = await driver.findComponent(ON.id('FunctionJichuWaterFlow0380_002')) + await button2.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_FUNCTION_JICHU_WATERFLOW_0380_2 finish.`); + done() + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets index 0860e1238b7d5125d3247205585c174e61e3e827..8a3caee6c4a05fc120618d4fc9beb0af323ea5f3 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/List.test.ets @@ -149,6 +149,30 @@ import UIComponentPopupBoxToastStyleInterface001 from './UIComponentPopupBoxToastStyleInterfaceTest/UIComponentPopupBoxToastStyleInterface001.test'; import UIComponentPopupBoxFullDialogInterface001 from './UIComponentPopupBoxFullDialogInterfaceTest/UIComponentPopupBoxFullDialogInterface001.test'; + +import UIComponentNavTabsOnWillHide from './UIComponentNavTabsOnWillHideTest/UIComponentNavTabsOnWillHide.test'; +import UIComponentWaterFlowSliding from './UIComponentWaterFlowSlidingTest/UIComponentWaterFlowSliding.test'; +import ArkUIAnimatedResponse from './ArkUIAnimatedResponseTest/ArkUIAnimatedResponse.test'; +import UIComponentNavTabsCapabilityEnhancement from './UIComponentNavTabsCapabilityEnhancementTest/UIComponentNavTabsCapabilityEnhancement.test'; +import UIComponentNavTabsAnimated from './UIComponentNavTabsAnimatedTest/UIComponentNavTabsAnimated.test'; +import UIComponentNavTabsNest from './UIComponentNavTabsNestTest/UIComponentNavTabsNest.test'; +import UIComponentNavTabsUx from './UIComponentNavTabsUxTest/UIComponentNavTabsUx.test'; +import UIComponentNavTabsLayout from './UIComponentNavTabsLayoutTest/UIComponentNavTabsLayout.test'; +import UIComponentOtherRefreshAnimation from './UIComponentOtherRefreshAnimationTest/UIComponentOtherRefreshAnimation.test'; +import UIComponentOtherRefreshInterConnection from './UIComponentOtherRefreshInterConnectionTest/UIComponentOtherRefreshInterConnection.test'; +import UIComponentOtherRefreshOnOffsetChange from './UIComponentOtherRefreshOnOffsetChangeTest/UIComponentOtherRefreshOnOffsetChange.test'; +import UIComponentNavTabsObserver from './UIComponentNavTabsObserverTest/UIComponentNavTabsObserver.test'; +import UIComponentWaterFlowFooter from './UIComponentWaterFlowFooterTest/UIComponentWaterFlowFooter.test'; +import UIComponentTabsClip from './UIComponentTabsClipTest/UIComponentTabsClip.test'; +import UIComponentRefreshPulldownradio from './UIComponentRefreshPulldownradioTest/UIComponentRefreshPulldownradio.test'; +import UIComponentListAndGridXommonOnscroll from './UIComponentListAndGridXommonOnscrollTest/UIComponentListAndGridXommonOnscroll.test'; +import UIComponentNavTabs from './UIComponentNavTabsTest/UIComponentNavTabs.test'; +import UIRefreshComponentContent from './UIRefreshComponentContentTest/UIRefreshComponentContent.test'; +import UIComponentNavTabsOnChange from './UIComponentNavTabsOnChangeTest/UIComponentNavTabsOnChange.test'; +import UIComponentListandgridWaterflowEventenhancement from './UIComponentListandgridWaterflowEventenhancementTest/UIComponentListandgridWaterflowEventenhancement.test'; +import UIComponentListAndGridWaterflowSections from './UIComponentListAndGridWaterflowSectionsTest/UIComponentListAndGridWaterflowSections.test'; +import UIComponentListAndGridWaterflowGetItemMainSizeByIndex from './UIComponentListAndGridWaterflowGetItemMainSizeByIndexTest/UIComponentListAndGridWaterflowGetItemMainSizeByIndex.test'; +import UIComponentListAndGridWaterflowSpring from './UIComponentListAndGridWaterflowSpringTest/UIComponentListAndGridWaterflowSpring.test'; export default function testsuite() { ComponentTextRicheditorFontfeatures(); @@ -166,6 +190,7 @@ export default function testsuite() { ComponentTextRicheditorShortKcutKeysTests(); UIComponentNavTabsOnWillShow(); + UIComponentNavTabsContentAdapt(); ArkUITabScrollable(); ArkUITabsLabelStylefont(); @@ -239,6 +264,31 @@ export default function testsuite() { UIComponentPopupBoxAttribute(); UIComponentPopupBoxPromptToastSequence(); UIComponentPopupBoxSpecificationsPopup(); + + UIComponentNavTabsOnWillHide(); + UIComponentWaterFlowSliding(); + ArkUIAnimatedResponse(); + UIComponentNavTabsCapabilityEnhancement(); + UIComponentNavTabsAnimated(); + UIComponentNavTabsNest(); + UIComponentNavTabsUx(); + UIComponentNavTabsLayout(); + UIComponentOtherRefreshAnimation(); + UIComponentOtherRefreshInterConnection(); + UIComponentOtherRefreshOnOffsetChange(); + UIComponentNavTabsObserver(); + UIComponentWaterFlowFooter(); + UIComponentTabsClip(); + UIComponentRefreshPulldownradio(); + UIComponentListAndGridXommonOnscroll(); + UIComponentNavTabs(); + UIRefreshComponentContent(); + UIComponentNavTabsOnChange(); + UIComponentListandgridWaterflowEventenhancement(); + UIComponentListAndGridWaterflowSections(); + UIComponentListAndGridWaterflowGetItemMainSizeByIndex(); + UIComponentListAndGridWaterflowSpring(); + } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterFlowAddTest/UIComponentListAndGridWaterFlowAdd.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterFlowAddTest/UIComponentListAndGridWaterFlowAdd.test.ets index 60f88eae7f2cd19c24f4b358609875b5c652dbe9..a7fbdaeb63ba49aba798926b8606203f6e9f589c 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterFlowAddTest/UIComponentListAndGridWaterFlowAdd.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterFlowAddTest/UIComponentListAndGridWaterFlowAdd.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentListAndGridWaterFlowAdd() { describe('UIComponentListAndGridWaterFlowAdd', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -40,7 +86,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { await Utils.sleep(1000) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0270_011 finish.`); done() @@ -56,7 +102,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0130_072 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0130072") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0130_072 finish.`); done() @@ -72,7 +118,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0140_666 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0140666") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0140_666 finish.`); done() @@ -88,7 +134,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0160_890 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0160890") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0160_890 finish.`); done() @@ -105,7 +151,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0150_827 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0150827") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0150_827 finish.`); done() @@ -121,7 +167,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0170_444 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0170444") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0170_444 finish.`); done() @@ -137,7 +183,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0280_056 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0280056") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0280_056 finish.`); done() @@ -153,7 +199,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0290_223 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0290223") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0290_223 finish.`); done() @@ -171,7 +217,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0300_414 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0300414") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0300_414 finish.`); done() @@ -187,7 +233,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0310_330 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0310330") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0310_330 finish.`); done() @@ -203,7 +249,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0320_534 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0320534") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0320_534 finish.`); done() @@ -222,7 +268,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0080_458 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0080458") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0080_458 finish.`); done() @@ -241,7 +287,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0090_321 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0090321") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0090_321 finish.`); done() @@ -260,7 +306,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0100_678 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0100678") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0100_678 finish.`); done() @@ -279,7 +325,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0110_972 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0110972") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0110_972 finish.`); done() @@ -298,7 +344,7 @@ export default function UIComponentListAndGridWaterFlowAdd() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0120_725 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterFlowAdd/UIComponentListAndGridWaterFlowAdd0120725") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_ADD_0120_725 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterSectionsTest/UIComponentListAndGridWaterSections.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterSectionsTest/UIComponentListAndGridWaterSections.test.ets index 0bd9f7c778dbe844413096c0c1d2d53ffcbd3ec4..3c5a91f6efda1bab9a2067a90bd9fb4813f6995c 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterSectionsTest/UIComponentListAndGridWaterSections.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterSectionsTest/UIComponentListAndGridWaterSections.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentListAndGridWaterSections() { describe('UIComponentListAndGridWaterSections', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -41,7 +87,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0560 finish.`); done() @@ -68,7 +114,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0380 finish.`); done() @@ -95,7 +141,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0370 finish.`); done() @@ -122,7 +168,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0390 finish.`); done() @@ -149,7 +195,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0410 finish.`); done() @@ -176,7 +222,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0400 finish.`); done() @@ -203,7 +249,7 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0420 finish.`); done() @@ -218,7 +264,7 @@ export default function UIComponentListAndGridWaterSections() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0500 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0500") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0500 finish.`); done() @@ -232,7 +278,7 @@ export default function UIComponentListAndGridWaterSections() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0510 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0510") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0510 finish.`); done() @@ -247,7 +293,7 @@ export default function UIComponentListAndGridWaterSections() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0520 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0520") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0520 finish.`); done() @@ -262,7 +308,7 @@ export default function UIComponentListAndGridWaterSections() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0530 start.`); Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0530") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0530 finish.`); done() @@ -286,10 +332,281 @@ export default function UIComponentListAndGridWaterSections() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0540 finish.`); done() }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0550 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0550 + * @tc.desc 1、创建分组瀑布流 + 2、设置offset属性 + */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0550', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0550 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0550") + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0550 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460 +* @tc.desc 1、创建分组瀑布流,分组中不设置返回高度 +2、scrollEdge跳转测试 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0460") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0460_001')) + await Utils.sleep(1000) + await button1.click() + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0460_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0440 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0440 +* @tc.desc 1、创建分组瀑布流,分组中不设置返回高度 +2、scrollPage跳转测试 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0440', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0440 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0440") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0440_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0440_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0440 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0430 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0430 +* @tc.desc 1、创建分组瀑布流,分组中不设置返回高度 +2、scrollToIndex到分组中的索引 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0430', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0430 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0430") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0430_001')) + await Utils.sleep(1000) + await button1.click() + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0430_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0430 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0450 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0450 +* @tc.desc 1、创建分组瀑布流,分组中不设置返回高度 +2、scrollTo跳转测试 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0450', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0450 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0450") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0450_001')) + await Utils.sleep(1000) + await button1.click() + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0450_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0450 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0490 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0490 +* @tc.desc 1、创建移动窗口布局的分组瀑布流,分组中不设置返回高度 + 2、scrollEdge跳转测试 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0490', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0490 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0490") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0490_001')) + await Utils.sleep(1000) + await button1.click() + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0490_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0490 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0480 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0480 +* @tc.desc 1、创建移动窗口布局的分组瀑布流,分组中不设置返回高度 + 2、scrollPage跳转测试 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0480', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0480 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0480") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0480_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0480_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0480 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0470 +* @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0470 +* @tc.desc 1、创建移动窗口布局的分组瀑布流,分组中不设置返回高度 + 2、scrollToIndex到分组中的索引 +*/ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0470', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0470 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0470") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0470_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0470_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0470 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0060 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0060") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0060_002')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0060 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0580', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0580 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0580") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let waterFlowCenter:Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0580')); + await Utils.sleep(1000) + let pos = await waterFlowCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(2000) + + + let button1 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0580_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(2000) + + let button2 :Component = await driver.findComponent(ON.id('UIComponentListAndGridWaterSections0580_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0580 finish.`); + done() + }) + + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowGetItemMainSizeByIndexTest/UIComponentListAndGridWaterflowGetItemMainSizeByIndex.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowGetItemMainSizeByIndexTest/UIComponentListAndGridWaterflowGetItemMainSizeByIndex.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3981d1409dfb2b61c8efe4549b563fef9de3f065 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowGetItemMainSizeByIndexTest/UIComponentListAndGridWaterflowGetItemMainSizeByIndex.test.ets @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentListAndGridWaterflowGetItemMainSizeByIndex() { + + describe('UIComponentListAndGridWaterflowGetItemMainSizeByIndex', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_656_824 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_656_824 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_656_824', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_656_824 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824"); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_656_824 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_1 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_1 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_1', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_1 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141_002')); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button1 = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141_001')); + await Utils.sleep(1000); + await button1.click(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141_002')); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_624 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_624 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_624', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_2 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624"); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_GETITEMMAINSIZEBTINDEX_0010_141_624 finish.`); + done() + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSectionsTest/UIComponentListAndGridWaterflowSections.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSectionsTest/UIComponentListAndGridWaterflowSections.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..13ebaec3e97913a1002e555fa37288ad2d82be35 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSectionsTest/UIComponentListAndGridWaterflowSections.test.ets @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentListAndGridWaterflowSections() { + + describe('UIComponentListAndGridWaterflowSections', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_1 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_1 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_1', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_1 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211"); + await Utils.sleep(1000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowSections0460211_002')); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_2 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_2 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_2', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_2 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211"); + await Utils.sleep(1000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowSections0460211_002')); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(1000); + let button2 = await driver.findComponent(ON.id('UIComponentListAndGridWaterflowSections0460211_001')); + await Utils.sleep(1000); + await button2.click(); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SECTIONS_0460_211_2 finish.`); + done() + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSpringTest/UIComponentListAndGridWaterflowSpring.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSpringTest/UIComponentListAndGridWaterflowSpring.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dedef2d47e4b8e12db949033ba2f08ccffa2ec89 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridWaterflowSpringTest/UIComponentListAndGridWaterflowSpring.test.ets @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON, PointerMatrix } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentListAndGridWaterflowSpring() { + + describe('UIComponentListAndGridWaterflowSpring', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0180_721 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0180_721 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0180_721', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0180_721 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0180721"); + await Utils.sleep(1000); + let driver = Driver.create(); + let WaterFlow = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let center = await WaterFlow.getBoundsCenter(); + await Utils.sleep(1000); + let pointers: PointerMatrix = PointerMatrix.create(1, 3); + pointers.setPoint(0, 0, { + x: center.x, y: center.y + 50 + }); + pointers.setPoint(0, 1, { + x: center.x, y: center.y + 20 + }); + pointers.setPoint(0, 2, { + x: center.x, y: center.y + }); + await driver.injectMultiPointerAction(pointers,1200); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0180_721 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0150_660 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0150_660 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0150_660', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0150_660 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0150660"); + await Utils.sleep(1000); + let driver = Driver.create(); + let WaterFlow = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let center = await WaterFlow.getBoundsCenter(); + await Utils.sleep(1000); + let pointers: PointerMatrix = PointerMatrix.create(1, 3); + pointers.setPoint(0, 0, { + x: center.x, y: center.y + 80 + }); + pointers.setPoint(0, 1, { + x: center.x, y: center.y + 50 + }); + pointers.setPoint(0, 2, { + x: center.x, y: center.y + }); + await driver.injectMultiPointerAction(pointers,1200); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0150_660 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0250_290 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0250_290 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0250_290', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0250_290 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0250290"); + await Utils.sleep(1000); + let driver = Driver.create(); + let WaterFlow = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let center = await WaterFlow.getBoundsCenter(); + await Utils.sleep(1000); + let pointers: PointerMatrix = PointerMatrix.create(1, 3); + pointers.setPoint(0, 0, { + x: center.x, y: center.y + 80 + }); + pointers.setPoint(0, 1, { + x: center.x, y: center.y + 50 + }); + pointers.setPoint(0, 2, { + x: center.x, y: center.y + }); + await driver.injectMultiPointerAction(pointers,1200); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_SPRING_0250_290 finish.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridXommonOnscrollTest/UIComponentListAndGridXommonOnscroll.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridXommonOnscrollTest/UIComponentListAndGridXommonOnscroll.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7fa149fe0101b13d5efbdf9fa96028da2e1ca6c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListAndGridXommonOnscrollTest/UIComponentListAndGridXommonOnscroll.test.ets @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentListAndGridXommonOnscroll() { + + describe('UIComponentListAndGridXommonOnscroll', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0540_791 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0540_791 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0540_791', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0540_791 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0540791"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0540791_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0540_791 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0530_136 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0530_136 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0530_136', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0530_136 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0530136"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0530136_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0530_136 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0510_711 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0510_711 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0510_711', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0510_711 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0510711"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0510711_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0510_711 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0550_659 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0550_659 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0550_659', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0550_659 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0550659"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0550659_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0550_659 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0570_768 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0570_768 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0570_768', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0570_768 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0570768"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0570768_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0570_768 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0560_601 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0560_601 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0560_601', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0560_601 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0560601"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button = await driver.findComponent(ON.id('UIComponentListAndGridXommonOnscroll0560601_001')); + let point = await button.getBoundsCenter(); + await driver.click(point.x, point.y); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0560_601 finish.`); + done() + }) + /* + * @tc.number UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0680_459 + * @tc.name UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0680_459 + * @tc.desc + */ + it('UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0680_459', 0, async (done: Function) => { + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0680_459 start.`); + Settings.createWindow("testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0680459"); + await Utils.sleep(2000); + let driver = Driver.create(); + let WaterFlow = await driver.findComponent(ON.type('WaterFlow')); + let point = await WaterFlow.getBoundsCenter(); + await driver.swipe(point.x, point.y, point.x, point.y + 100); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `UI_COMPONENT_LISTANDGRID_XOMMON_ONSCROLL_0680_459 finish.`); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListandgridWaterflowEventenhancementTest/UIComponentListandgridWaterflowEventenhancement.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListandgridWaterflowEventenhancementTest/UIComponentListandgridWaterflowEventenhancement.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ff7af48bfb134ceaae19884d6bd2287b035e9bf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentListandgridWaterflowEventenhancementTest/UIComponentListandgridWaterflowEventenhancement.test.ets @@ -0,0 +1,306 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentListandgridWaterflowEventenhancement() { + + describe('UIComponentListandgridWaterflowEventenhancement', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0080_380 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0080_380 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0080_380', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0080_380 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0080380"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.mouseScroll(point, true, 10); + await Utils.sleep(3000); + await driver.mouseScroll(point, false, 10); + await Utils.sleep(3000) + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0080_380 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0200_448 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0200_448 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0200_448', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0200_448 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0200448"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.swipe(point.x, point.y + 100, point.x, point.y - 100); + await Utils.sleep(3000); + await driver.swipe(point.x, point.y - 100, point.x, point.y + 100); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0200_448 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0240_733 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0240_733 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0240_733', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0240_733 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0240733"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.id('UIComponentListandgridWaterflowEventenhancement0240733_001')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.click(point.x, point.y); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0240_733 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0230_655 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0230_655 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0230_655', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0230_655 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0230655"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.mouseScroll(point, true, 10); + await Utils.sleep(3000); + await driver.mouseScroll(point, false, 10); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0230_655 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0300_527 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0300_527 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0300_527', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0300_527 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0300527"); + await Utils.sleep(1000); + let driver = Driver.create(); + let button:Component = await driver.findComponent(ON.id('UIComponentListandgridWaterflowEventenhancement0300527_01')); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.fling(point, { + x: point.x, y: point.y - 100 + }, 5, 600); + await Utils.sleep(3000); + await driver.fling({ + x: point.x, y: point.y - 100 + },point, 5, 600); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0300_527 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0250_294 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0250_294 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0250_294', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0250_294 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0250294"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.swipe(point.x, point.y, point.x, point.y - 100); + await Utils.sleep(3000); + await driver.swipe(point.x, point.y - 100, point.x, point.y); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0250_294 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0290_143 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0290_143 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0290_143', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0290_143 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0290143"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.id('UIComponentListandgridWaterflowEventenhancement0290143_001')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.click(point.x, point.y); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0290_143 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0280_114 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0280_114 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0280_114', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0280_114 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0280114"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.mouseScroll(point, true, 10); + await Utils.sleep(3000); + await driver.mouseScroll(point, false, 10); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0280_114 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0180_890 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0180_890 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0180_890', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0180_890 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0180890"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.id('UIComponentListandgridWaterflowEventenhancement0180890_001')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.click(point.x, point.y); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0180_890 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0090_043 + * @tc.name SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0090_043 + * + * */ + it('SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0090_043', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0090_043 start.`); + Settings.createWindow("testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0090043"); + await Utils.sleep(1000); + let driver = Driver.create(); + let water = await driver.findComponent(ON.type('WaterFlow')); + await Utils.sleep(1000); + let point = await water.getBoundsCenter(); + await Utils.sleep(1000); + await driver.swipe(point.x, point.y + 100, point.x, point.y - 100); + await Utils.sleep(3000); + await driver.swipe(point.x, point.y - 100, point.x, point.y + 100); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_LISTANDGRID_WATERFLOW_EVENTENHANCEMENT_0090_043 finish.`); + done() + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavModifierTest/UIComponentNavModifier.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavModifierTest/UIComponentNavModifier.test.ets index 12e9b46a299fc7bf8c4a3c3f58caf88fc3e9c9d5..457a974de10fd8f022abdbee8c1b4b29c7a49f6f 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavModifierTest/UIComponentNavModifier.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavModifierTest/UIComponentNavModifier.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver, ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavModifier() { describe('UIComponentNavModifier', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0460 * @tc.name SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0460 @@ -32,7 +79,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0460 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier046") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0460 finish.`); done() @@ -55,7 +102,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0530 finish.`); done() @@ -77,7 +124,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0560 finish.`); done() @@ -99,7 +146,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0580 finish.`); done() @@ -121,7 +168,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0830 finish.`); done() @@ -138,7 +185,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0480 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier048") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0480 finish.`); done() @@ -154,7 +201,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0450 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier045") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0450 finish.`); done() @@ -176,7 +223,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0410 finish.`); done() @@ -198,7 +245,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0440 finish.`); done() @@ -220,7 +267,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0430 finish.`); done() @@ -237,7 +284,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0600 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier060") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0600 finish.`); done() @@ -260,7 +307,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0650 finish.`); done() @@ -282,7 +329,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0630 finish.`); done() @@ -304,7 +351,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0660 finish.`); done() @@ -320,7 +367,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0810 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0810") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0810 finish.`); done() @@ -336,7 +383,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0770 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0770") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0770 finish.`); done() @@ -352,7 +399,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0860 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0860") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0860 finish.`); done() @@ -368,7 +415,7 @@ export default function UIComponentNavModifier() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0840 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0840") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0840 finish.`); done() @@ -395,7 +442,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0900 finish.`); done() @@ -421,7 +468,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0920 finish.`); done() @@ -447,7 +494,7 @@ export default function UIComponentNavModifier() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0370 finish.`); done() @@ -461,7 +508,7 @@ export default function UIComponentNavModifier() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0380 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0380") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0380 finish.`); done() @@ -475,7 +522,7 @@ export default function UIComponentNavModifier() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0400 start.`); Settings.createWindow("testability/pages/UIComponentNavModifier/UIComponentNavModifier0400") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_MODIFIER_0400 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsActionTest/UIComponentNavTabsAction.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsActionTest/UIComponentNavTabsAction.test.ets index 9c7a17f444b30e9d3ddceef1830970449312938a..0d283ec82097b761a9bbb43f707aa831f80c5640 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsActionTest/UIComponentNavTabsAction.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsActionTest/UIComponentNavTabsAction.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsAction() { describe('UIComponentNavTabsAction', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0011 @@ -50,7 +97,7 @@ export default function UIComponentNavTabsAction() { let pos1 = await tabsCenter.getBoundsCenter() await driver.swipe(pos1.x-100,pos1.y,pos1.x+300,pos1.y) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0011 finish.`); done() @@ -79,7 +126,7 @@ export default function UIComponentNavTabsAction() { await Utils.sleep(100) await tabBar1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0030 finish.`); done() @@ -110,10 +157,84 @@ export default function UIComponentNavTabsAction() { await driver.swipe(pos.x-100,pos.y,pos.x+356,pos.y) await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0012 finish.`); done() }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0090 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0090") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabBar:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tabBar.click() + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0090 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0180', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0180 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0180") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsAction0180')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0180 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsAction0130_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsAction0140_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ACTION_0140 finish.`); + done() + }) + + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsAnimatedTest/UIComponentNavTabsAnimated.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsAnimatedTest/UIComponentNavTabsAnimated.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fec8c2c6c9e19ab75722c62c04eaca8f4d8b533 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsAnimatedTest/UIComponentNavTabsAnimated.test.ets @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsAnimated() { + + describe('UIComponentNavTabsAnimated', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_012 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_012 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_012', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_012 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated012") + await Utils.sleep(1000) + /*let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + let button2:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(6000)*/ + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_012 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_007 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_007 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_007', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_007 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated007") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated007_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(500) + + let buttonYellow:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await buttonYellow.click() + await Utils.sleep(2000) + + let buttonPink:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(1000) + await buttonPink.click() + await Utils.sleep(2000) + + let clearbutton:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated007_002')); + await Utils.sleep(1000) + await clearbutton.click() + await Utils.sleep(1000) + + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_007 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_005 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_005 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_005', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_005 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated005") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated005_001')); + await Utils.sleep(500) + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(1000) + + + let clearbutton:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated005_002')); + await Utils.sleep(1000) + await clearbutton.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_005 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_003 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_003 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_003', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_003 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated003") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated003_001')); + await Utils.sleep(500) + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(500) + + await button1.click() + await Utils.sleep(1000) + + + let clearbutton:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated003_002')); + await Utils.sleep(1000) + await clearbutton.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_003 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_015 +* @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_015 +* @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_015', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_015 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated015") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsAnimated015_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ANIMATED_015 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsBlurStyleTest/UIComponentNavTabsBlurStyle.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsBlurStyleTest/UIComponentNavTabsBlurStyle.test.ets index e5dabdb4539a51fcdee9aad9e8d08db5c89be36e..627859f6255d64995eb90256b167b13c2c487731 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsBlurStyleTest/UIComponentNavTabsBlurStyle.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsBlurStyleTest/UIComponentNavTabsBlurStyle.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver, ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsBlurStyle() { describe('UIComponentNavTabsBlurStyle', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -93,7 +140,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0016 finish.`); done() @@ -168,7 +215,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0015 finish.`); done() @@ -243,7 +290,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0014 finish.`); done() @@ -318,7 +365,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0013 finish.`); done() @@ -392,7 +439,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0012 finish.`); done() @@ -467,7 +514,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(100) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0017 finish.`); done() @@ -542,7 +589,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(100) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0011 finish.`); done() @@ -617,7 +664,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button13.click() await Utils.sleep(100) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0010 finish.`); done() @@ -638,7 +685,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(1000) let driver: Driver = Driver.create(); await driver.delayMs(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0050 finish.`); done() @@ -659,7 +706,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(1000) let driver: Driver = Driver.create(); await driver.delayMs(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0049 finish.`); done() @@ -689,7 +736,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button2.click() await Utils.sleep(100) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0048 finish.`); done() @@ -707,7 +754,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0042 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0042") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0042 finish.`); done() @@ -725,7 +772,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0046 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0046") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0046 finish.`); done() @@ -743,7 +790,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0043 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0043") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0043 finish.`); done() @@ -760,7 +807,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0045 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0045") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0045 finish.`); done() @@ -778,7 +825,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0044 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0044") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0044 finish.`); done() @@ -795,7 +842,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0038 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0038") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0038 finish.`); done() @@ -814,7 +861,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0041 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0041") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0041 finish.`); done() @@ -833,7 +880,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0040 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0040") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0040 finish.`); done() @@ -864,7 +911,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(100) await button2.click() await Utils.sleep(100) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0039 finish.`); done() @@ -882,7 +929,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0033 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0033") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0033 finish.`); done() @@ -900,7 +947,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0034 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0034") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0034 finish.`); done() @@ -918,7 +965,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0036 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0036") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0036 finish.`); done() @@ -936,7 +983,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0035 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0035") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0035 finish.`); done() @@ -953,7 +1000,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0032 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0032") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0032 finish.`); done() @@ -972,7 +1019,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0031 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0031") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0031 finish.`); done() @@ -991,7 +1038,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0030 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0030") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0030 finish.`); done() @@ -1022,7 +1069,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0029 finish.`); done() @@ -1041,7 +1088,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0018 finish.`); done() @@ -1060,7 +1107,7 @@ export default function UIComponentNavTabsBlurStyle() { await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0019 finish.`); done() @@ -1074,7 +1121,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0020 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0020") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0020 finish.`); done() @@ -1088,7 +1135,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0021 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0021") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0021 finish.`); done() @@ -1102,7 +1149,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0022 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0022") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0022 finish.`); done() @@ -1116,7 +1163,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0023 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0023") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0023 finish.`); done() @@ -1130,7 +1177,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0024 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0024") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0024 finish.`); done() @@ -1144,7 +1191,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0025 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0025") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0025 finish.`); done() @@ -1158,7 +1205,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0026 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0026") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0026 finish.`); done() @@ -1172,7 +1219,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0026 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0027") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0027 finish.`); done() @@ -1186,7 +1233,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0028 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0028") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0028 finish.`); done() @@ -1200,7 +1247,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0047 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0047") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0047 finish.`); done() @@ -1214,7 +1261,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0051 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0051") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0051 finish.`); done() @@ -1228,7 +1275,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0052 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0052") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0052 finish.`); done() @@ -1242,7 +1289,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0053 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0053") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0053 finish.`); done() @@ -1256,7 +1303,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0060 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0060") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0060 finish.`); done() @@ -1270,7 +1317,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0080 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0080") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0080 finish.`); done() @@ -1284,7 +1331,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0100 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0100") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0100 finish.`); done() @@ -1298,7 +1345,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0110 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0110") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0110 finish.`); done() @@ -1312,7 +1359,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0160 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0160") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0160 finish.`); done() @@ -1326,7 +1373,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0170 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0170") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0170 finish.`); done() @@ -1340,7 +1387,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0180 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0180") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0180 finish.`); done() @@ -1354,7 +1401,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0190 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0190") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0190 finish.`); done() @@ -1368,7 +1415,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0200 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0200") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0200 finish.`); done() @@ -1382,7 +1429,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0210 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0210") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0210 finish.`); done() @@ -1396,7 +1443,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0220 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0220") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `ccSUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0220 finish.`); done() @@ -1410,7 +1457,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0230 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0230") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0230 finish.`); done() @@ -1424,7 +1471,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0240 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0240") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0240 finish.`); done() @@ -1438,7 +1485,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0250 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0250") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0250 finish.`); done() @@ -1452,7 +1499,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0260 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0260") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0260 finish.`); done() @@ -1466,7 +1513,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0270 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0270") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0270 finish.`); done() @@ -1480,7 +1527,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0280 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0280") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0280 finish.`); done() @@ -1494,7 +1541,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0290 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0290") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0290 finish.`); done() @@ -1508,7 +1555,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0300 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0300") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0300 finish.`); done() @@ -1522,7 +1569,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0310 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0310") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0310 finish.`); done() @@ -1536,7 +1583,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0320 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0320") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0320 finish.`); done() @@ -1550,7 +1597,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0340 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0340") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0340 finish.`); done() @@ -1564,7 +1611,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0350 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0350") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0350 finish.`); done() @@ -1578,7 +1625,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0360 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0360") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0360 finish.`); done() @@ -1592,7 +1639,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0370 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0370") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0370 finish.`); done() @@ -1606,7 +1653,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0380 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0380") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0380 finish.`); done() @@ -1620,7 +1667,7 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0390 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0390") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0390 finish.`); done() @@ -1634,12 +1681,118 @@ export default function UIComponentNavTabsBlurStyle() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0400 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0400") await Utils.sleep(1000) - await windowSnap.snapShot() + await await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0400 finish.`); done() }) + it('SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_1', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_1 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button1: Component = await driver.findComponent(ON.id('UIComponentNavTabsBlurStyle0037_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + await button1.click() + await Utils.sleep(3000) + + await await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_1 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_2', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_2 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button1: Component = await driver.findComponent(ON.id('UIComponentNavTabsBlurStyle0037_002')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + await button1.click() + await Utils.sleep(3000) + + await await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_2 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_3', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_3 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button1: Component = await driver.findComponent(ON.id('UIComponentNavTabsBlurStyle0037_003')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + await button1.click() + await Utils.sleep(3000) + + await await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_3 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_4', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_4 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button1: Component = await driver.findComponent(ON.id('UIComponentNavTabsBlurStyle0037_004')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + await button1.click() + await Utils.sleep(3000) + + await await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_4 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_5', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_5 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button1: Component = await driver.findComponent(ON.id('UIComponentNavTabsBlurStyle0037_005')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + await button1.click() + await Utils.sleep(3000) + + await await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_BLURSTYLE_0037_5 finish.`); + done() + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCachedCountTest/UIComponentNavTabsCachedCount.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCachedCountTest/UIComponentNavTabsCachedCount.test.ets index 764434b8c2b2c931b4e999d6ff9f380ce62b05fb..4fbacc0c53dd58be36d08bcd4046b29a5b83ab4f 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCachedCountTest/UIComponentNavTabsCachedCount.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCachedCountTest/UIComponentNavTabsCachedCount.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,76 +18,656 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsCachedCount() { describe('UIComponentNavTabsCachedCount', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* - * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140 - * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140 - * @tc.desc 1、创建tabs,设置BarPosition.Start 2、设置preloadItens[1,3] - */ - it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140', 0, async (done: Function) => { - Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140 start.`); - Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount014") + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_016 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_016 + * @tc.desc 1、创建tabs,设置BarPosition动态改变 + 2、设置preloadItens[1,3] + 3、动态切换BarPosition + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_016', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_016 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount016") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabs016_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(1000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_016 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0290 +* @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0290 +* @tc.desc 1、创建tabs,设置BarPosition动态改变 + 2、设置preloadItens[1,3] + 3、动态切换BarPosition +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0290', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0290 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0290") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0290_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0290 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0280 +* @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0280 +* @tc.desc 1、创建tabs,设置BarPosition动态改变 + 2、设置preloadItens[1,3] + 3、动态切换BarPosition +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0280', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0280 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0280") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0280_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0280 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0010_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0020_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0020 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0030 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0030") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0030_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0030 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0040 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0040_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0050 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0050") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0050_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0050 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0060 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0060") await Utils.sleep(1000) let driver : Driver = Driver.create(); await driver.delayMs(1000) - let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabs014_001')); + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0060_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0060 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0070_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0070 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0080 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0080") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0080_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0080 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0090 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0090") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0090_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0090 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0100_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0100 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0110") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0110_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0110 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0120', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0120 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0120") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0120_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0120 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0130_001')); + await Utils.sleep(1000) + await button1.click() await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0130_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0140_001')); + await Utils.sleep(1000) + await button.click() await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0140 finish.`); done() }) - /* - * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0150 - * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0150 - * @tc.desc 1、创建tabs,设置BarPosition.End 2、设置preloadItens[1,3] - */ it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0150', 0, async (done: Function) => { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0150 start.`); - Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount015") + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0150") await Utils.sleep(1000) let driver : Driver = Driver.create(); await driver.delayMs(1000) - let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabs015_001')); - await Utils.sleep(1000) - await button1.click() + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0150_001')); await Utils.sleep(1000) - windowSnap.snapShot() + await button.click() await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0150 finish.`); done() }) - /* - * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160 - * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160 - * @tc.desc 1、创建tabs,设置BarPosition动态改变 - 2、设置preloadItens[1,3] - 3、动态切换BarPosition - */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160', 0, async (done: Function) => { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160 start.`); - Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount016") + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0160") await Utils.sleep(1000) let driver : Driver = Driver.create(); await driver.delayMs(1000) - let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabs016_002')); + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0160_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0160_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0170_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0170 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0180', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0180 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0180") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0180_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0180 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0190', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0190 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0190") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0190_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0190 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0200', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0200 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0200") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0200_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0200_002')); await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0200 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0210', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0210 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0210") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0210_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0210_002')); + await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0210 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0220', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0220 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0220") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsCachedCount0220_001')); await Utils.sleep(1000) - Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0160 finish.`); + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0220 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0230', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0230 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0230") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0230_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0230 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0240', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0240 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0240") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0240_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('发现')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0240 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0250', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0250 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0250") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0250_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('发现')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0250 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0260', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0260 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0260") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0260_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('发现')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0260 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0270', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0270 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0270") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0270_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('tabsCachedCount0270_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0270 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0300', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0300 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0300") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('tabsCachedCount0300_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CACHEDCOUNT_0300 finish.`); done() }) diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCapabilityEnhancementTest/UIComponentNavTabsCapabilityEnhancement.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCapabilityEnhancementTest/UIComponentNavTabsCapabilityEnhancement.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6cd4638e3b8411b02814ff28161e0d9cbc5bf9c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsCapabilityEnhancementTest/UIComponentNavTabsCapabilityEnhancement.test.ets @@ -0,0 +1,453 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsCapabilityEnhancement() { + + describe('UIComponentNavTabsCapabilityEnhancement', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0030 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0030 + * @tc.desc 1、创建Tabs包含5个TabContent,index=0 + 2、设置onContentWil1Change接口,如果comingIndex为3,return true,编译安装 + 3、点击素引3页的tabbar + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0030 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0030") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0030')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(1000) + + let tabBar5:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0030_001')); + await Utils.sleep(500) + await tabBar5.click() + await Utils.sleep(500) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0030 finish.`); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0010 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0010 + * @tc.desc 1、创建Tabs包含5个TabContent,index=0 + 2、设置onContentWil1Change接口,如果comingIndex为3,return true,编译安装 + 3、点击素引3页的tabbar + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0010')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(1000) + + let tabBar5:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0010_001')); + await Utils.sleep(500) + await tabBar5.click() + await Utils.sleep(500) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0010 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0040 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0040')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(500) + + await tabsCenter.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0090 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0090") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0090')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0090 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0080 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0080") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0080')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y-200) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0080 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabBar5:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tabBar5.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0100 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0120', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0120 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0120") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y-200) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0120 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0110") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + + let tabBarYellow:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tabBarYellow.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0110 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0150', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0150") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0150')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.fling({x: pos.x, y: pos.y+200},{x: pos.x, y: pos.y-200},5,4000); + await Utils.sleep(2000) + + await driver.fling({x: pos.x, y: pos.y+200},{x: pos.x, y: pos.y-200},5,4000); + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0150 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0020')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y+200, pos.x, pos.y-200); + await Utils.sleep(2000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0020 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0160')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y+200, pos.x, pos.y-200); + await Utils.sleep(2000) + await driver.swipe(pos.x, pos.y-200, pos.x, pos.y+200); + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0160 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsCapabilityEnhancement0130')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y+50, pos.x, pos.y-50); + await Utils.sleep(2000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsYellow:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tabsYellow.click() + await Utils.sleep(3000) + + let tabsBlue:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tabsBlue.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0140 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0050 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0050") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsYellow:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tabsYellow.click() + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0050 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0019', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0019 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0019") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsblue:Component = await driver.findComponent(ON.id('blue')); + await Utils.sleep(1000) + await tabsblue.click() + await Utils.sleep(2000) + + let tabsgreen:Component = await driver.findComponent(ON.id('green')); + await Utils.sleep(1000) + await tabsgreen.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0019 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0060 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsblue:Component = await driver.findComponent(ON.id('blue')); + await Utils.sleep(1000) + await tabsblue.click() + await Utils.sleep(2000) + + let tabsgreen:Component = await driver.findComponent(ON.id('green')); + await Utils.sleep(1000) + await tabsgreen.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0060 finish.`); + done() + }) + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsblue:Component = await driver.findComponent(ON.id('blue')); + await Utils.sleep(1000) + await tabsblue.click() + await Utils.sleep(2000) + + let tabsgreen:Component = await driver.findComponent(ON.id('green')); + await Utils.sleep(1000) + await tabsgreen.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CAPABILITY_ENHANCEMENT_0070 finish.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsContentAdaptTest/UIComponentNavTabsContentAdapt.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsContentAdaptTest/UIComponentNavTabsContentAdapt.test.ets index 2cf0a074255dab4bb0c450dc5eb0aca3e305bd01..40af161b75aa13105dd355b3ae83ad7e99b84ea0 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsContentAdaptTest/UIComponentNavTabsContentAdapt.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsContentAdaptTest/UIComponentNavTabsContentAdapt.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsContentAdapt() { describe('UIComponentNavTabsContentAdapt', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -43,7 +89,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await tabBar1.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0310 finish.`); done() @@ -59,7 +105,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0010 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt001") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0010 finish.`); done() @@ -74,7 +120,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0020 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt002") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0020 finish.`); done() @@ -89,7 +135,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0030 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt003") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0030 finish.`); done() @@ -104,7 +150,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0040 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt004") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0040 finish.`); done() @@ -120,7 +166,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0100 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt010") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0100 finish.`); done() @@ -135,7 +181,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0110 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt011") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0110 finish.`); done() @@ -150,7 +196,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0120 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt012") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0120 finish.`); done() @@ -166,7 +212,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0130 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt013") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0130 finish.`); done() @@ -189,7 +235,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0330 finish.`); done() @@ -223,7 +269,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button4.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0340 finish.`); done() @@ -256,7 +302,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0350 finish.`); done() @@ -290,7 +336,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button4.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0070 finish.`); done() @@ -311,7 +357,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0320 finish.`); done() @@ -327,7 +373,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0140 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt014") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0140 finish.`); done() @@ -353,7 +399,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0270 finish.`); done() @@ -391,7 +437,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button5.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0280 finish.`); done() @@ -407,7 +453,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0300 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt030") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0300 finish.`); done() @@ -433,7 +479,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0080 finish.`); done() @@ -449,7 +495,7 @@ export default function UIComponentNavTabsContentAdapt() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0050 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0050") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0050 finish.`); done() @@ -473,7 +519,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0210 finish.`); done() @@ -497,7 +543,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0150 finish.`); done() @@ -521,7 +567,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0240 finish.`); done() @@ -545,7 +591,7 @@ export default function UIComponentNavTabsContentAdapt() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0180 finish.`); done() @@ -563,7 +609,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0220_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0220 finish.`); done() @@ -581,7 +627,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0160_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0160 finish.`); done() @@ -599,7 +645,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0250_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0250 finish.`); done() @@ -617,7 +663,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0190_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0190 finish.`); done() @@ -635,7 +681,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0170_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0170 finish.`); done() @@ -653,7 +699,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0200_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0200 finish.`); done() @@ -671,7 +717,7 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0230_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0230 finish.`); done() @@ -689,11 +735,91 @@ export default function UIComponentNavTabsContentAdapt() { let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentadapt0260_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0260 finish.`); done() }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0380 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0380 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0380', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0380 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0380") + await Utils.sleep(1000) + let driver: Driver = Driver.create() + await driver.delayMs(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsContentAdapt0380')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y-200) + await Utils.sleep(1000) + await driver.swipe(pos.x,pos.y-200,pos.x,pos.y+200) + await Utils.sleep(1000) + + let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentAdapt0380_001')) + await Utils.sleep(500) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0380 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0360 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0360 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0360', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0360 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0360") + await Utils.sleep(1000) + let driver: Driver = Driver.create() + await driver.delayMs(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsContentAdapt0360')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y-200) + await Utils.sleep(1000) + await driver.swipe(pos.x,pos.y-200,pos.x,pos.y+200) + await Utils.sleep(1000) + + let button: Component = await driver.findComponent(ON.id('UIComponentNavTabsContentAdapt0360_001')) + await Utils.sleep(500) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0360 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0370', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0370 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0370") + await Utils.sleep(1000) + let driver: Driver = Driver.create() + await driver.delayMs(500) + + let button: Component = await driver.findComponent(ON.id('2')) + await Utils.sleep(500) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_CONTENTADAPT_0370 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsEdgeeffectTest/UIComponentNavTabsEdgeeffect.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsEdgeeffectTest/UIComponentNavTabsEdgeeffect.test.ets index c40fb8c1875d17bc8c262d644cbe1c6663924561..23a48c6734c94058ca85acc915ce40325990ccea 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsEdgeeffectTest/UIComponentNavTabsEdgeeffect.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsEdgeeffectTest/UIComponentNavTabsEdgeeffect.test.ets @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsEdgeeffect() { describe('UIComponentNavTabsEdgeeffect', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0230 * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0230 @@ -32,7 +78,7 @@ export default function UIComponentNavTabsEdgeeffect() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0230 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0230") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0230 finish.`); done() @@ -46,10 +92,202 @@ export default function UIComponentNavTabsEdgeeffect() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0270 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0270") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0270 finish.`); done() }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0200 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0200 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0200 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0200") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0200')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0200_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0200 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0190 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0190 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0190', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0190 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0190") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0190')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0190_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0190 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0170 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0170 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0170', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0170") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0170')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0170_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0170 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0220 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0220 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0220', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0220 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0220") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0220')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0220_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0220 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0210 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0210 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0210 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0210") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0210')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0210_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0210 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0180 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0180 + * @tc.desc nav width + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0180', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0180 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0180") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0180')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-100,pos.y,pos.x+200,pos.y) + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0180_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0180 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsEdgeeffect0100')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-200,pos.y,pos.x+200,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EDGEEFFECT_0100 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsExpandsafeareaTest/UIComponentNavTabsExpandsafearea.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsExpandsafeareaTest/UIComponentNavTabsExpandsafearea.test.ets index 48b15dd262f8ad2dd0b7efab5b306eed1b0bdd05..67bd608ff5b6897816fd664e2391882a226b662f 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsExpandsafeareaTest/UIComponentNavTabsExpandsafearea.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsExpandsafeareaTest/UIComponentNavTabsExpandsafearea.test.ets @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsExpandsafearea() { describe('UIComponentNavTabsExpandsafearea', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0090 * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0090 @@ -35,7 +81,7 @@ export default function UIComponentNavTabsExpandsafearea() { // let driver: Driver = Driver.create() // let button: Component = await driver.findComponent(ON.id('UIComponentTabTabbarTabbarsymbol0050_001')) // await button.click() - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0090 finish.`); done() @@ -49,7 +95,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0090 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0010") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0090 finish.`); done() @@ -63,7 +109,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0120 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0120") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0120 finish.`); done() @@ -77,7 +123,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0050 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0050") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0050 finish.`); done() @@ -91,7 +137,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0080 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0080") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0080 finish.`); done() @@ -105,7 +151,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0070 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0070") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0070 finish.`); done() @@ -119,7 +165,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0060 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0060") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0060 finish.`); done() @@ -133,7 +179,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0040 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0040") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0040 finish.`); done() @@ -147,7 +193,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0030 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0030") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0030 finish.`); done() @@ -161,7 +207,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0020 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0020") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0020 finish.`); done() @@ -175,7 +221,7 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0100 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0100") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0100 finish.`); done() @@ -189,10 +235,71 @@ export default function UIComponentNavTabsExpandsafearea() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0110 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0110") await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(3000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0110 finish.`); done() }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0130 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0130 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0130', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0130"); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0130 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0140 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0140 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0140', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0140"); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0140 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0150 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0150 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0150', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0150"); + await Utils.sleep(2000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0150 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0160 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0160 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0160', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0160"); + await Utils.sleep(2000); + let driver = Driver.create(); + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsExpandsafearea0160_001')); + await Utils.sleep(1000); + await button.click(); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_EXPANDSAFEAREA_0160 finish.`); + done(); + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsHeightTest/UIComponentNavTabsHeight.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsHeightTest/UIComponentNavTabsHeight.test.ets index aad3189a1be0291fbf0d0170441db0c00781eb86..128ac5276517ee6b7208e9408bb1e75d05fea520 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsHeightTest/UIComponentNavTabsHeight.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsHeightTest/UIComponentNavTabsHeight.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsHeight() { describe('UIComponentNavTabsHeight', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_HEIGHT_0010 * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_HEIGHT_0010 @@ -33,7 +79,7 @@ export default function UIComponentNavTabsHeight() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_HEIGHT_0010 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsHeight/UIComponentNavTabsHeight001") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_HEIGHT_0010 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsImproTraceTest/UIComponentNavTabsImproTrace.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsImproTraceTest/UIComponentNavTabsImproTrace.test.ets index ebabf71df0bd7811fd4ea809df34b7dce2e32766..4a6254c2859b663231f944d763b2c98416568225 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsImproTraceTest/UIComponentNavTabsImproTrace.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsImproTraceTest/UIComponentNavTabsImproTrace.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsImproTrace() { describe('UIComponentNavTabsImproTrace', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0150 @@ -44,7 +90,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0150 finish.`); done() @@ -70,7 +116,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0140 finish.`); done() @@ -96,7 +142,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0120 finish.`); done() @@ -124,7 +170,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0080 finish.`); done() @@ -152,7 +198,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await driver.swipe(pos.x,pos.y+250,pos.x+350,pos.y+250) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0040 finish.`); done() @@ -178,7 +224,7 @@ export default function UIComponentNavTabsImproTrace() { let pos = await tabsCenter.getBoundsCenter() await driver.swipe(pos.x,pos.y+250,pos.x+200,pos.y+250) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0060 finish.`); done() @@ -204,7 +250,7 @@ export default function UIComponentNavTabsImproTrace() { let pos = await tabsCenter.getBoundsCenter() await driver.swipe(pos.x+300,pos.y,pos.x-300,pos.y) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0070 finish.`); done() @@ -230,7 +276,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(1000) await tabBar.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0030 finish.`); done() @@ -246,7 +292,7 @@ export default function UIComponentNavTabsImproTrace() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0020 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0020") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0020 finish.`); done() @@ -301,7 +347,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(500) await button9.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0160 finish.`); done() @@ -327,7 +373,7 @@ export default function UIComponentNavTabsImproTrace() { await Utils.sleep(500) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0130 finish.`); done() @@ -343,12 +389,52 @@ export default function UIComponentNavTabsImproTrace() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0010 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0010") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0010 finish.`); done() }) + it('SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0110") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsImproTrace0110_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0110 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsImproTrace0170_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(3000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsImproTrace0170')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+250,pos.y,pos.x-250,pos.y) + await Utils.sleep(2000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_IMPROTRACE_0170 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterceptionTest/UIComponentNavTabsInterception.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterceptionTest/UIComponentNavTabsInterception.test.ets index e30fe0a5afa1508c0979cc14c8e1a4cf22feb6db..81ff322c445a032d9e9dc3ce554eca15b76531b6 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterceptionTest/UIComponentNavTabsInterception.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterceptionTest/UIComponentNavTabsInterception.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsInterception() { describe('UIComponentNavTabsInterception', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -42,7 +89,7 @@ export default function UIComponentNavTabsInterception() { let pos = await tabsCenter.getBoundsCenter() await driver.swipe(pos.x,pos.y,pos.x-56,pos.y) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0130 finish.`); done() @@ -66,7 +113,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0040 finish.`); done() @@ -90,7 +137,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0060 finish.`); done() @@ -114,7 +161,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await tabBar.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0080 finish.`); done() @@ -138,7 +185,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0050 finish.`); done() @@ -161,7 +208,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0070 finish.`); done() @@ -191,7 +238,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0010 finish.`); done() @@ -232,7 +279,7 @@ export default function UIComponentNavTabsInterception() { await driver.swipe(pos.x-100,pos.y,pos.x+356,pos.y) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0030 finish.`); done() @@ -260,7 +307,7 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0150 finish.`); done() @@ -283,12 +330,112 @@ export default function UIComponentNavTabsInterception() { await Utils.sleep(1000) await tabBar.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0090 finish.`); done() }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0020 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0020 + * @tc.desc 1、创建Tabs包含5个TabContent,index=0 + 2、设置onContentWil1Change接口,如果comingIndex为3,return true,编译安装 + 3、点击素引3页的tabbar + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabBar3:Component = await driver.findComponent(ON.id('three')); + await Utils.sleep(500) + await tabBar3.click() + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsInterception0020')); + await Utils.sleep(1000) + let pos3 = await tabsCenter.getBoundsCenter() + await driver.swipe(pos3.x+100,pos3.y,pos3.x-100,pos3.y) + await Utils.sleep(1000) + + let tabBar5:Component = await driver.findComponent(ON.id('five')); + await Utils.sleep(500) + await tabBar5.click() + await Utils.sleep(500) + + let pos5 = await tabsCenter.getBoundsCenter() + await driver.swipe(pos5.x-100,pos5.y,pos5.x+100,pos5.y) + await Utils.sleep(1000) + + let tabBar1:Component = await driver.findComponent(ON.id('one')); + await Utils.sleep(500) + await tabBar1.click() + await Utils.sleep(500) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0020 finish.`); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0160 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0160 + * @tc.desc 1、创建Tabs包含5个TabContent,index=0 + 2、设置onContentWil1Change接口,如果comingIndex为3,return true,编译安装 + 3、点击素引3页的tabbar + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabBar3:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(500) + await tabBar3.click() + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsInterception0160')); + await Utils.sleep(1000) + let pos3 = await tabsCenter.getBoundsCenter() + await driver.swipe(pos3.x+100,pos3.y,pos3.x-100,pos3.y) + await Utils.sleep(1000) + + let tabBar0:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(500) + await tabBar0.click() + await Utils.sleep(500) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0160 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabBar3:Component = await driver.findComponent(ON.id('Green')); + await Utils.sleep(1000) + await tabBar3.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERCEPTION_0140 finish.`); + done() + }) }) diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterfaceTest/UIComponentNavTabsInterface.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterfaceTest/UIComponentNavTabsInterface.test.ets index 826714182f47bfdb0b6470b6407a34dc0c625ce6..68096b0646c410671c81e7539b7a637d52f16e3e 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterfaceTest/UIComponentNavTabsInterface.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsInterfaceTest/UIComponentNavTabsInterface.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsInterface() { describe('UIComponentNavTabsInterface', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0120 @@ -38,7 +84,7 @@ export default function UIComponentNavTabsInterface() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0120 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface012") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0120 finish.`); done() @@ -68,7 +114,7 @@ export default function UIComponentNavTabsInterface() { await Utils.sleep(100) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_1190 finish.`); done() @@ -93,11 +139,46 @@ export default function UIComponentNavTabsInterface() { let pos = await tabsCenter.getBoundsCenter() await driver.swipe(pos.x,pos.y,pos.x-100,pos.y) await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_1220 finish.`); done() }) + it('SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0150', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0150") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsInterface0150_001')); + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0150 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsInterface0170_001')); + await Utils.sleep(1000) + + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_INTERFACE_0170 finish.`); + done() + }) + + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsLayoutTest/UIComponentNavTabsLayout.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsLayoutTest/UIComponentNavTabsLayout.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0baa9b984ea9cdb77e7bf2f0217b29b27f54e1b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsLayoutTest/UIComponentNavTabsLayout.test.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsLayout() { + + describe('UIComponentNavTabsLayout', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_LAYOUT_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_LAYOUT_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsLayout/UIComponentNavTabsLayout0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentNavTabsLayout0070')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-150,pos.y,pos.x+150,pos.y) + await Utils.sleep(4000) + + await driver.swipe(pos.x,pos.y,pos.x,pos.y+100) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_LAYOUT_0070 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsMirrorTest/UIComponentNavTabsMirror.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsMirrorTest/UIComponentNavTabsMirror.test.ets index 66e339f31b8f9cc6d50f0b85ff6ea41ee5e74db9..47c6675a66a4e7317e6e56d018b073f6f4795f42 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsMirrorTest/UIComponentNavTabsMirror.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsMirrorTest/UIComponentNavTabsMirror.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsMirror() { describe('UIComponentNavTabsMirror', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -41,7 +88,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0100 finish.`); done() @@ -69,7 +116,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_0OMPONENT_NAV_TABS_MIRROR_0070 finish.`); done() @@ -94,7 +141,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0030 finish.`); done() @@ -119,7 +166,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0090 finish.`); done() @@ -142,7 +189,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(500) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0110 finish.`); done() @@ -164,7 +211,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(500) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0160 finish.`); done() @@ -189,7 +236,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0120 finish.`); done() @@ -215,7 +262,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0140 finish.`); done() @@ -239,7 +286,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0130 finish.`); done() @@ -269,7 +316,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(100) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0150 finish.`); done() @@ -304,7 +351,7 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(200) await button.click() await Utils.sleep(200) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0260 finish.`); done() @@ -327,9 +374,9 @@ export default function UIComponentNavTabsMirror() { let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsMirror0250_001')); await Utils.sleep(1000) await button.click() - await Utils.sleep(1000) - windowSnap.snapShot() await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0250 finish.`); done() }) @@ -367,12 +414,196 @@ export default function UIComponentNavTabsMirror() { await Utils.sleep(1000) await button5.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0080 finish.`); done() }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0320', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0320 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0320") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsMirror0320_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0320 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0190', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0190 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0190") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('tabsMirror0190_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0190 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0200', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0200 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0200") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('tabsMirror0200_001')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0200 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0210', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0210 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0210") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('tabsMirror0210_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + let button3:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button3.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0210 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0220', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0220 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0220") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('tabsMirror0220_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + let button3:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button3.click() + await Utils.sleep(2000) + + let tabsCenter:Component = await driver.findComponent(ON.id('tabsMirror0220')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0220 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0230', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0230 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0230") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('tabsMirror0230_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + let button3:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button3.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0230 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0240', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0240 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0240") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsMirror0240_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + let button3:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button3.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_MIRROR_0240 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsNestTest/UIComponentNavTabsNest.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsNestTest/UIComponentNavTabsNest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..970dcb89953df70de991122d5e0b2c0d5ef9a7f1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsNestTest/UIComponentNavTabsNest.test.ets @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsNest() { + + describe('UIComponentNavTabsNest', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + + + /* + * @tc.number SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0010 + * @tc.name SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0010 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsNest0010')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+100,pos.y,pos.x-356,pos.y) + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button1:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsNest0020')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+100,pos.y,pos.x-356,pos.y) + await Utils.sleep(1000) + + let button2:Component = await driver.findComponent(ON.id('Pink')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COIIPONENT_NAV_TABS_NEST_0020 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsObserverTest/UIComponentNavTabsObserver.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsObserverTest/UIComponentNavTabsObserver.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dd5fbde9b43ca55fc249258156a41e88adc7026 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsObserverTest/UIComponentNavTabsObserver.test.ets @@ -0,0 +1,466 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsObserver() { + + describe('UIComponentNavTabsObserver', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0020', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0020") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0020 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0030', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0030 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0030") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button2:Component = await driver.findComponent(ON.id('blue')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0030 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0010', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0010") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0160', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0160") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+120,pos.y,pos.x-120,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0160 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0060', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0060 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0060") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + tarBarCenter.click() + await Utils.sleep(500) + tarBarCenter.click() + await Utils.sleep(500) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0060_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0060_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0060 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0100', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0100") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0100_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0100 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0170', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0170") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+120,pos.y,pos.x-120,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0170 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0150', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0150") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0150 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0110', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0110") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+200,pos.y,pos.x-200,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0110 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0210 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0210") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0210 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0200 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0200") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0200 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0080', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0080 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0080") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0080_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0080 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0090', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0090 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0090") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0090_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0090 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0040', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0040 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0040") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0040_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0070', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0070") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0070_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0070 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0120', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0120 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0120") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0120_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0120 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0130', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0130") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0130_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0050', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0050 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0050") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBarCenter :Component = await driver.findComponent(ON.id('testId')) + await Utils.sleep(1000) + let pos = await tarBarCenter.getBoundsCenter() + await driver.swipe(pos.x+150,pos.y,pos.x-150,pos.y) + await Utils.sleep(2000) + + tarBarCenter.click() + await Utils.sleep(1000) + tarBarCenter.click() + await Utils.sleep(1000) + + let button1:Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0050_001')); + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(2000) + + let button2:Component = await driver.findComponent(ON.id('UIComponentNavTabsObserver0050_002')); + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_OBSERVER_0050 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnChangeTest/UIComponentNavTabsOnChange.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnChangeTest/UIComponentNavTabsOnChange.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..946a1a2a99c5e96034ba96ebbc5d00323103ec02 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnChangeTest/UIComponentNavTabsOnChange.test.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsOnChange() { + + describe('UIComponentNavTabsOnChange', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_ONCHANGE_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ONCHANGE_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnChange/UIComponentNavTabsOnChange0010") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let tarBar1 :Component = await driver.findComponent(ON.id('Blue')) + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('tabsOnChange0010')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-90,pos.x,pos.y+90) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_ONCHANGE_0010 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillHideTest/UIComponentNavTabsOnWillHide.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillHideTest/UIComponentNavTabsOnWillHide.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dae7238a478217921bee934f60a12d8ac86b11e4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillHideTest/UIComponentNavTabsOnWillHide.test.ets @@ -0,0 +1,427 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsOnWillHide() { + + describe('UIComponentNavTabsOnWillHide', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWillHide_0110 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWillHide_0110 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWillHide_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWillHide_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0110") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWillHide_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0060 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0060 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0060 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0060')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+50,pos.x,pos.y-50) + await Utils.sleep(1000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0060 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0160 +* @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0160 +* @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 +*/ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0160')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0160_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0160 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0010')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0100_002')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0100 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0190', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0190 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0190") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0190')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0190 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0070')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0070 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0080 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0080") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0080')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0080_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0080 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0040 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0040')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0020')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0020 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0150', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0150") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0150')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0150 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0120', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0120 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0120") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillHide0120')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0120 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsYellow :Component = await driver.findComponent(ON.id('Yellow')) + await Utils.sleep(1000) + await tabsYellow.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0140 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0030 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0030") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsYellow :Component = await driver.findComponent(ON.id('Yellow')) + await Utils.sleep(1000) + await tabsYellow.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0030 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('tabsOnWillhide0130_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('two')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0170 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0050 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0050") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button1 :Component = await driver.findComponent(ON.id('three')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('tabsOnWillhide0050')); + await Utils.sleep(1000) + + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-30,pos.y,pos.x+30,pos.y) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLHIDE_0050 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillShowTest/UIComponentNavTabsOnWillShow.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillShowTest/UIComponentNavTabsOnWillShow.test.ets index acfc595c35a3fcee873ac41bd734968ed43fc563..c90033651cefb96ce2b834a22a4f5bbac9aa1126 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillShowTest/UIComponentNavTabsOnWillShow.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsOnWillShowTest/UIComponentNavTabsOnWillShow.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsOnWillShow() { describe('UIComponentNavTabsOnWillShow', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0190 @@ -44,12 +90,371 @@ export default function UIComponentNavTabsOnWillShow() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0190 finish.`); done() }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0070 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0070 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 +*/ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0070 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0070')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0070_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0070 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0080 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0080 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0080 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0080") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0080 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0110 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0110 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0110 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0110") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0040 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0040 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0040 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0040')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0040 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0060 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0060 + * @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 + */ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0060 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0060')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+50,pos.x,pos.y-50) + await Utils.sleep(1000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0060 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0150 +* @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0150 +* @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 +*/ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0150', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0150 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0150") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0150')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0150_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0150 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0160 +* @tc.name SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0160 +* @tc.desc 1、创建tabs组件,包含子组件TabContent + 2、点击底部页签或侧边页签 +*/ + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0160 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0160')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+100,pos.x,pos.y-356) + await Utils.sleep(1000) + + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+356) + await Utils.sleep(1000) + + let button:Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0160_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0160 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0010") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0020 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0020") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tarBar1 :Component = await driver.findComponent(ON.id('Blue')) + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0020 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0030 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0030") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tarBar1 :Component = await driver.findComponent(ON.id('two')) + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0030 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0050 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0050") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('tabsOnWillshow0050')); + await Utils.sleep(1000) + + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x-30,pos.y,pos.x+30,pos.y) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0050 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0120', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0120 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0120") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let tarBar1 :Component = await driver.findComponent(ON.id('two')) + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0120 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0130 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0130") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('tabsOnWillshow0130_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0140 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0140") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('two')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0140 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0170 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0170") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('two')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0170 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0100 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0100") + await Utils.sleep(1000) + + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0100_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('UIComponentNavTabsOnWillShow0100_002')) + await Utils.sleep(1000) + await button2.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_ONWILLSHOW_0100 finish.`); + done() + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsSubTabbarStyleTest/UIComponentNavTabsSubTabbarStyle.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsSubTabbarStyleTest/UIComponentNavTabsSubTabbarStyle.test.ets index 577359a2b716e31c682a93610342017ec229f0fc..76b05757a91f5c5c7b43fc5ac0a3d4484a67f074 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsSubTabbarStyleTest/UIComponentNavTabsSubTabbarStyle.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsSubTabbarStyleTest/UIComponentNavTabsSubTabbarStyle.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsSubTabbarStyle() { describe('UIComponentNavTabsSubTabbarStyle', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_SUBTABBARSTYLE_0010 * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_SUBTABBARSTYLE_0010 @@ -44,7 +90,7 @@ export default function UIComponentNavTabsSubTabbarStyle() { await Utils.sleep(100) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_SUBTABBARSTYLE_0010 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsTest/UIComponentNavTabs.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsTest/UIComponentNavTabs.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..783229c0e121965265b991bbeabaa8de1c7cecfb --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsTest/UIComponentNavTabs.test.ets @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabs() { + + describe('UIComponentNavTabs', () => { + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabs/UIComponentNavTabs0010"); + await Utils.sleep(2000); + let driver: Driver = Driver.create(); + let tabs: Component = await driver.findComponent(ON.id('UIComponentNavTabs0010_001')); + await Utils.sleep(1000); + let point = await tabs.getBoundsCenter(); + await driver.swipe(point.x + 200, point.y, point.x - 200, point.y); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_0010_2 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_0010_2 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_0010_2', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_0010_2 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabs/UIComponentNavTabs0010"); + await Utils.sleep(2000); + let driver: Driver = Driver.create(); + let tabbar: Component = await driver.findComponent(ON.text('Green')); + await tabbar.click(); + await Utils.sleep(5000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_0010_1 finish.`); + done(); + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsUxTest/UIComponentNavTabsUx.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsUxTest/UIComponentNavTabsUx.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fba2f30818fc8adafd17256226660238ebd831b4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsUxTest/UIComponentNavTabsUx.test.ets @@ -0,0 +1,469 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentNavTabsUx() { + + describe('UIComponentNavTabsUx', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_NAV_TABS_UX_022 + * @tc.name SUB_ACE_UI_COMPONENT_NAV_TABS_UX_022 + * @tc.desc 纵向 tabs(BarPosition.Start), width: auto, change barheight +*/ + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_022', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_022 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx022") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentNavTabsUx022')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+100,pos.y,pos.x-356,pos.y) + await Utils.sleep(1000) + + await driver.swipe(pos.x-356,pos.y,pos.x+100,pos.y) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_022 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_019', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_019 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx019") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(500) + await button2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_019 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_003', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_003 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx003") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_003 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_004', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_004 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx004") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_004 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_005', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_005 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx005") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_005 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_007', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_007 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx007") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_007 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_008', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_008 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx008") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Blue')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_008 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_009', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_009 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx009") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Red')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_009 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_010 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Red')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_011', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_011 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx011") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Red')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_011 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_012', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_012 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx012") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Red')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_012 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_013', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_013 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx013") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Red')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Yellow')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_013 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_014', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_014 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx014") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Tab3')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Tab2')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_014 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_015', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_015 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx015") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Tab3')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Tab2')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_015 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_016', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_016 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx016") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Tab3')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Tab2')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_016 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_017', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_017 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx017") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Tab3')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Tab2')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_017 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_NAV_TABS_UX_018', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_018 start.`); + Settings.createWindow("testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx018") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tarBar1:Component = await driver.findComponent(ON.id('Tab3')); + await Utils.sleep(1000) + await tarBar1.click() + await Utils.sleep(3000) + + let tarBar2:Component = await driver.findComponent(ON.id('Tab2')); + await Utils.sleep(1000) + await tarBar2.click() + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_UX_018 finish.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsWidthTest/UIComponentNavTabsWidth.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsWidthTest/UIComponentNavTabsWidth.test.ets index 54b79ec31f3f5ba9066214dd83618a1c419187a7..1062d529c07bd1127c3e75b74000ebbedf5d9eaa 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsWidthTest/UIComponentNavTabsWidth.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentNavTabsWidthTest/UIComponentNavTabsWidth.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,56 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentNavTabsWidth() { describe('UIComponentNavTabsWidth', () => { + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -35,7 +80,7 @@ export default function UIComponentNavTabsWidth() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_WIDTH_0010 start.`); Settings.createWindow("testability/pages/UIComponentNavTabsWidth/UIComponentNavTabsWidth001") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_NAV_TABS_WIDTH_0010 finish.`); done() diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAbilityTest/UIComponentOtherRefreshAbility.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAbilityTest/UIComponentOtherRefreshAbility.test.ets index a86014eb02d477754646809d0d45533d8da4a822..22eb9dc7e8053c99589fcce7a804a4428c10b956 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAbilityTest/UIComponentOtherRefreshAbility.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAbilityTest/UIComponentOtherRefreshAbility.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentOtherRefreshAbility() { describe('UIComponentOtherRefreshAbility', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -42,7 +88,7 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0080 finish.`); done() @@ -64,7 +110,7 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0070 finish.`); done() @@ -87,7 +133,7 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0090 finish.`); done() @@ -110,7 +156,7 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0050 finish.`); done() @@ -132,7 +178,7 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0100 finish.`); done() @@ -159,11 +205,144 @@ export default function UIComponentOtherRefreshAbility() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0040 finish.`); done() }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0160 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAbility0160')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0160 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_1 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_1 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_1 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0:Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAbility0170_002')); + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_2 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_2 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_2 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button:Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAbility0170_001')); + await Utils.sleep(1000) + await button.click() + let refreshListItem0:Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAbility0170_002')); + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0170_2 finish.`); + done() + }) + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0180', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0180 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0180") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAbility0180_001')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0180 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0130 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0130") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + let button1 :Component = await driver.findComponent(ON.id('refreshAbility0130_001')) + await Utils.sleep(500) + await button1.click() + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0140 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0140") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + let button1 :Component = await driver.findComponent(ON.id('refreshAbility0140_001')) + await Utils.sleep(500) + await button1.click() + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0140 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0150', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0150 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0150") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + let button1 :Component = await driver.findComponent(ON.id('refreshAbility0150_001')) + await Utils.sleep(500) + await button1.click() + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ABILITY_0150 finish.`); + done() + }) + + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAnimationTest/UIComponentOtherRefreshAnimation.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAnimationTest/UIComponentOtherRefreshAnimation.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..896d21ddbc8ff324ad0e781a40a40f17facf829d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshAnimationTest/UIComponentOtherRefreshAnimation.test.ets @@ -0,0 +1,331 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentOtherRefreshAnimation() { + + describe('UIComponentOtherRefreshAnimation', () => { + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0070 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0070") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0070')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0070 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0080 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0080") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0080')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0080 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0110 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0110") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0110')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0110 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0100 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0100')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0100 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0090 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0090") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0090')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0090 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0140 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0140") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0140')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(2000) + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0140 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0050 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0050") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0050')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.fling({x: pos.x, y: pos.y+400},{x: pos.x, y: pos.y},5,40000); + await Utils.sleep(2000) + await driver.fling({x: pos.x, y: pos.y+400},{x: pos.x, y: pos.y},5,40000); + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0050 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0020 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0020')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y, pos.x, pos.y+300, 40000) + await driver.swipe(pos.x, pos.y+300, pos.x, pos.y+600, 200) + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0020 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0010 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0010')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y, pos.x, pos.y+300, 40000) + await driver.swipe(pos.x, pos.y+300, pos.x, pos.y+600, 200) + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0040 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0040')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y+200, pos.x, pos.y) + await Utils.sleep(2000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0060 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0060')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y, pos.x, pos.y+200) + await Utils.sleep(4000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y+200) + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0060 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0130 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0130") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0130 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0030 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let refreshCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshAnimation0030')) + await Utils.sleep(1000) + let pos = await refreshCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y, pos.x, pos.y+200) + await Utils.sleep(4000) + + Settings.createWindow("testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030") + await Utils.sleep(1000) + + let driver1 : Driver = Driver.create(); + await driver1.delayMs(1000) + + let refreshCenter1 :Component = await driver1.findComponent(ON.id('UIComponentOtherRefreshAnimation0030')) + await Utils.sleep(1000) + let pos1 = await refreshCenter.getBoundsCenter() + await driver.swipe(pos1.x, pos1.y, pos1.x, pos1.y+200) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_0THER_REFRESH_ANIMATION_0030 finish.`); + done() + }) + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterActionTest/UIComponentOtherRefreshInterAction.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterActionTest/UIComponentOtherRefreshInterAction.test.ets index 5982175f3a3a9ba4c186c19b9337d12d3bae81f1..3f5a97519458dee631ec45e1ae9e186167797137 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterActionTest/UIComponentOtherRefreshInterAction.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterActionTest/UIComponentOtherRefreshInterAction.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -17,13 +17,58 @@ import Settings from '../model/Settings' import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' -import { Component, Driver ,ON } from '@ohos.UiTest' - +import { Component, Driver, ON, PointerMatrix } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentOtherRefreshInterAction() { describe('UIComponentOtherRefreshInterAction', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -36,15 +81,15 @@ export default function UIComponentOtherRefreshInterAction() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0380 start.`); Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0380") await Utils.sleep(1000) - let driver : Driver = Driver.create(); + let driver: Driver = Driver.create(); await driver.delayMs(1000) - let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + let refreshListItem0: Component = await driver.findComponent(ON.id('0')) await Utils.sleep(200) let pos = await refreshListItem0.getBoundsCenter() await Utils.sleep(100) - await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0380 finish.`); done() @@ -60,15 +105,15 @@ export default function UIComponentOtherRefreshInterAction() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0400 start.`); Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0400") await Utils.sleep(1000) - let driver : Driver = Driver.create(); + let driver: Driver = Driver.create(); await driver.delayMs(1000) - let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + let refreshListItem0: Component = await driver.findComponent(ON.id('0')) await Utils.sleep(200) let pos = await refreshListItem0.getBoundsCenter() await Utils.sleep(100) - await driver.swipe(pos.x,pos.y,pos.x,pos.y+400) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 400) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0400 finish.`); done() @@ -84,15 +129,15 @@ export default function UIComponentOtherRefreshInterAction() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0390 start.`); Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0390") await Utils.sleep(1000) - let driver : Driver = Driver.create(); + let driver: Driver = Driver.create(); await driver.delayMs(1000) - let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + let refreshListItem0: Component = await driver.findComponent(ON.id('0')) await Utils.sleep(200) let pos = await refreshListItem0.getBoundsCenter() await Utils.sleep(100) - await driver.swipe(pos.x,pos.y,pos.x,pos.y+400) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 400) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0390 finish.`); done() @@ -108,18 +153,500 @@ export default function UIComponentOtherRefreshInterAction() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0410 start.`); Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0410") await Utils.sleep(1000) - let driver : Driver = Driver.create(); + let driver: Driver = Driver.create(); await driver.delayMs(1000) - let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + let refreshListItem0: Component = await driver.findComponent(ON.id('0')) await Utils.sleep(200) let pos = await refreshListItem0.getBoundsCenter() await Utils.sleep(100) - await driver.swipe(pos.x,pos.y,pos.x,pos.y+400) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 400) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0410 finish.`); done() }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0100 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0100") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0100')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 400) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0100 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0130 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0130 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0130 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0130") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0130')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y + 100, pos.x, pos.y); + await Utils.sleep(1000) + await driver.fling(pos, { + x: pos.x, y: pos.y + 200 + }, 5, 600) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0130 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0430 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0430 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0430', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0430 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0430") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0430')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0430 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0170 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0170 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0170 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0170") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0170')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0170 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0250 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0250 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0250', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0250 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0250") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0250')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0250 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0240 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0240 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0240', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0240 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0240") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0240')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0240 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0260 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0260 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0260', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0260 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0260") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0260')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0260 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0270 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0270 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0270', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0270 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0270") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0270')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000) + let textinput: Component = await driver.findComponent(ON.id('0')); + await textinput.inputText('abc'); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0270 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0010 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0010 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0010 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0010") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0010')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + let pointers: PointerMatrix = PointerMatrix.create(1, 10); + pointers.setPoint(0, 0, { + x: pos.x, y: pos.y + }); + pointers.setPoint(0, 1, { + x: pos.x, y: pos.y + }); + pointers.setPoint(0, 2, { + x: pos.x, y: pos.y + }); + pointers.setPoint(0, 3, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 4, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 5, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 6, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 7, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 8, { + x: pos.x, y: pos.y + 200 + }); + pointers.setPoint(0, 9, { + x: pos.x, y: pos.y + 200 + }); + await driver.injectMultiPointerAction(pointers); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0010 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0060 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0060 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0060 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0060") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0060')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 20); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0060 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0080 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0080 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0080 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0080") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0080')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0080 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0090 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0090 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0090 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0090") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterAction0090')) + await Utils.sleep(500) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0090 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0020 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0020") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0020_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0020 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0030 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0030") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0030_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-50,pos.x,pos.y+50) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0030 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0040 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0040") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0040_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0040 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0050 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0050") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0050 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0070 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0070") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0070 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0180', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0180 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0180") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0180_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-30,pos.x,pos.y+30) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0180 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0190', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0190 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0190") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0190_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-50,pos.x,pos.y+50) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0190 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0200', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0200 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0200") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0200_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0200 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0210', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0210 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0210") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0210_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0210 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0220', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0220 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0220") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshInteraction0220_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERACTION_0220 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterConnectionTest/UIComponentOtherRefreshInterConnection.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterConnectionTest/UIComponentOtherRefreshInterConnection.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de656b962190e12b6c195e2fd1323eba0c9e134b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterConnectionTest/UIComponentOtherRefreshInterConnection.test.ets @@ -0,0 +1,296 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentOtherRefreshInterConnection() { + + describe('UIComponentOtherRefreshInterConnection', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0040 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0040") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0040 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0110 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0110 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0110 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0110"); + await Utils.sleep(1000); + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0110_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0110 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0130 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0130 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0130 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0130"); + await Utils.sleep(1000); + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0130_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0130 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0120 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0120 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0120', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0120 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0120") + await Utils.sleep(1000); + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0120_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0120 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0010 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0010 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0010 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0010") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0010_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x + 100, pos.y, pos.x - 100, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0010 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0030 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0030 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0030 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0030") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0030_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0030 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0060 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0060 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0060 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0060") + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0060_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0060 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0050 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0050 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0050', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0050 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0050") + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0050_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot(); + await Utils.sleep(3000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0050 finish.`); + done(); + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0080 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0080 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0080 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0080") + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0080_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0080 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0070 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0070 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0070 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0070") + let driver: Driver = Driver.create(); + await driver.delayMs(1000); + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterConnection0070_001')); + await Utils.sleep(200); + let pos = await refreshListItem0.getBoundsCenter(); + await Utils.sleep(100); + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200); + await Utils.sleep(1000); + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y); + await Utils.sleep(1000); + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERCONNECTION_0070 finish.`); + done() + }) + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterfaceTest/UIComponentOtherRefreshInterface.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterfaceTest/UIComponentOtherRefreshInterface.test.ets index 5243db1f0b868ca6b54197d73bfb65d499e168e5..1741471dc1a662399b1d5243d2068ca09f8c5ecb 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterfaceTest/UIComponentOtherRefreshInterface.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshInterfaceTest/UIComponentOtherRefreshInterface.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,11 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentOtherRefreshInterface() { describe('UIComponentOtherRefreshInterface', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) @@ -44,7 +90,7 @@ export default function UIComponentOtherRefreshInterface() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0140 finish.`); done() @@ -67,7 +113,7 @@ export default function UIComponentOtherRefreshInterface() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0170 finish.`); done() @@ -91,12 +137,159 @@ export default function UIComponentOtherRefreshInterface() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0180 finish.`); done() }) + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0160', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0160 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterface0160')) + await Utils.sleep(1000) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0160 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0200', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0200 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0200") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshInterface0200')) + await Utils.sleep(1000) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(1000) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(4000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0200 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0130 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0130 + * @tc.desc 1、Refresh的offset参数:string :'0'设置friction:100 + 2、页面下拉 + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0130', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0130 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0130 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0010 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0010 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0010 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0010 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0020 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0020 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0020 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0020") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0020 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0030 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0030 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0030 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0030") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0030 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0040 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0040 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0040', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0040 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0040") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_INTERFACE_0040 finish.`); + done() + }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshOnOffsetChangeTest/UIComponentOtherRefreshOnOffsetChange.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshOnOffsetChangeTest/UIComponentOtherRefreshOnOffsetChange.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd2ab5eeca4385e4b4f5a147ed2fe682625e877a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshOnOffsetChangeTest/UIComponentOtherRefreshOnOffsetChange.test.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentOtherRefreshOnOffsetChange() { + + describe('UIComponentOtherRefreshOnOffsetChange', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ONOFFSETCHANGE_0100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ONOFFSETCHANGE_0100 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshOnOffsetChange/UIComponentOtherRefreshOnOffsetChange0100") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await Utils.sleep(1000) + + let refreshCenter :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshOnOffsetChange0100')) + await Utils.sleep(1000) + let pos = await refreshCenter.getBoundsCenter() + await driver.swipe(pos.x, pos.y, pos.x, pos.y+200) + await Utils.sleep(3000) + + await driver.swipe(pos.x, pos.y+300, pos.x, pos.y, 40000) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_ONOFFSETCHANGE_0100 finish.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshPromptTextTest/UIComponentOtherRefreshPromptText.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshPromptTextTest/UIComponentOtherRefreshPromptText.test.ets index f1c73b54f9e9d514fe6d425f5bc1449316efd3d7..737f828497a51f66db61e33c3c4f0f00f0b908be 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshPromptTextTest/UIComponentOtherRefreshPromptText.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentOtherRefreshPromptTextTest/UIComponentOtherRefreshPromptText.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentOtherRefreshPromptText() { describe('UIComponentOtherRefreshPromptText', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) @@ -43,7 +90,7 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0110 finish.`); done() @@ -67,7 +114,7 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0100 finish.`); done() @@ -91,7 +138,7 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0060 finish.`); done() @@ -115,7 +162,7 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0050 finish.`); done() @@ -139,7 +186,7 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0120 finish.`); done() @@ -162,12 +209,317 @@ export default function UIComponentOtherRefreshPromptText() { await Utils.sleep(100) await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) await Utils.sleep(3000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0040 finish.`); done() }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0250 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0250 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0250', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0250 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0250") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0250 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0240 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0240 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0240', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0240 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0240") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0240 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_1 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_1 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_1 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0230_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_2 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_2 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_2 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0230_001')); + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0230_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0230_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_1 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_1 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_1 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_2 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_2 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_2 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0220_001')); + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0220_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0220_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0170 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0170 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0170', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0170 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0170") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0170 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0180 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0180 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0180', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0180 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0180") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('0')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0180 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_1 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_1 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_1 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0160_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_2 + * @tc.name SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_2 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_2 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0160_001')); + await button.click(); + await Utils.sleep(200) + let refreshListItem0: Component = await driver.findComponent(ON.id('UIComponentOtherRefreshPromptText0160_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y + 200, pos.x, pos.y) + await Utils.sleep(3000) + await driver.swipe(pos.x, pos.y, pos.x, pos.y + 200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(1000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_OTHER_REFRESH_PROMPTTEXT_0160_2 finish.`); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0010 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0010") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let list1:Component = await driver.findComponent(ON.id('refreshPrompttext0010_001')); + await Utils.sleep(1000) + let pos = await list1.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0010 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0030 start.`); + Settings.createWindow("testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0030") + await Utils.sleep(500) + let driver: Driver = Driver.create(); + await Utils.sleep(500) + + let list1:Component = await driver.findComponent(ON.id('refreshPrompttext0030_001')); + await Utils.sleep(1000) + let pos = await list1.getBoundsCenter() + await driver.swipe(pos.x,pos.y-30,pos.x,pos.y+30) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PROMPTTEXT_0030 finish.`); + done() + }) }) diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentRefreshPulldownradioTest/UIComponentRefreshPulldownradio.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentRefreshPulldownradioTest/UIComponentRefreshPulldownradio.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4ed436b65d035be159603f1b81bfc99b6d90f49 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentRefreshPulldownradioTest/UIComponentRefreshPulldownradio.test.ets @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentRefreshPulldownradio() { + + describe('UIComponentRefreshPulldownradio', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_1 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_1 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_1 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0130_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_2 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_2 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_2 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0130_001')) + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0130_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0130_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_1 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_1 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_1 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0120_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_2 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_2 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_2 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0120_001')) + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0120_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0120_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_1 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_1 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_1 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0060_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_2 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_2 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_2 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0060_001')) + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0060_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0060_2 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_1 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_1 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_1', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_1 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0160_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_1 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_2 + * @tc.name SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_2 + * @tc.desc +*/ + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_2', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_2 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0160_001')) + await button.click(); + await Utils.sleep(200) + let refreshListItem0 :Component = await driver.findComponent(ON.id('UIComponentRefreshPulldownradio0160_002')) + await Utils.sleep(200) + let pos = await refreshListItem0.getBoundsCenter() + await Utils.sleep(100) + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADIO_0160_2 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADI0_0140', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADI0_0140 start.`); + Settings.createWindow("testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0140") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + + let tabsCenter:Component = await driver.findComponent(ON.id('refreshPullDownradio0140_001')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y-100,pos.x,pos.y+100) + await Utils.sleep(3000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_REFRESH_PULLDOWNRADI0_0140 finish.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentScrollSwiperTeaceTest/UIComponentScrollSwiperTeace.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentScrollSwiperTeaceTest/UIComponentScrollSwiperTeace.test.ets index 45774daa06b73cc24a86ec09b5236769d0be1526..b1b80a733a87d82bf52222ff34204fadc65ce70e 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentScrollSwiperTeaceTest/UIComponentScrollSwiperTeace.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentScrollSwiperTeaceTest/UIComponentScrollSwiperTeace.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -17,10 +17,57 @@ import Settings from '../model/Settings' import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' -import { Component, Driver ,ON, PointerMatrix } from '@ohos.UiTest' - +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentScrollSwiperTeace() { + describe('UIComponentScrollSwiperTeace', () => { + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* * @tc.number SUB_ACE_UI_COMPONENT_SCROLL_SWIPER_TEACE_0070 */ @@ -55,5 +102,35 @@ export default function UIComponentScrollSwiperTeace() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_SCROLL_SWIPER_Teace_0080 finish.`); done() }) + + + it('SUB_ACE_UI_COMPONENT_SCROLL_SWIPER_TEACE_0370', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_SCROLL_SWIPER_TEACE_0370 start.`); + Settings.createWindow("testability/pages/UIComponentScrollSwiperTeace/UIComponentScrollSwiperTeace0370") + await Utils.sleep(2000) + /*let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentScrollSwiperTeace0370')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+356,pos.y,pos.x-100,pos.y) + await Utils.sleep(2000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentScrollSwiperTeace0370_001')) + await Utils.sleep(1000) + button1.click() + await Utils.sleep(1000) + + let button2 :Component = await driver.findComponent(ON.id('UIComponentScrollSwiperTeace0370_002')) + await Utils.sleep(1000) + button2.click() + await Utils.sleep(1000)*/ + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_SCROLL_SWIPER_TEACE_0370 finish.`); + done() + }) }) } \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabTabBarSymbolTest/UIComponentTabTabBarSymbol.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabTabBarSymbolTest/UIComponentTabTabBarSymbol.test.ets index 17371bd33b6103d8cb1a19d02cc62a1ef53345e1..1f8dd45467d2164e037affe8ea55ed91a3d7574a 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabTabBarSymbolTest/UIComponentTabTabBarSymbol.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabTabBarSymbolTest/UIComponentTabTabBarSymbol.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,10 +18,57 @@ import windowSnap from '../model/snapShot' import Logger from '../model/Logger' import Utils from '../model/Utils' import { Component, Driver ,ON } from '@ohos.UiTest' - +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' export default function UIComponentTabTabBarSymbol() { describe('UIComponentTabTabBarSymbol', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -44,7 +91,7 @@ export default function UIComponentTabTabBarSymbol() { await Utils.sleep(1000) await button2.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0040 finish.`); done() @@ -60,7 +107,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0090 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0090") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0090 finish.`); done() @@ -76,7 +123,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0120 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0120") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0120 finish.`); done() @@ -92,7 +139,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0110 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0110") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0110 finish.`); done() @@ -108,7 +155,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0070 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0070") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0070 finish.`); done() @@ -124,7 +171,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0080 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0080") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0080 finish.`); done() @@ -140,7 +187,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0060 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0060") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0060 finish.`); done() @@ -162,7 +209,7 @@ export default function UIComponentTabTabBarSymbol() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0140 finish.`); done() @@ -187,7 +234,7 @@ export default function UIComponentTabTabBarSymbol() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0130 finish.`); done() @@ -211,7 +258,7 @@ export default function UIComponentTabTabBarSymbol() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0260 finish.`); done() @@ -235,7 +282,7 @@ export default function UIComponentTabTabBarSymbol() { await Utils.sleep(1000) await button1.click() await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0190 finish.`); done() @@ -251,7 +298,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0180 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0180") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0180 finish.`); done() @@ -267,7 +314,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0160 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0160") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0160 finish.`); done() @@ -283,7 +330,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0170 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0170") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0170 finish.`); done() @@ -299,7 +346,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0030 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0030") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0030 finish.`); done() @@ -315,7 +362,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0020 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0020") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0020 finish.`); done() @@ -331,7 +378,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0010 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0010") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0010 finish.`); done() @@ -346,7 +393,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0230 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0230") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0230 finish.`); done() @@ -362,7 +409,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0150 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabBarSymbol0150") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(2000) Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0150 finish.`); done() @@ -380,7 +427,7 @@ export default function UIComponentTabTabBarSymbol() { let button: Component = await driver.findComponent(ON.id('UIComponentTabTabbarTabbarsymbol0050_001')) await button.click() await Utils.sleep(2000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0050 finish.`); done() @@ -394,7 +441,7 @@ export default function UIComponentTabTabBarSymbol() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0240 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0050") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0240 finish.`); done() @@ -408,10 +455,75 @@ export default function UIComponentTabTabBarSymbol() { Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0250 start.`); Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0250") await Utils.sleep(1000) - windowSnap.snapShot() + await windowSnap.snapShot() await Utils.sleep(1000) Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0250 finish.`); done() }) + + it('SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0200', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0200 start.`); + Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0200") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let tabsCenter :Component = await driver.findComponent(ON.id('UIComponentTabTabbarTabbarsymbol0200')) + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x+356,pos.y,pos.x-100,pos.y) + await Utils.sleep(2000) + + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0200 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0210', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0210 start.`); + Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0210") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let buttonPink :Component = await driver.findComponent(ON.id('Pink')) + await Utils.sleep(1000) + await buttonPink.click() + await Utils.sleep(1000) + + let buttonBlack :Component = await driver.findComponent(ON.id('Black')) + await Utils.sleep(1000) + await buttonBlack.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0210 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0220', 0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0220 start.`); + Settings.createWindow("testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0220") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let button :Component = await driver.findComponent(ON.id('UIComponentTabTabbarTabbarsymbol0220_001')) + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_TAB_TABBAR_TABBARSYMBOL_0220 finish.`); + done() + }) + }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabsClipTest/UIComponentTabsClip.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabsClipTest/UIComponentTabsClip.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..770cd28e4a0d781a30da0c8a3737a652199745b3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentTabsClipTest/UIComponentTabsClip.test.ets @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentTabsClip() { + + describe('UIComponentTabsClip', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_CLIP_0020 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_CLIP_0020 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_TABS_CLIP_0020', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_CLIP_0020 start.`); + Settings.createWindow("testability/pages/UIComponentTabsClip/UIComponentTabsClip0020"); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_CLIP_0020 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_TABS_CLIP_0010 + * @tc.name SUB_ACE_UI_COMPONENT_TABS_CLIP_0010 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_TABS_CLIP_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_CLIP_0010 start.`); + Settings.createWindow("testability/pages/UIComponentTabsClip/UIComponentTabsClip0010"); + await Utils.sleep(3000); + await windowSnap.snapShot(); + await Utils.sleep(2000); + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_TABS_CLIP_0010 finish.`); + done() + }) + }) +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentUISupportColorTest/UIComponentUISupportColor.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentUISupportColorTest/UIComponentUISupportColor.test.ets index daf797ea095d73d75a47ee5fe88209d0fec33dae..4b202a2ebbde3561ef9c65d39b0b3341d7f33953 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentUISupportColorTest/UIComponentUISupportColor.test.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentUISupportColorTest/UIComponentUISupportColor.test.ets @@ -12,34 +12,63 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver, ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentUISupportColor() { -import { describe, afterEach, it } from '@ohos/hypium'; -import Settings from '../model/Settings'; -import windowSnap from '../model/snapShot'; -import Logger from '../model/Logger'; -import Utils from '../model/Utils'; -import uiAppearance from '@ohos.uiAppearance'; -import { Driver ,ON } from '@ohos.UiTest' + describe('UIComponentUISupportColor', () => { -/* - * UIComponentUISupportColor - * - * Settings.createWindow(config.url): - * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 - * - * windowSnap.snapShot(globalThis.context): - * 窗口截屏&图片文件保存,存储在设备端 - * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 - * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 - * - * Logger日志使用方法: - * import Logger form './model/Logger' - * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) - * */ + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) -export default function UIComponentUISupportColor() { +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); - describe('UIComponentUISupportColor', () => { + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) /* @@ -389,6 +418,115 @@ export default function UIComponentUISupportColor() { await Utils.sleep(1000); Logger.info('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_0950 finish.`); done(); + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1060 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1060 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1060', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1060 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1060") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('UIComponentUISupportColor1060_001')) + await Utils.sleep(200) + await button.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1060 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1070 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1070 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1070', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1070 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1070") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('UIComponentUISupportColor1070_001')) + await Utils.sleep(200) + await button.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1070 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1080 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1080 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1080', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1080 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1080") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('UIComponentUISupportColor1080_001')) + await Utils.sleep(200) + await button.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1080 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1090 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1090 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1090', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1090 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1090") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await driver.delayMs(1000) + let button: Component = await driver.findComponent(ON.id('UIComponentUISupportColor1090_001')) + await Utils.sleep(200) + await button.click(); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1090 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1100 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1100 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1100', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1100 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1100") + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1100 finish.`); + done() + }) + /* + * @tc.number SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1110 + * @tc.name SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1110 + * @tc.desc + */ + it('SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1110', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1110 start.`); + Settings.createWindow("testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1110"); + await Utils.sleep(3000) + await windowSnap.snapShot() + await Utils.sleep(2000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_UISUPPORT_COLOR_1110 finish.`); + done() }) }) } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowFooterTest/UIComponentWaterFlowFooter.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowFooterTest/UIComponentWaterFlowFooter.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9b3f5a34f3130265442581c144c0008f2a611aa --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowFooterTest/UIComponentWaterFlowFooter.test.ets @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentWaterFlowFooter() { + + describe('UIComponentWaterFlowFooter', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + it('SUB_ACE_UI_COMPONENT_WATERFLOW_FOOTER_0010', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_FOOTER_0010 start.`); + Settings.createWindow("testability/pages/UIComponentWaterFlowFooter/UIComponentWaterFlowFooter0010") + await Utils.sleep(1000) + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + let button:Component = await driver.findComponent(ON.id('UIComponentWaterFlowFooter0010_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + let tabsCenter:Component = await driver.findComponent(ON.id('UIComponentWaterFlowFooter0010')); + await Utils.sleep(1000) + let pos = await tabsCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y,pos.x,pos.y+200) + await Utils.sleep(2000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_FOOTER_0010 finish.`); + done() + }) + + + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowSlidingTest/UIComponentWaterFlowSliding.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowSlidingTest/UIComponentWaterFlowSliding.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dc7e2afd45758c781073d5f8fb00c6a5020eba9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIComponentWaterFlowSlidingTest/UIComponentWaterFlowSliding.test.ets @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIComponentWaterFlowSliding() { + + describe('UIComponentWaterFlowSliding', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + + /* +* @tc.number SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0480 +* @tc.name SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0480 +* @tc.desc 1、创建waterflow,设置为移动窗口模式布局 + 2、设置margin属性 + 3、动态改变margin +*/ + it('SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0480', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0480 start.`); + Settings.createWindow("testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0480") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentWaterFlowSliding0480_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0480 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0470 +* @tc.name SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0470 +* @tc.desc 1、创建waterflow,设置为移动窗口模式布局 + 2、设置margin属性 + 3、动态改变margin +*/ + it('SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0470', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0470 start.`); + Settings.createWindow("testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0470") + await Utils.sleep(1000) + + let driver: Driver = Driver.create() + await Utils.sleep(1000) + + let button1 :Component = await driver.findComponent(ON.id('UIComponentWaterFlowSliding0470_001')) + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + await button1.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0470 finish.`); + done() + }) + + /* +* @tc.number SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0270 +* @tc.name SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0270 +* @tc.desc 1、创建waterflow,顶部设置一个单独的flowitem可以改变显隐 + 2、顶部flowitem设为visibility.none,删除末尾节点 +*/ + it('SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0270', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0270 start.`); + Settings.createWindow("testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0270") + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0270 finish.`); + done() + }) + + it('SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0320', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0320 start.`); + Settings.createWindow("testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0320") + await Utils.sleep(1000) + + let driver : Driver = Driver.create(); + await driver.delayMs(1000) + + let waterFlowCenter:Component = await driver.findComponent(ON.id('UIComponentWaterFlowSliding0320')); + await Utils.sleep(1000) + let pos = await waterFlowCenter.getBoundsCenter() + await driver.swipe(pos.x,pos.y+200,pos.x,pos.y) + await Utils.sleep(2000) + + let button:Component = await driver.findComponent(ON.id('UIComponentWaterFlowSliding0320_001')); + await Utils.sleep(1000) + await button.click() + await Utils.sleep(1000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + Logger.error('TEST', `SUB_ACE_UI_COMPONENT_WATERFLOW_SLIDING_0320 finish.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIRefreshComponentContentTest/UIRefreshComponentContent.test.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIRefreshComponentContentTest/UIRefreshComponentContent.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..41da24cd28e3611882543d5f62d433516cbbe54d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/test/UIRefreshComponentContentTest/UIRefreshComponentContent.test.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Component, Driver ,ON } from '@ohos.UiTest' +import { uiAppearance } from '@kit.ArkUI' +import { i18n } from '@kit.LocalizationKit' +export default function UIRefreshComponentContent() { + + describe('UIRefreshComponentContent', () => { + + beforeEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting before Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting before Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting before dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch before CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + done(); +}) + +afterEach(async (done: Function) => { + if (uiAppearance.getDarkMode() == uiAppearance.DarkMode.ALWAYS_DARK) { + await uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_LIGHT).then(() => { + console.info('Setting after Set dark-mode successfully.'); + }).catch((error: Error) => { + console.error('Setting after Set dark-mode failed, ' + error.message); + }); + Utils.sleep(1000); + } else { + console.info('Setting after dark-mode is uiAppearance.DarkMode.ALWAYS_LIGHT'); + } + i18n.System.setAppPreferredLanguage('zh-Hans-CN'); + let appPreferredLanguage2: string = i18n.System.getAppPreferredLanguage(); + console.log(`Switch after CusLocales,appPreferredLanguage2=${appPreferredLanguage2}`); + + if (Settings.windowClass == undefined) { + return + } + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + it('SUB_ACE_UI_REFRESH_COMPONENTCONTENT_0030', 0, async (done: Function) => { + Logger.error('TEST', `SUB_ACE_UI_REFRESH_COMPONENTCONTENT_0030 start.`); + Settings.createWindow("testability/pages/UIRefreshComponentContent/UIRefreshComponentContent0030") + await Utils.sleep(1000) + let driver: Driver = Driver.create(); + await Utils.sleep(1000) + + let list1:Component = await driver.findComponent(ON.id('refreshComponentcontent0030_001')); + await Utils.sleep(1000) + let pos = await list1.getBoundsCenter() + await driver.swipe(pos.x,pos.y-50,pos.x,pos.y+50) + await Utils.sleep(4000) + + await windowSnap.snapShot() + await Utils.sleep(3000) + + Logger.error('TEST', `SUB_ACE_UI_REFRESH_COMPONENTCONTENT_0030 start.`); + done() + }) + + + }) +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddafffc2c40ff2940dc621a3efcb37a2898f9e59 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0040.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource00400 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0040 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource00400 = new MyDataSource00400([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource00400(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.CONTENT_FIRST) + .height('80%') + .width('100%'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a305b1c46053d4af99240fa04c447119c03b9cb --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0050.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0050 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0050 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0050 = new MyDataSource0050([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0050(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.CONTENT_FIRST) + .height('80%') + .width('100%'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1a573f975beed6c52893a3696f234aa25922f75 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0060.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0060 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0060 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0060 = new MyDataSource0060([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0060(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.ACTION_FIRST) + .height('80%') + .width('auto'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('auto') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..a00d525bc7affbfaab51ce3c852ded48db473f44 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0070.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0070 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0070 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0070 = new MyDataSource0070([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0070(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.ACTION_FIRST) + .height('80%') + .width('auto'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..767625910dfe936754d6dc880e5a5630385963d4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0080.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0080 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0080 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0080 = new MyDataSource0080([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0080(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.NO_ANIMATION) + .height('80%') + .width('100%'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..07fd300e00b154fd0d5e1048b8c1da0912565c73 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0090.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0090 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0090 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0090 = new MyDataSource0090([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0090(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(AnimationMode.ACTION_FIRST) + .height('auto') + .width('auto'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('auto') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..47d8d8f27e4b8524744f591e05c551cc56fe35fa --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0100.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0100 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0100 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0100 = new MyDataSource0100([]) + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0100(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(null) + .height('80%') + .width('100%'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d10e9161d7680bd0de6be2b70dd12e9b3e97bf7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0110.ets @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0110 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct ArkUIAnimatedResponse0110 { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0; + @State color1: Color[] = [Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green,Color.Red, Color.Blue, Color.Green, Color.Yellow]; + private list: number[] = []; + @State msgInfo: string = 'no TabContentMarkRenderDone'; + private tabsController: TabsController = new TabsController() + private swiperController: SwiperController = new SwiperController() + private swiperData: MyDataSource0110 = new MyDataSource0110([]) + + aboutToAppear(): void { + for (let i = 1; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource0110(this.list) + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }); + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('20%').id(name); + } + + build() { + Column() { + Text(this.msgInfo); + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController, index:6 }) { + ForEach(this.list, (index: number) => { + TabContent().tabBar(this.tabBuilder(index, 'tab' + this.list[index])).backgroundColor(this.color1[index]); + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index + this.swiperController.changeIndex(index, true) + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .animationMode(null) + .height('80%') + .width('100%'); + + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()) + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()) + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(false) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(targetIndex) + }); + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcb898778a1c78f888e657cab47e46c1577216ad --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737.ets @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct FunctionJichuWaterFlow0350737 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + //this.itemHeightArray.push(this.getSize()) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + @Builder + itemFoot() { + Column() { + Text('Footer123') + .fontSize(100) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + + WaterFlow({ footer: this.itemFoot(), scroller: this.scroller, sections: this.sections ,layoutMode:1}) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0470') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737142.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737142.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7f6ab8a091968906da3b9e0444b648c5b2515e6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737142.ets @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct FunctionJichuWaterFlow0350737142 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + //this.itemHeightArray.push(this.getSize()) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + @Builder + itemFoot() { + Column() { + Text('Footer123') + .fontSize(100) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + + WaterFlow({ footer: this.itemFoot(), scroller: this.scroller, sections: this.sections ,layoutMode:3}) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0470') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380.ets new file mode 100644 index 0000000000000000000000000000000000000000..522e853f0eeb6341bb255a709da966cad85261da --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct FunctionJichuWaterFlow0380 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + @State sections: WaterFlowSections = new WaterFlowSections() + @State isFullScreen: boolean = false + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State speed: number = 0 + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('change speed') + .id('FunctionJichuWaterFlow0380_001') + .onClick(()=>{ + this.speed = 20; + }) + Button('top') + .id('FunctionJichuWaterFlow0380_002') + .onClick(()=>{ + this.scroller.scrollEdge(Edge.Top) + }) + WaterFlow({ scroller: this.scroller, layoutMode: WaterFlowLayoutMode.ALWAYS_TOP_DOWN }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Red) + }, (item: string) => item) + } + .flingSpeedLimit(this.speed) + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d6f4b1ab33cd7957083e0a15bcb4b590e3e8808 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/FunctionJichuWaterFlow/WaterFlowDataSource.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..1924563ddb8362730b1f45611d1f8aa40f758320 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0060.ets @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' + +import image from '@ohos.multimedia.image' + +@Entry +@Component +struct UIComponentListAndGridWaterSections0060 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number = 1 + @State bool:boolean=true + // @State layoutMode1:number=1 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + + Column({ space: 2 }) { + Scroll() { + Column() { + Row(){ + Button('默认布局').height(40).onClick(() => { + this.layoutMode1 = 0 + }) + Button('移动窗口布局').height(40).onClick(() => { + this.layoutMode1 = 1 + + }).id('UIComponentListAndGridWaterSections0060_001'); + + } + Row(){ + Button('单独节点显隐:'+`${this.visibilitys[this.Visibilitynum%3]}`) + .onClick((event: ClickEvent) => { + this.Visibilitynum++ + }) + Button("footer显隐:"+this.flag ) + .onClick(() => { + this.flag=!this.flag + }).id('UIComponentListAndGridWaterSections0060_002'); + } + } + } .border({width:1}).margin({left:2}) + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(this.visibilitys[this.Visibilitynum%3]); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.img2')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(this.colors[item % 5]) + }, (item: string, index: number) => item + index+Math.random()) + } + .id('UIComponentListAndGridWaterSections0060') + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Black) + .width(350) + .height('40%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0430.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0430.ets new file mode 100644 index 0000000000000000000000000000000000000000..510f4779ed88a629c35494c272ffeb01a5c0433e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0430.ets @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0430 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollToIndex+5') + .height('5%') + .onClick(() => { + this.scroller.scrollToIndex(5, false, ScrollAlign.START) + }).id('UIComponentListAndGridWaterSections0430_001') + .margin({ top: 10, left: 20 }); + Button('scrollToIndex+0') + .height('5%') + .onClick(() => { + this.scroller.scrollToIndex(0, false, ScrollAlign.START) + }).id('UIComponentListAndGridWaterSections0430_002') + .margin({ top: 10, left: 20 }); + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0430') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0440.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0440.ets new file mode 100644 index 0000000000000000000000000000000000000000..eea2e813c26006a81e625bb17ae0125dbe4366ce --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0440.ets @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0440 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollPage + next Page') + .height('5%') + .onClick(() => { + this.scroller.scrollPage({ next: true }); + }).id('UIComponentListAndGridWaterSections0440_001') + .margin({ top: 10, left: 20 }); + Button('scrollPage + back Page') + .height('5%') + .onClick(() => { + this.scroller.scrollPage({ next: false }); + }).id('UIComponentListAndGridWaterSections0440_002') + .margin({ top: 10, left: 20 }) + + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0440') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0450.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0450.ets new file mode 100644 index 0000000000000000000000000000000000000000..0173af524eba5fc60504b1bca529ea5a147da4df --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0450.ets @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0450 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + @State yOffset: number=0; + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollTo+100') + .height('5%') + .onClick(() => { + this.yOffset = this.scroller.currentOffset().yOffset; + this.scroller.scrollTo({ xOffset: 0, yOffset: this.yOffset + 100 }); + }).id('UIComponentListAndGridWaterSections0450_001') + .margin({ top: 10, left: 20 }); + + Button('scrollTo-100') + .height('5%') + .onClick(() => { + this.scroller.scrollTo({ xOffset: 0, yOffset: this.yOffset }); + }).id('UIComponentListAndGridWaterSections0450_002') + .margin({ top: 10, left: 20 }) + + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0450') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0460.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0460.ets new file mode 100644 index 0000000000000000000000000000000000000000..623ce0a63ca79428d1604d8bb6ce015e37b0b01d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0460.ets @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0460 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + @State yOffset: number=0; + @State xOffset: number=0; + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollEdge Edge.Bottom') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Bottom); + }).id('UIComponentListAndGridWaterSections0460_001') + .margin({ top: 10, left: 20 }); + + Button('scrollEdge Edge.Top') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }).id('UIComponentListAndGridWaterSections0460_002') + .margin({ top: 10, left: 20 }); + + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0460') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0470.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0470.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f467ee14ab43b87e27eaadd52cb19f937117b66 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0470.ets @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0470 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollToIndex+5') + .height('5%') + .onClick(() => { + this.scroller.scrollToIndex(5, false, ScrollAlign.START, { extraOffset: LengthMetrics.vp(5) }) + }).id('UIComponentListAndGridWaterSections0470_001') + .margin({ top: 10, left: 20 }); + Button('scrollToIndex+0') + .height('5%') + .onClick(() => { + this.scroller.scrollToIndex(0, false, ScrollAlign.START, { extraOffset: LengthMetrics.vp(5) }) + }).id('UIComponentListAndGridWaterSections0470_002') + .margin({ top: 10, left: 20 }) + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections ,layoutMode:1}) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0470') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0480.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0480.ets new file mode 100644 index 0000000000000000000000000000000000000000..0776a25a4a5d0cacbde7e69fc2db2a4e49421236 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0480.ets @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0480 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollPage+Page') + .height('5%') + .onClick(() => { + this.scroller.scrollPage({ next: true }); + }).id('UIComponentListAndGridWaterSections0480_001') + .margin({ top: 10, left: 20 }); + Button('scrollPage-Page') + .height('5%') + .onClick(() => { + this.scroller.scrollPage({ next: false }); + }).id('UIComponentListAndGridWaterSections0480_002') + .margin({ top: 10, left: 20 }); + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections ,layoutMode:1}) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0480') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0490.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0490.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9f6d39a7a059320f4d968dbc5b9faf13e143b08 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0490.ets @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Reusable +@Component +struct ReusableFlowItem { + @State item: number = 0 + + // 从复用缓存中加入到组件树之前调用,可在此处更新组件的状态变量以展示正确的内容 + aboutToReuse(params: Record) { + this.item = params.item; + console.info('Reuse item:' + this.item) + } + + aboutToAppear() { + console.info('new item:' + this.item) + } + + build() { + Image('res/waterFlowTest(' + this.item % 5 + ').jpg') + .overlay('N' + this.item, { align: Alignment.Top }) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } +} + +@Entry +@Component +struct UIComponentListAndGridWaterSections0490 { + minSize: number = 80 + maxSize: number = 180 + fontSize: number = 24 + colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + dataCount: number = this.dataSource.totalCount() + private itemHeightArray: number[] = [] + @State sections: WaterFlowSections = new WaterFlowSections() + sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 } + oneColumnSection: SectionOptions = { + itemsCount: 4, + crossCount: 1, + columnsGap: '5vp', + rowsGap: 10, + margin: this.sectionMargin, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + twoColumnSection: SectionOptions = { + itemsCount: 2, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return 100 + } + } + lastSection: SectionOptions = { + itemsCount: 20, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + + // 计算FlowItem高度 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的高度数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + // 初始化瀑布流分组信息 + let sectionOptions: SectionOptions[] = [] + let count = 0 + let oneOrTwo = 0 + while (count < this.dataCount) { + if (this.dataCount - count < 20) { + this.lastSection.itemsCount = this.dataCount - count + sectionOptions.push(this.lastSection) + break; + } + if (oneOrTwo++ % 2 == 0) { + sectionOptions.push(this.oneColumnSection) + count += this.oneColumnSection.itemsCount + } else { + sectionOptions.push(this.twoColumnSection) + count += this.twoColumnSection.itemsCount + } + } + this.sections.splice(0, 0, sectionOptions) + } + + build() { + Column({ space: 2 }) { + Row() { + Button('scrollEdge Edge.Bottom') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Bottom); + }).id('UIComponentListAndGridWaterSections0490_001') + .margin({ top: 10, left: 20 }) + Button('scrollEdge Edge.Top') + .height('5%') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }).id('UIComponentListAndGridWaterSections0490_002') + .margin({ top: 10, left: 20 }) + }.margin({ bottom: 20 }) + + WaterFlow({ scroller: this.scroller, sections: this.sections,layoutMode:1 }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + ReusableFlowItem({ item: item }) + } + .width('100%') + // 以onGetItemMainSizeByIndex为准 + // .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .id('UIComponentListAndGridWaterSections0490') + .columnsTemplate('1fr 1fr') // 瀑布流使用sections参数时该属性无效 + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .layoutWeight(1) + .onScrollIndex((first: number, last: number) => { + // 即将触底时提前增加数据 + if (last + 20 >= this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + // 更新数据源后同步更新sections,修改最后一个section的FlowItem数量 + const sections: Array = this.sections.values(); + let newSection: SectionOptions = sections[this.sections.length() - 1]; + newSection.itemsCount += 100; + this.sections.update(-1, newSection); + } + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0550.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0550.ets new file mode 100644 index 0000000000000000000000000000000000000000..30bd10cef33297ac1616fcc2fd7e91506f4ee953 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0550.ets @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridWaterSections0550 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State newPosition: Position = {x:100,y:100} + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + // 存在对应的jpg文件才会显示图片 + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + // 即将触底时提前增加数据 + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .offset(this.newPosition) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onReachStart(() => { + console.info('waterFlow reach start') + }) + .onScrollStart(() => { + console.info('waterFlow scroll start') + }) + .onScrollStop(() => { + console.info('waterFlow scroll stop') + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()) + return { offsetRemain: offset } + }) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0580.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0580.ets new file mode 100644 index 0000000000000000000000000000000000000000..5348ca99e313a7f2000c917bd9e745d531bed215 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0580.ets @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource1' +import { LengthMetrics } from '@kit.ArkUI' + +import image from '@ohos.multimedia.image' + +@Entry +@Component +struct UIComponentListAndGridWaterSections0580 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State onscrollIndexInfo: string = '' + @State textvisibility: Visibility = Visibility.Visible; + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number|undefined|null=0 + @State bool:boolean=true + //@State layoutMode1:number=0 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + + Column({ space: 2 }) { + Scroll() { + Column() { + Row(){ + Button('默认布局').height(40).onClick(() => { + this.layoutMode1 = 0 + }) + Button('移动窗口布局').height(40).onClick(() => { + this.layoutMode1 = 1 + + }).id('UIComponentListAndGridWaterSections0580_001'); + + } + Row(){ + Button('单独节点显隐:'+`${this.visibilitys[this.Visibilitynum%3]}`) + .onClick((event: ClickEvent) => { + this.Visibilitynum++ + }); + Button("footer显隐:"+this.flag ) + .onClick(() => { + this.flag=!this.flag + }); + Button("Text隐藏" ) + .onClick(() => { + this.textvisibility = Visibility.Hidden; + }).id('UIComponentListAndGridWaterSections0580_002'); + } + Row(){ + Text(this.onscrollIndexInfo).visibility(this.textvisibility) + } + + } + } .border({width:1}).margin({left:2}) + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(Visibility.None); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.img2')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(this.colors[item % 5]) + }, (item: string, index: number) => item + index+Math.random()) + } + .id('UIComponentListAndGridWaterSections0580') + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '+last:' + last); + this.onscrollIndexInfo='onScrollIndex-' + 'first:' + first + '+last:' + last; + }) + .backgroundColor(Color.Black) + .width(350) + .height('40%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d6f4b1ab33cd7957083e0a15bcb4b590e3e8808 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource1.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource1.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b7ef412b866b2efdabb2579175f618b0ba00bb4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterSections/WaterFlowDataSource1.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 10; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b79dbbd19c9407393af4e4cd2507662a83bf71b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + @State sections: WaterFlowSections = new WaterFlowSections() + @State isFullScreen: boolean = false + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State mode:number = 0; + @State row:string = '1fr 1fr 1fr'; + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('change mode') + .id('UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141_001') + .onClick((event: ClickEvent) => { + this.mode = 1; + }) + Button('change row') + .id('UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141_002') + .onClick((event: ClickEvent) => { + this.row = '1fr 1fr'; + }) + WaterFlow({ scroller: this.scroller, layoutMode: this.mode }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Blue) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate(this.row) + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624.ets new file mode 100644 index 0000000000000000000000000000000000000000..4740ad84ade2b411a8212f76118c8ea3567f3de6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + @State sections: WaterFlowSections = new WaterFlowSections() + @State isFullScreen: boolean = false + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller, layoutMode: WaterFlowLayoutMode.ALWAYS_TOP_DOWN }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Blue) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0dfb0fc43e86cf6436dcc91408cb12ad68b32ce --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + @State sections: WaterFlowSections = new WaterFlowSections() + @State isFullScreen: boolean = false + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller, layoutMode: -1 }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Blue) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..eff87786a6e2817dc4637d7a567ae26d988ddc5d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/WaterFlowDataSource.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211.ets new file mode 100644 index 0000000000000000000000000000000000000000..574063ebb094bedc8c84508c6d6cfa5f6786b035 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211.ets @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import window from '@ohos.window'; +import common from '@ohos.app.ability.common'; +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListAndGridWaterflowSections0460211 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + @State sections: WaterFlowSections = new WaterFlowSections() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State isFullScreen: boolean = false + + horVerSwitch() { + let context = getContext(this) as common.UIAbilityContext; + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(this.isFullScreen ? window.Orientation.PORTRAIT : window.Orientation.LANDSCAPE) + this.isFullScreen = !this.isFullScreen + }) + } + + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('splice') + .id('UIComponentListAndGridWaterflowSections0460211_002') + .height('5%') + .onClick(() => { + let totalCount: number = this.dataSource.totalCount() + let newSection: SectionOptions = { + itemsCount: totalCount, + crossCount: 2, + onGetItemMainSizeByIndex: (index: number) => { + return this.itemHeightArray[index % 100] + } + } + let oldLength: number = this.sections.length() + this.sections.splice(0, oldLength, [newSection]) + }) + .margin({ top: 10, left: 20 }) + Button("横竖屏切换") + .id('UIComponentListAndGridWaterflowSections0460211_001') + .onClick(() => { + this.horVerSwitch(); + }) + WaterFlow({ scroller: this.scroller, sections: this.sections }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Blue) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..eff87786a6e2817dc4637d7a567ae26d988ddc5d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSections/WaterFlowDataSource.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0150660.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0150660.ets new file mode 100644 index 0000000000000000000000000000000000000000..9709c2a1716ab658bdbc95faed4ed0b848b09a38 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0150660.ets @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource2' + +@Entry +@Component +struct UIComponentListAndGridWaterflowSpring0150660 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number = 1 + @State bool:boolean=true + // @State layoutMode1:number=1 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + Column({ space: 2 }) { + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(this.visibilitys[this.Visibilitynum%3]); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.icon')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(Color.Grey) + }, (item: string, index: number) => item + index+Math.random()) + } + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Transparent) + .width(350) + .height('60%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0180721.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0180721.ets new file mode 100644 index 0000000000000000000000000000000000000000..1bffc6e46e850d172f230f7589796d30f0ccea86 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0180721.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridWaterflowSpring0180721 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number = 1 + @State bool:boolean=true + // @State layoutMode1:number=1 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + Column({ space: 2 }) { + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(50) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(this.visibilitys[this.Visibilitynum%3]); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.icon')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(Color.Yellow) + }, (item: string, index: number) => item + index+Math.random()) + } + .id('UIComponentListAndGridWaterflowSpring0180721_001') + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Transparent) + .width(350) + .height('60%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0250290.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0250290.ets new file mode 100644 index 0000000000000000000000000000000000000000..300b9a2a7559aa53ae90fb798ede30b1ec783e28 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0250290.ets @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridWaterflowSpring0250290 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number = 1 + @State bool:boolean=true + // @State layoutMode1:number=1 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + Column({ space: 2 }) { + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(this.visibilitys[this.Visibilitynum%3]); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.img2')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(Color.Pink) + }, (item: string, index: number) => item + index+Math.random()) + } + .padding(this.fatherPadding) + .layoutDirection(FlexDirection.RowReverse) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Black) + .width(350) + .height('60%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb2bcd7aa61579831007049d6bbba156a1c116d2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 10; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource2.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource2.ets new file mode 100644 index 0000000000000000000000000000000000000000..f95647ac1765a4a95e97b4cffea81c2263137bb3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridWaterflowSpring/WaterFlowDataSource2.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 15; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0510711.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0510711.ets new file mode 100644 index 0000000000000000000000000000000000000000..426849c5f85ef4b4327c39182be2501b07981b5d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0510711.ets @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource'; +import Curves from '@ohos.curves'; + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0510711 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + Button('scrollTo') + .id('UIComponentListAndGridXommonOnscroll0510711_001') + .onClick(()=>{ + let curve: Curve | ICurve = Curves.interpolatingSpring(10, 1, 228, 30); + const yOffset: number = this.scroller.currentOffset().yOffset; + this.scroller.scrollTo({ xOffset: 0, yOffset: yOffset + 100, animation: { duration: 1000, curve: curve } }) + }) + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0510711_002') + .onClick(()=>{ + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0530136.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0530136.ets new file mode 100644 index 0000000000000000000000000000000000000000..28957bad45cb8c089edcbca2911cb5847de69faf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0530136.ets @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0530136 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + + Button('scrollToIndex') + .id('UIComponentListAndGridXommonOnscroll0530136_001') + .onClick(() => { + this.scroller.scrollToIndex(10) + }) + + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0530136_002') + .onClick(()=>{ + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0540791.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0540791.ets new file mode 100644 index 0000000000000000000000000000000000000000..82ce3bf8732581463ada454db980d54e75a04d61 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0540791.ets @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0540791 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + Button('scrollToIndex') + .id('UIComponentListAndGridXommonOnscroll0540791_001') + .onClick(()=>{ + this.scroller.scrollToIndex(10) + }) + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0540791_002') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0550659.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0550659.ets new file mode 100644 index 0000000000000000000000000000000000000000..514dd23dea5eea003c9cae11e0d321b148e9854b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0550659.ets @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0550659 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + Button('scrollBy') + .id('UIComponentListAndGridXommonOnscroll0550659_001') + .onClick(()=>{ + this.scroller.scrollBy(0,100); + }) + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0550659_002') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0560601.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0560601.ets new file mode 100644 index 0000000000000000000000000000000000000000..4915383d9b0ce23e946c5e92a39a1fabb9c2ba3a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0560601.ets @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0560601 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + + Button('scrollPage') + .id('UIComponentListAndGridXommonOnscroll0560601_001') + .onClick(() => { + this.scroller.scrollPage({ next: true }); + }) + + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0560601_002') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0570768.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0570768.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e4b7fe3bc26437267c11415857c6320d4fe3b4c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0570768.ets @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0570768 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0570768_001') + .onClick(()=>{ + this.scroller.scrollEdge(Edge.Bottom); + }) + + Button('scrollEdge') + .id('UIComponentListAndGridXommonOnscroll0570768_002') + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }) + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0680459.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0680459.ets new file mode 100644 index 0000000000000000000000000000000000000000..358d43603ee697a7908a7efbdd677b5b782b8ea6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0680459.ets @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentListAndGridXommonOnscroll0680459 { + @State minSize: number = 80; + @State maxSize: number = 180; + @State fontSize: number = 24; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]; + scroller: Scroller = new Scroller(); + dataSource: WaterFlowDataSource = new WaterFlowDataSource(); + @State willScoll: string = ''; + @State didScoll: string = ''; + private itemWidthArray: number[] = []; + private itemHeightArray: number[] = []; + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize); + return (ret > this.minSize ? ret : this.minSize); + } + + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()); + this.itemHeightArray.push(this.getSize()); + } + } + + aboutToAppear() { + this.setItemSizeArray(); + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Column() { + Text('onWillScroll handler: ' + this.willScoll) + Text('onDidScroll handler: ' + this.didScoll) + } + + Column({ space: 2 }) { + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(40) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height(300) + .edgeEffect(EdgeEffect.Spring) + .onWillScroll(() => { + this.willScoll = 'onWillScroll succ'; + }) + .onDidScroll(() => { + this.didScoll = 'onDidScroll succ'; + }) + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d6f4b1ab33cd7957083e0a15bcb4b590e3e8808 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListAndGridXommonOnscroll/WaterFlowDataSource.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0080380.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0080380.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a1d9a3c65877f3bc3c8ac2cfe57e01ecfb46fd1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0080380.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0080380 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollIndex: string = ''; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollIndex((first, last) => { + console.log(`renyj+${first},${last}`) + this.onScrollIndex = '' + first + last; + }) + + Text('onScrollIndex:' + this.onScrollIndex) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0090043.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0090043.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c35e37b9c0653a24b583cc379b436ba0c60a3b2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0090043.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0090043 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollIndex: string = ''; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollIndex((first, last) => { + console.log(`renyj+${first},${last}`) + this.onScrollIndex = '' + first + last; + }) + + Text('onScrollIndex:' + this.onScrollIndex) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0180890.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0180890.ets new file mode 100644 index 0000000000000000000000000000000000000000..315be1f88b50e5229f55b04abb21bd5f6474c740 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0180890.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0180890 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollIndex: string = ''; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('scrollToIndex') + .id('UIComponentListandgridWaterflowEventenhancement0180890_001') + .onClick(()=>{ + this.scroller.scrollPage({ next: true }); + }) + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollIndex((first, last) => { + console.log(`renyj+${first},${last}`) + this.onScrollIndex = '' + first + last; + }) + + Text('onScrollIndex:' + this.onScrollIndex) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0200448.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0200448.ets new file mode 100644 index 0000000000000000000000000000000000000000..10f97537948091735338d27c18830a93d5389dde --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0200448.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0200448 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStart: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onScrollStart(() => { + this.onScrollStart = 'onScrollStart succ' + }) + Text('onScrollStart:' + this.onScrollStart) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0230655.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0230655.ets new file mode 100644 index 0000000000000000000000000000000000000000..b80d93fd147be41418b0f28f1817fe0b567e001e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0230655.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0230655 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStart: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStart(() => { + this.onScrollStart = 'onScrollStart succ' + }) + Text('onScrollStart:' + this.onScrollStart) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0240733.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0240733.ets new file mode 100644 index 0000000000000000000000000000000000000000..e31d2fef31817648ba584f3c7405d3cdc6986954 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0240733.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0240733 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStart: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('scrollToIndex') + .id('UIComponentListandgridWaterflowEventenhancement0240733_001') + .onClick(()=>{ + this.scroller.scrollToIndex(20); + }) + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStart(() => { + this.onScrollStart = 'onScrollStart succ' + }) + Text('onScrollStart:' + this.onScrollStart) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0250294.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0250294.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b0ec6fa016c16603beb848488af521ddd3b4b3d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0250294.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0250294 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStop: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStop(() => { + this.onScrollStop = 'onScrollStop succ'; + }) + Text('onScrollStop:' + this.onScrollStop) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0280114.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0280114.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d5e0bc091f7927dee9d74d2efb131d6d8d95021 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0280114.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0280114 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStop: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStop(() => { + this.onScrollStop = 'onScrollStop succ'; + }) + Text('onScrollStop:' + this.onScrollStop) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0290143.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0290143.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d8967f9d9810e28e9f9999263b7e5ea0cacf2b5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0290143.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0290143 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStop: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('scrollToIndex') + .id('UIComponentListandgridWaterflowEventenhancement0290143_001') + .onClick(()=>{ + this.scroller.scrollToIndex(20); + }) + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStop(() => { + this.onScrollStop = 'onScrollStop succ'; + }) + Text('onScrollStop:' + this.onScrollStop) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0300527.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0300527.ets new file mode 100644 index 0000000000000000000000000000000000000000..500de62b18fd90dd174197bbe727ced0039e6884 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0300527.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct UIComponentListandgridWaterflowEventenhancement0300527 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State onScrollStop: string = '' + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 12; i++) { + //this.itemWidthArray.push(this.getSize()) + //this.itemHeightArray.push(this.getSize()) + this.itemWidthArray.push(60) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button("滚动到Top") + .id("UIComponentListandgridWaterflowEventenhancement0300527_01") + .onClick(() => { + this.scroller.scrollEdge(Edge.Top); + }) + + WaterFlow({ scroller: this.scroller }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r("app.media.icon")) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(50) + .backgroundColor(Color.Pink) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .rowsTemplate("1fr 1fr 1fr") + .columnsGap('abc') + .rowsGap('abc') + .backgroundColor(0xFAEEE0) + .width('100%') + .height('60%') + .onScrollStop(() => { + this.onScrollStop = 'onScrollStop succ'; + }) + + Text('onScrollStop:' + this.onScrollStop) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..eff87786a6e2817dc4637d7a567ae26d988ddc5d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentListandgridWaterflowEventenhancement/WaterFlowDataSource.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabs/UIComponentNavTabs0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabs/UIComponentNavTabs0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..dea2d84137d1858e528e17b33ac9ceebbbdf194e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabs/UIComponentNavTabs0010.ets @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import webview from '@ohos.web.webview'; + +@Entry +@Component +struct UIComponentNavTabs0010 { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column({ space: 5 }) { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column() { + Web({ src: $rawfile("index.html"), controller: this.controller, incognitoMode: true }) + }.width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink')); + + TabContent() { + Column() { + Web({ src: $rawfile("index.html"), controller: this.controller, incognitoMode: true }) + }.width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow')); + + TabContent() { + Column() { + Web({ src: $rawfile("index.html"), controller: this.controller, incognitoMode: true }) + }.width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue')); + + TabContent() { + Column() { + Web({ src: $rawfile("index.html"), controller: this.controller, incognitoMode: true }) + }.width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green')); + + } + .id('UIComponentNavTabs0010_001') + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb34207b98427a01c8a08bbc2f3634bf3e413219 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0090.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType0090 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAction0090 { + @State data: itemType0090[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + private durationList: number[] = [] + private timeoutList: number[] = [] + private customContentTransition: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + } + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition + return tabContentAnimatedTransition + } + + aboutToAppear(): void { + let duration = 1000 + let timeout = 1000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration * i) + this.timeoutList.push(timeout * i) + } + } + + build() { + Column() { + Tabs() { + ForEach(this.data, (item: itemType0090, index: number) => { + TabContent() { + } + .tabBar(new SubTabBarStyle(item.text).id(item.text)) + .backgroundColor(item.backgroundColor) + // 自定义动画变化透明度、缩放页面等 + .opacity(this.opacityList[index]) + .scale({ x: this.scaleList[index], y: this.scaleList[index] }) + }) + } + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .id('UIComponentNavTabsAction0090') + .customContentTransition(this.customContentTransition); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..491b70aea4980a05a021eda2f244bbe6b5614055 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0130.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsAction0130 { + @State currentIndex: number = 0; + @State infoMsg: string = ''; + @State simpleList: Array = ['1']; + private controller: TabsController = new TabsController() + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title) + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center); + } + + + build() { + Row() { + Column() { + Tabs({ barPosition: BarPosition.End, index: this.currentIndex }) { + ForEach(this.simpleList, (item: string) => { + TabContent() { + Column() { + Text(`Content:${item}`) + } + }.tabBar(this.tabBuilder(item, 1)); + }, (item: string) => item) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(360) + .height(200) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsAction0130'); + Text('' + this.infoMsg).id('tabsAction0130_003') + Button('addTabs').width('50%').margin({ top: 20 }) + .onClick(() => { + for (let i = 2; i <= 10; i++) { + this.simpleList.push(i.toString()); + } + this.infoMsg='add success'; + }).id('tabsAction0130_001'); + + Button('changeTabIndex').width('50%').margin({ top: 20 }) + .onClick(() => { + this.currentIndex += 1; + }).id('tabsAction0130_002'); + } + .width('100%') + .height('100%'); + + } + .height('100%') + .backgroundColor(0xF1F3F5); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..5da972a07c2f381faf5fa99cff124a85e85965b2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0140.ets @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsAction0140 { + @State currentIndex: number = 0; + @State infoMsg: string = ''; + @State simpleList: Array = ['1','2','3','4']; + private controller: TabsController = new TabsController() + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title) + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center); + } + + + build() { + Row() { + Column() { + Tabs({ barPosition: BarPosition.End, index: this.currentIndex }) { + ForEach(this.simpleList, (item: string) => { + TabContent() { + Column() { + Text(`Content:${item}`) + } + }.tabBar(this.tabBuilder(item, 1)); + }, (item: string) => item) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(360) + .height(200) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsAction0140'); + Text('' + this.infoMsg).id('tabsAction0140_003') + Button('delTabs').width('50%').margin({ top: 20 }) + .onClick(() => { + this.simpleList.pop(); + this.infoMsg='del success'; + }).id('tabsAction0140_001'); + + Button('changeTabIndex').width('50%').margin({ top: 20 }) + .onClick(() => { + this.currentIndex += 1; + }).id('tabsAction0140_002'); + } + .width('100%') + .height('100%'); + + } + .height('100%') + .backgroundColor(0xF1F3F5); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3874ea69a9fe95b68a72fa7ad89e63a54e8faa0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0180.ets @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class A { + text: string = '' + num: number = 0 +} + +@Entry +@Component +struct UIComponentNavTabsAction0180 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State currentIndex: number = 0 + @State msgInfo: string = '' + @Builder + NavigationTitle() { + Column() { + Text('Navigation Title') + .fontColor('#182431') + .fontSize(30) + .lineHeight(41) + .fontWeight(700) + }.alignItems(HorizontalAlign.Start) + } + + + build() { + Column() { + Navigation() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo=this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo=this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + }) + + } + .id('UIComponentNavTabsAction0180') + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('90%') + .height('50%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + } + .title(this.NavigationTitle) + .titleMode(NavigationTitleMode.Mini) + .hideTitleBar(false) + .hideToolBar(false) + .onTitleModeChange((titleModel: NavigationTitleMode) => { + console.info('titleMode' + titleModel); + }); + }.width('100%').height('100%').backgroundColor('#F1F3F5'); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated003.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated003.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d397a7d95d579adf0ed691bcacd849428785b8d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated003.ets @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType003 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAnimated003 { + @State data: itemType003[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State changeIndex: number = 0; + private tabsController: TabsController = new TabsController() + @State msgInfo: string = '' + private durationList: number[] = [] + private timeoutList: number[] = [] + private baseCustomAnination: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + this.msgInfo='from ' + from + ' to ' + to; + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 300 + let timeout = 2000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration ) + this.timeoutList.push(timeout ) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink').selectedMode(this.selectedMode)).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green').selectedMode(this.selectedMode)).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.baseCustomAnination) + .onTabBarClick((index: number) => { + //this.msgInfo = 'trigger onTabBarClick' + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // this.msgInfo = 'trigger onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + //this.msgInfo = 'trigger onAnimationEnd' + }) + .onChange((index: number) => { + // this.msgInfo = 'trigger onChange' + }) + .id('UIComponentNavTabsAnimated003'); + + Text(this.msgInfo); + + Button('BOARDMode') + .onClick(() => { + if (this.selectedMode == SelectedMode.INDICATOR) { + this.selectedMode = SelectedMode.BOARD; + } + else { + this.selectedMode = SelectedMode.INDICATOR; + } + this.changeIndex++; + if(this.changeIndex>=4) + { + this.changeIndex=0; + } + this.msgInfo = 'trigger changeIndex' + this.changeIndex; + this.tabsController.changeIndex(this.changeIndex); + }).id('UIComponentNavTabsAnimated003_001'); + Button('clear') + .onClick(() => { + this.msgInfo = ''; + }).id('UIComponentNavTabsAnimated003_002'); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated005.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated005.ets new file mode 100644 index 0000000000000000000000000000000000000000..d30e4c56927f3a33690f1f3881c4800a387bd0f4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated005.ets @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType005 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAnimated005 { + @State data: itemType005[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State changeIndex: number = 0; + private tabsController: TabsController = new TabsController() + @State msgInfo: string = '' + private durationList: number[] = [] + private timeoutList: number[] = [] + private baseCustomAnination: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + this.msgInfo='from ' + from + ' to ' + to; + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 300 + let timeout = 2000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration ) + this.timeoutList.push(timeout ) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink').selectedMode(this.selectedMode)).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green').selectedMode(this.selectedMode)).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.baseCustomAnination) + .onTabBarClick((index: number) => { + //this.msgInfo = 'trigger onTabBarClick' + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // this.msgInfo = 'trigger onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + //this.msgInfo = 'trigger onAnimationEnd' + }) + .onChange((index: number) => { + // this.msgInfo = 'trigger onChange' + }) + .id('UIComponentNavTabsAnimated005'); + + Text(this.msgInfo); + + Button('BOARDMode') + .onClick(() => { + if (this.selectedMode == SelectedMode.INDICATOR) { + this.selectedMode = SelectedMode.BOARD; + } + else { + this.selectedMode = SelectedMode.INDICATOR; + } + this.changeIndex++; + if(this.changeIndex>=4) + { + this.changeIndex=0; + } + this.msgInfo = 'trigger changeIndex' + this.changeIndex; + this.tabsController.changeIndex(this.changeIndex); + }).id('UIComponentNavTabsAnimated005_001'); + Button('clear') + .onClick(() => { + this.msgInfo = ''; + }).id('UIComponentNavTabsAnimated005_002'); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated007.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated007.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8c5fdb62fd99614a9f7f31f5f13530b67438acd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated007.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType007 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAnimated007 { + @State data: itemType007[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State msgInfo: string = '' + private durationList: number[] = [] + private timeoutList: number[] = [] + private baseCustomAnination: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + this.msgInfo='from ' + from + ' to ' + to; + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 3000 + let timeout = 5000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration * i) + this.timeoutList.push(timeout * i) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink').selectedMode(this.selectedMode)).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green').selectedMode(this.selectedMode)).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.baseCustomAnination) + .onTabBarClick((index: number) => { + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + }) + .onChange((index: number) => { + }).id('UIComponentNavTabsAnimated007'); + + Text(this.msgInfo); + + Button('BOARDMode') + .onClick(()=>{ + if(this.selectedMode == SelectedMode.INDICATOR) { + this.selectedMode = SelectedMode.BOARD; + } + else + { + this.selectedMode = SelectedMode.INDICATOR; + } + }).id('UIComponentNavTabsAnimated007_001'); + Button('clear') + .onClick(()=>{ + this.msgInfo=''; + }).id('UIComponentNavTabsAnimated007_002'); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated012.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated012.ets new file mode 100644 index 0000000000000000000000000000000000000000..c54e833f1e89c3f1586fae38066baf10786aed42 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated012.ets @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType012 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAnimated012 { + @State data: itemType012[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State msgInfo: string = '' + private durationList: number[] = [] + private timeoutList: number[] = [] + private customContentTransition: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + this.msgInfo='trigger finishTransition' + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + this.msgInfo='trigger customContentTransition'; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 3000 + let timeout = 5000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration * i) + this.timeoutList.push(timeout * i) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')).opacity(this.opacityList[2]) + .scale({ x: this.scaleList[2], y: this.scaleList[2] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.customContentTransition) + .onTabBarClick((index: number) => { + this.msgInfo='trigger onTabBarClick' + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.msgInfo='trigger onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.msgInfo='trigger onAnimationEnd' + }) + .onChange((index: number) => { + this.msgInfo='trigger onChange' + }).id('UIComponentNavTabsAnimated012'); + Text(this.msgInfo); + Button('clear') + .onClick(()=>{ + this.msgInfo=''; + }).id('UIComponentNavTabsAnimated012_001'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated015.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated015.ets new file mode 100644 index 0000000000000000000000000000000000000000..4715fc6f62cd4c321545fa7f6ae1bc503bf631bd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated015.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType015 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsAnimated015 { + @State data: itemType015[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State msgInfo: string = '' + @State height1: string = '100%' + @State width1: string = '100%' + private durationList: number[] = [] + private timeoutList: number[] = [] + private customContentTransition: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + this.msgInfo='trigger finishTransition' + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + this.msgInfo='trigger customContentTransition'; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 3000 + let timeout = 5000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration * i) + this.timeoutList.push(timeout * i) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')).opacity(this.opacityList[2]) + .scale({ x: this.scaleList[2], y: this.scaleList[2] }); + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.customContentTransition) + .onChange((index: number) => { + this.msgInfo='trigger onChange' + }).id('UIComponentNavTabsAnimated015'); + + Button('change width/height') + .onClick(()=>{ + if(this.width1 == '100%') + { + this.width1 = '80%'; + } + else + { + this.width1 = '100%'; + } + + if(this.height1 == '100%') + { + this.height1 = '80%'; + } + else + { + this.height1 = '100%'; + } + + }).id('UIComponentNavTabsAnimated015_001'); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9e57d4a6ac8571269b0e38b0e8495840ffb0bad --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037.ets @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsBlurStyle0037 { + private controller: TabsController = new TabsController() + @State indicatorColor: Color = Color.Yellow; + @State indicatorWidth: number = 40; + @State indicatorHeight: number = 10; + @State indicatorBorderRadius: number = 5; + @State indicatorSpace: number = 10; + @State subTabBorderRadius: number = 20; + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + private colorFlag: boolean = true; + private widthFlag: boolean = true; + private heightFlag: boolean = true; + private borderFlag: boolean = true; + private spaceFlag: boolean = true; + + build() { + Column() { + Button("下划线颜色变化").width('100%').margin({ bottom: '12vp' }) + .onClick((event?: ClickEvent) => { + // 对Button组件的宽高属性进行动画配置 + if (this.colorFlag) { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorColor = Color.Red + }) + } else { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorColor = Color.Yellow + }) + } + this.colorFlag = !this.colorFlag + }).id('UIComponentNavTabsBlurStyle0037_001'); + Button("下划线高度变化").width('100%').margin({ bottom: '12vp' }) + .onClick((event?: ClickEvent) => { + // 对Button组件的宽高属性进行动画配置 + if (this.heightFlag) { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorHeight = 20 + }) + } else { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorHeight = 10 + }) + } + this.heightFlag = !this.heightFlag + }).id('UIComponentNavTabsBlurStyle0037_002'); + Button("下划线宽度变化").width('100%').margin({ bottom: '12vp' }) + .onClick((event?: ClickEvent) => { + // 对Button组件的宽高属性进行动画配置 + if (this.widthFlag) { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorWidth = 30 + }) + } else { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorWidth = 50 + }) + } + this.widthFlag = !this.widthFlag + }).id('UIComponentNavTabsBlurStyle0037_003'); + Button("下划线圆角半径变化").width('100%').margin({ bottom: '12vp' }) + .onClick((event?: ClickEvent) => { + // 对Button组件的宽高属性进行动画配置 + if (this.borderFlag) { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorBorderRadius = 0 + }) + } else { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorBorderRadius = 5 + }) + } + this.borderFlag = !this.borderFlag + }).id('UIComponentNavTabsBlurStyle0037_004'); + Button("下划线间距变化").width('100%').margin({ bottom: '12vp' }) + .onClick((event?: ClickEvent) => { + // 对Button组件的宽高属性进行动画配置 + if (this.spaceFlag) { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorSpace = 20 + }) + } else { + animateTo({ + duration: 1000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 200, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + console.info('play end') + } + }, () => { + this.indicatorSpace = 10 + }) + } + this.spaceFlag = !this.spaceFlag + }).id('UIComponentNavTabsBlurStyle0037_005'); + + Tabs({ barPosition: BarPosition.End, controller: this.controller }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp') + }.tabBar(SubTabBarStyle.of('Pink') + .indicator({ + color: this.indicatorColor, //下划线颜色 + height: this.indicatorHeight, //下划线高度 + width: this.indicatorWidth, //下划线宽度 + borderRadius: this.indicatorBorderRadius, //下划线圆角半径 + marginTop: this.indicatorSpace //下划线与文字间距 + }) + .selectedMode(this.selectedMode) + .board({ borderRadius: this.subTabBorderRadius }) + .labelStyle({}) + ) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp') + }.tabBar(SubTabBarStyle.of('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue).borderRadius('12vp') + }.tabBar(SubTabBarStyle.of('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green).borderRadius('12vp') + }.tabBar(SubTabBarStyle.of('Green')); + } + .vertical(false) + .scrollable(true) + .barHeight(140) + .barMode(BarMode.Fixed) + .animationDuration(400) + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_ULTRA_THICK) + .onChange((index: number) => { + console.info(index.toString()) + }) + .backgroundColor(0xF5F5F5) + .height(320) + .id('UIComponentNavTabsBlurStyle0037'); + }.width('100%').height(250).padding({ top: '24vp', left: '24vp', right: '24vp' }) + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..234f4acf3de4b9e06a2eda11c1f5c40c84726535 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0010.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0010 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + ////Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + ////Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + ////Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + ////Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: []') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([]) + .then(() => { + console.info('preloadItems success.') + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0010_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba68b23fa80d49edee17922f0b0872326a1b3edf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0020.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0020 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [-1]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([-1]) + .then(() => { + console.info('preloadItems success.') + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0020_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..d049aefc41fe4025332f30fff07c60fd3db1c907 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0030.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0030 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [null]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([null]) + .then(() => { + console.info('preloadItems success.') + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0030_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..1aa288a9ac20a98b3c6f055cd4b3800542260478 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0040.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0040 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo='preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0040_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..163f064b2cccfd8798317d631e537f6d7151b897 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0050.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0050 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,2,4,5]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,2,4,5]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo='preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0050_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..f177f43669e8bcf1ed41bfee9170b4b6d9b6cc7c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0060.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0060 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1000]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1000]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo='preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0060_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..fabfba5a308b743958013d29bf0178f667da5b53 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0070.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0070 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State msgInfo: string='' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [[2,-2]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([2,-2]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo='preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo='preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0070_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..a415251b4a33c585a47a59b368749dac9be4f43c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0080.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0080 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [this.currentIndex - 1, this.currentIndex + 1]]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([this.currentIndex - 1, this.currentIndex + 1]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0080_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..44099233aede219b64c02b1b67460b85ff16550d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0090.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0090 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,10]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,10]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0090_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..f43a5bc5020a02a155c6589255a22d865cada65b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0100.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0100 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,1]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,1]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0100_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..87905883a9b9b7901e63f0751430996d3f5cdf82 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0110.ets @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0110 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(true) + .barHeight(100) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(300) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0110_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..edfd4746e96240299de538a5f69f32907ab0a6d3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0120.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0120 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0120_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc13201b5fcce965a6cc26eb915213a6fa07617b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0130.ets @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0130 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State newVertical: boolean = false; + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(this.newVertical) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + // 按钮用于切换 barPosition + Button('Toggle Vertical') + .margin(5) + .onClick(() => { + this.newVertical = !this.newVertical; + console.info('this.newVertical=', this.newVertical); + }) + .id('UIComponentNavTabsCachedCount0130_001'); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0130_002'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d274a03c67635f4b7b8857e7b44209170103416 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0140.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0140 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0140_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f9eaddad48584a9622333a49d79122144f22998 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0150.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0150 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0150_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..35dca64822fa69fcbf4c862fd7cd183f3be9249c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0160.ets @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0160 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State barPosition: BarPosition = BarPosition.Start // 新增状态以动态改变 barPosition + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .barPosition(this.barPosition) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0160_001'); + + Button('change BarPosition') + .margin(5) + .onClick(() => { + this.barPosition = (this.barPosition == BarPosition.Start) ? BarPosition.End : BarPosition.Start; + }).id('UIComponentNavTabsCachedCount0160_002'); + + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..4008cb16650c0a5d4278b6dfbe576b3d2a0413d9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0170.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0170 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width('auto') + .height('auto') + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0170_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..75e8f2bf6b0325494c8f80ee883208404f5381a1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0180.ets @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0180 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width('auto') + .height('auto') + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0180_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4786bc0fe97f5cca532b951e8b4c47e3fed3066 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0190.ets @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0190 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width('auto') + .height('auto') + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1,3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0190_001'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..79b7e2d93031486e393fcbf66acce351d27722f2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0200.ets @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0200 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State msgInfo: string = '' + @State barMode: BarMode = BarMode.Fixed // 新增状态以动态改变 barMode + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(false) + .barHeight(56) + .barMode(this.barMode) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width('auto') + .height('auto') + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1, 3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0200_001'); + + Button('Toggle barMode') + .margin(5) + .onClick(() => { + // 切换 barPosition + this.barMode = (this.barMode == BarMode.Fixed) ? BarMode.Scrollable : BarMode.Fixed; + console.info('Bar position changed to: ' + this.barMode); + }).id('UIComponentNavTabsCachedCount0200_002'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..275727f32248061993f179fba0255e7ce28173a2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0210.ets @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0210 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 3 + @State direction1: Direction = Direction.Rtl; + @State msgInfo: string = '' + @State barMode: BarMode = BarMode.Fixed // 新增状态以动态改变 barMode + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(4)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + //Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(5)) + + } + .vertical(true) + .barHeight(56) + .barMode(this.barMode) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(400) + .height(300) + .direction(this.direction1) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [1,3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([1, 3]) + .then(() => { + console.info('preloadItems success.') + this.msgInfo = 'preloadItems success.' + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.msgInfo = 'preloadItems failed, error code: ' + error.code + ', error message: ' + error.message + }) + }).id('UIComponentNavTabsCachedCount0210_001'); + + Button('change Direction') + .margin(5) + .onClick(() => { + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + console.info('Bar position changed to: ' + this.barMode); + }).id('UIComponentNavTabsCachedCount0210_002'); + Text(this.msgInfo); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8d26dd2040901e5c5fcbaee2b47da409129c452 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0220.ets @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0220 { + @State nextIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.nextIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .padding(20) + .barHeight(60) + .animationDuration(0) + .onTabBarClick((index: number) => { + this.nextIndex = index + console.log("this.nextIndex=",this.nextIndex ); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsCachedCount0220'); + + Button('preload items: [1, 3]') + .margin(5) + .onClick(() => { + this.tabsController.preloadItems([1, 3]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('UIComponentNavTabsCachedCount0220_001'); + + Text('' + this.errMsg) + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..970b6fc44007b3d3b416d7066bdc819a18a9c49c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0230.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0230 { + @State nextIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.nextIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)).margin(10); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)).margin(20); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)).margin(30); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)).margin(40); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onTabBarClick((index: number) => { + this.nextIndex = index + console.log("this.nextIndex=",this.nextIndex ); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsCachedCount0230'); + + Button('preload items: [1, 3]') + .margin(5) + .onClick(() => { + this.tabsController.preloadItems([1, 3]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('tabsCachedCount0230_001'); + + Text('' + this.errMsg).id('tabsCachedCount0230_003'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4b39479ed07d99ac336505ce2f689f92a1c5fef --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0240.ets @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0240 { + @State currentIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + console.log("this.currentIndex=",this.currentIndex ); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + + .id('tabsCachedCount0240'); + + Button('preload items: [1, 3]') + .margin(5) + .onClick(() => { + // 预加载第this.currentIndex -1、this.currentIndex + 1个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabsController.preloadItems([1, 3]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('tabsCachedCount0240_001'); + + Text('' + this.errMsg).id('tabsCachedCount0240_003'); + Text('' + this.currentIndex).id('tabsCachedCount0240_004'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c3d50bc90d2b6f31aa70ef0a2ecdeb3a68d2f2c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0250.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0250 { + @State nextIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.nextIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onTabBarClick((index: number) => { + this.nextIndex = index + console.log("this.nextIndex=",this.nextIndex ); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsCachedCount0250'); + + Button('preload items: [1, 3]') + .margin(5) + .onClick(() => { + this.tabsController.preloadItems([1, 3]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('tabsCachedCount0250_001'); + + Text('' + this.errMsg).id('tabsCachedCount0250_003'); + Text('' + this.nextIndex).id('tabsCachedCount0250_004'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0260.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0260.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd562413baa04502dbfc4c51280f09756c277b6a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0260.ets @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0260 { + @State nextIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.nextIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onContentWillChange((currentIndex, comingIndex) => { + this.nextIndex = comingIndex; + console.log("this.currentIndex=",this.nextIndex ); + return true + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsCachedCount0260'); + + Button('preload items: [1, 4]') + .margin(5) + .onClick(() => { + // 预加载第this.currentIndex -1、this.currentIndex + 1个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabsController.preloadItems([1, 4]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('tabsCachedCount0260_001'); + + Text('' + this.errMsg).id('tabsCachedCount0260_003'); + Text('' + this.nextIndex).id('tabsCachedCount0260_004'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a0ef6cd6435076536c23f13b9ab27b6f9b67605 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0270.ets @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0270 { + @State currentIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('首页',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('发现',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('推荐',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('我的',3)); + + TabContent() { + Column(){ + Text('其它') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('其它',4)); + + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsCachedCount0270'); + + Button('preload items: [1, 4]') + .margin(5) + .onClick(() => { + // 预加载第this.currentIndex -1、this.currentIndex + 1个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabsController.preloadItems([1, 4]) + .then(() => { + this.errMsg = 'success'; + }) + .catch((error: BusinessError) => { + this.errMsg = error.message; + console.log("error=",this.errMsg ) + }) + }).id('tabsCachedCount0270_001'); + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 5 + this.tabsController.changeIndex(this.currentIndex) + }).id('tabsCachedCount0270_002'); + + Text('' + this.errMsg).id('tabsCachedCount0270_003'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0280.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0280.ets new file mode 100644 index 0000000000000000000000000000000000000000..08bf1563c75589ce5cd0352b932e0185197a074c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0280.ets @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0280 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Image(this.selectedIndex === index ? $r('app.media.cat') : $r('app.media.cat')) + .width(24) + .height(24) + .margin({ bottom: 4 }) + .objectFit(ImageFit.Contain); + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Image($r('app.media.cat')); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [2, 3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([2, 3]) + .then(() => { + console.info('preloadItems success.') + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + }) + }).id('UIComponentNavTabsCachedCount0280_001') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0290.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0290.ets new file mode 100644 index 0000000000000000000000000000000000000000..70d626fef5ed0427c566beb7971b0194eeb70762 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0290.ets @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit' + +@Entry +@Component +struct UIComponentNavTabsCachedCount0290 { + @State webController: webview.WebviewController = new webview.WebviewController(); + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabController }) { + TabContent() { + Column() { + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Web({ src: 'www.huawei.com', controller: this.webController }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Web({ src: 'www.huawei.com', controller: this.webController }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Web({ src: 'www.huawei.com', controller: this.webController }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }); + Web({ src: 'www.huawei.com', controller: this.webController }); + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }); + + Button('preload items: [2, 3]') + .margin(5) + .onClick(() => { + // 预加载第2、3个子节点,提高滑动或点击切换至这些节点时的性能 + this.tabController.preloadItems([2, 3]) + .then(() => { + console.info('preloadItems success.') + }) + .catch((error: BusinessError) => { + console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + }) + }).id('UIComponentNavTabsCachedCount0290_001') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount014.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0300.ets similarity index 74% rename from function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount014.ets rename to function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0300.ets index 0a9b2b6dac4bc4348365dfeaa880fa66686b7c47..658251f337f3b36ab1f523abe60cbec76c6bcf2e 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount014.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0300.ets @@ -13,12 +13,15 @@ * limitations under the License. */ import { BusinessError } from '@kit.BasicServicesKit' - +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' @Entry @Component -struct UIComponentNavTabsCachedCount014 { - @State currentIndex: number = 0 - private tabsController: TabsController = new TabsController() +struct UIComponentNavTabsCachedCount0300 { + @State currentIndex: number = 0; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); build() { Column() { @@ -41,24 +44,28 @@ struct UIComponentNavTabsCachedCount014 { } .width(360) .height(296) + .vertical(true) .backgroundColor('#F1F3F5') .onChange((index: number) => { this.currentIndex = index }) + .id('tabsCachedCount0300'); - Button('preload items: [1, 3]') + Button('preload items: [undefined]') .margin(5) .onClick(() => { // 预加载第1、3个子节点,提高滑动或点击切换至这些节点时的性能 - this.tabsController.preloadItems([1, 3]) + this.tabsController.preloadItems([undefined]) .then(() => { - console.info('preloadItems success.') }) .catch((error: BusinessError) => { - console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) + this.errMsg = error.message; + console.log("error=",this.errMsg ) }) - }) - .id('UIComponentNavTabs014_001') + }).id('tabsCachedCount0300_001'); + + Text('' + this.errMsg).id('tabsCachedCount0300_002') + } } } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..0849fe727cb63832b546aa17274417f59388b829 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0010.ets @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0010 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + this.textValue='trigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onTabBarClick((index: number) => { + + console.log(this.textValue); + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsCapabilityEnhancement0010'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsCapabilityEnhancement0010_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0019.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0019.ets new file mode 100644 index 0000000000000000000000000000000000000000..2706c679c62068847dfba2a0f6c2e35fa3b5f294 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0019.ets @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { i18n } from '@kit.LocalizationKit' +import { LengthMetrics } from '@kit.ArkUI' +import { intl } from '@kit.LocalizationKit' +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0019 { + @State currentIndex: number = 0 + @State animationDuration: string = 'null' + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State errMsg: string = 'haveno'; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name1: string) { + Column() { + Text(name1) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }) + }.width('100%').id(name1) + } + + build() { + + Column({ }) { + + + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area)=> { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(null) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(0, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + this.errMsg='trigger onAnimationStart' + console.info('trigger onAnimationStart') + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onAnimationEnd' + console.info('trigger onAnimationEnd') + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onGestureSwipe' + console.info('trigger onGestureSwipe') + }); + + Text('' + this.errMsg).id('tabsCapabilityEnhancement0019_003'); + + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} + diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..e83a6cddbe83cf3f9328dd7cd560325f42bd3b1b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0020.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0020 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0020') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..973fc62307c30bf1a8baca0397e53fae5bf07031 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0030.ets @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0030 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + this.textValue='trigger onAnimationEnd'; + }) + .onTabBarClick((index: number) => { + + console.log(this.textValue); + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsCapabilityEnhancement0030'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsCapabilityEnhancement0030_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b73d5d644321b3480646fc22c34d09199a2b2f3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0040.ets @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0040 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + this.textValue='trigger onAnimationEnd'; + }) + .onTabBarClick((index: number) => { + console.log(this.textValue); + }) + .onClick(() => { + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width); + }).id('UIComponentNavTabsCapabilityEnhancement0040'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsCapabilityEnhancement0040_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..73257e2f8b72e7cd61a6a9c2e634e79c589a89cf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0050.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0050 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = this.msgInfo + '\nBlue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = this.msgInfo + '\nGreen will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(1000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0050') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d1c5a241ba7138178e5b3a4517f1bc3335b3633 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0060.ets @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { i18n } from '@kit.LocalizationKit' +import { LengthMetrics } from '@kit.ArkUI' +import { intl } from '@kit.LocalizationKit' +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // ϵͳñ仯 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0060 { + @State currentIndex: number = 0 + @State animationDuration: number = 0 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State errMsg: string = 'haveno'; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name1: string) { + Column() { + Text(name1) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }) + }.width('100%').id(name1) + } + + build() { + + Column({ }) { + + + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area)=> { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // indexı仯ʵҳǩݵл + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // лʼʱûص»߸ҳһ𻬶ͬʱȽ䡣 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + this.errMsg='trigger onAnimationStart' + console.info('trigger onAnimationStart') + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // лʱûص»߶ֹͣ + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onAnimationEnd' + console.info('trigger onAnimationEnd') + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // ҳֻУ֡ûص + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onGestureSwipe' + console.info('trigger onGestureSwipe') + }); + + Text('' + this.errMsg).id('tabsCapabilityEnhancement0060_003'); + + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // ҳ滬һ룬tabBarлһҳ + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // ʱ + curve: Curve.Linear, // + iterations: 1, // Ŵ + playMode: PlayMode.Normal, // ģʽ + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} + diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a35317d92bf1ef6c7aa3ff7bd80058be38b7b4d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0070.ets @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { i18n } from '@kit.LocalizationKit' +import { LengthMetrics } from '@kit.ArkUI' +import { intl } from '@kit.LocalizationKit' +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0070 { + @State currentIndex: number = 0 + @State animationDuration: number = 600 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State errMsg: string = 'haveno'; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + @Builder + tabBuilder(index: number, name1: string) { + Column() { + Text(name1) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }) + }.width('100%').id(name1) + } + + build() { + + Column({ }) { + + + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area)=> { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + this.errMsg='trigger onAnimationStart' + console.info('trigger onAnimationStart') + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onAnimationEnd' + console.info('trigger onAnimationEnd') + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + this.errMsg='trigger onGestureSwipe' + console.info('trigger onGestureSwipe') + }); + + Text('' + this.errMsg).id('tabsCapabilityEnhancement0070_003'); + + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} + diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4728765f0e6a07c9ba467419b750c1e8b4b27a6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0080.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0080 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0080') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..7706799040873ded28eaa52b861a571b69ff7d84 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0090.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0090 { + @State currentIndex: number = 2 + private controller: TabsController = new TabsController() + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('首页',0)) + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('发现',1)) + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('推荐',2)) + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('我的',3)) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .id('UIComponentNavTabsCapabilityEnhancement0090') + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(false); + + Button('动态修改index').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + }).id('UIComponentNavTabsCapabilityEnhancement0090_001'); + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + this.controller.changeIndex(this.currentIndex) + }).id('UIComponentNavTabsCapabilityEnhancement0090_002'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..2bf29af9d3ecd51a068fa690a51fb4f411790a85 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0100.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0100 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0100') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a27fcd9a5ff50855c2d8f96377774524eb45cf6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0110.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0110 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0110') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..641a976d7aa622e313743f68fba37755b8f2e71f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0120.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0120 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0120') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..71d8ed1fe2afbe05ca93573d896aaad2ad5cc388 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0130.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0130 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0130') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca97d7672d74c9a4832a9a9b35b4c8c4dc85bc3e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0140.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0140 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = this.msgInfo + '\nBlue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = this.msgInfo + '\nGreen will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(1000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0140') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc59f9efbba7c77f14280bede3293aee33bd0f44 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0150.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0150 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0150') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e0f8d5732bce757aad688024803a2e216bc8efd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0160.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsCapabilityEnhancement0160 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onAnimationEnd'; + }) + .id('UIComponentNavTabsCapabilityEnhancement0160') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + //Text(this.msgInfo); + }.width('100%').height(400) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0360.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0360.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f045c2efba62bc6cc94d6e337eaa06e6deaf0da --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0360.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsContentAdapt0360 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + this.msgInfo='trigger onChange' + }) + .onContentWillChange((currentIndex, comingIndex) => { + return true + }) + .width('100%') + .height('auto') + .id('UIComponentNavTabsContentAdapt0360') + .backgroundColor(0xF1F3F5); + + Text(this.msgInfo); + Button('clear') + .onClick(()=>{ + this.msgInfo=''; + }).id('UIComponentNavTabsContentAdapt0360_001'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0370.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0370.ets new file mode 100644 index 0000000000000000000000000000000000000000..8df7bd92e0760364cb9cad7067766f6db11a5677 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0370.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsContentAdapt0370 { + private controller: TabsController = new TabsController() + @State gridMargin: number = 10 + @State gridGutter: number = 10 + @State sm: number = -2 + @State clickedContent: string = ""; + + build() { + Column() { + + Text("点击内容:" + this.clickedContent).width('100%').height(200).margin({ top: 5 }) + + + Tabs({ barPosition: BarPosition.End, controller: this.controller }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "1").id('1')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "2").id('2')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "3").id('3')) + } + .width('350vp') + .animationDuration(300) + .height('60%') + .barGridAlign({ sm: this.sm, margin: this.gridMargin, gutter: this.gridGutter }) + .backgroundColor(0xf1f3f5) + .onTabBarClick((index: number) => { + this.clickedContent += "now index " + index + " is clicked\n"; + }) + } + .width('100%') + .height(500) + .margin({ top: 5 }) + .padding('10vp') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0380.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0380.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bba8f7a96374ba12a5a66d4580140434a1c545b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0380.ets @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsContentAdapt0380 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .onContentWillChange((currentIndex, comingIndex) => { + this.msgInfo='trigger onContentWillChange' + return true + }) + .width('100%') + .height('auto') + .id('UIComponentNavTabsContentAdapt0380') + .backgroundColor(0xF1F3F5); + + Text(this.msgInfo); + Button('clear') + .onClick(()=>{ + this.msgInfo=''; + }).id('UIComponentNavTabsContentAdapt0380_001'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..04fbba59b57dd4173d02e58904bd6e6ed985c81d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0100.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0100 { + @State currentIndex: number = 3 + private controller: TabsController = new TabsController() + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('首页',0)) + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('发现',1)) + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('推荐',2)) + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('我的',3)) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .id('UIComponentNavTabsEdgeeffect0100') + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(false); + + Button('动态修改index').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + }).id('UIComponentNavTabsEdgeeffect0100_001'); + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + this.controller.changeIndex(this.currentIndex) + }).id('UIComponentNavTabsEdgeeffect0100_002'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..c160120672f249ef1f849fd8ddd30b35c4fa4148 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0170.ets @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0170 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + this.textValue='trigger onChange'; + console.log(this.textValue); + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsEdgeeffect0170'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0170_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d92782580607cd07e99adc8b1fc7e9c7cf7d44a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0180.ets @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0180 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onTabBarClick((index: number) => { + this.textValue='trigger onTabBarClick'; + console.log(this.textValue); + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsEdgeeffect0180'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0180_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..c90da6b9065b9c178e2715175416332e1d16f851 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0190.ets @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0190 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + this.textValue='trigger onAnimationStart'; + console.log(this.textValue); + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsEdgeeffect0190'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0190_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..92b66a78dcbcf39d6c1fe45ceb221f533eab295a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0200.ets @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0200 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + this.textValue='trigger onAnimationEnd'; + console.log(this.textValue); + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsEdgeeffect0200'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0200_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e6894de07e51eab8ed4a4ea4dba4d1105280e52 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0210.ets @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0210 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onContentWillChange((currentIndex, comingIndex) => { + + return true + }) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + this.textValue='trigger onGestureSwipe'; + console.log(this.textValue); + }).id('UIComponentNavTabsEdgeeffect0210'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0210_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..057e3baee8ae6e535495f4436bec3efaa44e5be7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0220.ets @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { LengthMetrics } from '@kit.ArkUI' +import { i18n, intl } from '@kit.LocalizationKit' + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + + +@Entry +@Component +struct UIComponentNavTabsEdgeeffect0220 { + @State currentIndex: number = 0 + @State animationDuration: number = 300 + @State indicatorLeftMargin: number = 0 + @State indicatorWidth: number = 0 + @State textValue: string = ''; + private tabsWidth: number = 0 + private textInfos: [number, number][] = [] + private isStartAnimateTo: boolean = false + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontSize(16) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontWeight(this.currentIndex === index ? 500 : 400) + .id(index.toString()) + .onAreaChange((oldValue: Area, newValue: Area) => { + this.textInfos[index] = [newValue.globalPosition.x as number, newValue.width as number] + }); + + }.width('100%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.tabsWidth = newValue.width as number + if (!this.isStartAnimateTo) { + this.setIndicatorAttr(this.textInfos[this.currentIndex][0], this.textInfos[this.currentIndex][1]) + } + }) + .barWidth('100%') + .barHeight(56) + .width('100%') + .height(296) + .backgroundColor('#F1F3F5') + .animationDuration(this.animationDuration) + .onContentWillChange((currentIndex, comingIndex) => { + this.textValue='trigger onContentWillChange'; + console.log(this.textValue); + return true + }) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]) + + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + // 切换动画结束时触发该回调。下划线动画停止。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); + + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + // 在页面跟手滑动过程中,逐帧触发该回调。 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) + this.currentIndex = currentIndicatorInfo.index + this.setIndicatorAttr(currentIndicatorInfo.left, currentIndicatorInfo.width) + }).id('UIComponentNavTabsEdgeeffect0220'); + Text(this.textValue); + Button('clear text') + .onClick(() => { + this.textValue=''; + }).id('UIComponentNavTabsEdgeeffect0220_001'); + }.width('100%'); + } + + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record { + let nextIndex = index + if (index > 0 && (CommonUtil.getIsRTL() ? event.currentOffset < 0 : event.currentOffset > 0)) { + nextIndex-- + } else if (index < 3 && (CommonUtil.getIsRTL() ? event.currentOffset > 0 : event.currentOffset < 0)) { + nextIndex++ + } + let indexInfo = this.textInfos[index] + let nextIndexInfo = this.textInfos[nextIndex] + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 + let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio + let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } + } + + private startAnimateTo(duration: number, leftMargin: number, width: number) { + this.isStartAnimateTo = true + animateTo({ + duration: duration, // 动画时长 + curve: Curve.Linear, // 动画曲线 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: () => { + this.isStartAnimateTo = false + console.info('play end') + } + }, () => { + this.setIndicatorAttr(leftMargin, width) + }) + } + + private setIndicatorAttr(leftMargin: number, width: number) { + this.indicatorWidth = width + if (CommonUtil.getIsRTL()) { + this.indicatorLeftMargin = this.tabsWidth - leftMargin - width + } else { + this.indicatorLeftMargin = leftMargin + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2db9758d70e428283a8cfa66fbaf0b40a0880d8 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0130.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentNavTabsExpandsafearea0130 { + @State currentIndex: number = 0; + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK; + private controller: TabsController = new TabsController(); + + build() { + Column() { + Text('文本') + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Pink') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + ) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Black') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + ) + + } + .backgroundColor(Color.Green) + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .height('100%') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..917f57842464d735e0096e78a78498ec6e539cee --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0140.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentNavTabsExpandsafearea0140 { + @State currentIndex: number = 0; + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK; + private controller: TabsController = new TabsController(); + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Pink') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + ) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Black') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + ) + + } + .backgroundColor(Color.Green) + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .height('100%') + Text('文本') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a9e9f1901ff4169583580bc69e5168175a00cd1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0150.ets @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentNavTabsExpandsafearea0150 { + @State currentIndex: number = 0; + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK; + private controller: TabsController = new TabsController(); + + build() { + Column() { + Text('文本') + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Pink') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + ) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Black') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + ) + + } + .backgroundColor(Color.Green) + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .height('50%') + Text('文本') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..c22b34fd64f2c30cf81077f3c65b7bae5c852212 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0160.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct UIComponentNavTabsExpandsafearea0160 { + @State currentIndex: number = 0; + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK; + private controller: TabsController = new TabsController(); + @State heightValue: Length = 300; + + build() { + Column() { + Button('change heightValue') + .id('UIComponentNavTabsExpandsafearea0160_001') + .onClick(()=>{ + this.heightValue = '80%'; + }) + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Pink') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Pink }) + ) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_ic_public_text'), 'Black') + .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Black }) + ) + + } + .backgroundColor(Color.Green) + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .height(this.heightValue) + Text('文本') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cd6ab482e76ef3be91b85665feadbcb90565379 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0110.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsImproTrace0110 { + @State currentIndex: number = 0 + @State tabContentWidth: number = 60 + @State tabContentHeight: number = 60 + @State simpleList: Array = ['1']; + private controller: TabsController = new TabsController() + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title) + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center); + } + + build() { + Row() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + ForEach(this.simpleList, (item: string) => { + TabContent() { + Column() { + Text(`Content:${item}`) + } + .height(this.tabContentHeight) + .width(this.tabContentWidth) + .backgroundColor('#FF0000') + .justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder(item, 1)); + }, (item: string) => item) + } + .vertical(false) + .barMode(BarMode.Scrollable) + .barWidth('100%') + .barHeight(200) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width('100%') + .height(400) + .backgroundColor('#F1F3F5') + .scrollable(true); + + Button('addTabContents').width('50%').margin({ top: 20 }) + .onClick(() => { + for (let i = 2; i <= 2000; i++) { + this.simpleList.push(i.toString()); + } + }).id('UIComponentNavTabsImproTrace0110_001'); + + } + .width('100%') + .height('100%'); + } + .height('100%') + .backgroundColor(0xF1F3F5); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..6399e7fce85c5e005ff2d6c90018532793598d29 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0170.ets @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsImproTrace0170 { + @State currentIndex: number = 0 + @State tabContentWidth: number = 60 + @State tabContentHeight: number = 60 + @State simpleList: Array = ['1']; + private controller: TabsController = new TabsController() + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title) + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center); + } + + build() { + Row() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + ForEach(this.simpleList, (item: string) => { + TabContent() { + Column() { + Text(`Content:${item}`) + } + .height(this.tabContentHeight) + .width(this.tabContentWidth) + .backgroundColor('#FF0000') + .justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder(item, 1)); + }, (item: string) => item) + } + .vertical(false) + .barMode(BarMode.Scrollable) + .barWidth('100%') + .barHeight(200) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width('100%') + .height(400) + .backgroundColor('#F1F3F5') + .scrollable(true).id('UIComponentNavTabsImproTrace0170'); + + Button('addTabContents').width('50%').margin({ top: 20 }) + .onClick(() => { + for (let i = 2; i <= 2000; i++) { + this.simpleList.push(i.toString()); + } + }).id('UIComponentNavTabsImproTrace0170_001'); + } + .width('100%') + .height('100%'); + } + .height('100%') + .backgroundColor(0xF1F3F5); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..65413fc55a667a4da63a3d15be09d7bf57ba97ca --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0020.ets @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsInterception0020 { + @State currentIndex: number = 0 + private controller: TabsController = new TabsController() + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + .id(title); + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)); + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)); + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)); + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)); + + TabContent() { + Column(){ + Text('他的内容') + }.width('100%').height('100%').backgroundColor(Color.Red).justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('five',4)); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .onContentWillChange((currentIndex, comingIndex) => { + if (comingIndex == 3) { + return false + } + return true + }) + .id('UIComponentNavTabsInterception0020'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0a4244432216f6108cd40a592429c29ac52ac00 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0140.ets @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsInterception0140 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'no_value'; + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(this.tabBuilder('Red')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width('100%') + .backgroundColor(0xF1F3F5) + .direction(this.direction1) + .onContentWillChange((currentIndex, comingIndex) => { + if(comingIndex==3) + { + return false; + } + else + { + return true + } + + }) + .onTabBarClick((index: number) => { + this.nextIndex = 'click onTabBarClick('+index.toString()+')'; + }) + .id('tabsInterception0140'); + + Text('' + this.nextIndex).id('tabsInterception0140_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..356f0725bbd54a970b6eef809e9b046b5ffb569c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0160.ets @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface itemType0160 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsInterception0160 { + @State data: itemType0160[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }, + { + text: 'Green', + backgroundColor: Color.Green + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State changeIndex: number = 0; + @State currentIndex: number = 0; + private tabsController: TabsController = new TabsController() + @State msgInfo: string = '' + private durationList: number[] = [] + private timeoutList: number[] = [] + private customContentTransition: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + this.msgInfo='from ' + from + ' to ' + to; + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + + } + + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition; + return tabContentAnimatedTransition; + } + + aboutToAppear(): void { + let duration = 300 + let timeout = 2000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration ) + this.timeoutList.push(timeout ) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink').selectedMode(this.selectedMode)).opacity(this.opacityList[0]) + .scale({ x: this.scaleList[0], y: this.scaleList[0] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue').selectedMode(this.selectedMode)).opacity(this.opacityList[1]) + .scale({ x: this.scaleList[1], y: this.scaleList[1] }); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green').selectedMode(this.selectedMode)).opacity(this.opacityList[3]) + .scale({ x: this.scaleList[3], y: this.scaleList[3] }); + + } + .animationDuration(3000) + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .vertical(false) + .customContentTransition(this.customContentTransition) + .onTabBarClick((index: number) => { + //this.msgInfo = 'trigger onTabBarClick' + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // this.msgInfo = 'trigger onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + //this.msgInfo = 'trigger onAnimationEnd' + }) + .onChange((index: number) => { + this.currentIndex = index + }) + .onContentWillChange((currentIndex, comingIndex) => { + if (comingIndex == 3) { + return false + } + return true + }) + .id('UIComponentNavTabsInterception0160'); + + + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..23807b87bf649e0440879369060e360c76edfeab --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0150.ets @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsInterface0150 { + @State currentIndex: number = 2 + private controller: TabsController = new TabsController() + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('首页的内容') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('首页',0)) + + TabContent() { + Column(){ + Text('发现的内容') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('发现',1)) + + TabContent() { + Column(){ + Text('推荐的内容') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('推荐',2)) + + TabContent() { + Column(){ + Text('我的内容') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('我的',3)) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(2000) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + Button('动态修改index').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + }).id('UIComponentNavTabsInterface0150_001'); + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + this.controller.changeIndex(this.currentIndex) + }).id('UIComponentNavTabsInterface0150_002'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..41cd229f8b2d3fed8d25d18129e3a7e699f5fb4b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0170.ets @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsInterface0170 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Scrollable) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3/100) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsInterface0170') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + console.info(index.toString()) + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + Button('Get duration') + .margin(5) + .onClick(() => { + let strJson = getInspectorByKey('UIComponentNavTabsInterface0170'); + let obj: ESObject = JSON.parse(strJson); + this.msgInfo = 'value=' + parseInt(obj.$attrs.animationDuration); + }).id('UIComponentNavTabsInterface0170_001'); + Text(this.msgInfo); + + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsLayout/UIComponentNavTabsLayout0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsLayout/UIComponentNavTabsLayout0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7dfc06d8cea095cb0a19de498a32b5853755059 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsLayout/UIComponentNavTabsLayout0070.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsLayout0070 { + @State arr: number[] = [1,2,3,4]; + @Styles + listCard() { + .backgroundColor(Color.White) + .height(72) + .width("100%") + .borderRadius(12) + } + + build() { + Column({ space: 5 }) { + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + List({ space: 10 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text("item" + item) + .fontSize(16) + }.listCard() + }, (item: string) => item) + }.width("100%"); + }.tabBar(new SubTabBarStyle('Pink')); + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green')); + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsLayout0070') + .width('100%') + .backgroundColor(0xF1F3F5); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..950920c45be776a8b8fb20576ac0a8f2a1e5970e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0190.ets @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0190 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + this.nextIndex = index.toString(); + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .direction(this.direction1) + .id('tabsMirror0190'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsMirror0190_001'); + Text('' + this.nextIndex).id('tabsMirror0190_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..055dab4e51f4860b1147618c6ab75c25aaf75673 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0200.ets @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0200 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onTabBarClick((index: number) => { + this.nextIndex = index.toString(); + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .direction(this.direction1) + .id('tabsMirror0200'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsMirror0200_001'); + Text('' + this.nextIndex).id('tabsMirror0200_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..174984e981959dbed4b3d14a5fc52e755f2268b5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0210.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0210 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width('100%') + .backgroundColor(0xF1F3F5) + .animationDuration(400) + .direction(this.direction1) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + this.nextIndex='onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='onAnimationEnd' + }) + .id('tabsMirror0210'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsMirror0210_001'); + Text('' + this.nextIndex).id('tabsMirror0210_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..54cdf4e68d21ded72a88ecb5710b57bb332159f5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0220.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0220 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width('100%') + .backgroundColor(0xF1F3F5) + .animationDuration(400) + .direction(this.direction1) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + //this.nextIndex='onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + //this.nextIndex='onAnimationEnd' + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + this.nextIndex='onGestureSwipe' + }) + .id('tabsMirror0220'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsMirror0220_001'); + Text('' + this.nextIndex).id('tabsMirror0220_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..94a97e3b5f5e38d68d837fc305f80f2126c94dcb --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0230.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0230 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width('100%') + .backgroundColor(0xF1F3F5) + .animationDuration(400) + .direction(this.direction1) + .onContentWillChange((currentIndex, comingIndex) => { + this.nextIndex = comingIndex.toString(); + return true + }) + .id('tabsMirror0230'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsMirror0230_001'); + Text('' + this.nextIndex).id('tabsMirror0230_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b9cc7617667dbb613d504ae31bdd8fb84b86c22 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0240.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsMirror0240 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width('100%') + .backgroundColor(0xF1F3F5) + .animationDuration(0) + .direction(this.direction1) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.nextIndex = index.toString(); + }) + .onContentWillChange((currentIndex, comingIndex) => { + if (comingIndex == 2) { + return false + } + return true + }) + .id('UIComponentNavTabsMirror0240'); + Button('change Direction').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.direction1 = Direction.Ltr; + }).id('UIComponentNavTabsMirror0240_001') + + Text('' + this.nextIndex).id('UIComponentNavTabsMirror0240_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0250.ets index 371a56d47e3357783d9e204f027907c7038069e1..6a928db491d5f5388b2f2986ed82cf05973af36c 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0250.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0250.ets @@ -43,7 +43,7 @@ struct UIComponentNavTabsMirror0250 { TabContent() { Column() { Text('www.sohu.com'); - Web({ src: 'www.sohu.com', controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .fileAccess(true); } .width('100%').height('100%').backgroundColor(Color.Pink) @@ -52,7 +52,7 @@ struct UIComponentNavTabsMirror0250 { TabContent() { Column() { Text('www.sina.com'); - Web({ src: 'www.sina.com', controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .fileAccess(true); }.width('100%').height('100%').backgroundColor(Color.Yellow) }.tabBar(this.tabBuilder(1)); @@ -60,7 +60,7 @@ struct UIComponentNavTabsMirror0250 { TabContent() { Column() { Text('www.baidu.com'); - Web({ src: 'www.baidu.com', controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .fileAccess(true); }.width('100%').height('100%').backgroundColor(Color.Blue) }.tabBar(this.tabBuilder(2)); @@ -68,7 +68,7 @@ struct UIComponentNavTabsMirror0250 { TabContent() { Column() { Text('www.jd.com'); - Web({ src: 'www.jd.com', controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .fileAccess(true); }.width('100%').height('100%').backgroundColor(Color.Green) }.tabBar(this.tabBuilder(3)); diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0320.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0320.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2211ac987344a30f326de1101b7af64b8831e57 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0320.ets @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsMirror0320 { + private controller: TabsController = new TabsController() + @State barOverlap: boolean = true; + @State barBackgroundColor: string = '#88888888'; + @State direction1: Direction = Direction.Rtl + build() { + Column() { + Button('方向改变').width('50%').margin({ top: 20 }) + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('UIComponentNavTabsMirror0320_001') + Tabs({ barPosition: BarPosition.Start, index: 2, controller: this.controller }) { + TabContent() { + Column() { + Text(`barOverlap ${this.barOverlap}`).fontSize(16).margin({ top: this.barOverlap ? '56vp' : 0 }) + Text(`barBackgroundColor ${this.barBackgroundColor}`).fontSize(16) + }.width('100%').width('100%').height(200) + .backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), "1")) + + TabContent() { + Column() { + Text(`barOverlap ${this.barOverlap}`).fontSize(16).margin({ top: this.barOverlap ? '56vp' : 0 }) + Text(`barBackgroundColor ${this.barBackgroundColor}`).fontSize(16) + }.width('100%').width('100%').height(300) + .backgroundColor(Color.Yellow) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), "2")) + + TabContent() { + Column() { + Text(`barOverlap ${this.barOverlap}`).fontSize(16).margin({ top: this.barOverlap ? '56vp' : 0 }) + Text(`barBackgroundColor ${this.barBackgroundColor}`).fontSize(16) + }.width('100%').width('100%').height(400) + .backgroundColor(Color.Green) + } + .tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), "3")) + } + .vertical(true) + .barMode(BarMode.Fixed) + .height('60%') + .barOverlap(true) + .scrollable(true) + .direction(this.direction1) + .animationDuration(10) + .barBackgroundColor(this.barBackgroundColor) + } + .height(500) + .padding({ top: '24vp', left: '24vp', right: '24vp' }) + + + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..a17ff6f8ea084e8e605c65485a1819a6f53663a9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0010.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsNest0010 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + + @Builder + tabBuilder(index: number) { + Column() { + Text('Tab') + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').height('100%').justifyContent(FlexAlign.Center) + } + + build() { + Column({ space: 5 }) { + Text("子页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(0)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(1)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(2)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(3)) + } + }.tabBar(new SubTabBarStyle('Pink').id('Pink')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')) + + } + .vertical(false) + .height(400) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('UIComponentNavTabsNest0010'); + }.width('100%').height(200); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..559a3687b16e5f16fef2371babe9a66d16a08bed --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0020.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsNest0020 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + + @Builder + tabBuilder(index: number) { + Column() { + Text('Tab') + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').height('100%').justifyContent(FlexAlign.Center) + } + + build() { + Column({ space: 5 }) { + Text("子页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(0)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(1)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(2)) + + TabContent() { + Column().width('100%').height('300').backgroundColor(Color.Red) + } + .tabBar(this.tabBuilder(3)) + } + }.tabBar(new SubTabBarStyle('Pink').id('Pink')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')) + + } + .vertical(false) + .height(400) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('UIComponentNavTabsNest0020'); + }.width('100%').height(200); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d5cc24edafe68d4bba9f4c3a472b24d1a336429 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0010.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0010 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'test' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'test' }, this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..cced43bd4bbb9a3b8e74b13e26999c4096e262c2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0020.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0020 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f9f97743aa3f7232e70c59597b0e674a9862906 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0030.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0030 { + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')).id('tabContentId0'); + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(new SubTabBarStyle('blue').id('blue')).id('tabContentId1'); + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(new SubTabBarStyle('red').id('red')).id('tabContentId2'); + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(new SubTabBarStyle('green').id('green')).id('tabContentId3'); + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + + //.id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd93b0f2892856f81b06cc09ed4f982b9141a6a4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0040.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0040 { + @State currentIndex: number = 0; + @State width1: number = 360; + @State height1: number = 296; + private controller: TabsController = new TabsController(); + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width(this.width1).height(this.height1).backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(this.width1) + .height(this.height1) + .backgroundColor('#F1F3F5') + .id('testId') + Button('change width').width('50%').margin({ top: 20 }) + .onClick(()=>{ + if(this.width1 == 360) + { + this.width1 = 300 + } + else + { + this.width1 = 360 + } + if(this.height1 == 296) + { + this.height1 = 360 + } + else + { + this.height1 = 296 + } + }) + .id('UIComponentNavTabsObserver0040_001'); + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..144a334348a8f82bf524ef826c07ae453c4419ec --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0050.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import screen from '@ohos.screenshot'; +import { common } from '@kit.AbilityKit'; +import { mediaquery, window } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0050 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + // 改变设备横竖屏状态函数 + private changeOrientation(isLandscape: boolean) { + // 获取UIAbility实例的上下文信息 + let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; + // 调用该接口手动改变设备横竖屏状态 + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT) + }); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId'); + + Button('Landscape') + .onClick(() => { + this.changeOrientation(true); + }).id('UIComponentNavTabsObserver0050_001'); + Button('Portrait') + .onClick(() => { + this.changeOrientation(false); + }).id('UIComponentNavTabsObserver0050_002'); + + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ff88dc2ffee1995fedc322fefe17400dd9f7ea5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0060.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import screen from '@ohos.screenshot'; +import { common } from '@kit.AbilityKit'; +import { mediaquery, window } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0060 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + // 改变设备横竖屏状态函数 + private changeOrientation(isLandscape: boolean) { + // 获取UIAbility实例的上下文信息 + let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; + // 调用该接口手动改变设备横竖屏状态 + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT) + }); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId'); + + Button('Landscape') + .onClick(() => { + this.changeOrientation(true); + }).id('UIComponentNavTabsObserver0060_001'); + Button('Portrait') + .onClick(() => { + this.changeOrientation(false); + }).id('UIComponentNavTabsObserver0060_002'); + + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0b233ad4c0fa102670dd1747a20456d0052a1f7 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0070.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0070 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + this.controller.changeIndex(this.currentIndex) + }) + .id('UIComponentNavTabsObserver0070_001'); + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1c9e58280509c47bf9e79d0482118dc335b7d77 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0080.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0080 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + this.controller.changeIndex(this.currentIndex) + }) + .id('UIComponentNavTabsObserver0080_001'); + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount015.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0090.ets similarity index 36% rename from function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount015.ets rename to function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0090.ets index 57f6ee4c8128606f7a91c98774151a39f7e319a4..9eaee081f819d010a72ee73fea4175cffbd0bb48 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount015.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0090.ets @@ -12,73 +12,69 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { BusinessError } from '@kit.BasicServicesKit' +import { uiObserver as observer } from '@kit.ArkUI'; @Entry @Component -struct UIComponentNavTabsCachedCount015 { - @State currentIndex: number = 0 - private tabsController: TabsController = new TabsController() +struct UIComponentNavTabsObserver0090 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } build() { Column() { - Tabs({ index: this.currentIndex, barPosition: BarPosition.End, controller: this.tabsController }) { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { TabContent() { - MyComponent({ color: '#00CB87' }) - }.tabBar(SubTabBarStyle.of('green')) + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') TabContent() { - MyComponent({ color: '#007DFF' }) - }.tabBar(SubTabBarStyle.of('blue')) + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') TabContent() { - MyComponent({ color: '#FFBF00' }) - }.tabBar(SubTabBarStyle.of('yellow')) + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') TabContent() { - MyComponent({ color: '#E67C92' }) - }.tabBar(SubTabBarStyle.of('pink')) + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') } .width(360) .height(296) .backgroundColor('#F1F3F5') - .onChange((index: number) => { - this.currentIndex = index - }) - - Button('preload items: [1, 3]') - .margin(5) - .onClick(() => { - // 预加载第1、3个子节点,提高滑动或点击切换至这些节点时的性能 - this.tabsController.preloadItems([1, 3]) - .then(() => { - console.info('preloadItems success.') - }) - .catch((error: BusinessError) => { - console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message) - }) + .id('testId') + Button('动态修改index').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 }) - .id('UIComponentNavTabs015_001') - } - } -} + .id('UIComponentNavTabsObserver0090_001'); -@Component -struct MyComponent { - private color: string = "" - - aboutToAppear(): void { - console.info('aboutToAppear backgroundColor:' + this.color) - } - - aboutToDisappear(): void { - console.info('aboutToDisappear backgroundColor:' + this.color) + }.width('100%') } - - build() { - Column() - .width('100%') - .height('100%') - .backgroundColor(this.color) - } -} \ No newline at end of file +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..4476fa57046eca0a7e322c703f854b9ea682afa6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0100.ets @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import screen from '@ohos.screenshot'; +import { common } from '@kit.AbilityKit'; +import { mediaquery, window } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0100 { + @State vertical1: boolean = true; + ; + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + // 改变设备横竖屏状态函数 + private changeOrientation(isLandscape: boolean) { + // 获取UIAbility实例的上下文信息 + let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; + // 调用该接口手动改变设备横竖屏状态 + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT) + }); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .vertical(this.vertical1) + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId'); + + Button('change vertical') + .onClick(() => { + this.vertical1 = !this.vertical1; + }).id('UIComponentNavTabsObserver0100_001'); + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9a1cf5eda8c7b87465ec766113a5d315476fac3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0110.ets @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0110 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + @Builder tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.selectedIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }) + }.id(name).width('100%') + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..bed4fedec5583f1ee21224c89921c6b14561e655 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0120.ets @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0120 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + @State visibility1: Visibility = Visibility.Visible + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0').visibility(this.visibility1) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + Button('change visibility').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.visibility1 = Visibility.Hidden; + }) + .id('UIComponentNavTabsObserver0120_001'); + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1daf219381567a10eca6f7febf0f7852d601016 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0130.ets @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0130 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + @State visibility1: Visibility = Visibility.Visible + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0').visibility(this.visibility1) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + Button('change visibility').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.visibility1 = Visibility.None; + }) + .id('UIComponentNavTabsObserver0130_001'); + + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..c10f84fc2efca152ffadab08406df7baaa344387 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0150.ets @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0150 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + @Builder tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.selectedIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }) + }.id(name).width('100%') + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.tabBuilder(0, 'green')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.tabBuilder(1, 'blue')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.tabBuilder(2, 'yellow')) + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.tabBuilder(3, 'pink')) + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d3fb65873b78b686e5e35b44a0edd3f34548b5c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0160.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0160 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..7549957e0d2befb696d9c0e2a3b5d847b85c1c4c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0170.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0170 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4e3dbf30a8acb5458128cc12a15857c5e14a810 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0200.ets @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import {tabContent11} from './tabcontent' +@Entry +@Component +struct UIComponentNavTabsObserver0200 { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + @State selectedIndex: number = 0 + private controller: TabsController = new TabsController() + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + + @Builder + tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%') + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller }) { + TabContent() { + Column() { + tabContent11('Tab1'); + }.width('100%') + }.tabBar(this.tabBuilder(0)) + + TabContent() { + Column() { + tabContent11('Tab2'); + }.width('100%') + }.tabBar(this.tabBuilder(1)) + + TabContent() { + Column() { + tabContent11('Tab3'); + }.width('100%') + }.tabBar(this.tabBuilder(2)) + + TabContent() { + Column() { + tabContent11('Tab4'); + }.width('100%') + }.tabBar(this.tabBuilder(3)) + } + .vertical(false) + .barHeight(56) + .onChange((index: number) => { + // currentIndex控制TabContent显示页签 + this.currentIndex = index + this.selectedIndex = index + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + if (index === targetIndex) { + return + } + // selectedIndex控制自定义TabBar内Image和Text颜色切换 + this.selectedIndex = targetIndex + }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }) + .id('testId') + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..be2b9382d5b15c662430d97ebaf62e3d4a9042c3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0210.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; + +@Entry +@Component +struct UIComponentNavTabsObserver0210 { + + callbackFunc(info: observer.TabContentInfo) { + AlertDialog.show( + { + title: 'title', + message: JSON.stringify(info), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + gridCount: 3, + confirm: { + value: 'confirm', + action: () => { + console.info('Button-clicking callback') + } + } + } + ) + } + + aboutToAppear(): void { + observer.on('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + aboutToDisappear(): void { + observer.off('tabContentUpdate', { id: 'testId' }, this.callbackFunc); + } + + build() { + Column() { + Tabs() { + TabContent() { + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar('green').id('tabContentId0') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar('blue').id('tabContentId1') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar('yellow').id('tabContentId2') + + TabContent() { + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar('pink').id('tabContentId3') + } + .width(360) + .height(296) + .backgroundColor('#F1F3F5') + .id('testId') + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/tabcontent.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/tabcontent.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9ddc3c7aa92122b7a544d7c59d7a9b3e5374ec0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsObserver/tabcontent.ets @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Builder export function tabContent11(name: string) { + Column() { + Column() { + Text(name) + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }) + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) + }.width('100%') + }.width('100%') +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnChange/UIComponentNavTabsOnChange0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnChange/UIComponentNavTabsOnChange0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1fd2408bac33c683b562066c6b29b97d6ad1806 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnChange/UIComponentNavTabsOnChange0010.ets @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsOnChange0010 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex:string = 'haveno'; + + + + @Builder tabBuilder(title: string) { + Column() { + Text(title) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(title); + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder('Blue')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder('Green')); + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .width(400) + .height(200) + .backgroundColor(0xF1F3F5) + .animationDuration(400) + .direction(this.direction1) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + //this.nextIndex='onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + //this.nextIndex='onAnimationEnd' + }) + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + this.nextIndex='onGestureSwipe' + }) + .id('tabsOnChange0010'); + + Button('Direction change').width('50%') + .onClick(()=>{ + if(this.direction1 == Direction.Ltr) + { + this.direction1 = Direction.Rtl + } + else if(this.direction1 == Direction.Rtl) + { + this.direction1 = Direction.Ltr + } + }).id('tabsOnChange0010_001'); + Text('' + this.nextIndex).id('tabsOnChange0010_003'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..63051e513c583c56674d594de11ac32e99159c7f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0010.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0010 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillHide(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = 'Pink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillHide(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = 'Yellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillHide(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = 'Blue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillHide(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = 'Green will hide'; + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillHide0010') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..9907d35a3fee8af83ba2f682d2bb4c75dd3b5cce --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0020.ets @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0020 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0020') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..563f99cde41d3a2b143e8093abdad0e74fb5e792 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0030.ets @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0030 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + }) + .id('UIComponentNavTabsOnWillHide0030') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .onTabBarClick((index: number) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..25ffc908ce00f6f4607b385376c21dd6ef5bf3ca --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0040.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0040 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; +build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0040') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..8cb25bb94a45b5a12e6e4dd8921b4f0a8aa5d552 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0050.ets @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillHide0050 { + @State currentIndex: number = 0; + @State infoMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column() { + Text('oneContent') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('one', 0)) + .onWillShow(() => { + this.infoMsg = 'one will show'; + }) + .onWillHide(() => { + this.infoMsg = 'one will hide'; + }); + + TabContent() { + Column() { + Text('twoContent') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('two', 1)) + .onWillShow(() => { + this.infoMsg = 'two will show'; + }).onWillHide(() => { + this.infoMsg = 'two will hide'; + }); + + TabContent() { + Column() { + Text('threeContent') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('three', 2)) + .onWillShow(() => { + this.infoMsg = 'three will show'; + }).onWillHide(() => { + this.infoMsg = 'three will hide'; + }); + + TabContent() { + Column() { + Text('fourContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('four', 3)) + .onWillShow(() => { + this.infoMsg = 'four will show'; + }).onWillHide(() => { + this.infoMsg = 'four will hide'; + }); + + TabContent() { + Column() { + Text('fiveContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('five', 4)) + .onWillShow(() => { + this.infoMsg = 'five will show'; + }).onWillHide(() => { + this.infoMsg = 'five will hide'; + }); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index; + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsOnWillhide0050'); + + Text('' + this.infoMsg).id('tabsOnWillhide0050_003'); + }.width('100%') + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..2934303f1eb27560d92a3fc7cfe99df6d0190f51 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0060.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0060 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillHide(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = 'Pink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillHide(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = 'Yellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillHide(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = 'Blue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillHide(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = 'Green will hide'; + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillHide0060') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillHide0060_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..aabfc9cfed6fa3c45d47834739c9a0974f63b798 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0070.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0070 { + @State msgInfo: string = ''; + + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0070') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac248258efc30317b351c833bfe5e2d20e7fe3f4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0080.ets @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0080 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; +build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0080') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Button("Hidden tabs") + .onClick((event?: ClickEvent) => { + this.visibility1 = Visibility.Hidden; + }).id('UIComponentNavTabsOnWillHide0080_001'); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..6095764a4cf4c8161cc0acd40a3d72c5adb2e2c4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0100.ets @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit' +function callbackFunc(info: observer.TabContentInfo) { + console.info('tabContentUpdate', JSON.stringify(info)); +} + +@Entry +@Component +struct UIComponentNavTabsOnWillHide0100 { + private controller: TabsController = new TabsController() + @State indicatorColor: Color = Color.Blue; + @State indicatorWidth: number = 40; + @State indicatorHeight: number = 10; + @State indicatorBorderRadius: number = 5; + @State indicatorSpace: number = 10; + @State subTabBorderRadius: number = 20; + @State mIndex: number = 0; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State dataArr: Array = new Array(); + @State msgInfo1: string = ''; + @State msgInfo2: string = ''; + + @State vertical: boolean = false + @State scrollable: boolean = false + + @State height1:number = 50 + // @State currentIndex: number = 1 + private tabsController: TabsController = new TabsController() + + aboutToAppear(): void { + for (let index = 1; index <= 5; index++) { + this.dataArr.push('page-' + index) + } + observer.on('tabContentUpdate', callbackFunc);//"state":0显示 "state":1 隐藏 + } + + aboutToDisappear(): void { + console.log('123') + observer.off('tabContentUpdate', callbackFunc);//不会有打印回调 + } + + build() { + Column() { + + Tabs({ barPosition: BarPosition.Start,index: this.mIndex, controller: this.controller }) { + ForEach(this.dataArr, (item: string, index: number) => { + TabContent() { + + Text(item) + .onAppear(()=>{ + console.info('Tabs_onAppear will123' + item.toString()); + + }) + .onDisAppear(()=>{ + console.info('Tabs_onDisAppear will123' + item.toString()) + this.msgInfo2='2. '+item+' trigger onDisAppear()'; + }) + .width('100%') + // .height(this.height1) + .height('100%') + .backgroundColor(this.colors[index%5]) + .borderRadius('12vp') + .textAlign(TextAlign.Center) + + }.tabBar(SubTabBarStyle.of(item) + .indicator({ + color: this.indicatorColor, //下划线颜色 + height: this.indicatorHeight, //下划线高度 + width: this.indicatorWidth, //下划线宽度 + borderRadius: this.indicatorBorderRadius, //下划线圆角半径 + marginTop: this.indicatorSpace //下划线与文字间距 + }) + .selectedMode(this.selectedMode) + .board({ borderRadius: this.subTabBorderRadius }) + .labelStyle({}) + ) .onWillShow(() => { + console.info("Pink will show") + }).onWillHide(() => { + console.info(item + "will Hide") + this.msgInfo1='1. '+ item+' trigger onWillHide()'; + }); + }, (item: string, index: number) => item + index) + } + // .fadingEdge(true) + .barBackgroundColor('#88888888') + .vertical(this.vertical) + .scrollable(this.scrollable) + .barMode(BarMode.Scrollable) + // .barWidth($r('app.float.boardSize_50')) + .barHeight(140) + .animationDuration(1000) + .edgeEffect(EdgeEffect.Spring) + .onChange((index: number) => { + console.info(index.toString()) + }) + .backgroundColor(0xF5F5F5) + .height(320); + + Column({ space: 10 }) { + Button('尾部动态增加页面').height(30).onClick(() => { + this.dataArr.splice(this.dataArr.length, 0, '尾部动态增加') + this.mIndex = this.dataArr.length-1 + this.height1 = 100 + }).id('UIComponentNavTabsOnWillHide0100_001'); + + Button('尾部动态减少页面').height(30).onClick(() => { + this.dataArr.splice(this.dataArr.length-1, 1) + this.height1 = 200 + }).id('UIComponentNavTabsOnWillHide0100_002'); + Text(this.msgInfo1); + Text(this.msgInfo2) + } + }.width('auto').height('auto').padding({ top: '24vp', left: '24vp', right: '24vp' }) + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..33a4e7ebbb91c5c9645c4eaac380781f6b3f07d0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0110.ets @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0110 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillHide0110') + .width(2000) + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { + this.msgInfo = 'trigger onVisibleAreaChange'; + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillHide0110_001'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..43de5cab6e7348f7569b05d317f3468aa24f5b9f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0120.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0120 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onChange'; + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + }) + .id('UIComponentNavTabsOnWillHide0120') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..befab5cecb21fb40a4cad46ae0038a7f799378be --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0130.ets @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillHide0130 { + @State currentIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('oneContent') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('one',0)) + .onWillHide(() => { + //console.info("one will Hide"); + this.errMsg='one will Hide'; + }); + + TabContent() { + Column(){ + Text('twoContent') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('two',1)) + .onWillHide(() => { + //console.info("two will Hide"); + this.errMsg='one will Hide'; + }); + + TabContent() { + Column(){ + Text('threeContent') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('three',2)) + .onWillHide(() => { + //console.info("three will Hide"); + this.errMsg='three will Hide'; + }); + + TabContent() { + Column(){ + Text('fourContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('four',3)) + .onWillHide(() => { + //console.info("four will Hide"); + this.errMsg='four will Hide'; + }); + + TabContent() { + Column(){ + Text('fiveContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('five',4)) + .onWillHide(() => { + //console.info("five will Hide"); + this.errMsg='five will Hide'; + }); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index; + this.errMsg = 'onChange,index='+index.toString(); + console.info('onChange,index='+index.toString()); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsOnWillhide0130'); + + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 5 + this.tabsController.changeIndex(this.currentIndex) + }).id('tabsOnWillhide0130_001'); + + Text('' + this.errMsg).id('tabsOnWillhide0130_003'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e10a43c4dbdf11ccd25252c4a094e5ad3066d15 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0140.ets @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0140 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + this.msgInfo = this.msgInfo + '\ntrigger onChange'; + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + }) + .id('UIComponentNavTabsOnWillHide0140') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .onTabBarClick((index: number) => { + this.msgInfo = this.msgInfo + '\ntrigger onTabBarClick'; + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..a17b0124577a2a37fb28a86266067ba8b39f0abe --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0150.ets @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0150 { + @State msgInfo: string = ''; + @State visibility1: Visibility = Visibility.Visible; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .visibility(this.visibility1) + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.msgInfo = this.msgInfo + '\ntrigger onAnimationStart'; + }) + .id('UIComponentNavTabsOnWillHide0150') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..d639c7f535856ac8ba03b3532cb9a256fa7fd509 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0160.ets @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0160 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + //this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = this.msgInfo + '\nBlue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = this.msgInfo + '\nGreen will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0160') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + this.msgInfo = 'GestureSwipe'; + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillHide0160_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..6766e71b08a2f8700b38f9aba262325bb74ce0fb --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0170.ets @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillHide0170 { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + @State infoMsg: string = 'no value'; + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center); + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('one') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + console.info("one will show"); + this.infoMsg='one will show'; + }) + .onWillHide(() => { + console.info("one will hide") + this.infoMsg='one will hide'; + }) + TabContent() { + Column(){ + Text('two') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + console.info("two will show"); + this.infoMsg='two will show'; + }) + .onWillHide(() => { + console.info("two will hide") + this.infoMsg='two will hide'; + }) + + TabContent() { + Column(){ + Text('three') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + console.info("three will show"); + this.infoMsg='three will show'; + }) + .onWillHide(() => { + console.info("three will hide") + this.infoMsg='three will hide'; + }) + + TabContent() { + Column(){ + Text('four') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + console.info("four will show"); + this.infoMsg='four will show'; + }) + .onWillHide(() => { + console.info("four will hide") + this.infoMsg='four will hide'; + }) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + /*.onChange((index: number) => { + this.currentIndex = index + this.infoMsg=('onChange,index='+index); + })*/ + .onContentWillChange((currentIndex, comingIndex) => { + this.infoMsg='will onContentWillChange' + comingIndex.toString(); + console.info('will onContentWillChange' + comingIndex.toString()); + return true + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsOnWillhide0170'); + + Text('' + this.infoMsg).id('tabsOnWillhide0170_003'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..11a8ef87acb7906e2f9c777f2c7d78303d40839f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0190.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillHide0190 { + @State msgInfo: string = ''; + + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + this.msgInfo = this.msgInfo + '\nPink will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + this.msgInfo = this.msgInfo + '\nYellow will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + this.msgInfo = this.msgInfo + '\nBlue will hide'; + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + this.msgInfo = this.msgInfo + '\nGreen will hide'; + }) + } + .vertical(true) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillHide0190') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..554e0cf9b983449a1cef54c4934a785cd81c8f0d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0010.ets @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0010 { + @State currentIndex: number = 0; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('oneContent') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + // console.info("one will show"); + this.errMsg='one will show'; + }); + + TabContent() { + Column(){ + Text('twoContent') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + // console.info("two will show"); + this.errMsg='two will show'; + }); + + TabContent() { + Column(){ + Text('threeContent') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + // console.info("three will show"); + this.errMsg='three will show'; + }); + + TabContent() { + Column(){ + Text('fourContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + // console.info("four will show"); + this.errMsg='four will show'; + }); + + TabContent() { + Column(){ + Text('fiveContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('five',4)) + .onWillShow(() => { + //console.info("five will show"); + this.errMsg='five will show'; + }); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index; + this.errMsg = 'onChange,index='+index.toString(); + //console.info('onChange,index='+index.toString()); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsOnWillshow0010'); + + + Text('' + this.errMsg).id('tabsOnWillshow0010_003'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..043536092f32b7b73853a3d3a3f56827e6f5fadf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0020.ets @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0020 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State currentIndex: number = 0; + @State nextIndex: string = 'no show'; + + @Builder NavigationTitle() { + Column() { + Text('Title') + .fontColor('#182431') + .fontSize(30) + .lineHeight(41) + .fontWeight(700) + Text('subtitle') + .fontColor('#182431') + .fontSize(14) + .lineHeight(19) + .opacity(0.4) + .margin({ top: 2, bottom: 20 }) + }.alignItems(HorizontalAlign.Start) + } + build() { + Column() { + Navigation() { + TextInput({ placeholder: 'search...' }) + .width('90%') + .height(40) + .backgroundColor('#FFFFFF') + .margin({ top: 8 }) + Text('' + this.nextIndex).id('tabsOnWillshow0020_003'); + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show"); + this.nextIndex='Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show"); + this.nextIndex='Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show"); + this.nextIndex='Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show"); + this.nextIndex='Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5); + } + .title(this.NavigationTitle) + .titleMode(NavigationTitleMode.Full) + .hideTitleBar(false) + .hideToolBar(false) + .onTitleModeChange((titleModel: NavigationTitleMode) => { + console.info('titleMode' + titleModel) + }); + + + + }.width('100%').height('100%').backgroundColor('#F1F3F5'); + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..815d5d34edd896e71c21aabc046ee6aa0296617c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0030.ets @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0030 { + @State currentIndex: number = 2; + private controller: TabsController = new TabsController(); + @State nextIndex: string = 'no value'; + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center); + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('one') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + console.info("one will show"); + this.nextIndex='one will show'; + }) + .onWillHide(() => { + console.info("one will hide") + }) + TabContent() { + Column(){ + Text('two') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + console.info("two will show"); + this.nextIndex='two will show'; + }) + .onWillHide(() => { + console.info("two will hide") + }) + + TabContent() { + Column(){ + Text('three') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + console.info("three will show"); + this.nextIndex='three will show'; + }) + .onWillHide(() => { + console.info("three will hide") + }) + + TabContent() { + Column(){ + Text('four') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + console.info("four will show"); + this.nextIndex='four will show'; + }) + .onWillHide(() => { + console.info("four will hide") + }) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + /*.onChange((index: number) => { + this.currentIndex = index + this.nextIndex=('onChange,index='+index); + })*/ + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true); + + Text('' + this.nextIndex).id('tabsOnWillshow0030_003'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..efca925328f6b6392b0c6087916e5ad579f61627 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0040.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0040 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillShow0040') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0040_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbadb22c3b5b13d99c38c31e12582e25f113c21b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0050.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsOnWillShow0050 { + @State direction1: Direction = Direction.Rtl; + @State nextIndex: string = 'no show'; + + + build() { + Column({ space: 5 }) { + Text("SubTabBarStyle sample") + Column() { + Tabs({ index:2, barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')) + .onWillShow(() => { + this.nextIndex = 'Pink will show'; + console.info("Pink will show"); + }) + .onWillHide(() => { + console.info("Pink will hide"); + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show"); + this.nextIndex = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide"); + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')) + .onWillShow(() => { + console.info("Blue will show"); + }) + .onWillHide(() => { + console.info("Blue will hide"); + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + this.nextIndex = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide"); + }) + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsOnWillshow0050'); + + Text('' + this.nextIndex).id('tabsOnWillshow0050_003'); + }.width('100%').height(200); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d23446f8cddf3cb6b261b7ed50c14ee113a0539 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0060.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0060 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillShow0060') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0060_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae7eaa1a2bfe5f7eef2b3e02d7cd788134e9682a --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0070.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0070 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillShow0070') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0070_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..47c02891513a3fd17f61a92c429b3e8a5fb8095b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0080.ets @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0080 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillShow0080') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0080_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..67d7f316e04293a1926908537f0b6a6184e5fc8d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0100.ets @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver as observer } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit' +function callbackFunc(info: observer.TabContentInfo) { + console.info('tabContentUpdate', JSON.stringify(info)); +} + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0100 { + private controller: TabsController = new TabsController() + @State indicatorColor: Color = Color.Blue; + @State indicatorWidth: number = 40; + @State indicatorHeight: number = 10; + @State indicatorBorderRadius: number = 5; + @State indicatorSpace: number = 10; + @State subTabBorderRadius: number = 20; + @State mIndex: number = 0; + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State selectedMode: SelectedMode = SelectedMode.INDICATOR; + @State dataArr: Array = new Array(); + @State msgInfo1: string = ''; + @State msgInfo2: string = ''; + + @State vertical: boolean = false + @State scrollable: boolean = false + + @State height1:number = 50 + // @State currentIndex: number = 1 + private tabsController: TabsController = new TabsController() + + aboutToAppear(): void { + for (let index = 1; index <= 3; index++) { + this.dataArr.push('page-' + index) + } + observer.on('tabContentUpdate', callbackFunc);//"state":0显示 "state":1 隐藏 + } + + aboutToDisappear(): void { + console.log('123') + observer.off('tabContentUpdate', callbackFunc);//不会有打印回调 + } + + build() { + Column() { + + Tabs({ barPosition: BarPosition.Start,index: this.mIndex, controller: this.controller }) { + ForEach(this.dataArr, (item: string, index: number) => { + TabContent() { + + Text(item) + .onAppear(()=>{ + console.info('Tabs_onAppear will123' + item.toString()); + this.msgInfo2='2. '+item+' trigger onAppear()'; + }) + .onDisAppear(()=>{ + console.info('Tabs_onDisAppear will123' + item.toString()) + }) + .width('100%') + // .height(this.height1) + .height('100%') + .backgroundColor(this.colors[index%5]) + .borderRadius('12vp') + .textAlign(TextAlign.Center) + + }.tabBar(SubTabBarStyle.of(item) + .indicator({ + color: this.indicatorColor, //下划线颜色 + height: this.indicatorHeight, //下划线高度 + width: this.indicatorWidth, //下划线宽度 + borderRadius: this.indicatorBorderRadius, //下划线圆角半径 + marginTop: this.indicatorSpace //下划线与文字间距 + }) + .selectedMode(this.selectedMode) + .board({ borderRadius: this.subTabBorderRadius }) + .labelStyle({}) + ) .onWillShow(() => { + console.info("Pink will show") + this.msgInfo1='1. '+ item+' trigger onWillShow()'; + }); + }, (item: string, index: number) => item + index) + } + // .fadingEdge(true) + .barBackgroundColor('#88888888') + .vertical(this.vertical) + .scrollable(this.scrollable) + .barMode(BarMode.Scrollable) + // .barWidth($r('app.float.boardSize_50')) + .barHeight(140) + .animationDuration(1000) + .edgeEffect(EdgeEffect.Spring) + .onChange((index: number) => { + console.info(index.toString()) + }) + .backgroundColor(0xF5F5F5) + .height(320); + + Column({ space: 10 }) { + Button('尾部动态增加页面').height(30).onClick(() => { + this.dataArr.splice(this.dataArr.length, 0, '尾部动态增加') + this.mIndex = this.dataArr.length-1 + this.height1 = 100 + }).id('UIComponentNavTabsOnWillShow0100_001'); + + Button('尾部动态减少页面').height(30).onClick(() => { + this.dataArr.splice(this.dataArr.length-1, 1) + this.height1 = 200 + }).id('UIComponentNavTabsOnWillShow0100_002'); + Text(this.msgInfo1); + Text(this.msgInfo2) + } + }.width('auto').height('auto').padding({ top: '24vp', left: '24vp', right: '24vp' }) + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1785f9d525c81957b45481178e9efd54b44bb4c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0110.ets @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0110 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + this.msgInfo = 'Pink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = 'Yellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = 'Blue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = 'Green will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .id('UIComponentNavTabsOnWillShow0110') + .width(2000) + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { + this.msgInfo = 'trigger onVisibleAreaChange'; + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0110_001'); + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..15b9b267f3ca519040573f7e00b5077fc91a345d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0120.ets @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0120 { + @State currentIndex: number = 2; + private controller: TabsController = new TabsController(); + @State nextIndex: string = 'no value'; + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('one') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + console.info("one will show"); + this.nextIndex='one will show'; + }) + .onWillHide(() => { + console.info("one will hide") + }) + TabContent() { + Column(){ + Text('two') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + console.info("two will show"); + this.nextIndex='two will show'; + }) + .onWillHide(() => { + console.info("two will hide") + }) + + TabContent() { + Column(){ + Text('three') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + console.info("three will show"); + this.nextIndex='three will show'; + }) + .onWillHide(() => { + console.info("three will hide") + }) + + TabContent() { + Column(){ + Text('four') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + console.info("four will show"); + this.nextIndex='four will show'; + }) + .onWillHide(() => { + console.info("four will hide") + }) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index + this.nextIndex=('onChange,index='+index); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 4 + }); + Text('' + this.nextIndex).id('tabsOnWillshow0120_003'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..90ffe52467c2c9a9396dfa03d9327209ca9049c5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0130.ets @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0130 { + @State currentIndex: number = 2; + @State errMsg: string = ''; + private tabsController: TabsController = new TabsController(); + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center) + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('oneContent') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + // console.info("one will show"); + this.errMsg='one will show'; + }); + + TabContent() { + Column(){ + Text('twoContent') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + // console.info("two will show"); + this.errMsg='two will show'; + }); + + TabContent() { + Column(){ + Text('threeContent') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + // console.info("three will show"); + this.errMsg='three will show'; + }); + + TabContent() { + Column(){ + Text('fourContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + // console.info("four will show"); + this.errMsg='four will show'; + }); + + TabContent() { + Column(){ + Text('fiveContent') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center); + }.tabBar(this.tabBuilder('five',4)) + .onWillShow(() => { + //console.info("five will show"); + this.errMsg='five will show'; + }); + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + .onChange((index: number) => { + this.currentIndex = index; + this.errMsg = 'onChange,index='+index.toString(); + //console.info('onChange,index='+index.toString()); + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true) + .id('tabsOnWillshow0130'); + + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(()=>{ + this.currentIndex = (this.currentIndex + 1) % 5 + this.tabsController.changeIndex(this.currentIndex) + }).id('tabsOnWillshow0130_001'); + + Text('' + this.errMsg).id('tabsOnWillshow0130_003'); + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..203857db286ad981e53fc862c73f4b13e5c972e5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0140.ets @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0140 { + @State currentIndex: number = 2; + private controller: TabsController = new TabsController(); + @State nextIndex: string = 'no value'; + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center); + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('one') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + console.info("one will show"); + this.nextIndex='one will show'; + }) + .onWillHide(() => { + console.info("one will hide") + }) + TabContent() { + Column(){ + Text('two') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + console.info("two will show"); + this.nextIndex='two will show'; + }) + .onWillHide(() => { + console.info("two will hide") + }) + + TabContent() { + Column(){ + Text('three') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + console.info("three will show"); + this.nextIndex='three will show'; + }) + .onWillHide(() => { + console.info("three will hide") + }) + + TabContent() { + Column(){ + Text('four') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + console.info("four will show"); + this.nextIndex='four will show'; + }) + .onWillHide(() => { + console.info("four will hide") + }) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + /*.onChange((index: number) => { + this.currentIndex = index + this.nextIndex=('onChange,index='+index); + })*/ + .onTabBarClick((index: number) => { + this.currentIndex = index; + this.nextIndex='will onTabBarClick' + index.toString(); + console.info('will onTabBarClick' + index.toString()) + }) + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true); + + Text('' + this.nextIndex).id('tabsOnWillshow0140_003'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcdf2d8d3f3086e21a55a6f4e3d8d5329bdf3a3f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0150.ets @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0150 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + //this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = this.msgInfo + '\nBlue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = this.msgInfo + '\nGreen will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.msgInfo = this.msgInfo + '\nonAnimationStart'; + }) + .id('UIComponentNavTabsOnWillShow0150') + .width('100%') + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0150_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..76b31fe7e2f703629fc5e02125557f29e7590811 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0160.ets @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsOnWillShow0160 { + @State msgInfo: string = ''; + build() { + Column({ space: 5 }) { + + Text("侧边页签样式") + Column() { + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink')) + .onWillShow(() => { + console.info("Pink will show") + //this.msgInfo = this.msgInfo + '\nPink will show'; + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + this.msgInfo = this.msgInfo + '\nYellow will show'; + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue')) + .onWillShow(() => { + console.info("Blue will show") + this.msgInfo = this.msgInfo + '\nBlue will show'; + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green')) + .onWillShow(() => { + console.info("Green will show") + this.msgInfo = this.msgInfo + '\nGreen will show'; + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(true).scrollable(true).barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .animationDuration(3000) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + + }) + .id('UIComponentNavTabsOnWillShow0160') + .width('100%') + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { + this.msgInfo = 'GestureSwipe'; + }) + .backgroundColor(0xF1F3F5); + Text(this.msgInfo); + Button("clear") + .onClick((event?: ClickEvent) => { + this.msgInfo ='' + }).id('UIComponentNavTabsOnWillShow0160_001') + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..974a775813b9070b91ab70a1eed4a4be6c86f398 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0170.ets @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +@Entry +@Component +struct UIComponentNavTabsOnWillShow0170 { + @State currentIndex: number = 2; + private controller: TabsController = new TabsController(); + @State nextIndex: string = 'no value'; + + + @Builder tabBuilder(title: string,targetIndex: number) { + Column(){ + Text(title).fontColor(this.currentIndex === targetIndex ? '#1698CE' : '#6B6B6B') + }.width('100%') + .height(50) + .id(title) + .justifyContent(FlexAlign.Center); + } + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) { + TabContent() { + Column(){ + Text('one') + }.width('100%').height('100%').backgroundColor('#00CB87').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('one',0)) + .onWillShow(() => { + console.info("one will show"); + this.nextIndex='one will show'; + }) + .onWillHide(() => { + console.info("one will hide") + }) + TabContent() { + Column(){ + Text('two') + }.width('100%').height('100%').backgroundColor('#007DFF').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('two',1)) + .onWillShow(() => { + console.info("two will show"); + this.nextIndex='two will show'; + }) + .onWillHide(() => { + console.info("two will hide") + }) + + TabContent() { + Column(){ + Text('three') + }.width('100%').height('100%').backgroundColor('#FFBF00').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('three',2)) + .onWillShow(() => { + console.info("three will show"); + this.nextIndex='three will show'; + }) + .onWillHide(() => { + console.info("three will hide") + }) + + TabContent() { + Column(){ + Text('four') + }.width('100%').height('100%').backgroundColor('#E67C92').justifyContent(FlexAlign.Center) + }.tabBar(this.tabBuilder('four',3)) + .onWillShow(() => { + console.info("four will show"); + this.nextIndex='four will show'; + }) + .onWillHide(() => { + console.info("four will hide") + }) + } + .vertical(false) + .barMode(BarMode.Fixed) + .barWidth(360) + .barHeight(60) + .animationDuration(0) + /*.onChange((index: number) => { + this.currentIndex = index + this.nextIndex=('onChange,index='+index); + })*/ + + .onContentWillChange((currentIndex, comingIndex) => { + this.nextIndex='will onContentWillChange' + comingIndex.toString(); + console.info('will onContentWillChange' + comingIndex.toString()); + return true + }) + + .width(360) + .height(600) + .backgroundColor('#F1F3F5') + .scrollable(true); + + Text('' + this.nextIndex).id('tabsOnWillshow0170_003'); + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx003.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx003.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dbe08c1065927375af0d81426fc3c578fef6559 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx003.ets @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx003 { + @State nextIndex:string = 'no_animation'; + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')); + + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx003'); + + Text('' + this.nextIndex).id('tabsUx003_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx004.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx004.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c0f1fc8659d511d385baf63e7256f08ff0e64cb --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx004.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx004 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')); + + } + .vertical(false) + .animationDuration(-300) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx004'); + + Text('' + this.nextIndex).id('tabsUx004_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx005.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx005.ets new file mode 100644 index 0000000000000000000000000000000000000000..ffe5aa5c0f88e2414668c6dab1917451983bc4e2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx005.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx005 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')); + + } + .vertical(false) + .animationDuration(undefined) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx005'); + + Text('' + this.nextIndex).id('tabsUx005_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx007.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx007.ets new file mode 100644 index 0000000000000000000000000000000000000000..30050b743a0cb0f8bd7940e5bc2efab82f60aadd --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx007.ets @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx007 { + @State nextIndex:string = 'no_animation'; + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')); + + } + .vertical(false) + .animationDuration(0) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx007'); + + Text('' + this.nextIndex).id('tabsUx007_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx008.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx008.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fedb0a1421dda58b4eebd8be46957d7d0fd2938 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx008.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx008 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue').id('Blue')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')); + + } + .vertical(false) + .animationDuration(300) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx008'); + + Text('' + this.nextIndex).id('tabsUx008_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx009.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx009.ets new file mode 100644 index 0000000000000000000000000000000000000000..863690c2c23315cd068f44009ffb74e74871a325 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx009.ets @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx009 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')); + + } + .vertical(false) + .scrollable(true) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx009'); + + Text('' + this.nextIndex).id('tabsUx009_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx010.ets new file mode 100644 index 0000000000000000000000000000000000000000..281037b294883e7a02c7555e36a84e42b8b42dda --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx010.ets @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx010 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')); + + } + .vertical(false) + .animationDuration(-300) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx010'); + + Text('' + this.nextIndex).id('tabsUx010_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx011.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx011.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc23e1c664f02228b6f03672cdb3a71806094f38 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx011.ets @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx010 { + @State nextIndex:string = 'no_animation'; + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')); + + } + .vertical(false) + .animationDuration(undefined) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx010'); + + Text('' + this.nextIndex).id('tabsUx010_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx012.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx012.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf5ce5b1a6d36c85180c482040918d98455a4f3f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx012.ets @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx012 { + @State nextIndex:string = 'no_animation'; + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')); + + } + .vertical(false) + .animationDuration(0) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx012'); + + Text('' + this.nextIndex).id('tabsUx012_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx013.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx013.ets new file mode 100644 index 0000000000000000000000000000000000000000..391d5809f371cceb2bf12267bed9339cbbb8aeed --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx013.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx013 { + @State nextIndex:string = 'no_animation'; + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')); + + } + .vertical(false) + .animationDuration(500) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx013'); + + Text('' + this.nextIndex).id('tabsUx013_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx014.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx014.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cffc21c279f57364d10d6c59fc997d8c36a9bd0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx014.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx014 { + @State nextIndex:string = 'no_animation'; + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + @State selectedIndex: number = 0; + + @Builder tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(`Tab${index + 1}`) + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder(0)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder(1)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder(2)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder(3)); + + } + .vertical(false) + /*.animationDuration(undefined) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='onAnimationStart' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='onAnimationEnd' + })*/ + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx014'); + + Text('' + this.nextIndex).id('tabsUx014_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx015.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx015.ets new file mode 100644 index 0000000000000000000000000000000000000000..072f43366cd86aed6127c5ff467933914ab0c639 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx015.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx015 { + @State nextIndex:string = 'no_animation'; + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + @State selectedIndex: number = 0; + + @Builder tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(`Tab${index + 1}`) + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder(0)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder(1)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder(2)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder(3)); + + } + .vertical(false) + .animationDuration(-100) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx015'); + + Text('' + this.nextIndex).id('tabsUx015_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx016.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx016.ets new file mode 100644 index 0000000000000000000000000000000000000000..496b02f81cbe53f08d7a33f6777906c424d5573e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx016.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx016 { + @State nextIndex:string = 'no_animation'; + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + @State selectedIndex: number = 0; + + @Builder tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(`Tab${index + 1}`) + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder(0)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder(1)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder(2)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder(3)); + + } + .vertical(false) + .animationDuration(undefined) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx016'); + + Text('' + this.nextIndex).id('tabsUx016_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx017.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx017.ets new file mode 100644 index 0000000000000000000000000000000000000000..57d7eaef5d250a871bef6112a196fc7c1ed96d1e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx017.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx017 { + @State nextIndex:string = 'no_animation'; + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + @State selectedIndex: number = 0; + + @Builder tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(`Tab${index + 1}`) + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder(0)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder(1)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder(2)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder(3)); + + } + .vertical(false) + .animationDuration(0) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx017'); + + Text('' + this.nextIndex).id('tabsUx017_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx018.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx018.ets new file mode 100644 index 0000000000000000000000000000000000000000..57cfd233126cc2cb2aa04840820527ca48194c81 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx018.ets @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +@Entry +@Component + +struct UIComponentNavTabsUx018 { + @State nextIndex:string = 'no_animation'; + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + @State selectedIndex: number = 0; + + @Builder tabBuilder(index: number) { + Column() { + Text(`Tab${index + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').id(`Tab${index + 1}`) + } + + + build() { + Column({ space: 5 }) { + + + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(this.tabBuilder(0)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(this.tabBuilder(1)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(this.tabBuilder(2)); + + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(this.tabBuilder(3)); + + } + .vertical(false) + .animationDuration(500) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + this.nextIndex='have_animation' + }) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('tabsUx018'); + + Text('' + this.nextIndex).id('tabsUx018_003'); + + }.width('100%').height(200) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx019.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx019.ets new file mode 100644 index 0000000000000000000000000000000000000000..e64c6d4aa19a85d3fb5b3a38e74d790a6caca2b9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx019.ets @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration, UIAbility } from '@kit.AbilityKit' +import { i18n, intl } from '@kit.LocalizationKit' +import { LengthMetrics } from '@kit.ArkUI' + +export class CommonUtil { + private static isRTL: boolean = i18n.isRTL((new intl.Locale()).language) + + public static setIsRTL(isRTL: boolean): void { + CommonUtil.isRTL = isRTL + } + + public static getIsRTL(): boolean { + return CommonUtil.isRTL + } +} + +export default class EntryAbility extends UIAbility { + onConfigurationUpdate(newConfig: Configuration): void { + // 监听系统配置变化 + if (newConfig.language) { + CommonUtil.setIsRTL(i18n.isRTL(newConfig.language)) + } + } +} + +interface itemType019 { + text: string, + backgroundColor: Color +} + +@Entry +@Component +struct UIComponentNavTabsUx019 { + @State currentIndex: number = 0; + @State msgInfo: string = 'begin'; + @State data: itemType019[] = [ + { + text: 'Red', + backgroundColor: Color.Red + }, + { + text: 'Yellow', + backgroundColor: Color.Yellow + }, + { + text: 'Blue', + backgroundColor: Color.Blue + }] + @State opacityList: number[] = [] + @State scaleList: number[] = [] + private durationList: number[] = [] + private timeoutList: number[] = [] + private customContentTransition: (from: number, to: number) => TabContentAnimatedTransition = (from: number, to: number) => { + let tabContentAnimatedTransition = { + timeout: this.timeoutList[from], + transition: (proxy: TabContentTransitionProxy) => { + this.scaleList[from] = 1.0 + this.scaleList[to] = 0.5 + this.opacityList[from] = 1.0 + this.opacityList[to] = 0.5 + animateTo({ + duration: this.durationList[from], + onFinish: () => { + proxy.finishTransition() + } + }, () => { + this.scaleList[from] = 0.5 + this.scaleList[to] = 1.0 + this.opacityList[from] = 0.5 + this.opacityList[to] = 1.0 + }) + } + } as TabContentAnimatedTransition + return tabContentAnimatedTransition + } + + aboutToAppear(): void { + let duration = 1000 + let timeout = 1000 + for (let i = 1; i <= this.data.length; i++) { + this.opacityList.push(1.0) + this.scaleList.push(1.0) + this.durationList.push(duration * i) + this.timeoutList.push(timeout * i) + } + } + + build() { + Column() { + Text(this.msgInfo); + Tabs() { + ForEach(this.data, (item: itemType019, index: number) => { + TabContent() { + } + .tabBar(new SubTabBarStyle(item.text).id(item.text)) + .backgroundColor(item.backgroundColor) + // 自定义动画变化透明度、缩放页面等 + .opacity(this.opacityList[index]) + .scale({ x: this.scaleList[index], y: this.scaleList[index] }) + }) + } + .backgroundColor(0xf1f3f5) + .width('100%') + .height(500) + .customContentTransition(this.customContentTransition) + .animationDuration(1000) + .onChange((index: number) => { + this.currentIndex = index // 监听索引index的变化,实现页签内容的切换。 + }) + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 + this.currentIndex = targetIndex + console.log('trigger onAnimationStart'); + this.msgInfo='trigger onAnimationStart'; + }) + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { + console.log('trigger onAnimationEnd'); + this.msgInfo='trigger onAnimationEnd' + }) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx022.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx022.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cdf4440ef3d31818b9041cb9b98b9f423b975a6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx022.ets @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentNavTabsUx022 { + build() { + Column({ space: 5 }) { + + Text("底部页签样式") + Column() { + Tabs({ barPosition: BarPosition.End }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink').id('Pink')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow').id('Yellow')) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Red').id('Red')) + .onWillShow(() => { + console.info("Blue will show") + }) + .onWillHide(() => { + console.info("Blue will hide") + }) + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green').id('Green')) + .onWillShow(() => { + console.info("Green will show") + }) + .onWillHide(() => { + console.info("Green will hide") + }) + } + .vertical(false) + .animationDuration(300) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('UIComponentNavTabsUx022'); + }.width('100%').height(400); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f44b8186f67710095b6ed39835c310347de29ea --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0130.ets @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAbility0130 { + @State isRefreshing: boolean = false; + @State refreshOffset1: number = 64; + @State infoMsg: string = 'no_value'; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Button('change refresh parameter') + .margin(5) + .onClick(() => { + this.refreshOffset1 = this.refreshOffset1 + 10; + this.infoMsg = 'this.refreshOffset='+this.refreshOffset1; + }).id('refreshAbility0130_001'); + + Text('' + this.infoMsg).id('refreshAbility0130_003'); + + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(this.refreshOffset1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..042259cdac66cb3405d7b32161055380a1475ad6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0140.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAbility0140 { + @State isRefreshing: boolean = false; + @State pullToRefresh1: boolean = false; + @State refreshOffset1: number = 64; + @State infoMsg: string = 'no_value'; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Button('change refresh parameter') + .margin(5) + .onClick(() => { + this.pullToRefresh1 = !this.pullToRefresh1; + this.refreshOffset1 = this.refreshOffset1 + 10; + this.infoMsg = 'this.pullToRefresh='+this.pullToRefresh1; + this.infoMsg += '\n'; + this.infoMsg += 'this.refreshOffset='+this.refreshOffset1; + }).id('refreshAbility0140_001'); + + Text('' + this.infoMsg).id('refreshAbility0140_003'); + + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh1) + .refreshOffset(this.refreshOffset1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0150.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0150.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a9dddb9eb99f1033afd7cf4f03b234e34d2fd6b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0150.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAbility0150 { + @State isRefreshing: boolean = false; + @State pullToRefresh1: boolean = false; + @State refreshOffset1: number = 64; + @State infoMsg: string = 'no_value'; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32); + Text("Refreshing...").fontSize(16).margin({left:20}) + } + + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // С߶Լ֤Զ߶ˢ߶ȱ仯ʱԶ߶ȲminHeight + .width("100%") + } + + build() { + Column() { + Button('change refresh parameter') + .margin(5) + .onClick(() => { + this.pullToRefresh1 = !this.pullToRefresh1; + this.refreshOffset1 = this.refreshOffset1 + 10; + this.infoMsg = 'this.pullToRefresh='+this.pullToRefresh1; + this.infoMsg += '\n'; + this.infoMsg += 'this.refreshOffset='+this.refreshOffset1; + }).id('refreshAbility0150_001'); + + Text('' + this.infoMsg).id('refreshAbility0150_003'); + + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh1) + .refreshOffset(this.refreshOffset1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }); + + + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a0664140a4ba9fe0833954636a36a4b62626d87 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0160.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAbility0160 { + @State isRefreshing: boolean = false; + @State refreshOffset: number = 60; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text("Refresh test") + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item).margin({bottom:10}) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshAbility0160') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .pullDownRatio(1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..979067d869bcf20e2533ddfc1bd560f4f88bf2c5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import window from '@ohos.window'; +import common from '@ohos.app.ability.common'; +@Entry +@Component +struct UIComponentOtherRefreshAbility0170 { + @State isRefreshing: boolean = false; + @State refreshOffset: number = 60; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State isFullScreen: boolean = false + + horVerSwitch() { + let context = getContext(this) as common.UIAbilityContext; + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(this.isFullScreen ? window.Orientation.PORTRAIT : window.Orientation.LANDSCAPE) + this.isFullScreen = !this.isFullScreen + }) + } + + build() { + Column() { + Text("Refresh test") + Button('change hor') + .id('UIComponentOtherRefreshAbility0170_001') + .onClick(()=>{ + this.horVerSwitch(); + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item).margin({bottom:10}) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshAbility0170_002') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .pullDownRatio(1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3bedfcb272c7ede52e8e35907063f72cd7b7c26 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0180.ets @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAbility0180 { + @State isRefreshing: boolean = false; + @State refreshOffset: number = 60; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text("Refresh test") + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item).margin({bottom:10}) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshAbility0180_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .pullDownRatio(1) + .padding(10) + .margin(20) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }) + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..dae01588d35536d24cbcdd1fe01ad1016546b272 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0010.ets @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0010 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0010'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..a72c8b855193906130353c920cea57659a21d746 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0020.ets @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0020 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0020'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..e38ca90ab739041dfefdf6d30ae63d63ffbd63a9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0030 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshAnimation0030') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb4ac2f0f7bea54ea50fa85a4a62eb755e97051f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0040.ets @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0040 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%') + .id('UIComponentOtherRefreshAnimation0040'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ed12eb5e3db53ffda6cb3a238b9885e5060aa08 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0050.ets @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0050 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(96) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0050'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c85d096ef0be2afe8ebef1ff67647a72ddaab5c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0060.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0060 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%') + .id('UIComponentOtherRefreshAnimation0060'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..622316130d177b0a602002f70bf884d9baee6392 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0070.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0070 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0070'); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..6721fdaa8d9f3534ae5fc68321d5125bdff1f70c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0080.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0080 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + @State numbers: String[] = ['0', '1', '2', '3', '4']; + scroller: Scroller = new Scroller(); + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + Grid(this.scroller) { + ForEach(this.numbers, (day: string) => { + ForEach(this.numbers, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + }, (day: string) => day) + }, (day: string) => day) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .friction(0.6) + .enableScrollInteraction(true) + .supportAnimation(false) + .multiSelectable(false) + .edgeEffect(EdgeEffect.Spring) + .scrollBar(BarState.On) + .scrollBarColor(Color.Grey) + .scrollBarWidth(4) + .width('90%') + .backgroundColor(0xFAEEE0) + .height(300) + + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0080'); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..26424c14fb1896a49c0f734bb5e4263b58be5be6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0090.ets @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentOtherRefreshAnimation0090 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + @State arr: String[] = ['0', '1', '2', '3']; + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 10; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + WaterFlow() { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16'); + } + } + .onAppear(() => { + // 即将触底时提前增加数据 + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 10; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(this.itemHeightArray[item % 10]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0090'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..72de61209c1e9958d5884ec06daed4c8171c98c3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0100.ets @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0100 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + scroller: Scroller = new Scroller(); + @State arr: String[] = ['0', '1', '2', '3']; + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item: number) => { + Text(item.toString()) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, (item: string) => item) + }.width('100%') + } + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0100'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..2dce547d578db64836e24b1e72b60f8551c8f744 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0110.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0110 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + scroller: Scroller = new Scroller(); + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State numbers: string[] = []; + + aboutToAppear() { + for (let i = 1; i <= 30; i++) { + this.numbers.push(i + '') + } + } + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + Scroll() { + Column({ space: 5 }) { + Blank() + Grid() { + ForEach(this.numbers, (day: string) => { + GridItem() { + Text(day).fontSize(16).backgroundColor(0xF9CF93) + }.width(40).height(80).borderWidth(2).borderColor(Color.Red) + }, (day: string) => day) + } + .height(300) + .columnsGap(10) + .rowsGap(10) + .backgroundColor(0xFAEEE0) + .maxCount(6) + .minCount(2) + .cellLength(0) + .layoutDirection(GridDirection.Row) + } + .width('90%').margin({ top: 5, left: 5, right: 5 }) + .align(Alignment.Center) + } + + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0110'); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..399f58be1b4740b2ad5ce8f3f06a133d814821e2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0130.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0130 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0130'); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..b28407893192002ad1b85d24a0100b79f1b9fb07 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0140.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshAnimation0140 { + @State isRefreshing: boolean = false; + @State msgLog1: string = 'Refresh onOffsetChange offset:0'; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6'] + + build() { + Column() { + Text(this.msgLog1); + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('90%'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgLog1 = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(96) + .pullToRefresh(true) + .id('UIComponentOtherRefreshAnimation0140'); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb2bcd7aa61579831007049d6bbba156a1c116d2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshAnimation/WaterFlowDataSource.ets @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 10; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..de872a57f6aba76b2631100e0e236d807aced112 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0010.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0010 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0010') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a25d334e5be87510bdb30b2207e0f2a52f97ca2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0020.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0020 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'no_value'; + @State infoMsg2: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0020_003'); + Text('' + this.infoMsg2).id('refreshInteraction0020_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0020_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + if(refreshStatus.toString() == '3') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..38d265df010864009ca53e1bd3a2781c3962e57b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0030.ets @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0030 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'refreshOffset less than 96'; + @State infoMsg2: string = 'no_trigger'; + @State maxRefreshOffset: number = 0; + + + + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0030_003'); + Text('' + this.infoMsg2).id('refreshInteraction0030_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0030_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(96) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + /*f(refreshStatus.toString() == '3') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus;*/ + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + if(value > 96) + { + this.infoMsg1 = 'refreshOffset > 96'; + } + }) + + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('trigger onRefreshing test'); + this.infoMsg2 = 'trigger onRefreshing test'; + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a3ac56eea1a9ee3aeb4910acc14382c0b295578 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0040.ets @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0040 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'refreshOffset less than 64'; + @State infoMsg2: string = 'no_trigger'; + @State maxRefreshOffset: number = 0; + + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0040_003'); + Text('' + this.infoMsg2).id('refreshInteraction0040_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0040_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + /*f(refreshStatus.toString() == '3') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus;*/ + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + if(value > 64) + { + this.infoMsg1 = 'refreshOffset > 64'; + } + }) + + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('trigger onRefreshing test'); + this.infoMsg2 = 'trigger onRefreshing test'; + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a635267ec27011411e295dd99bb392e96a045d1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0050.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0050 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: number = 0; + @State infoMsg2: number = 0; + @State maxRefreshOffset: number = 0; + + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0050_003'); + Text('' + this.infoMsg2).id('refreshInteraction0050_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0050_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + /*f(refreshStatus.toString() == '3') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus;*/ + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.infoMsg1 = value; + }) + + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('trigger onRefreshing test'); + this.infoMsg2 = 1; + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..72c308e11742119558a11ffa0d1df00111a1cebc --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0060.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0060 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0060') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(640) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..65a6e54822284c5ed698483fe3a3cc1195f28401 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0070.ets @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0070 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: number = 0; + @State infoMsg2: number = 0; + @State maxRefreshOffset: number = 0; + + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0070_003'); + Text('' + this.infoMsg2).id('refreshInteraction0070_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0070_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + this.infoMsg2 = 1; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.infoMsg1 = value; + }) + + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('trigger onRefreshing test'); + + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..48ee4c20f48c1b9dd48e00271dac88ce7004c22f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0080.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0080 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0080') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0090.ets new file mode 100644 index 0000000000000000000000000000000000000000..4180c2367580a64f2ba5456fb27c48e18d102658 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0090.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0090 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0090') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..545527e8bd9383f80c74e578a2e41c9d67c9006b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0100.ets @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0100 { + @State isRefreshing: boolean = false; + @State msgLog2: string = 'Refresh onStatueChange state is:4'; + + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Text(this.msgLog2); + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterAction0100') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + this.msgLog2 = 'Refresh onStatueChange state is:' + refreshStatus; + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .refreshOffset(64) + .pullToRefresh(true); + + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..d07a5de2736e7476666fccf68c26644d0ac1700f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0130.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0130 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0130') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..4181f677cb95dbc5479a056ac2adeb2cd71c5e42 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0170.ets @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0170 { + @State isRefreshing: boolean = false; + @State marginValue: number = 10; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0170') + .margin(this.marginValue) + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + this.marginValue +=10; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..37317682760669b648034bc46d728790494a4986 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0180.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0180 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'Refresh onStatueChange state is 0'; + @State infoMsg2: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0180_003'); + Text('' + this.infoMsg2).id('refreshInteraction0180_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0180_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(128) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + if(refreshStatus.toString() == '0') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0190.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0190.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf8c77d737d92a0a4abc20008f046d2408af3c66 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0190.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0190 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'no_value'; + @State infoMsg2: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0190_003'); + Text('' + this.infoMsg2).id('refreshInteraction0190_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0190_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(128) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + if(refreshStatus.toString() == '1') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ec582de40ddc6b5f11419256ed38b24f460e6db --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0200.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0200 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'no_value'; + @State infoMsg2: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0200_003'); + Text('' + this.infoMsg2).id('refreshInteraction0200_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0200_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + if(refreshStatus.toString() == '2') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8f53d4fa0625e6c02ef1e2df747d597d32a6cce --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0210.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0210 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State infoMsg1: string = 'no_value'; + @State infoMsg2: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshInteraction0210_003'); + Text('' + this.infoMsg2).id('refreshInteraction0210_004'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0210_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(1) + .pullToRefresh(true) + .refreshOffset(64) + + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + if(refreshStatus.toString() == '3') { + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + } + this.infoMsg2 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..08d0493ff14bd14f9907d037a5e4eb97d6425019 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0220.ets @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0220 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State ratio: number = 1; + @State infoMsg: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg).id('refreshInteraction0220_003'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshInteraction0220_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(this.ratio) + .pullToRefresh(true) + .refreshOffset(64) + .onOffsetChange((offset: number)=>{ + this.ratio = 1 - Math.pow((offset / this.maxRefreshingHeight), 3) // 越接近最大距离,下拉跟手系数越小 + }) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + this.infoMsg = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..37134bffe7e781c289c9cb636d77f8ba5f07cf14 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0240.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0240 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10'] + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing,builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0240') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + this.arr.splice(5,1); + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..d11b8a3363d8c9f299f32246ff55e6d91a322c14 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0250.ets @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0250 { + @State isRefreshing: boolean = false + @State lanesNumber: number = 1 + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + @Builder + customRefreshComponent() { + Stack() { + Row() { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({ left: 20 }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({ minHeight: 32 }) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, builder: this.customRefreshComponent() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .lanes(this.lanesNumber) + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0250') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + this.lanesNumber += 1; + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0260.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0260.ets new file mode 100644 index 0000000000000000000000000000000000000000..20e18f9eb03de414aa63f256351ffd8415547912 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0260.ets @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface TimeTable { + title: string; + projects: string[]; +} + +@Entry +@Component +struct UIComponentOtherRefreshInterAction0260 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + private timeTable: TimeTable[] = [ + { + title: '星期一', + projects: ['语文', '数学', '英语'] + }, + { + title: '星期二', + projects: ['物理', '化学', '生物'] + }, + { + title: '星期三', + projects: ['历史', '地理', '政治'] + }, + { + title: '星期四', + projects: ['美术', '音乐', '体育'] + } + ] + + @Builder + customRefreshComponent() { + Stack() { + Row() { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({ left: 20 }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({ minHeight: 32 }) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + @Builder + itemHead(text: string) { + Text(text) + .fontSize(20) + .backgroundColor(0xAABBCC) + .width("100%") + .padding(10) + } + + @Builder + itemFoot(num: number) { + Text('共' + num + "节课") + .fontSize(16) + .backgroundColor(0xAABBCC) + .width("100%") + .padding(5) + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, builder: this.customRefreshComponent() }) { + List({ space: 20 }) { + ForEach(this.timeTable, (item: TimeTable) => { + ListItemGroup({ header: this.itemHead(item.title), footer: this.itemFoot(item.projects.length) }) { + ForEach(item.projects, (project: string) => { + ListItem() { + Text(project) + .width("100%") + .height(100) + .fontSize(20) + .textAlign(TextAlign.Center) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .divider({ strokeWidth: 1, color: Color.Blue }) // 每行之间的分界线 + }) + } + .width('90%') + .sticky(StickyStyle.Header | StickyStyle.Footer) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0260') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..42a3e27c92127733abb45381ba52be50b1619e5f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0270.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0270 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + @Builder + customRefreshComponent() { + Stack() { + Row() { + LoadingProgress().height(32) + Text("Refreshing...").fontSize(16).margin({ left: 20 }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue) + .height('50%') + .width('50%') + } + .align(Alignment.Center) + .clip(true) + .height('50%') + .width('50%') + .backgroundColor(Color.Red) + .constraintSize({ minHeight: 32 }) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, builder: this.customRefreshComponent() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + TextInput() + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0270') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0430.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0430.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4d433e18edbed2e18cd7092e6ceb6e42ec6dd6e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0430.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterAction0430 { + @State isRefreshing: boolean = false + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + @Builder + customRefreshComponent() { + Scroll() { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(Color.Yellow) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, builder: this.customRefreshComponent() }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .id('UIComponentOtherRefreshInterAction0430') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..97dd6ac2e4668dcba56ead08fa651d3965c1b3a1 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0010.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0010 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0010 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: DataSource0010 = new DataSource0010([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0010(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0010_001') + .cachedCount(2) + .index(0) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b2992de04643a0b21a9c88bff1e8042a9c34e62 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0030.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0030 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0030 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: DataSource0030 = new DataSource0030([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0030(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0030_001') + .cachedCount(2) + .index(0) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .vertical(true) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..77b4cf46b317fc22d36fa80fa628ec6091c50a23 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0040.ets @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class MyDataSource0040 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0040 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: MyDataSource0040 = new MyDataSource0040([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new MyDataSource0040(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .cachedCount(2) + .index(0) + .autoPlay(true) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0050.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0050.ets new file mode 100644 index 0000000000000000000000000000000000000000..d521693c2a8406a5bcdc3d1df3839de7372dca5f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0050.ets @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0050 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0050 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + private swiperController: SwiperController = new SwiperController() + private data: DataSource0050 = new DataSource0050([]) + + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0050(list) + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0050_001') + .cachedCount(2) + .index(0) + .displayCount(2, true) + .interval(1000) + .indicator(Indicator.digit()// 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..8456c39aed8c1651d44361737c768a74124de1d2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0060.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0060 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0060 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: DataSource0060 = new DataSource0060([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0060(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0060_001') + .cachedCount(2) + .index(0) + .disableSwipe(true) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0070.ets new file mode 100644 index 0000000000000000000000000000000000000000..26656b8be1c6b3321fe3568ebddf08b4f5765a7f --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0070.ets @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0070 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0070 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: DataSource0070 = new DataSource0070([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0070(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0070_001') + .nestedScroll(SwiperNestedScrollMode.SELF_ONLY) + .cachedCount(2) + .index(0) + .autoPlay(true) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0080.ets new file mode 100644 index 0000000000000000000000000000000000000000..31ddec8690d65cf077d4052b13e736579b7d393e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0080.ets @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DataSource0080 implements IDataSource { + private list: number[] = [] + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): number { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener() { + } +} + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0080 { + @State isRefreshing: boolean = false; + private swiperController: SwiperController = new SwiperController() + private data: DataSource0080 = new DataSource0080([]) + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + aboutToAppear(): void { + let list: number[] = [] + for (let i = 1; i <= 3; i++) { + list.push(i); + } + this.data = new DataSource0080(list) + } + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Swiper(this.swiperController) { + LazyForEach(this.data, (item: string) => { + Text(item.toString()) + .width('90%') + .height(160) + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterConnection0080_001') + .nestedScroll(SwiperNestedScrollMode.SELF_FIRST) + .cachedCount(2) + .index(0) + .interval(1000) + .indicator(Indicator.digit() // 设置数字导航点样式 + .top(200) + .fontColor(Color.Gray) + .selectedFontColor(Color.Gray) + .digitFont({ size: 20, weight: FontWeight.Bold }) + .selectedDigitFont({ size: 20, weight: FontWeight.Normal })) + .loop(false) + .duration(1000) + .itemSpace(0) + .displayArrow(true, false); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0110.ets new file mode 100644 index 0000000000000000000000000000000000000000..f84b3522519d0a12ae0e87085024323072ba52f3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0110.ets @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import webview from '@ohos.web.webview' + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0110 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Web({ src: $rawfile("index.html"), controller: this.controller }) + .id('UIComponentOtherRefreshInterConnection0110_001') + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..587aefe4a501be3fb52dc242842a4654e256b1ca --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0120.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import webview from '@ohos.web.webview' + + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0120 { + @State isRefreshing: boolean = false; + controller: webview.WebviewController = new webview.WebviewController(); + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Web({ src: $rawfile("index.html"), controller: this.controller }) + .id('UIComponentOtherRefreshInterConnection0120_001') + .nestedScroll({ + scrollForward: NestedScrollMode.SELF_FIRST, + scrollBackward: NestedScrollMode.SELF_FIRST, + }) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..7298ebb3d4bf7d06ba4155b01ef4150d3651f791 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0130.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import webview from '@ohos.web.webview' + + +@Entry +@Component +struct UIComponentOtherRefreshInterConnection0130 { + @State isRefreshing: boolean = false; + controller: webview.WebviewController = new webview.WebviewController(); + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + Web({ src: $rawfile("index.html"), controller: this.controller }) + .id('UIComponentOtherRefreshInterConnection0130_001') + .nestedScroll({ + scrollForward: NestedScrollMode.PARALLEL, + scrollBackward: NestedScrollMode.PARALLEL, + }) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true); + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b7fb5733c618f25bd4034596d110f8e26faf55d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0010.ets @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0010 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State RefreshStatus: RefreshStatus = RefreshStatus.Inactive; + + build() { + Column() { + Text("RefreshStatus" + this.RefreshStatus) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + + .onStateChange((refreshStatus: RefreshStatus) => { + this.RefreshStatus = refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..4bf29a84d7b2d590736d6dd1dabad8b65f227729 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0020.ets @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0020 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State RefreshStatus: RefreshStatus = RefreshStatus.Inactive; + + build() { + Column() { + Text("RefreshStatus" + this.RefreshStatus) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + + .onStateChange((refreshStatus: RefreshStatus) => { + this.RefreshStatus = refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..7edd3183389b8a56831ae8ac2b83d3b9b3507fab --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0030.ets @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0030 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State RefreshStatus: RefreshStatus = RefreshStatus.Inactive; + + build() { + Column() { + Text("RefreshStatus" + this.RefreshStatus) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + + .onStateChange((refreshStatus: RefreshStatus) => { + this.RefreshStatus = refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0040.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0040.ets new file mode 100644 index 0000000000000000000000000000000000000000..45791950326dc45573911f75534d6e8996d93766 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0040.ets @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0040 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State RefreshStatus: RefreshStatus = RefreshStatus.Inactive; + + build() { + Column() { + Text("RefreshStatus" + this.RefreshStatus) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + + .onStateChange((refreshStatus: RefreshStatus) => { + this.RefreshStatus = refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..e197f908fcc76b7d0eb3a54b768630f08a5f3209 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0130.ets @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0130 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text("Refresh test") + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ec378a4eed5c610ef9d72042d09eaad28c6cbc9 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0160.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0160 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterface0160') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(150) + .pullDownRatio(1) + .pullToRefresh(true); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0170.ets index 07269db1e9cc607229127091680bb03d6a3223cf..d62317713642f286397adc43472336d81a7be924 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0170.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0170.ets @@ -14,7 +14,7 @@ */ @Entry @Component -struct UIComponentOtherRefreshPromptText0170 { +struct UIComponentOtherRefreshInterface0170 { @State isRefreshing: boolean = false; @State promptText: string = "Refreshing..."; @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0180.ets index 49240b52287bb14d925011ab51f2c888b8192bf2..60fb0a2fc290b6d8ade2f567e7fca90aa719a2ae 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0180.ets +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0180.ets @@ -14,7 +14,7 @@ */ @Entry @Component -struct UIComponentOtherRefreshPromptText0180 { +struct UIComponentOtherRefreshInterface0180 { @State isRefreshing: boolean = false; @State promptText: string = "Refreshing..."; @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..0aa1de9a0f5eb6b9112b478f2045b88cbc9bb443 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0200.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshInterface0200 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('UIComponentOtherRefreshInterface0200') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(150) + .pullDownRatio(1) + .pullToRefresh(true); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshOnOffsetChange/UIComponentOtherRefreshOnOffsetChange0100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshOnOffsetChange/UIComponentOtherRefreshOnOffsetChange0100.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dffac58cccfc4c24f256356e673bd4c6b309e2e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshOnOffsetChange/UIComponentOtherRefreshOnOffsetChange0100.ets @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshOnOffsetChange0100 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State msgInfo: string = 'Refresh onOffsetChange offset:0'; + build() { + Column() { + Text(this.msgInfo); + Refresh({ refreshing: $$this.isRefreshing }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + .id('UIComponentOtherRefreshOnOffsetChange0100'); + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + this.msgInfo = 'Refresh onOffsetChange offset:' + value; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d52627346650907c8a976ade8dd0b50b064a45d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0010.ets @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0010 { + @State isRefreshing: boolean = false; + @State RefreshingTxt: Resource = $r("app.string.module_test_desc"); + @State infoMsg1: string = 'no trigger'; + @State infoMsg2: string = 'no trigger'; + @State refreshOffset: number = 0; + + + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshPrompttext0010_003'); + Text('' + this.infoMsg2).id('refreshPrompttext0010_004'); + Refresh({ refreshing: $$this.isRefreshing, promptText:this.RefreshingTxt}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshPrompttext0010_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .onOffsetChange((offset: number) => { + this.refreshOffset=offset; + this.infoMsg2 = 'this.refreshOffset=' + this.refreshOffset ; + }) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + + if(refreshStatus == 2 || refreshStatus == 3) + { + if(this.refreshOffset >= 96) { + + this.infoMsg1 = 'this.refreshOffset default is 96vp'; + } + } + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..618ef240f2c25ed0508458208b05e01f9e2703aa --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0030.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0030 { + @State isRefreshing: boolean = false; + @State RefreshingTxt: string = 'Refreshing...'; + @State infoMsg1: string = 'no trigger'; + @State infoMsg2: number = 0; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @Builder + customRefreshComponent() + { + Stack() + { + Row() + { + LoadingProgress().height(32) + Text(this.RefreshingTxt).fontSize(16).margin({left:20}) + } + .alignItems(VerticalAlign.Center) + .backgroundColor(Color.Blue); + } + } + + build() { + Column() { + Text('' + this.infoMsg1).id('refreshPrompttext0030_003'); + Text('' + this.infoMsg2).id('refreshPrompttext0030_004'); + Refresh({ refreshing: $$this.isRefreshing, promptText: 'promptText123', builder:this.customRefreshComponent()}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshPrompttext0030_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + //.refreshOffset(64) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + this.infoMsg1 = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..41b36f30a75266b77ed180ec9196d98c01f85eaf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160.ets @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0160 { + @State isRefreshing: boolean = false; + @State promptText: string | null = null; + @State offsetValue: number = 20; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + build() { + Column() { + Button('change offset') + .id('UIComponentOtherRefreshPromptText0160_001') + .onClick(() => { + this.offsetValue += 10; + }) + Refresh({ refreshing: this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentOtherRefreshPromptText0160_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(this.offsetValue) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0170.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0170.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc7ee23507315142758cca6acd8bce1c27e70625 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0170.ets @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0170 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text("Refresh test") + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item).margin({bottom:10}) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(false) + .refreshOffset(-100) + .pullDownRatio(1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0180.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0180.ets new file mode 100644 index 0000000000000000000000000000000000000000..49240b52287bb14d925011ab51f2c888b8192bf2 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0180.ets @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0180 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Text("Refresh test") + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).id('' + item).margin({bottom:10}) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(0) + .pullDownRatio(1) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..324c8daa8d06eb5d504759bfe85c39735f1dc545 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import window from '@ohos.window'; +import common from '@ohos.app.ability.common'; +@Entry +@Component +struct UIComponentOtherRefreshPromptText0220 { + @State isRefreshing: boolean = false; + @State promptText: string = 'openHarmon1234openHarmon1234openHarmon1234openHarmon1234openHarmon1234openHarmon1234openHarmon1234openHarmon1234openHarmon1234'; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State isFullScreen: boolean = false + + horVerSwitch() { + let context = getContext(this) as common.UIAbilityContext; + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(this.isFullScreen ? window.Orientation.PORTRAIT : window.Orientation.LANDSCAPE) + this.isFullScreen = !this.isFullScreen + }) + } + + build() { + Column() { + Button('change hor') + .id('UIComponentOtherRefreshPromptText0220_001') + .onClick(()=>{ + this.horVerSwitch(); + }) + Refresh({ refreshing: this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentOtherRefreshPromptText0220_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b55818fab173b1f3bcd604fdce2cfe25823883b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0230 { + @State isRefreshing: boolean = false; + @State promptText: string = 'cde'; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Button('change promptText') + .id('UIComponentOtherRefreshPromptText0230_001') + .onClick(()=>{ + this.promptText = 'abc'; + }) + Refresh({ refreshing: this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentOtherRefreshPromptText0230_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0240.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0240.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c5744d186ddccc19142dd5d306b99b2c9e0c75b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0240.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0240 { + @State isRefreshing: boolean = false; + @State promptText: string | undefined = undefined; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + + build() { + Column() { + Refresh({ refreshing: this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0250.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0250.ets new file mode 100644 index 0000000000000000000000000000000000000000..e91c54db40348e4e5e483b76a689354e2b83ab81 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0250.ets @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentOtherRefreshPromptText0250 { + @State isRefreshing: boolean = false; + @State promptText: string | null = null; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + + build() { + Column() { + Refresh({ refreshing: this.isRefreshing, promptText: this.promptText}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10).id('' + item) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060.ets new file mode 100644 index 0000000000000000000000000000000000000000..54e8abd88f6d6d865da366a28f7da2ddc64971d5 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060.ets @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentRefreshPulldownradio0060 { + @State isRefreshing: boolean = false; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State ratio: number = 10; + @State refreshOffset: number = 80; + @State pullToRefresh: boolean = true; + + build() { + Column() { + Button('change') + .id('UIComponentRefreshPulldownradio0060_001') + .onClick(() => { + this.ratio += 10; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentRefreshPulldownradio0060_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh) + .refreshOffset(96) + .pullDownRatio(this.ratio) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120.ets new file mode 100644 index 0000000000000000000000000000000000000000..c21ba599fa1891e8f37926339650e951a26335cc --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentRefreshPulldownradio0120 { + @State isRefreshing: boolean = false; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State ratio: number = 10; + @State refreshOffset: number = 80; + @State pullToRefresh: boolean = true; + + build() { + Column() { + Button('change') + .id('UIComponentRefreshPulldownradio0120_001') + .onClick(() => { + this.ratio += 10; + this.refreshOffset = 50; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentRefreshPulldownradio0120_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh) + .refreshOffset(96) + .pullDownRatio(this.ratio) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3e393a39fd348db4ce8f80122b554887a8dcab0 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentRefreshPulldownradio0130 { + @State isRefreshing: boolean = false; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State ratio: number = 10; + @State refreshOffset: number = 80; + @State pullToRefresh: boolean = true; + + build() { + Column() { + Button('change') + .id('UIComponentRefreshPulldownradio0130_001') + .onClick(() => { + this.ratio += 10; + this.pullToRefresh = !this.pullToRefresh; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentRefreshPulldownradio0130_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh) + .refreshOffset(96) + .pullDownRatio(this.ratio) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0140.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0140.ets new file mode 100644 index 0000000000000000000000000000000000000000..34cf825e52897d0190cae3408b72c6b0792d2d09 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0140.ets @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@ohos.arkui.node'; + +@Builder +function customRefreshingContent() { + Stack() { + Row() { + LoadingProgress().height(32) + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIComponentRefreshPulldownradio0140 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State maxRefreshingHeight: number = 100.0; + @State ratio: number = 1; + @State infoMsg: string = 'no_value'; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent)) + } + + build() { + Column() { + Text('' + this.infoMsg).id('refreshPullDownradio0140_003'); + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .id('refreshPullDownradio0140_001') + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullDownRatio(this.ratio) + .pullToRefresh(true) + .refreshOffset(64) + .onOffsetChange((offset: number)=>{ + this.ratio = 1 - Math.pow((offset / this.maxRefreshingHeight), 3) // 越接近最大距离,下拉跟手系数越小 + }) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + this.infoMsg = 'Refresh onStatueChange state is ' + refreshStatus; + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160.ets new file mode 100644 index 0000000000000000000000000000000000000000..d808343a436553caf6a92ceba921fcfe1cab8d3b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160.ets @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import window from '@ohos.window'; +import common from '@ohos.app.ability.common'; +@Entry +@Component +struct UIComponentRefreshPulldownradio0160 { + @State isRefreshing: boolean = false; + @State promptText: string = ' '; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State ratio: number = 10; + @State refreshOffset: number = 80; + @State pullToRefresh: boolean = true; + @State isFullScreen: boolean = false + + horVerSwitch() { + let context = getContext(this) as common.UIAbilityContext; + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(this.isFullScreen ? window.Orientation.PORTRAIT : window.Orientation.LANDSCAPE) + this.isFullScreen = !this.isFullScreen + }) + } + + build() { + Column() { + Button('change') + .id('UIComponentRefreshPulldownradio0160_001') + .onClick(() => { + this.horVerSwitch(); + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .margin(10) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .id('UIComponentRefreshPulldownradio0160_002') + .backgroundColor(0x89CFF0) + .pullToRefresh(this.pullToRefresh) + .refreshOffset(96) + .pullDownRatio(this.ratio) + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus); + }) + .onOffsetChange((value: number) => { + console.info('Refresh onOffsetChange offset:' + value); + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test'); + }); + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentScrollSwiperTeace/UIComponentScrollSwiperTeace0370.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentScrollSwiperTeace/UIComponentScrollSwiperTeace0370.ets new file mode 100644 index 0000000000000000000000000000000000000000..cbd3f4a0e63e79b11ee37932e3825879b977e186 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentScrollSwiperTeace/UIComponentScrollSwiperTeace0370.ets @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { common } from '@kit.AbilityKit'; +import { mediaquery, window } from '@kit.ArkUI'; +@Entry +@Component +struct UIComponentScrollSwiperTeace0370 { + + // 改变设备横竖屏状态函数 + private changeOrientation(isLandscape: boolean) { + // 获取UIAbility实例的上下文信息 + let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; + // 调用该接口手动改变设备横竖屏状态 + window.getLastWindow(context).then((lastWindow) => { + lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT) + }); + } + + build() { + Column({ space: 5 }) { + Column() { + Button('Landscape') + .onClick(() => { + this.changeOrientation(true); + }).id('UIComponentScrollSwiperTeace0370_001'); + Button('Portrait') + .onClick(() => { + this.changeOrientation(false); + }).id('UIComponentScrollSwiperTeace0370_002'); + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar(new SubTabBarStyle('Green').id('Green')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar(new SubTabBarStyle('Pink').id('Pink')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar(new SubTabBarStyle('Yellow').id('Yellow')); + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar(new SubTabBarStyle('Blue').id('Blue')); + + } + .vertical(false) + .scrollable(true) + .animationDuration(3000) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + .id('UIComponentScrollSwiperTeace0370'); + + + + }.width('100%').height(400) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0200.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0200.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fe1c10a6b072be02804427427b457562802a7cf --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0200.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SymbolGlyphModifier } from '@ohos.arkui.modifier' + +@Entry +@Component +struct UIComponentTabTabbarTabbarsymbol0200 { + @State currentIndex: number = 0 + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK + @State symbolModifier: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.openeye')) + @State symbolModifierSelect: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.closeeye')) + private controller: TabsController = new TabsController() + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Black')) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Pink')) + + } + .id('UIComponentTabTabbarTabbarsymbol0200') + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .barOverlap(true) + .barGridAlign( + { + lg: 10 + } + ) + .height(296) + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0210.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0210.ets new file mode 100644 index 0000000000000000000000000000000000000000..05583d83d06a71ec3b432327533f3fb5a4a6873c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0210.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SymbolGlyphModifier } from '@ohos.arkui.modifier' + +@Entry +@Component +struct UIComponentTabTabbarTabbarsymbol0210 { + @State currentIndex: number = 0 + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK + @State symbolModifier: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.openeye')) + @State symbolModifierSelect: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.closeeye')) + private controller: TabsController = new TabsController() + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Black').id('Black')) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Pink').id('Pink')) + + } + .id('UIComponentTabTabbarTabbarsymbol0210') + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .barOverlap(true) + .barGridAlign( + { + lg: 10 + } + ) + .height(296) + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0220.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0220.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd8766594efe076b6777b0fef892c3008812a347 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0220.ets @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SymbolGlyphModifier } from '@ohos.arkui.modifier' + +@Entry +@Component +struct UIComponentTabTabbarTabbarsymbol0220 { + @State currentIndex: number = 0 + @State blurStyle: BlurStyle = BlurStyle.BACKGROUND_THICK + @State symbolModifier: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.openeye')) + @State symbolModifierSelect: SymbolGlyphModifier = new SymbolGlyphModifier($r('app.media.closeeye')) + private controller: TabsController = new TabsController() + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Black) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Black').id('Black')) + + TabContent() { + Column().width(500).height('100%').backgroundColor(Color.Pink) + } + .tabBar(new BottomTabBarStyle({ + normal: this.symbolModifier, + selected: this.symbolModifierSelect + }, 'Pink').id('Pink')) + + } + .id('UIComponentTabTabbarTabbarsymbol0220') + .barBackgroundBlurStyle(BlurStyle.BACKGROUND_REGULAR) + .barOverlap(true) + .barGridAlign( + { + lg: 10 + } + ) + .height(296); + + Button('changeIndex').width('50%').margin({ top: 20 }) + .onClick(() => { + this.currentIndex = (this.currentIndex + 1) % 2 + this.controller.changeIndex(this.currentIndex) + }).id('UIComponentTabTabbarTabbarsymbol0220_001') + + }.width('100%') + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..f16924dc35befc28a732239f70bf4d21e0458e60 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0010.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentTabsClip0010 { + private controller1: TabsController = new TabsController(); + @State dividerColor: string = 'red'; + @State strokeWidth: number = 2; + @State startMargin: number = 0; + @State endMargin: number = 0; + @State nullFlag: boolean = false; + + build() { + Column() { + Tabs({ controller: this.controller1 }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar('pink') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar('yellow') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar('blue') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar('green') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar('red') + } + .borderRadius(20) + .clip(true) + .vertical(true) + .scrollable(true) + .barWidth(70) + .barHeight(200) + .animationDuration(400) + .height('200vp') + .margin({ bottom: '12vp' }) + .divider(this.nullFlag ? null : { + strokeWidth: this.strokeWidth, + color: this.dividerColor, + startMargin: this.startMargin, + endMargin: this.endMargin + }) + }.padding({ top: '24vp', left: '24vp', right: '24vp' }) + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0020.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0020.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5b63551d753ce5f7f73476ad6b740b379ff630b --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentTabsClip/UIComponentTabsClip0020.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentTabsClip0020 { + private controller1: TabsController = new TabsController(); + @State dividerColor: string = 'red'; + @State strokeWidth: number = 2; + @State startMargin: number = 0; + @State endMargin: number = 0; + @State nullFlag: boolean = false; + + build() { + Column() { + Tabs({ controller: this.controller1 }) { + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Pink) + }.tabBar('pink') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Yellow) + }.tabBar('yellow') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Blue) + }.tabBar('blue') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Green) + }.tabBar('green') + + TabContent() { + Column().width('100%').height('100%').backgroundColor(Color.Red) + }.tabBar('red') + } + .borderRadius(20) + .clip(false) + .vertical(true) + .scrollable(true) + .barWidth(70) + .barHeight(200) + .animationDuration(400) + .height('200vp') + .margin({ bottom: '12vp' }) + .divider(this.nullFlag ? null : { + strokeWidth: this.strokeWidth, + color: this.dividerColor, + startMargin: this.startMargin, + endMargin: this.endMargin + }) + }.padding({ top: '24vp', left: '24vp', right: '24vp' }) + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1060.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1060.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe4a67582b22cf35e722c6a9a3c38054955fdbed --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1060.ets @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1060 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.LIGHT; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Button('change colorMode') + .id('UIComponentUISupportColor1060_001') + .onClick(()=>{ + this.colorMode = ThemeColorMode.LIGHT; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1070.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1070.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6645282d32937ce195b39a171fce2cbeb297f0e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1070.ets @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1070 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.LIGHT; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Button('change colorMode') + .id('UIComponentUISupportColor1070_001') + .onClick(()=>{ + this.colorMode = ThemeColorMode.DARK; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1080.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1080.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c871e2e4b65f6815d3a3dd0ed91d40d0a10cd45 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1080.ets @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1080 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.DARK; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Button('change colorMode') + .id('UIComponentUISupportColor1080_001') + .onClick(()=>{ + this.colorMode = ThemeColorMode.LIGHT; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1090.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1090.ets new file mode 100644 index 0000000000000000000000000000000000000000..514301bf275e7d3e194476b96e81be7c20d3dc4e --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1090.ets @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1090 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.DARK; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Button('change colorMode') + .id('UIComponentUISupportColor1090_001') + .onClick(()=>{ + this.colorMode = ThemeColorMode.DARK; + }) + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1100.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1100.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c72489b45ecd2988a70bd9c944b1b8ce4ef9f97 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1100.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1100 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.LIGHT; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1110.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1110.ets new file mode 100644 index 0000000000000000000000000000000000000000..df07ed24560ef22212400dc8508b930181236574 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1110.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UIComponentUISupportColor1110 { + @State isRefreshing: boolean = false; + @State promptText: string = "Refreshing..."; + @State arr: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; + @State colorMode: ThemeColorMode = ThemeColorMode.DARK; + + build() { + WithTheme({ colorMode: this.colorMode }) { + Column() { + Refresh({ refreshing: $$this.isRefreshing, promptText: this.promptText }) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%') + .height(80) + .fontSize(16) + .id('' + item) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFF0000); + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off); + } + .backgroundColor($r('sys.color.background_primary')) + .pullToRefresh(true) + .refreshOffset(-100) + .pullDownRatio(100) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + console.log('onRefreshing test'); + }); + } + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/UIComponentWaterFlowFooter0010.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/UIComponentWaterFlowFooter0010.ets new file mode 100644 index 0000000000000000000000000000000000000000..6514d17bc9e131aa6c3d4d14ab5d2e5c4c54db29 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/UIComponentWaterFlowFooter0010.ets @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' +import { LengthMetrics } from '@kit.ArkUI' + +import image from '@ohos.multimedia.image' + +@Entry +@Component +struct UIComponentWaterFlowFooter0010 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number =0 + @State layoutMode1: number|undefined|null=1 + @State bool:boolean=true + // @State layoutMode1:number=1 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + + Column({ space: 2 }) { + Scroll() { + Column() { + Row(){ + Button('默认布局').height(40).onClick(() => { + this.layoutMode1 = 0 + }) + Button('移动窗口布局').height(40).onClick(() => { + this.layoutMode1 = 1 + + }) + + } + Row(){ + Button('单独节点显隐:'+`${this.visibilitys[this.Visibilitynum%3]}`) + .onClick((event: ClickEvent) => { + this.Visibilitynum++ + }) + Button("footer显隐:"+this.flag ) + .onClick(() => { + this.flag=!this.flag + }).id('UIComponentWaterFlowFooter0010_001'); + } + } + } .border({width:1}).margin({left:2}) + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + } + .visibility(this.visibilitys[this.Visibilitynum%3]) + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.img2')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(this.colors[item % 5]) + }, (item: string, index: number) => item + index+Math.random()) + } + .id('UIComponentWaterFlowFooter0010') + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Black) + .width(350) + .height('40%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..70577a8fd1f3e8dd318aa2949179433386591301 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowFooter/WaterFlowDataSource.ets @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDeleted(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMoved(from, to) + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public Add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public AddLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public AddItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public Delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public Delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public DeleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public Reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 10) + this.notifyDataReload() + } +} + diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0270.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0270.ets new file mode 100644 index 0000000000000000000000000000000000000000..532c700df41ed53c0b5412569a556bb79ab27e7d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0270.ets @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentWaterFlowSliding0270 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()) + this.itemHeightArray.push(this.getSize()) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemHeader() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow() { + FlowItem() { + Column() { + Text("N9999").fontSize(12).height('16') + } + } + + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + // 存在对应的jpg文件才会显示图片 + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .visibility(Visibility.None) + .width('100%') + .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onReachStart(() => { + console.info('waterFlow reach start') + }) + .onScrollStart(() => { + console.info('waterFlow scroll start') + }) + .onScrollStop(() => { + console.info('waterFlow scroll stop') + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()) + return { offsetRemain: offset } + }) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0320.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0320.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddbe1f95b2872be9a6bd82b9e380b46a3630914d --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0320.ets @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource1' +import { LengthMetrics } from '@kit.ArkUI' + +import image from '@ohos.multimedia.image' + +@Entry +@Component +struct UIComponentWaterFlowSliding0320 { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + @State onReachText: string = '' + @State columnsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr','null', '0.5fr', 'abc' ,'repeat(auto-fill,100)','undefined'] + @State columnsTemplateNum: number = 0 + @State columnsGap: [string, string, number] = ['5vp', 'abc', 10] + @State columnsGapNum: number = 0 + @State rowsTemplate: string[] = ['1fr 1fr 2fr', '1fr 1fr 0fr', '0.5fr', 'abc' ,'repeat(auto-fill,100)'] + @State rowsTemplateNum: number = 0 + @State rowsGap: [string, string, number] = ['5vp', 'abc', 10] + @State rowsGapNum: number = 0 + @State layoutDirection: FlexDirection[] = [FlexDirection.Column, FlexDirection.ColumnReverse, FlexDirection.RowReverse, FlexDirection.Row] + @State layoutDirectionNum: number = 0 + @State fatherPadding: number = 0 + @State fatherMargin: number = 0 + @State safePadding:number=30 + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + @State rotation: number = 0 + @State data: number[] = [] + @State smooth:boolean=false + @State directions :Direction[]=[Direction.Auto,Direction.Ltr,Direction.Rtl] + @State Direction : number = 0 + @State layoutMode1: number|undefined|null=0 + @State bool:boolean=true + //@State layoutMode1:number=0 + @State extraoffsetnum:number=0 + @State extraoffsets:number[]=[0,-1.5,20,100,50,-1000,500,100000] + @State ScrollAlign:number=0 + @State ScrollAligns:ScrollAlign[]=[ScrollAlign.START,ScrollAlign.CENTER,ScrollAlign.END,ScrollAlign.AUTO] + @State text1:string='' + @State height1:number=50 + // + @State visibilitys:Visibility[]=[Visibility.Visible,Visibility.Hidden,Visibility.None] + @State Visibilitynum:number=0 + @State canoverscroll:boolean=true + + // + @State flag :boolean = true + // + @State clipNum:number=0 + @State text2:string='' + @State bool1:boolean=true + @State bool2:boolean=true + + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(200) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + if(this.flag) { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + }else{} + } + + build() { + + Column({ space: 2 }) { + Scroll() { + Column() { + Row(){ + Button('默认布局').height(40).onClick(() => { + this.layoutMode1 = 0 + }) + Button('移动窗口布局').height(40).onClick(() => { + this.layoutMode1 = 1 + + }).id('UIComponentWaterFlowSliding0320_001'); + + } + Row(){ + Button('单独节点显隐:'+`${this.visibilitys[this.Visibilitynum%3]}`) + .onClick((event: ClickEvent) => { + this.Visibilitynum++ + }) + Button("footer显隐:"+this.flag ) + .onClick(() => { + this.flag=!this.flag + }).id('UIComponentWaterFlowSliding0320_002'); + } + } + } .border({width:1}).margin({left:2}) + Column(){ + }.height('10%') + WaterFlow({ footer: this.itemFoot, scroller: this.scroller, layoutMode:this.layoutMode1}) { + FlowItem() { + Text("TopItem") + .width(60).height(this.height1) + .fontColor(Color.White) + .backgroundColor(Color.Brown) + }.visibility(this.visibilitys[this.Visibilitynum%3]); + LazyForEach(this.datasource, (item: number,index:number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image($r('app.media.img2')) + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(100) + .backgroundColor(this.colors[item % 5]) + }, (item: string, index: number) => item + index+Math.random()) + } + .id('UIComponentWaterFlowSliding0320') + .padding(this.fatherPadding) + .direction(this.directions[this.Direction]) + .edgeEffect(EdgeEffect.Spring,{alwaysEnabled:true}) + .scrollBar(BarState.Auto) + .scrollBarWidth(20) + .enableScrollInteraction(this.bool) + .columnsTemplate(this.columnsTemplate[this.columnsTemplateNum]) + .rowsTemplate(this.rowsTemplate[this.rowsTemplateNum]) + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(this.columnsGap[this.columnsGapNum]) + .rowsGap(this.rowsGap[this.rowsGapNum]) + .onScrollIndex((first: number, last: number) => { + console.info('onScrollIndex-' + 'first:' + first + '、last:' + last) + }) + .backgroundColor(Color.Black) + .width(350) + .height('40%') + .border({width:1}) + .layoutDirection(this.layoutDirection[this.layoutDirectionNum]) + .margin(this.fatherMargin) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0470.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0470.ets new file mode 100644 index 0000000000000000000000000000000000000000..5222046567f813d2b2ad5ab6e06237b13f1e737c --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0470.ets @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentWaterFlowSliding0470 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State newPosition: Position = {x:100,y:100} + @State newPosition1: Position = {x:50,y:50} + @State newPosition2: Position = {x:100,y:100} + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('change position') + .height('5%') + .onClick(() => { + if(this.newPosition == this.newPosition1) + { + this.newPosition = this.newPosition2; + } + else + { + this.newPosition = this.newPosition1; + } + }) + .id('UIComponentWaterFlowSliding0470_001') + .margin({ top: 10, left: 20 }) + + WaterFlow({ layoutMode: 1 }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + // 存在对应的jpg文件才会显示图片 + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + // 即将触底时提前增加数据 + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .id('UIComponentWaterFlowSliding0470') + .offset(this.newPosition) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onReachStart(() => { + console.info('waterFlow reach start') + }) + .onScrollStart(() => { + console.info('waterFlow scroll start') + }) + .onScrollStop(() => { + console.info('waterFlow scroll stop') + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()) + return { offsetRemain: offset } + }) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0480.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0480.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac28df1ebe2ac46bdbe207759dbe55418142a0a6 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0480.ets @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct UIComponentWaterFlowSliding0480 { + @State minSize: number = 80 + @State maxSize: number = 180 + @State newMargin: number = 0 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + dataSource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + // 计算FlowItem宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 设置FlowItem的宽/高数组 + setItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(200) + this.itemHeightArray.push(100) + } + } + + aboutToAppear() { + this.setItemSizeArray() + } + + @Builder + itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + Button('change margin') + .height('5%') + .onClick(() => { + if(this.newMargin == 100) + { + this.newMargin = 0; + } + else + { + this.newMargin = 100; + } + }) + .id('UIComponentWaterFlowSliding0480_001') + .margin({ top: 10, left: 20 }) + + WaterFlow({ layoutMode: 1 }) { + LazyForEach(this.dataSource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + // 存在对应的jpg文件才会显示图片 + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .onAppear(() => { + // 即将触底时提前增加数据 + if (item + 20 == this.dataSource.totalCount()) { + for (let i = 0; i < 100; i++) { + this.dataSource.addLastItem() + } + } + }) + .width('100%') + .height(this.itemHeightArray[item % 100]) + .backgroundColor(this.colors[item % 5]) + }, (item: string) => item) + } + .columnsTemplate("1fr 1fr") + .columnsGap(10) + .id('UIComponentWaterFlowSliding0480') + .margin(this.newMargin) + .rowsGap(5) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('100%') + .onReachStart(() => { + console.info('waterFlow reach start') + }) + .onScrollStart(() => { + console.info('waterFlow scroll start') + }) + .onScrollStop(() => { + console.info('waterFlow scroll stop') + }) + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('waterFlow scrollFrameBegin offset: ' + offset + ' state: ' + state.toString()) + return { offsetRemain: offset } + }) + } + } +} diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d6f4b1ab33cd7957083e0a15bcb4b590e3e8808 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource1.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource1.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b7ef412b866b2efdabb2579175f618b0ba00bb4 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIComponentWaterFlowSliding/WaterFlowDataSource1.ets @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 10; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): number { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } + + //通知控制器数据批量修改 + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public addLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length - 1) + } + + // 在指定索引位置增加一个元素 + public addItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public deleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 在指定索引位置删除一个元素 + public deleteItem(index: number): void { + this.dataArray.splice(index, 1) + this.notifyDataDelete(index) + } + + // 重新加载数据 + public reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIRefreshComponentContent/UIRefreshComponentContent0030.ets b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIRefreshComponentContent/UIRefreshComponentContent0030.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5d9664a26350d1c62db353558742f322185bc85 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/ets/testability/pages/UIRefreshComponentContent/UIRefreshComponentContent0030.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ComponentContent } from '@ohos.arkui.node'; + +class Params { + refreshStatus: RefreshStatus = RefreshStatus.Inactive + + constructor(refreshStatus: RefreshStatus) { + this.refreshStatus = refreshStatus; + } +} + +@Builder +function customRefreshingContent(params:Params) { + Stack() { + Row() { + LoadingProgress().height(32) + Text("refreshStatus: "+params.refreshStatus).fontSize(16).margin({left:20}).id('refreshComponentcontent0030_003'); + } + .alignItems(VerticalAlign.Center) + } + .align(Alignment.Center) + .clip(true) + .constraintSize({minHeight:32}) // 设置最小高度约束保证自定义组件高度随刷新区域高度变化时自定义组件高度不会低于minHeight + .width("100%") +} + +@Entry +@Component +struct UIRefreshComponentContent0030 { + @State isRefreshing: boolean = false; + @State arr: String[] = ['0', '1', '2', '3', '4','5','6','7','8','9','10']; + @State refreshStatus: RefreshStatus = RefreshStatus.Inactive; + private contentNode?: ComponentContent = undefined; + + aboutToAppear():void { + let uiContext = this.getUIContext(); + this.contentNode = new ComponentContent(uiContext, wrapBuilder(customRefreshingContent), new Params(this.refreshStatus)) + } + + build() { + Column() { + Refresh({ refreshing: $$this.isRefreshing, refreshingContent:this.contentNode}) { + List() { + ForEach(this.arr, (item: string) => { + ListItem() { + Text('' + item) + .width('70%').height(80).fontSize(16).margin(10) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + } + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .id('refreshComponentcontent0030_001') + .width('100%') + .height('100%') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .backgroundColor(0x89CFF0) + .pullToRefresh(true) + .refreshOffset(96) + .onStateChange((refreshStatus: RefreshStatus) => { + this.refreshStatus = refreshStatus + this.contentNode?.update(new Params(this.refreshStatus)) // 更新自定义组件内容 + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false + }, 2000) + console.log('onRefreshing test') + }) + } + } +} \ No newline at end of file diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower1.jpg b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..29cc6c27358b19227f89bc2764761bd84e40cb3a Binary files /dev/null and b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower1.jpg differ diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower2.jpg b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ebb21d26e2793d751a6dba71fff81540fdfaabe2 Binary files /dev/null and b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower2.jpg differ diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower3.jpg b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dba38752cec8f3b66f2b3326a890fe94a75cedf0 Binary files /dev/null and b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/media/flower3.jpg differ diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json index 5cc05ce92cff61b76d701a3fe495c11c73638078..0ace47383dfd5bcb3bbad44a6908891cd89f3b25 100644 --- a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -1801,6 +1801,300 @@ "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface007", "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface008", "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface009", - "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface0010" + "testability/pages/UIComponentPopupBoxFullDialogInterface/UIComponentPopupBoxFullDialogInterface0010", + "testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0360", + "testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0380", + "testability/pages/UIComponentNavTabsContentAdapt/UIComponentNavTabsContentAdapt0370", + "testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737", + "testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0350737142", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0430", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0440", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0450", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0460", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0470", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0480", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0490", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0550", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0060", + "testability/pages/UIComponentListAndGridWaterSections/UIComponentListAndGridWaterSections0580", + "testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0090", + "testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0180", + "testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0130", + "testability/pages/UIComponentNavTabsAction/UIComponentNavTabsAction0140", + "testability/pages/UIComponentNavTabsBlurStyle/UIComponentNavTabsBlurStyle0037", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0280", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0290", + "testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0110", + "testability/pages/UIComponentNavTabsImproTrace/UIComponentNavTabsImproTrace0170", + "testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0020", + "testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0140", + "testability/pages/UIComponentNavTabsInterception/UIComponentNavTabsInterception0160", + "testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0150", + "testability/pages/UIComponentNavTabsInterface/UIComponentNavTabsInterface0170", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0320", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0190", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0200", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0210", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0220", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0230", + "testability/pages/UIComponentNavTabsMirror/UIComponentNavTabsMirror0240", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0080", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0100", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0110", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0070", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0040", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0060", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0150", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0160", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0010", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0020", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0030", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0050", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0120", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0130", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0140", + "testability/pages/UIComponentNavTabsOnWillShow/UIComponentNavTabsOnWillShow0170", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0110", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0100", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0020", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0030", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0040", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0050", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0060", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0070", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0080", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0120", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0130", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0140", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0150", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0160", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0170", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0010", + "testability/pages/UIComponentNavTabsOnWillHide/UIComponentNavTabsOnWillHide0190", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0130", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0140", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0150", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0160", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0170", + "testability/pages/UIComponentOtherRefreshAbility/UIComponentOtherRefreshAbility0180", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0100", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0130", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0430", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0170", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0250", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0260", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0240", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0270", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0010", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0060", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0080", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0020", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0030", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0040", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0050", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0070", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0090", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0180", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0190", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0200", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0210", + "testability/pages/UIComponentOtherRefreshInterAction/UIComponentOtherRefreshInterAction0220", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0010", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0020", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0030", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0040", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0130", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0160", + "testability/pages/UIComponentOtherRefreshInterface/UIComponentOtherRefreshInterface0200", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0010", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0030", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0160", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0170", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0180", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0220", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0230", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0240", + "testability/pages/UIComponentOtherRefreshPromptText/UIComponentOtherRefreshPromptText0250", + "testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0200", + "testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0210", + "testability/pages/UIComponentTabTabBarSymbol/UIComponentTabTabbarTabbarsymbol0220", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0100", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0170", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0180", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0190", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0200", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0210", + "testability/pages/UIComponentNavTabsEdgeeffect/UIComponentNavTabsEdgeeffect0220", + "testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0130", + "testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0140", + "testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0150", + "testability/pages/UIComponentNavTabsExpandsafearea/UIComponentNavTabsExpandsafearea0160", + "testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0270", + "testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0470", + "testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0480", + "testability/pages/UIComponentWaterFlowSliding/UIComponentWaterFlowSliding0320", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0040", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0050", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0060", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0070", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0080", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0090", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0100", + "testability/pages/ArkUIAnimatedResponse/ArkUIAnimatedResponse0110", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0020", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0030", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0050", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0080", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0090", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0100", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0110", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0120", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0130", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0140", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0150", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0160", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0010", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0040", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0060", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0070", + "testability/pages/UIComponentNavTabsCapabilityEnhancement/UIComponentNavTabsCapabilityEnhancement0019", + "testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated003", + "testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated005", + "testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated007", + "testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated012", + "testability/pages/UIComponentNavTabsAnimated/UIComponentNavTabsAnimated015", + "testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0010", + "testability/pages/UIComponentNavTabsNest/UIComponentNavTabsNest0020", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx003", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx004", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx005", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx007", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx008", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx009", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx010", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx011", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx012", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx013", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx014", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx015", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx016", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx017", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx018", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx019", + "testability/pages/UIComponentNavTabsUx/UIComponentNavTabsUx022", + "testability/pages/UIComponentNavTabsLayout/UIComponentNavTabsLayout0070", + "testability/pages/UIComponentScrollSwiperTeace/UIComponentScrollSwiperTeace0370", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0070", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0080", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0110", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0100", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0090", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0140", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0050", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0020", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0010", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0040", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0060", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0130", + "testability/pages/UIComponentOtherRefreshAnimation/UIComponentOtherRefreshAnimation0030", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0040", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0110", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0130", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0120", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0010", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0030", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0060", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0050", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0080", + "testability/pages/UIComponentOtherRefreshInterConnection/UIComponentOtherRefreshInterConnection0070", + "testability/pages/UIComponentOtherRefreshOnOffsetChange/UIComponentOtherRefreshOnOffsetChange0100", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0020", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0030", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0040", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0010", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0160", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0060", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0050", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0170", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0100", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0150", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0110", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0120", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0130", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0200", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0210", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0070", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0080", + "testability/pages/UIComponentNavTabsObserver/UIComponentNavTabsObserver0090", + "testability/pages/UIComponentWaterFlowFooter/UIComponentWaterFlowFooter0010", + "testability/pages/UIComponentTabsClip/UIComponentTabsClip0020", + "testability/pages/UIComponentTabsClip/UIComponentTabsClip0010", + "testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0130", + "testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0120", + "testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0140", + "testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0060", + "testability/pages/UIComponentRefreshPulldownradio/UIComponentRefreshPulldownradio0160", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1060", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1070", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1080", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1090", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1100", + "testability/pages/UIComponentUISupportColor/UIComponentUISupportColor1110", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0540791", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0530136", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0510711", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0550659", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0570768", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0560601", + "testability/pages/UIComponentListAndGridXommonOnscroll/UIComponentListAndGridXommonOnscroll0680459", + "testability/pages/UIComponentNavTabs/UIComponentNavTabs0010", + "testability/pages/UIRefreshComponentContent/UIRefreshComponentContent0030", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0010", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0020", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0030", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0040", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0050", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0060", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0070", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0080", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0090", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0100", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0110", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0120", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0130", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0140", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0150", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0160", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0170", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0180", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0190", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0200", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0210", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0220", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0230", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0240", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0250", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0260", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0270", + "testability/pages/UIComponentNavTabsCachedCount/UIComponentNavTabsCachedCount0300", + "testability/pages/UIComponentNavTabsOnChange/UIComponentNavTabsOnChange0010", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0080380", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0200448", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0240733", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0230655", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0300527", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0250294", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0290143", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0280114", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0180890", + "testability/pages/UIComponentListandgridWaterflowEventenhancement/UIComponentListandgridWaterflowEventenhancement0090043", + "testability/pages/FunctionJichuWaterFlow/FunctionJichuWaterFlow0380", + "testability/pages/UIComponentListAndGridWaterflowSections/UIComponentListAndGridWaterflowSections0460211", + "testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141656824", + "testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141", + "testability/pages/UIComponentListAndGridWaterflowGetItemMainSizeByIndex/UIComponentListAndGridWaterflowGetItemMainSizeByIndex0010141624", + "testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0180721", + "testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0150660", + "testability/pages/UIComponentListAndGridWaterflowSpring/UIComponentListAndGridWaterflowSpring0250290" ] } diff --git a/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/rawfile/index.html b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/rawfile/index.html new file mode 100644 index 0000000000000000000000000000000000000000..565132cc0864fa0fc6056b5ff41c0450254134e3 --- /dev/null +++ b/function/ui_compare_rh/uicompare/entry/src/ohosTest/resources/rawfile/index.html @@ -0,0 +1,11 @@ + + + + + + Hello World + + +

Hello, World!

+ + \ No newline at end of file