未验证 提交 aea0020c 编写于 作者: O openharmony_ci 提交者: Gitee

!9068 UX一期 Search组件相关XTS

Merge pull request !9068 from sunjiakun/UXI_xts_search
......@@ -24,6 +24,7 @@ group("componentUxTest") {
"ace_ets_component_popup:ActsAcePopupTest",
"ace_ets_component_progress:ActsAceProgressTest",
"ace_ets_component_radio:ActsAceRadioTest",
"ace_ets_component_search:ActsAceSearchTest",
"ace_ets_component_select:ActsAceSelectTest",
"ace_ets_component_sidebar:ActsAceSideBarTest",
"ace_ets_component_slider:ActsAceSliderTest",
......
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ace_ets_component_search.iml" filepath="$PROJECT_DIR$/.idea/ace_ets_component_search.iml" />
</modules>
</component>
</project>
\ No newline at end of file
{
"app": {
"bundleName": "com.example.acesearchtest",
"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":"MyApplication"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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("ActsAceSearchTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_search_js_assets",
":ace_ets_component_search_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceSearchTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_search_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_search_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_search_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_search_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.acesearchtest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsAceSearchTest.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');
}
}
/*
* 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 SliderExample {
@State caretWidthNumber: number = 5
@State caretWidthString: string = '15px'
@State caretWidthResource: Resource = $r('sys.float.ohos_id_text_margin_vertical')
@State caretColorColor: Color = Color.Red
@State caretColorNumber: number = 0x000000
@State caretColorString: string = '#ff9a35'
@State caretColorResource: Resource = $r('sys.color.ohos_id_color_connected')
@State leftSearchIconSizeNumber: number = 20
@State leftSearchIconSizeString: string = '50px'
@State leftSearchIconSizeResource: Resource = $r('sys.float.ohos_id_text_paragraph_margin_m')
@State leftSearchIconColorColor: Color = Color.Red
@State leftSearchIconColorNumber: number = 0x000000
@State leftSearchIconColorString: string = '#ff9a35'
@State leftSearchIconColorResource: Resource = $r('sys.color.ohos_id_color_connected')
@State searchSrcPath: string = 'common/icon.png'
@State searchSrcPathResource: Resource = $r('sys.media.ohos_app_icon')
@State rightButtonStyleParam: CancelButtonStyle = CancelButtonStyle.INPUT
@State rightCancelIconSizeNumber: number = 20
@State rightCancelIconSizeString: string = '50px'
@State rightCancelIconSizeResource: Resource = $r('sys.float.ohos_id_text_paragraph_margin_m')
@State rightCancelIconColorColor: Color = Color.Red
@State rightCancelIconColorNumber: number = 0x000000
@State rightCancelIconColorString: string = '#ff9a35'
@State rightCancelIconColorResource: Resource = $r('sys.color.ohos_id_color_connected')
@State rightIconSrcPath: string = 'common/icon.png'
@State rightIconSrcPathResource: Resource = $r('sys.media.ohos_app_icon')
@State searchButtonFontSizeNumber: number = 20
@State searchButtonFontSizeString: string = '10vp'
@State searchButtonFontSizeResource: Resource = $r('sys.float.ohos_id_text_paragraph_margin_m')
@State searchButtonFontColorColor: Color = Color.Blue
@State searchButtonFontColorNumber: number = 0x000000
@State searchButtonFontColorString: string = '#ff9a35'
@State searchButtonFontColorResource: Resource = $r('sys.color.ohos_id_color_connected')
@State textColorColor: Color = Color.Red
@State textColorNumber: number = 0x000000
@State textColorString: string = '#ff9a35'
@State textColorResource: Resource = $r('sys.color.ohos_id_color_connected')
@State placeholderFont: Font = { size: '16sp', weight: FontWeight.Normal }
@State textFont: Font = { size: '16sp', weight: FontWeight.Normal }
private stateChangCallBack = (eventData) => {
console.info("search page state change called:" + JSON.stringify(eventData));
this.caretWidthNumber = eventData.data.caretWidthNumber;
this.caretWidthString = eventData.data.caretWidthString;
this.caretWidthResource = eventData.data.caretWidthResource;
this.caretColorColor = eventData.data.caretColorColor;
this.caretColorNumber = eventData.data.caretColorNumber;
this.caretColorString = eventData.data.caretColorString;
this.caretColorResource = eventData.data.caretColorResource;
this.leftSearchIconSizeNumber = eventData.data.leftSearchIconSizeNumber;
this.leftSearchIconSizeString = eventData.data.leftSearchIconSizeString;
this.leftSearchIconSizeResource = eventData.data.leftSearchIconSizeResource;
this.leftSearchIconColorColor = eventData.data.leftSearchIconColorColor;
this.leftSearchIconColorNumber = eventData.data.leftSearchIconColorNumber;
this.leftSearchIconColorString = eventData.data.leftSearchIconColorString;
this.leftSearchIconColorResource = eventData.data.leftSearchIconColorResource;
this.searchSrcPath = eventData.data.searchSrcPath;
this.searchSrcPathResource = eventData.data.searchSrcPathResource;
this.rightButtonStyleParam = eventData.data.rightButtonStyleParam;
this.rightCancelIconSizeNumber = eventData.data.rightCancelIconSizeNumber;
this.rightCancelIconSizeString = eventData.data.rightCancelIconSizeString;
this.rightCancelIconSizeResource = eventData.data.rightCancelIconSizeResource;
this.rightCancelIconColorColor = eventData.data.rightCancelIconColorColor;
this.rightCancelIconColorNumber = eventData.data.rightCancelIconColorNumber;
this.rightCancelIconColorString = eventData.data.rightCancelIconColorString;
this.rightCancelIconColorResource = eventData.data.rightCancelIconColorResource;
this.rightIconSrcPath = eventData.data.rightIconSrcPath;
this.rightIconSrcPathResource = eventData.data.rightIconSrcPathResource;
this.searchButtonFontSizeNumber = eventData.data.searchButtonFontSizeNumber;
this.searchButtonFontSizeString = eventData.data.searchButtonFontSizeString;
this.searchButtonFontSizeResource = eventData.data.searchButtonFontSizeResource;
this.searchButtonFontColorColor = eventData.data.searchButtonFontColorColor;
this.searchButtonFontColorNumber = eventData.data.searchButtonFontColorNumber;
this.searchButtonFontColorString = eventData.data.searchButtonFontColorString;
this.searchButtonFontColorResource = eventData.data.searchButtonFontColorResource;
this.textColorColor = eventData.data.textColorColor;
this.textColorNumber = eventData.data.textColorNumber;
this.textColorString = eventData.data.textColorString;
this.textColorResource = eventData.data.textColorResource;
}
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() {
Column() {
Search({ value: '', placeholder: 'Type to search...' })
.searchButton('Search')
.key('searchTestDefault')
Search({ value: '', placeholder: 'Type to search...' })
.caretStyle({
color: $r('sys.color.ohos_id_color_text_primary_activated')
})
.searchIcon({
color: $r('sys.color.ohos_id_color_secondary'),
})
.cancelButton({
icon: {
color: $r('sys.color.ohos_id_color_secondary'),
}
})
.searchButton(
'Search',
{
fontSize: $r('sys.float.ohos_id_text_size_body1'),
fontColor: $r('sys.color.ohos_id_color_text_primary_activated')
}
)
.key('searchTestDefaultValue')
Search({ value: '', placeholder: 'Type to search...' })
.width(300)
.height(40)
.margin(5)
.caretStyle({
width: this.caretWidthNumber,
color: this.caretColorNumber
})
.searchIcon({
size: this.leftSearchIconSizeNumber,
color: this.leftSearchIconColorNumber,
src: this.searchSrcPath
})
.cancelButton({
style: this.rightButtonStyleParam,
icon: {
size: this.rightCancelIconSizeNumber,
color: this.rightCancelIconColorNumber,
src: this.rightIconSrcPath
}
})
.searchButton(
'Search',
{
fontSize: this.searchButtonFontSizeNumber,
fontColor: this.searchButtonFontColorNumber
}
)
.placeholderFont(this.placeholderFont)
.textFont(this.textFont)
.fontColor(this.textColorNumber)
.key('searchTestNumber')
Search({ value: '', placeholder: 'Type to search...' })
.width(300)
.height(40)
.margin(5)
.caretStyle({
width: this.caretWidthString,
color: this.caretColorString
})
.searchIcon({
size: this.leftSearchIconSizeString,
color: this.leftSearchIconColorString,
src: this.searchSrcPath
})
.cancelButton({
style: this.rightButtonStyleParam,
icon: {
size: this.rightCancelIconSizeString,
color: this.rightCancelIconColorString,
src: this.rightIconSrcPath
}
})
.searchButton(
'Search',
{
fontSize: this.searchButtonFontSizeString,
fontColor: this.searchButtonFontColorString
}
)
.placeholderFont(this.placeholderFont)
.textFont(this.textFont)
.fontColor(this.textColorString)
.key('searchTestString')
Search({ value: '', placeholder: 'Type to search...' })
.width(300)
.height(40)
.margin(5)
.caretStyle({
width: this.caretWidthResource,
color: this.caretColorResource
})
.searchIcon({
size: this.leftSearchIconSizeResource,
color: this.leftSearchIconColorResource,
src: this.searchSrcPathResource
})
.cancelButton({
style: this.rightButtonStyleParam,
icon: {
size: this.rightCancelIconSizeResource,
color: this.rightCancelIconColorResource,
src: this.rightIconSrcPathResource
}
})
.searchButton(
'Search',
{
fontSize: this.searchButtonFontSizeResource,
fontColor: this.searchButtonFontColorResource
}
)
.placeholderFont(this.placeholderFont)
.textFont(this.textFont)
.fontColor(this.textColorResource)
.key('searchTestResource')
Search({ value: '', placeholder: 'Type to search...' })
.width(300)
.height(40)
.margin(5)
.caretStyle({
width: this.caretWidthNumber,
color: this.caretColorColor
})
.searchIcon({
size: this.leftSearchIconSizeNumber,
color: this.leftSearchIconColorColor,
src: this.searchSrcPath
})
.cancelButton({
style: this.rightButtonStyleParam,
icon: {
size: this.rightCancelIconSizeNumber,
color: this.rightCancelIconColorColor,
src: this.rightIconSrcPath
}
})
.searchButton(
'Search',
{
fontSize: this.searchButtonFontSizeNumber,
fontColor: this.searchButtonFontColorColor
}
)
.placeholderFont(this.placeholderFont)
.textFont(this.textFont)
.fontColor(this.textColorColor)
.key('searchTestColor')
}
.width('100%')
.height('100%')
}
}
\ 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 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');
}
}
\ 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 search from './Search'
export default function testsuite() {
search()
}
\ 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.
*/
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
}
{
"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"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ 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"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册