提交 576afcfd 编写于 作者: S sunjiakun

add indexer update textinterface

Signed-off-by: Nsunjiakun <sunjiakun3@huawei.com>
上级 06833552
...@@ -21,6 +21,7 @@ group("componentUxTest") { ...@@ -21,6 +21,7 @@ group("componentUxTest") {
"ace_ets_component_clickeffect:ActsAceClickEffectTest", "ace_ets_component_clickeffect:ActsAceClickEffectTest",
"ace_ets_component_datapanel:ActsAceDatapanelTest", "ace_ets_component_datapanel:ActsAceDatapanelTest",
"ace_ets_component_datepicker:ActsAceDatePickerTest", "ace_ets_component_datepicker:ActsAceDatePickerTest",
"ace_ets_component_indexer:ActsAlphabetIndexerTest",
"ace_ets_component_list:ActsAceListTest", "ace_ets_component_list:ActsAceListTest",
"ace_ets_component_menu:ActsAceMenuTest", "ace_ets_component_menu:ActsAceMenuTest",
"ace_ets_component_popup:ActsAcePopupTest", "ace_ets_component_popup:ActsAcePopupTest",
......
{
"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
{
"string": [
{
"name": "app_name",
"value": "AlphabetIndexerTest"
}
]
}
\ No newline at end of file
# 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"
}
{
"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
/*
* 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
/*
* 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%')
}
}
/*
* 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<void> {
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');
}
}
/*
* 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
/*
* 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
{
"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"
]
}
]
}
]
}
}
{
"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
{
"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
...@@ -280,6 +280,7 @@ struct textTest { ...@@ -280,6 +280,7 @@ struct textTest {
.height(20) .height(20)
.maxLines(1) .maxLines(1)
.textOverflow({ overflow: TextOverflow.Clip }) .textOverflow({ overflow: TextOverflow.Clip })
.textAlign(TextAlign.JUSTIFY)
.fontSize(15) .fontSize(15)
} }
...@@ -294,6 +295,7 @@ struct textTest { ...@@ -294,6 +295,7 @@ struct textTest {
.key('ArkUX_Stage_Text_TextAlign_0200') .key('ArkUX_Stage_Text_TextAlign_0200')
.height(20) .height(20)
.textAlign(TextAlign.Start) .textAlign(TextAlign.Start)
.textOverflow({ overflow: TextOverflow.MARQUEE })
} }
ListItem() { ListItem() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册