diff --git a/arkui/ace_ets_components_ux/BUILD.gn b/arkui/ace_ets_components_ux/BUILD.gn index ce2dc475e36b7b7174c2ade5f3ee124b408e8211..acee0332edff7437e900264381d864d0b45e3c4a 100644 --- a/arkui/ace_ets_components_ux/BUILD.gn +++ b/arkui/ace_ets_components_ux/BUILD.gn @@ -18,6 +18,7 @@ group("componentUxTest") { "ace_ets_component_badge:ActsAcebadgeTest", "ace_ets_component_button:ActsAceButtonTest", "ace_ets_component_checkbox:ActsAceCheckboxTest", + "ace_ets_component_clickeffect:ActsAceClickEffectTest", "ace_ets_component_datapanel:ActsAceDatapanelTest", "ace_ets_component_datepicker:ActsAceDatePickerTest", "ace_ets_component_progress:ActsAceProgressTest", diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/app.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..32010143c5467b35172e21895be2b74fcd885dac --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.clickeffecttest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/element/string.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..30af7cfee6766dda361b893d1565490dc145fdf0 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"MyApplication" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/media/app_icon.png b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/AppScope/resources/base/media/app_icon.png differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/BUILD.gn b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e93310d66c7d671e5900a0afafaa8512ee7d3c30 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAceClickEffectTest") { + hap_profile = "src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ace_ets_component_clickeffect_js_assets", + ":ace_ets_component_clickeffect_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAceClickEffectTest" + part_name = "ace_engine" + subsystem_name = "arkui" +} + +ohos_app_scope("ace_ets_component_clickeffect_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ace_ets_component_clickeffect_js_assets") { + source_dir = "src/main/ets" +} + +ohos_resources("ace_ets_component_clickeffect_resources") { + sources = [ "src/main/resources" ] + deps = [ ":ace_ets_component_clickeffect_profile" ] + hap_profile = "src/main/module.json" +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/Test.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9ed5926ae0850c982a0f5b7c6c13c411f1a6a7ab --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.clickeffecttest", + "module-name": "entry_test", + "shell-timeout": "600000", + "testcase-timeout": 240000 + }, + "kits": [ + { + "test-file-name": [ + "ActsAceClickEffectTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602" + ] + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/signature/openharmony_sx.p7b b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..1a3ad75244ea6b1cc30dd5adaec4eb0255567c55 Binary files /dev/null and b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/signature/openharmony_sx.p7b differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/TestAbility.ets b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3248533a352af747208e9ce1adeda1198c8dee7 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/TestAbility.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 hilog from '@ohos.hilog'; +import Ability from '@ohos.app.ability.UIAbility' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import testsuite from '../test/List.test' +import Window from '@ohos.window' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('TestAbility/pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/pages/Index.ets b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e2e645e8c03c802f5661c60c13f9d39fe5b7623 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestAbility/pages/Index.ets @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//@ts-nocheck +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import hilog from '@ohos.hilog'; +import testsuite from '../../test/List.test' + +@Entry +@Component +struct ClickEffectTest { + aboutToAppear() { + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Row() { + Column() { + List({ space: 0, initialIndex: 0 }) { + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_1') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.MIDDLE }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_2') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.HEAVY }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_3') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_4') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 1 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_5') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_6') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.8 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_7') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.LIGHT, scale: -1 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_8') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: null, scale: 0.1 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_9') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: undefined, scale: 0 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_10') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.2 }) + .clickEffect({ level: ClickEffectLevel.HEAVY, scale: 0.1 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_11') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.MIDDLE }) + .clickEffect({ level: null }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_12') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: null }) + .clickEffect({ level: ClickEffectLevel.MIDDLE }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_13') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.HEAVY, scale: null }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_14') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: undefined }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_15') + } + ListItem() { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .clickEffect({ level: undefined, scale: null }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + .key('clickEffect_16') + } + } + .alignListItem(ListItemAlign.Center) + } + .width('100%') + } + .height('100%') + } +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e1abddd7bbe6397074c212e829534c6202bf6b3 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]); + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}`; + } + } + return targetParams.trim(); +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err): Promise { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters); + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') { + cmd += ' -D'; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err, d) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/List.test.ets b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85d0c2821f5ccd8bd018b1c8b0643d3c0fbacb91 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 clickeffectTest from './clickeffect' + +export default function testsuite() { + clickeffectTest() +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/clickeffect.ets b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/clickeffect.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf8fa4962735b935688db15db72dd6d3f5138a28 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/ets/test/clickeffect.ets @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// @ts-nocheck +import { describe, beforeEach, afterEach, it, expect } from '@ohos/hypium' +let emitKey = "emitUserAgent"; +export default function clickeffectTest() { + describe('ActsClickEffectTest', function () { + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0100 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the parameter to Light level with default scale + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0100', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0100 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_1'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0100]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.900000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0100 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0200 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the parameter to Middle level with default scale + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0200', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0200 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_2'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0200]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('1'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.950000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0200 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0300 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the parameter to Heavy level with default scale + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0300', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0300 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_3'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0300]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('2'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.950000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0300 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0400 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to Light and set scale to 0 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0400', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0400 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_4'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0400]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.000000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0400 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0500 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to Light and set scale to 1 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0500', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0500 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_5'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0500]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('1.000000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0500 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0600 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to Light and set scale to 0.5 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0600', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Options_0600 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_6'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0600]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.500000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0600 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0700 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to Light and set scale to 0.8 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0700', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0700 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_7'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0700]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.800000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0700 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0800 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to Light and set scale to -1 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0800', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0800 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_8'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0800]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.900000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0800 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_0900 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to null and set scale to 0.1 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_0900', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_0900 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_9'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_0900]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.100000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_0900 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1000 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc Set the level to undefine and set scale to 0 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1000', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1000 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_10'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1000]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.000000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1000 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1100 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to Middle, set the scale to 0.2 + * Second Set the level to Heavy, set the scale to 0.1 + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1100', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Options_01000 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_11'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1100]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('2'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.100000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1100 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1200 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to Middle + * Second Set the level to null + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1200', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1200 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_12'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1200]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.900000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1200 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1300 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to null + * Second Set the level to Middle + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1300', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1300 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_13'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1300]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('1'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.950000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1300 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1400 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to Heavy and set the scale to null + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1400', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1400 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_14'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1400]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('2'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.950000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1400 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1500 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to Middle and set the scale to undefined + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1500', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1500 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_15'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1500]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('1'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.950000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1500 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + + /** + * @tc.number ArkUXII_Stage_ClickEffect_Toggle_1600 + * @tc.name Test the ClickEffect properties of the Toogle_Switch component + * @tc.desc First Set the level to undefined and set the scale to null + */ + it('ArkUXII_Stage_ClickEffect_Toggle_1600', 0, async function (done) { + console.info("ArkUXII_Stage_ClickEffect_Toggle_1600 start"); + setTimeout(() => { + try { + let strJson = getInspectorByKey('clickEffect_16'); + let obj = JSON.parse(strJson); + console.info("[ArkUXII_Stage_ClickEffect_Toggle_1600]:" + JSON.stringify(obj.$attrs.clickEffect)); + expect(obj.$attrs.clickEffect.level).assertEqual('0'); + expect(obj.$attrs.clickEffect.scale).assertEqual('0.900000'); + done(); + } catch (err) { + expect().assertFail(); + console.info('ArkUXII_Stage_ClickEffect_Toggle_1600 ERR ' + JSON.stringify(err)); + done(); + } + }, 500) + }); + }) +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/module.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..5be6f421ae1908e6af0c90561ba0dfc4f8c8d38c --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/color.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/string.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c91ea0a919a12a554b7181f95d94e15bee08df7a --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "Divider_width", + "value": "10px" + }, + { + "name": "Divider_startMargin", + "value": "5px" + }, + { + "name": "Divider_endMargin", + "value": "5px" + }, + { + "name": "Check_Mark_Size_test", + "value": "50" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/media/icon.png b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/media/icon.png differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/profile/test_pages.json b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..77e90731b5a38d861663029b483df3d3ac9ec74b --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_clickeffect/src/main/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/Index" + ] +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/Test.json b/arkui/ace_ets_components_ux/ace_ets_component_slider/Test.json index 091fba3dd67dea3623ffc9838a42662aaa016b11..a909adb08194eb90d6d9489ecc87242aab1774c4 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_slider/Test.json +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/Test.json @@ -4,7 +4,7 @@ "type": "OHJSUnitTest", "test-timeout": "600000", "bundle-name": "com.example.slidertest", - "module-name": "phone", + "module-name": "entry_test", "shell-timeout": "600000", "testcase-timeout": 240000 }, diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/TestAbility/pages/SliderTestSec.ets b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/TestAbility/pages/SliderTestSec.ets new file mode 100644 index 0000000000000000000000000000000000000000..a312ac51e12ed29004e83a3350856c065c274b4a --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/TestAbility/pages/SliderTestSec.ets @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// @ts-nocheck +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import testsuite from '../../test/List.test'; +import events_emitter from '@ohos.events.emitter'; +@Entry +@Component +struct Index { + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + console.info("key==>pages res : onPageShow") + } + private valueChangeCallBack=(eventData)=> { + console.info("key==> page valueChangeCallBack"); + if (eventData != null) { + console.info("valueChangeCallBack:" + JSON.stringify(eventData)); + if(eventData.data.value=="true"){ + if( eventData.data.content=="no") { + this.valueNo = true; + } + if( eventData.data.content=="null") { + this.value = true + this.isStr = false + this.isNum = false + this.isNUll = true + } + if( eventData.data.content=="undefined") { + this.value = true + this.isStr = false + this.isNum = false + this.isNUll = false + } + if( eventData.data.content=="ResourceTest") { + this.Style = SliderStyle.InSet + this.resFalg = true + } + } + if(eventData.data.value=="false"){ + if( eventData.data.content=="no") { + this.valueNo = false; + } + if( eventData.data.content=="null") { + this.value = false + this.isStr = false + this.isNum = false + this.isNUll = true + } + if( eventData.data.content=="undefined") { + this.value = false + this.isStr = false + this.isNum = false + this.isNUll = false + } + if( eventData.data.content=="ResourceTest") { + this.Style = SliderStyle.OutSet + this.resFalg = false + } + } + if(eventData.data.value=="trueStr") { + this.Style = SliderStyle.InSet + this.isStr = true + this.value = true + this.content = eventData.data.content; + } + if(eventData.data.value=="falseStr") { + this.Style = SliderStyle.OutSet + this.value = false + this.isStr = true + this.content = eventData.data.content; + } + if(eventData.data.value=="trueNum") { + this.isStr = false + this.isNum = true + this.value = true + this.num = Number(eventData.data.content); + } + if(eventData.data.value=="falseNum") { + this.value = false + this.isStr = false + this.isNum = true + this.num = Number(eventData.data.content); + } + } + + } + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State ValueOne: number = 40; + @State ValueTwo: number = 40; + @State ValueThi: number = 40; + @State ValueFour: number = 40; + @State value:boolean = false; + @State isStr:boolean = false; + @State isNum:boolean = false; + @State isNUll:boolean = false; + @State valueNo:boolean = false; + @State resFalg:boolean = false; + @State content:string = ""; + @State style:enum = SliderStyle.InSet; + @State direction:enum =Axis.Vertical; + + build() { + Row() { + Column() { + Slider({ + value: this.ValueOne, + min: 0, + max: 100, + style: this.Style + }) + .showTips(this.value,this.isStr?this.content:(this.isNum?this.num:(this.isNUll? null:undefined))) + .onChange((value: number, mode: SliderChangeMode) => { + this.ValueOne = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + .key('Slider') + Slider({ + value: this.ValueTwo, + min: 0, + max: 100, + style: this.Style + }) + .showTips(this.valueNo) + .onChange((value: number, mode: SliderChangeMode) => { + this.ValueTwo = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + .key('SliderNoContent') + Row(){ + Slider({ + value: this.ValueThi, + step: 10, + style: this.Style, + direction:Axis.Vertical + }) + .height(300) + .showSteps(true) + .showTips(this.resFalg,$r("app.string.sliderTest")) + .onChange((value: number, mode: SliderChangeMode) => { + this.ValueThi = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + .key('SliderResourceTest') + Slider({ + value: this.ValueFour, + step: 10, + style: this.Style, + direction:Axis.Vertical + }) + .height(300) + .showSteps(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.ValueFour = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + .key('SliderNoShowTips') + } + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/List.test.ets b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/List.test.ets index b348accf6dc96c7acdf2eabb98cef7cde95b5a2a..d57a728bfc0e2ab5617d66c378b62d3cc0205534 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/List.test.ets @@ -13,7 +13,9 @@ * limitations under the License. */ import sliderTest from './SliderTest' +import SliderTestSec from './SliderTestSec' export default function testsuite() { sliderTest() + SliderTestSec() } \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/SliderTestSec.ets b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/SliderTestSec.ets new file mode 100644 index 0000000000000000000000000000000000000000..5bbf91932acc4bcb349f7039de001fee5913216e --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/ets/test/SliderTestSec.ets @@ -0,0 +1,668 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 hilog from '@ohos.hilog'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import events_emitter from '@ohos.events.emitter'; +import router from '@system.router'; + +function sleep(time){ + return new Promise((resolve,reject)=>{ + setTimeout(()=>{ + resolve("ok") + },time) + }).then(()=>{ + console.info(`sleep ${time} over...`) + }) +} +async function forKey(Key,text) { + console.info("web afterEach start:"+Key); + try { + let backData = { + data: { + "value": Key, + "content": text, + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + sleep(2000); +} +export default function SliderTestSec() { + describe('SliderTestSec', function () { + + beforeEach(async function (done) { + let options = { + uri: "TestAbility/pages/SliderTestSec", + } + try { + router.clear(); + let pages = router.getState(); + console.info("get SliderTestSec state success " + JSON.stringify(pages)); + if (!("SliderTestSec" == pages.name)) { + console.info("get SliderTestSec state success " + JSON.stringify(pages.name)); + let result = await router.push(options) + console.info("push SliderTestSec page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push SliderTestSec page error " + JSON.stringify(err)); + } + await sleep(2) + done() + }); + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0100 + * @tc.name Set the Slider component showTips property with the parameter (value: true) + * @tc.desc Verify that the Slider component only sets the showTips attribute value parameter + * to a bubble type and no custom text + */ + it('ArkUX_Stage_Slider_showTips_0100',0, async function (done) { + await sleep(1000) + await forKey("true","no"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('SliderNoContent'); + console.info('ArkUX_Stage_Slider_showTips_0100 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0100 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0100 obj $attr :'+ JSON.stringify(obj.$attrs)); + console.info('ArkUX_Stage_Slider_showTips_0100 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0100 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0100 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0200 + * @tc.name Set the Slider component showTips property with the parameter (value:false) + * @tc.desc Verify that the Slider component only sets the showTips attribute value parameter + * to a bubble free type and no custom text + */ + it('ArkUX_Stage_Slider_showTips_0200',0, async function (done) { + await sleep(1000) + await forKey("false","no"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('SliderNoContent'); + console.info('ArkUX_Stage_Slider_showTips_0200 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0200 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0200 obj $attr :'+ JSON.stringify(obj.$attrs)); + console.info('ArkUX_Stage_Slider_showTips_0200 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0200 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0200 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0300 + * @tc.name Set the Slider component showTips attribute with parameters (value: false, content: "test"). + * @tc.desc Verify that the Slider component sets the showTips attribute value parameter to a bubble free + * type, and also sets the custom text 'test'. The custom text setting is successful + */ + it('ArkUX_Stage_Slider_showTips_0300',0, async function (done) { + await forKey("falseStr","test"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_0300 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0300 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0300 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0300 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual("test") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0300 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0400 + * @tc.name Set the showTips property of Slider to (value:false, content:"ab$12@"). + * @tc.desc Verify that the Slider component has set the showTips attribute value parameter to a bubble free + * type, and set the custom text 'ab $12 @'. The custom text setting was successful + */ + it('ArkUX_Stage_Slider_showTips_0400',0, async function (done) { + await sleep(1000) + await forKey("falseStr","ab$12@"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_0400 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0400 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0400 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0400 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual("ab$12@") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0400 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0500 + * @tc.name Set the showTips property of the Slider component to (value:false, content:Resources). + * @tc.desc Verify that the Slider component has set the showTips attribute value parameter to a bubble free + * type, and set the resource reference type. The custom text has been successfully set + */ + it('ArkUX_Stage_Slider_showTips_0500',0, async function (done) { + await forKey("false","ResourceTest"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('SliderResourceTest'); + console.info('ArkUX_Stage_Slider_showTips_0500 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0500 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0500 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0500 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual("ResourceTest") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0500 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0600 + * @tc.name Set the showTips property of the Slider to (value:false, content:""). + * @tc.desc Verify that the Slider component showTips property parameter value is set to a bubble free type, + * while also setting the text to '' + */ + it('ArkUX_Stage_Slider_showTips_0600',0, async function (done) { + await sleep(1000) + await forKey("falseStr",""); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_0600 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0600 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0600 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0600 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual("") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0600 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0700 + * @tc.name Set the showTips property of the Slider to (value:true,content:"test"). + * @tc.desc Verify that the Slider component showTips property parameter value is set to true with bubble + * type, and the text is custom text + */ + it('ArkUX_Stage_Slider_showTips_0700',0, async function (done) { + await sleep(1000) + await forKey("trueStr","test"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_0700 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0700 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0700 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0700 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("test") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0700 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0800 + * @tc.name Set the showTips property of the Slider to (value:true,content:"ab$12@"). + * @tc.desc Verify that the Slider component showTips property parameter value is of bubble + * type, and the text is custom text with special symbols + */ + it('ArkUX_Stage_Slider_showTips_0800',0, async function (done) { + await sleep(1000) + await forKey("trueStr","ab$12@"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_0800 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0800 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0800 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0800 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("ab$12@") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0800 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_0900 + * @tc.name Set the showTips property of the Slider component (value:true,content:resources) + * @tc.desc Verify that the Slider component showTips attribute parameter value is of bubble + * type and content is of reference type $r ("app. string. sliderTest") + */ + it('ArkUX_Stage_Slider_showTips_0900',0, async function (done) { + await forKey("true","ResourceTest"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('SliderResourceTest'); + console.info('ArkUX_Stage_Slider_showTips_0900 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_0900 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_0900 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_0900 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("ResourceTest") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_0900 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1000 + * @tc.name Set the showTips property of the Slider component (value:true,content:"") + * @tc.desc Verify that the Slider component showTips attribute parameter value is of + * bubble type, and the content is' ' + */ + it('ArkUX_Stage_Slider_showTips_1000',0, async function (done) { + await sleep(1000) + await forKey("trueStr",""); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1000 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1000 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1000 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1000 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1300 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1100 + * @tc.name Continuously set the Slider component showTips property, passing in normal values multiple times + * @tc.desc Verify that the Slider component showTips attribute has been passed in multiple times with normal + * values, and the content text is the last setting + */ + it('ArkUX_Stage_Slider_showTips_1100',0, async function (done) { + await sleep(1000) + await forKey("falseStr","no"); + await forKey("trueStr","test"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1100 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1100 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1100 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1100 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("test") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1100 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1200 + * @tc.name Set the showTips property of the Slider to (value:false, content:null). + * @tc.desc Verify that the parameter value of the Slider component showTips attribute is of bubble free type, + * content is of outlier, and the result is no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1200',0, async function (done) { + await sleep(1000) + await forKey("false","null"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1200 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1200 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1200 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1200 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1200 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1300 + * @tc.name Set the Slider component showTips attribute parameter for (value: false, content: undefined) + * @tc.desc Verify that the parameter value of the Slider component showTips attribute is of bubble free type, + * content is of outlier, and the result is no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1300',0, async function (done) { + await sleep(1000) + await forKey("false","undefined"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1300 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1300 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1300 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1300 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1300 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1400 + * @tc.name Set the showTips property of the Slider to (value:false,content:1234). + * @tc.desc Verify that the parameter value of the Slider component showTips attribute is of bubble free type, + * content is of outlier, and the result is no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1400',0, async function (done) { + await sleep(1000) + await forKey("falseNum","123"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1400 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1400 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1400 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1400 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1400 err :' + JSON.stringify(err)) + done() + } + }) + + + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1500 + * @tc.name Set the showTips property of the Slider component (value:true,content:null). + * @tc.desc Verify and set the Slider component showTips attribute parameter value as the type with bubbles, + * content as the outlier, and obtain the result as no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1500',0, async function (done) { + await sleep(1000) + await forKey("true","null"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1500 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1500 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1500 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1500 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1400 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1600 + * @tc.name Set the Slider component showTips attributes (value: true, content: undefined) + * @tc.desc Verify and set the Slider component showTips attribute parameter value as the type with bubbles, + * content as the outlier, and obtain the result as no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1600',0, async function (done) { + await sleep(1000) + await forKey("true","undefined"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1600 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1600 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1600 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1600 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1600 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1700 + * @tc.name Set the showTips property of the Slider component (value:true,content:1234) + * @tc.desc Verify and set the Slider component showTips attribute parameter value as the type with bubbles, + * content as the outlier, and obtain the result as no user-defined text + */ + it('ArkUX_Stage_Slider_showTips_1700',0, async function (done) { + await sleep(1000) + await forKey("trueNum","123"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1700 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1700 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1700 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1700 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1700 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1800 + * @tc.name Continuously set the Slider component showTips attribute, + * and set the content to an invalid value the last time + * @tc.desc Verify that the Slider component showTips property is set continuously, and the last time it is + * set to an invalid value, the result obtained is no custom text. + */ + it('ArkUX_Stage_Slider_showTips_1800',0, async function (done) { + await sleep(1000) + await forKey("trueStr","test"); + await sleep(1000) + await forKey("true","null"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1800 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1800 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1800 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1800 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1800 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_1900 + * @tc.name Set the showTips attribute of the Slider component continuously, + * and pass in the outlier and then the normal value + * @tc.desc Verify that the Slider component showTips attribute is set continuously. After passing in the + outlier,the normal value is passed in. The result is the last set normal value + */ + it('ArkUX_Stage_Slider_showTips_1900',0, async function (done) { + await sleep(1000) + await forKey("true","null"); + await sleep(1000) + await forKey("trueStr","test"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_1900 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_1900 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_1900 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_1900 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("test") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_1900 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_2000 + * @tc.name Do not set the Slider component showTips property + * @tc.desc Verify that the Slider component showTips property is not set and the + * result is no bubbles or text appearing + */ + it('ArkUX_Stage_Slider_showTips_2000',0, async function (done) { + try{ + let strJson = getInspectorByKey('SliderNoShowTips'); + console.info('ArkUX_Stage_Slider_showTips_2000 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_2000 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_2000 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_2000 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("false") + expect(obj.$attrs.content).assertEqual(undefined) + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_2100 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_2100 + * @tc.name Slider custom text display + * @tc.desc Set the parameter to an overly long string + */ + it('ArkUX_Stage_Slider_showTips_2100',0, async function (done) { + await forKey("trueStr","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_2100 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_2100 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_2100 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_2100 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_2100 err :' + JSON.stringify(err)) + done() + } + }) + + /** + * @tc.number ArkUX_Stage_Slider_showTips_2200 + * @tc.name Slider custom text display + * @tc.desc Set the parameter to a string with line breaks + */ + it('ArkUX_Stage_Slider_showTips_2200',0, async function (done) { + await forKey("trueStr","aaa\nbbb"); + await sleep(1000) + try{ + let strJson = getInspectorByKey('Slider'); + console.info('ArkUX_Stage_Slider_showTips_2200 START :' + JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info('ArkUX_Stage_Slider_showTips_2200 obj :' + JSON.stringify(obj)); + console.info('ArkUX_Stage_Slider_showTips_2200 obj $attrs.showTips :'+ JSON.stringify(obj.$attrs.showTips)); + console.info('ArkUX_Stage_Slider_showTips_2200 obj $attrs.content :'+ JSON.stringify(obj.$attrs.content)); + expect(obj.$attrs.showTips).assertEqual("true") + expect(obj.$attrs.content).assertEqual("aaa\nbbb") + done() + } catch (err) { + expect().assertFail() + console.info('ArkUX_Stage_Slider_showTips_2200 err :' + JSON.stringify(err)) + done() + } + }) + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/module.json b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/module.json index 2b03fde2a1898cf911b3b3f2f94a553bca8ebb86..41203db25b2f1fa0a38ba77ab433d414374d1053 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/module.json +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "phone", + "name": "entry_test", "type": "feature", "description": "$string:module_test_desc", "mainElement": "TestAbility", diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/element/string.json b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/element/string.json index 4ac461b47470698ca1fee4b277d9619b2e577979..aeec32c523717a17f81b0faeee6298a2498e78ad 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/element/string.json +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/element/string.json @@ -35,6 +35,10 @@ { "name":"block_size_height_test", "value":"50vp" + }, + { + "name": "sliderTest", + "value": "ResourceTest" } ] } \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/profile/test_pages.json b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/profile/test_pages.json index 77e90731b5a38d861663029b483df3d3ac9ec74b..238907d311eb6ad10634656a6f58e2689e4e34b1 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/profile/test_pages.json +++ b/arkui/ace_ets_components_ux/ace_ets_component_slider/src/main/resources/base/profile/test_pages.json @@ -1,5 +1,6 @@ { "src": [ - "TestAbility/pages/Index" + "TestAbility/pages/Index", + "TestAbility/pages/SliderTestSec" ] }