diff --git a/arkui/ace_ets_components_ux/BUILD.gn b/arkui/ace_ets_components_ux/BUILD.gn index fe4d32e211858767c3b7e7b41589d7bbd35faed3..b9dec330cae6e4f97b4cb1d2d546eebd62326802 100644 --- a/arkui/ace_ets_components_ux/BUILD.gn +++ b/arkui/ace_ets_components_ux/BUILD.gn @@ -21,6 +21,7 @@ group("componentUxTest") { "ace_ets_component_clickeffect:ActsAceClickEffectTest", "ace_ets_component_datapanel:ActsAceDatapanelTest", "ace_ets_component_datepicker:ActsAceDatePickerTest", + "ace_ets_component_indexer:ActsAlphabetIndexerTest", "ace_ets_component_list:ActsAceListTest", "ace_ets_component_menu:ActsAceMenuTest", "ace_ets_component_popup:ActsAcePopupTest", diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/app.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..08a68cf7f29552db2b71cf27049f085cdb8bc9e3 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.alphabetindexer", + "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_indexer/AppScope/resources/base/element/string.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..57bf809a86192640b690ae502c925467c4abdb42 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AlphabetIndexerTest" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/AppScope/resources/base/media/app_icon.png b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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_indexer/AppScope/resources/base/media/app_icon.png differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/BUILD.gn b/arkui/ace_ets_components_ux/ace_ets_component_indexer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..281326efd84aa8f32d04fe46f57bec4839adc747 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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("ActsAlphabetIndexerTest") { + hap_profile = "src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ace_ets_component_alphabetIndexer_js_assets", + ":ace_ets_component_alphabetIndexer_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAlphabetIndexerTest" + part_name = "ace_engine" + subsystem_name = "arkui" +} + +ohos_app_scope("ace_ets_component_alphabetIndexer_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ace_ets_component_alphabetIndexer_js_assets") { + source_dir = "src/main/ets" +} + +ohos_resources("ace_ets_component_alphabetIndexer_resources") { + sources = [ "src/main/resources" ] + deps = [ ":ace_ets_component_alphabetIndexer_profile" ] + hap_profile = "src/main/module.json" +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/Test.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..761058b869759d9baf71817caecee8bf9816a48b --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/Test.json @@ -0,0 +1,26 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.alphabetindexer", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 240000 + }, + "kits": [{ + "test-file-name": [ + "ActsAlphabetIndexerTest.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_indexer/signature/openharmony_sx.p7b b/arkui/ace_ets_components_ux/ace_ets_component_indexer/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..b7787dfa38d82e65bf93f6bbe090ce0134dcf6a5 Binary files /dev/null and b/arkui/ace_ets_components_ux/ace_ets_component_indexer/signature/openharmony_sx.p7b differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestAbility/TestAbility.ets b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3248533a352af747208e9ce1adeda1198c8dee7 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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_indexer/src/main/ets/TestAbility/pages/Index.ets b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestAbility/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e503891b38ebdc6f724be889951b3c7b09a51d11 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestAbility/pages/Index.ets @@ -0,0 +1,441 @@ +/* + * 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 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 AlphabetIndexerTest { + private arrayA: string[] = ['安', '爱', '奥'] + private arrayB: string[] = ['卜', '白', '包', '毕', '丙'] + private arrayC: string[] = ['曹', '成', '陈', '催'] + private arrayH: string[] = ['韩', '何', '郝', '黑'] + private arrayL: string[] = ['刘', '李', '楼', '梁', '雷', '吕', '柳', '卢'] + private arrayT: string[] = ['太', '天', '田', '唐', '陶', '汤'] + private value: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] + + @State popupSelectedColorStr: string = '#00FF00' + @State popupUnselectedColorStr: string = '#DA70D6' + @State popupItemBackgroundStr: string = '#FFD700' + @State popupItemFontSizeStr: string = '20' + @State popupItemFontWeightStr: string = '400' + @State popupSpaceStr: string = '120' + @State popupSelectedColor: Color = Color.Orange + @State popupUnselectedColor: Color = Color.Green + @State popupItemBackgroundColor: Color = Color.Pink + @State popupSelectedColorNum: number = 0x00CED1 + @State popupUnselectedColorNum: number = 0xC0FF3E + @State popupItemBackgroundNum: number = 0x8470FF + @State popupItemFontSizeNum: number = 30 + @State popupItemFontWeightNum: number = FontWeight.Normal + @State popupSpaceNum: number = 50 + @State popupSelectedColorRes: Resource = $r('app.color.popupSelectedColor') + @State popupUnselectedColorRes: Resource = $r('app.color.popupUnselectedColor') + @State popupItemBackgroundRes: Resource = $r('app.color.popupItemBackground') + @State popupItemFontSizeRes: Resource = $r('app.string.fontSize') + @State popupSpaceRes: Resource = $r('app.string.popupSpace') + @State popupItemFontWeightFont: number = FontWeight.Bolder + @State nullFlag1: boolean = false + @State nullFlag2: boolean = false + @State nullFlag3: boolean = false + @State nullFlag4: boolean = false + @State nullFlag5: boolean = false + + private stateChangCallBack = (eventData) => { + console.info("sideBar page state change called:" + JSON.stringify(eventData)); + if (eventData != null) { + if (eventData.data.popupSelectedColorStr != null) { + this.popupSelectedColorStr = eventData.data.popupSelectedColorStr; + } + if (eventData.data.popupUnselectedColorStr != null) { + this.popupUnselectedColorStr = eventData.data.popupUnselectedColorStr; + } + if (eventData.data.popupItemBackgroundStr != null) { + this.popupItemBackgroundStr = eventData.data.popupItemBackgroundStr; + } + if (eventData.data.popupItemFontSizeStr != null) { + this.popupItemFontSizeStr = eventData.data.popupItemFontSizeStr; + } + if (eventData.data.popupItemFontWeightStr != null) { + this.popupItemFontWeightStr = eventData.data.popupItemFontWeightStr; + } + if (eventData.data.popupSpaceStr != null) { + this.popupSpaceStr = eventData.data.popupSpaceStr; + } + if (eventData.data.popupSelectedColor != null) { + this.popupSelectedColor = eventData.data.popupSelectedColor; + } + if (eventData.data.popupUnselectedColor != null) { + this.popupUnselectedColor = eventData.data.popupUnselectedColor; + } + if (eventData.data.popupItemBackgroundColor != null) { + this.popupItemBackgroundColor = eventData.data.popupItemBackgroundColor; + } + if (eventData.data.popupSelectedColorNum != null) { + this.popupSelectedColorNum = eventData.data.popupSelectedColorNum; + } + + if (eventData.data.popupUnselectedColorNum != null) { + this.popupUnselectedColorNum = eventData.data.popupUnselectedColorNum; + } + if (eventData.data.popupItemBackgroundNum != null) { + this.popupItemBackgroundNum = eventData.data.popupItemBackgroundNum; + } + if (eventData.data.popupItemFontSizeNum != null) { + this.popupItemFontSizeNum = eventData.data.popupItemFontSizeNum; + } + if (eventData.data.popupItemFontWeightStr != null) { + this.popupItemFontWeightStr = eventData.data.popupItemFontWeightStr; + } + if (eventData.data.popupSpaceNum != null) { + this.popupSpaceNum = eventData.data.popupSpaceNum; + } + if (eventData.data.popupSelectedColorRes != null) { + this.popupSelectedColorRes = eventData.data.popupSelectedColorRes; + } + if (eventData.data.popupUnselectedColorRes != null) { + this.popupUnselectedColorRes = eventData.data.popupUnselectedColorRes; + } + if (eventData.data.popupItemBackgroundRes != null) { + this.popupItemBackgroundRes = eventData.data.popupItemBackgroundRes; + } + if (eventData.data.popupItemFontSizeRes != null) { + this.popupItemFontSizeRes = eventData.data.popupItemFontSizeRes; + } + if (eventData.data.popupSpaceRes != null) { + this.popupSpaceRes = eventData.data.popupSpaceRes; + } + if (eventData.data.popupItemFontWeightFont != null) { + this.popupItemFontWeightFont = eventData.data.popupItemFontWeightFont; + } + if (eventData.data.nullFlag1 != null) { + this.nullFlag1 = eventData.data.nullFlag1; + } + if (eventData.data.nullFlag2 != null) { + this.nullFlag2 = eventData.data.nullFlag2; + } + if (eventData.data.nullFlag3 != null) { + this.nullFlag3 = eventData.data.nullFlag3; + } + if (eventData.data.nullFlag4 != null) { + this.nullFlag4 = eventData.data.nullFlag4; + } + if (eventData.data.nullFlag5 != null) { + this.nullFlag5 = eventData.data.nullFlag5; + } + } + } + + aboutToAppear() { + var stateChangeEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + 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() { + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest1') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .alignStyle(IndexerAlign.Left) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20 }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest2') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .alignStyle(IndexerAlign.Left,this.nullFlag5 ? null : this.popupSpaceNum) + .popupSelectedColor(this.nullFlag1 ? null : this.popupSelectedColorNum) + .popupUnselectedColor(this.nullFlag2 ? null : this.popupUnselectedColorNum) + .popupItemBackgroundColor(this.nullFlag3 ? null : this.popupItemBackgroundNum) + .popupItemFont(this.nullFlag4 ? null : { size: this.popupItemFontSizeNum, weight: this.popupItemFontWeightNum }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest3') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .alignStyle(IndexerAlign.Left,this.nullFlag5 ? null : this.popupSpaceStr) + .popupSelectedColor(this.nullFlag1 ? null : this.popupSelectedColorStr) + .popupUnselectedColor(this.nullFlag2 ? null : this.popupUnselectedColorStr) + .popupItemBackgroundColor(this.nullFlag3 ? null : this.popupItemBackgroundStr) + .popupItemFont(this.nullFlag4 ? null : { size: this.popupItemFontSizeStr, weight: this.popupItemFontWeightStr }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest4') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .alignStyle(IndexerAlign.Left,this.nullFlag5 ? null : this.popupSpaceRes) + .popupSelectedColor(this.nullFlag1 ? null : this.popupSelectedColorRes) + .popupUnselectedColor(this.nullFlag2 ? null : this.popupUnselectedColorRes) + .popupItemBackgroundColor(this.nullFlag3 ? null : this.popupItemBackgroundRes) + .popupItemFont(this.nullFlag4 ? null : { size: this.popupItemFontSizeRes, weight: this.popupItemFontWeightFont }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest5') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .alignStyle(IndexerAlign.Left,this.popupSpaceNum) + .popupSelectedColor(this.popupSelectedColor) + .popupUnselectedColor(this.popupUnselectedColor) + .popupItemBackgroundColor(this.popupItemBackgroundColor) + .popupItemFont({ size: this.popupItemFontSizeNum, weight: this.popupItemFontWeightNum }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest6') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .alignStyle(IndexerAlign.Left) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .popupItemFont({ size: this.popupItemFontSizeNum }) + + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .key('alphabetIndexerTest7') + .font({ size: 18, weight: FontWeight.Normal }) + .selectedFont({ size: 28, weight: FontWeight.Bold }) + .color(0x000000) + .selectedColor(0xFF1493) + .backgroundColor(0xF8F8FF) + .selectedBackgroundColor(0xBEBEBE) + .itemSize(26) + .onSelect((index: number) => { + console.info(this.value[index] + ' Selected!') + }) + .usingPopup(true) + .alignStyle(IndexerAlign.Left) + .popupFont({ size: 28, weight: FontWeight.Bold }) + .popupColor(0xFFA500) + .popupBackground(0x32CD32) + .onRequestPopupData((index: number) => { + if (this.value[index] == 'A') { + return this.arrayA + } else if (this.value[index] == 'B') { + return this.arrayB + } else if (this.value[index] == 'C') { + return this.arrayC + } else if (this.value[index] == 'L') { + return this.arrayL + } else if (this.value[index] == 'T') { + return this.arrayT + } else { + return [] + } + }) + .onPopupSelect((index: number) => { + console.info('onPopupSelected label :' + index) + }) + .margin({ top: 20, left: 20 }) + .popupItemFont({ weight: this.popupItemFontWeightNum }) + }.backgroundColor(0x00FFFF).width('100%').height('100%') + } +} diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e1abddd7bbe6397074c212e829534c6202bf6b3 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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_indexer/src/main/ets/test/AlphabetIndexer.ets b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/AlphabetIndexer.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f96bb1daad6faf2552c792b334bbadb4cddb91d --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/AlphabetIndexer.ets @@ -0,0 +1,555 @@ +/* + * 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' +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +let emitKey = "emitUserAgent"; + +export default function AlphabetIndexer() { + describe('ActsAlphabetIndexerTest', function () { + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("AlphabetIndexer beforeEach start"); + done(); + }) + + afterEach(async function (done) { + console.info("AlphabetIndexer afterEach start"); + try { + var eventData = { + data: { + "popupSelectedColorStr": '#00FF00', + "popupUnselectedColorStr": '#DA70D6', + "popupItemBackgroundStr": '#FFD700', + "popupItemFontSizeStr": '20', + "popupItemFontWeightStr": '400', + "popupSpaceStr": '120', + "popupSelectedColor": Color.Orange, + "popupUnselectedColor": Color.Green, + "popupItemBackgroundColor": Color = Color.Pink, + "popupSelectedColorNum": 0x00CED1, + "popupUnselectedColorNum": 0xC0FF3E, + "popupItemBackgroundNum": 0x8470FF, + "popupItemFontSizeNum": 30, + "popupItemFontWeightNum": FontWeight.Normal, + "popupSpaceNum": 50, + "popupSelectedColorRes": $r('app.color.popupSelectedColor'), + "popupUnselectedColorRes": $r('app.color.popupUnselectedColor'), + "popupItemBackgroundRes": $r('app.color.popupItemBackground'), + "popupItemFontSizeRes": $r('app.string.fontSize'), + "popupSpaceRes": $r('app.string.popupSpace'), + "popupItemFontWeightFont": FontWeight.Bolder, + "nullFlag1": false, + "nullFlag2": false, + "nullFlag3": false, + "nullFlag4": false, + "nullFlag5": false + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer] change component data error: " + err.message); + } + await Utils.sleep(2000); + done(); + }) + + it('ArkUI_AlphabetIndexer_0100', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_0100 start"); + let strJson = getInspectorByKey('alphabetIndexerTest1'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.popupSelectedColor).assertEqual("#FF182431"); + expect(obj.$attrs.popupUnselectedColor).assertEqual("#FF182431"); + expect(obj.$attrs.popupItemBackground).assertEqual("#FFFFFFFF"); + expect(obj.$attrs.popupItemFontSize).assertEqual("24.00vp"); + expect(obj.$attrs.popupItemFontWeight).assertEqual("FontWeight.Medium"); + expect(obj.$attrs.popupHorizontalSpace).assertEqual("-1.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_0600', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_0600 start"); + let strJson = getInspectorByKey('alphabetIndexerTest6'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.popupItemFontSize).assertEqual("30.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_0700', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_0700 start"); + let strJson = getInspectorByKey('alphabetIndexerTest7'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.popupItemFontWeight).assertEqual("FontWeight.Normal"); + done(); + }); + + it('ArkUI_AlphabetIndexer_0800', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_0800 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag1": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_0800] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_0800] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupSelectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_0900', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_0900 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag2": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_0900] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_0900] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupUnselectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1000', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1000 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag3": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1000] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1000] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemBackground).assertEqual("#FFFFFFFF"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1100', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1100 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1100] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1100] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontSize).assertEqual("24.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1200', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1200 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1200] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1200] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontWeight).assertEqual("FontWeight.Medium"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1300', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1300 start"); + let strJson = getInspectorByKey('alphabetIndexerTest2'); + try { + var eventData = { + data: { + "nullFlag5": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1300] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1300] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest2'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupHorizontalSpace).assertEqual("-1.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1400', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1400 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag1": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1400] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1400] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupSelectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1500', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1500 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag2": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1500] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1500] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupUnselectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1600', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1600 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag3": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1600] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1600] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemBackground).assertEqual("#FFFFFFFF"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1700', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1700 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1700] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1700] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontSize).assertEqual("24.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1800', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1800 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1800] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1800] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontWeight).assertEqual("FontWeight.Medium"); + done(); + }); + + it('ArkUI_AlphabetIndexer_1900', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_1900 start"); + let strJson = getInspectorByKey('alphabetIndexerTest3'); + try { + var eventData = { + data: { + "nullFlag5": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_1900] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_1900] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest3'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupHorizontalSpace).assertEqual("-1.00vp"); + done(); + }) + + it('ArkUI_AlphabetIndexer_2600', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_2600 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag1": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_2600] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_2600] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupSelectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_2700', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_2700 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag2": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_2700] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_2700] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupUnselectedColor).assertEqual("#FF182431"); + done(); + }); + + it('ArkUI_AlphabetIndexer_2800', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_2800 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag3": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_2800] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_2800] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemBackground).assertEqual("#FFFFFFFF"); + done(); + }); + + it('ArkUI_AlphabetIndexer_2900', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_2900 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_2900] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_2900] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontSize).assertEqual("24.00vp"); + done(); + }); + + it('ArkUI_AlphabetIndexer_3000', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_3000 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag4": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_3000] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_3000] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupItemFontWeight).assertEqual("FontWeight.Medium"); + done(); + }); + + it('ArkUI_AlphabetIndexer_3100', 0, async function (done) { + console.info("ArkUI_AlphabetIndexer_3100 start"); + let strJson = getInspectorByKey('alphabetIndexerTest4'); + try { + var eventData = { + data: { + "nullFlag5": true, + } + } + var innerEvent = { + eventId: 183, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_AlphabetIndexer_3100] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_AlphabetIndexer_3100] change component data error: " + err.message); + } + await Utils.sleep(2000); + let newJson = getInspectorByKey('alphabetIndexerTest4'); + let obj = JSON.parse(newJson); + expect(obj.$attrs.popupHorizontalSpace).assertEqual("-1.00vp"); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/List.test.ets b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1292b45818abb5c88b108e65e50fd33e4e4dc6e1 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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 alphabetIndexer from './AlphabetIndexer' + +export default function testsuite() { + alphabetIndexer() +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/Utils.ets b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..66e1cb1b2e76679f508277220828c0d9d444ebc0 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/ets/test/Utils.ets @@ -0,0 +1,142 @@ +/* + * 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 events_emitter from '@ohos.events.emitter'; +import { expect } from "@ohos/hypium"; + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve("ok") + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static registerEvent(testCaseName, expectedValue, eventId, done) { + console.info(`[${testCaseName}] START`); + try { + let callBack = (backData) => { + console.info(`${testCaseName} get result is:` + JSON.stringify(backData)); + expect(backData.data.ACTION).assertEqual(expectedValue); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent, callBack) + } catch (err) { + console.info(`[${testCaseName}] err:` + JSON.stringify(err)); + } + } + + static emitEvent(actualValue, eventId) { + try { + let backData = { + data: { + "ACTION": actualValue + } + } + let backEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + console.info("webFlag start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("webFlag emit action state err: " + JSON.stringify(err)); + } + } + + static registerEventTwo(testCaseName, eventId, done) { + console.info(`[${testCaseName}] START`); + try { + let callBack = (backData) => { + console.info(`${testCaseName} get result is:` + JSON.stringify(backData)); + expect(backData.data.actualValue).assertLarger(backData.data.expectedValue - 100); + expect(backData.data.actualValue).assertLess(backData.data.expectedValue - (-100)); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent, callBack) + } catch (err) { + console.info(`[${testCaseName}] err:` + JSON.stringify(err)); + } + } + + static emitEventTwo(expectedValue, actualValue, eventId) { + try { + let backData = { + data: { + "expectedValue": expectedValue, + "actualValue": actualValue + } + } + let backEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + console.info("webFlag start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("webFlag emit action state err: " + JSON.stringify(err)); + } + } + + static registerContainEvent(testCaseName, expectedValue, eventId, done) { + console.info(`[${testCaseName}] START`); + try { + let callBack = (backData) => { + console.info(`${testCaseName} get result is:` + JSON.stringify(backData)); + expect(backData.data.ACTION).assertContain(expectedValue); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId: eventId, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent, callBack) + } catch (err) { + console.info(`[${testCaseName}] err:` + JSON.stringify(err)); + } + } + + static commitKey(emitKey) { + try { + let backData = { + data: { + "ACTION": emitKey + } + } + 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)); + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/module.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..2b03fde2a1898cf911b3b3f2f94a553bca8ebb86 --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/module.json @@ -0,0 +1,41 @@ +{ + "module": { + "name": "phone", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "metadata": [{ + "name": "ArkTSPartialUpdate", + "value": "true" + }], + "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_indexer/src/main/resources/base/element/color.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..77184783c1312019eaed57881860b4b6a29b488e --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "Divider_color", + "value": "#000000" + }, + { + "name": "popupSelectedColor", + "value": "#00C5CD" + }, + { + "name": "popupUnselectedColor", + "value": "#FFEC8B" + }, + { + "name": "popupItemBackground", + "value": "#4EEE94" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/element/string.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b4eb464fd2865495eb6fa1af9db4f6f2eb78b6ce --- /dev/null +++ b/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "popupSelectedColor", + "value": "#00C5CD" + }, + { + "name": "popupUnselectedColor", + "value": "#4EEE94" + }, + { + "name": "popupItemBackground", + "value": "#FFEC8B" + }, + { + "name": "fontSize", + "value": "25px" + }, + { + "name": "popupSpace", + "value": "10" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/media/icon.png b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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_indexer/src/main/resources/base/media/icon.png differ diff --git a/arkui/ace_ets_components_ux/ace_ets_component_indexer/src/main/resources/base/profile/test_pages.json b/arkui/ace_ets_components_ux/ace_ets_component_indexer/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_indexer/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_text/src/main/ets/TestAbility/pages/Index.ets b/arkui/ace_ets_components_ux/ace_ets_component_text/src/main/ets/TestAbility/pages/Index.ets index f192a3fc7c700fb2ae174e26d804e3cf7022510f..871aa661fbe3c7c1aae7c9a83c32bca6f272a423 100755 --- a/arkui/ace_ets_components_ux/ace_ets_component_text/src/main/ets/TestAbility/pages/Index.ets +++ b/arkui/ace_ets_components_ux/ace_ets_component_text/src/main/ets/TestAbility/pages/Index.ets @@ -280,6 +280,7 @@ struct textTest { .height(20) .maxLines(1) .textOverflow({ overflow: TextOverflow.Clip }) + .textAlign(TextAlign.JUSTIFY) .fontSize(15) } @@ -294,6 +295,7 @@ struct textTest { .key('ArkUX_Stage_Text_TextAlign_0200') .height(20) .textAlign(TextAlign.Start) + .textOverflow({ overflow: TextOverflow.MARQUEE }) } ListItem() {