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

!9794 删除智能语音xts用例

Merge pull request !9794 from lvqiang214/master
...@@ -19,7 +19,6 @@ group("ai") { ...@@ -19,7 +19,6 @@ group("ai") {
] ]
if (is_standard_system) { if (is_standard_system) {
deps += [ deps += [
"intelligent_voice_framework:intelligentvoice_js_hap",
"mindspore/mindsporectest:ActsMindSporeTest", "mindspore/mindsporectest:ActsMindSporeTest",
"mindspore/mindsporejstest:ActsMindsporeJSTest", "mindspore/mindsporejstest:ActsMindsporeJSTest",
] ]
......
{
"app":{
"bundleName":"ohos.acts.ai.intelligentvoice",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":10,
"targetAPIVersion":10,
"car":{
"apiCompatibleVersion":10,
"singleUser":false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "ohosProject"
}
]
}
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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("intelligentvoice_js_hap") {
hap_profile = "src/main/module.json"
deps = [
":ActsIntelligentVocieTest_js_assets",
":ActsIntelligentVocieTest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsIntelligentVoiceTest"
subsystem_name = "ai"
part_name = "intelligent_voice_framework"
}
ohos_app_scope("ActsIntelligentVoiceTest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ActsIntelligentVocieTest_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ActsIntelligentVocieTest_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ActsIntelligentVoiceTest_app_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for intelligent voice framework Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1500000",
"testcase-timeout": "50000",
"bundle-name": "ohos.acts.ai.intelligentvoice",
"module-name": "entry_test",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsIntelligentVoiceTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
"power-shell setmode 602"
],
"teardown-command":[
"power-shell setmode 600"
],
"cleanup-apps": true
},
{
"type": "PushKit",
"pre-push": [],
"push": [
]
}
]
}
\ 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 UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
import Want from '@ohos.app.ability.Want';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
export default class TestAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
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) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
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 hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
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 intelligentVoice from '@ohos.ai.intelligentVoice';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function intelligentVoiceManagerApi10Test() {
describe('ActsIntelligentVoiceManagerApi10Test', function () {
let tagFrmwk = "intelligentvoiceManagerApi10Test";
console.info(`${tagFrmwk}: Create IntelligentvoiceManger Object JS Framework`);
let intelligentvoiceManager = null;
function getIntelligentvoiceManager() {
intelligentvoiceManager = intelligentVoice.getIntelligentVoiceManager();
if (intelligentvoiceManager != null) {
console.info(`${tagFrmwk}: getIntelligentvoiceManger : PASS`);
} else {
console.info(`${tagFrmwk}: getIntelligentvoiceManger : FAIL`);
}
}
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(async function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
console.info(`${tagFrmwk}: beforeAll: Prerequisites at the test suite level`);
await getIntelligentvoiceManager();
console.info(`${tagFrmwk}: beforeAll: END`);
})
beforeEach(async function () {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
console.info(`${tagFrmwk}: beforeEach: Prerequisites at the test case level`);
})
afterEach(async function () {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
console.info(`${tagFrmwk}: afterEach: Test case-level clearance conditions`);
})
afterAll(function () {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
console.info(`${tagFrmwk}: afterAll: Test suite-level cleanup condition`);
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_ENGINE_TYPE_0100
*@tc.name : INTELLIGENT_VOICE_ENGINE_TYPE
*@tc.desc : INTELLIGENT_VOICE_ENGINE_TYPE
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 1
*/
it('SUB_AI_INTELLIGENT_VOICE_ENGINE_TYPE_0100', 1, function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
expect(intelligentVoice.IntelligentVoiceEngineType.ENROLL_ENGINE_TYPE).assertEqual(0);
expect(intelligentVoice.IntelligentVoiceEngineType.WAKEUP_ENGINE_TYPE).assertEqual(1);
expect(intelligentVoice.IntelligentVoiceEngineType.UPDATE_ENGINE_TYPE).assertEqual(2);
done();
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_ENROLL_RESULT_0100
*@tc.name : INTELLIGENT_VOICE_ENROLL_RESULT
*@tc.desc : INTELLIGENT_VOICE_ENROLL_RESULT
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 1
*/
it('SUB_AI_INTELLIGENT_VOICE_ENROLL_RESULT_0100', 1, function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
expect(intelligentVoice.EnrollResult.SUCCESS).assertEqual(0);
expect(intelligentVoice.EnrollResult.VPR_TRAIN_FAILED).assertEqual(-1);
expect(intelligentVoice.EnrollResult.WAKEUP_PHRASE_NOT_MATCH).assertEqual(-2);
expect(intelligentVoice.EnrollResult.TOO_NOISY).assertEqual(-3);
expect(intelligentVoice.EnrollResult.TOO_LOUD).assertEqual(-4);
expect(intelligentVoice.EnrollResult.INTERVAL_LARGE).assertEqual(-5);
expect(intelligentVoice.EnrollResult.DIFFERENT_PERSON).assertEqual(-6);
expect(intelligentVoice.EnrollResult.UNKNOWN_ERROR).assertEqual(-100);
done();
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_WAKEUP_EVENT_0100
*@tc.name : INTELLIGENT_VOICE_WAKEUP_EVENT
*@tc.desc : INTELLIGENT_VOICE_WAKEUP_EVENT
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 1
*/
it('SUB_AI_INTELLIGENT_VOICE_WAKEUP_EVENT_0100', 1, function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
expect(intelligentVoice.WakeupIntelligentVoiceEventType.INTELLIGENT_VOICE_EVENT_WAKEUP_NONE).assertEqual(0);
expect(intelligentVoice.WakeupIntelligentVoiceEventType.INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE).assertEqual(1);
done();
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_ERROR_CODE_0100
*@tc.name : INTELLIGENT_VOICE_ERROR_CODE
*@tc.desc : INTELLIGENT_VOICE_ERROR_CODE
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 1
*/
it('SUB_AI_INTELLIGENT_VOICE_ERROR_CODE_0100', 1, function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
expect(intelligentVoice.IntelligentVoiceErrorCode.INTELLIGENT_VOICE_NO_MEMORY).assertEqual(22700101);
expect(intelligentVoice.IntelligentVoiceErrorCode.INTELLIGENT_VOICE_INVALID_PARAM).assertEqual(22700102);
expect(intelligentVoice.IntelligentVoiceErrorCode.INTELLIGENT_VOICE_INIT_FAILED).assertEqual(22700103);
expect(intelligentVoice.IntelligentVoiceErrorCode.INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED).assertEqual(22700104);
done();
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_ENGINE_MANAGER_0100
*@tc.name : INTELLIGENT_VOICE_ENGINE_MANAGER
*@tc.desc : INTELLIGENT_VOICE_ENGINE_MANAGER
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_AI_INTELLIGENT_VOICE_ENGINE_MANAGER_0100', 2, function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
try {
let info = intelligentvoiceManager.getCapabilityInfo();
expect(info.length).assertEqual(2);
for (let key in info) {
console.info(`supported intelligent voice engine type: ${key}`);
}
} catch (error) {
console.info(`failed to get supported intelligent voice engine type: ${JSON.stringify(error)}`);
done();
return;
}
intelligentvoiceManager.on('serviceChange', (serviceChangeType) => {});
expect(true).assertTrue();
intelligentvoiceManager.off('serviceChange');
expect(true).assertTrue();
expect(intelligentVoice.ServiceChangeType.SERVICE_UNAVAILABLE).assertEqual(0);
// expect(intelligentVoice.IntelligentVoiceEngineType.WAKEUP_ENGINE_TYPE).assertEqual(1);
// expect(intelligentVoice.IntelligentVoiceEngineType.UPDATE_ENGINE_TYPE).assertEqual(2);
done();
})
})
}
\ 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 intelligentVoiceManagerApi10Test from './IntelligentVoiceManagerApi10.test'
import enrollIntelligentVoiceEngineTest from './EnrollIntelligentVoiceEngine.test'
import wakeupIntelligentVoiceEngineTest from './WakeupIntelligentVoiceEngine.test'
export default function testsuite() {
intelligentVoiceManagerApi10Test()
enrollIntelligentVoiceEngineTest()
wakeupIntelligentVoiceEngineTest()
}
\ 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 intelligentVoice from '@ohos.ai.intelligentVoice';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function wakeupIntelligentVoiceEngineTest() {
describe('ActsWakeupIntelligentVoiceEngineTest', function () {
let tag = "wakeupIntelligentvoiceEngineTest";
console.info(`${tag}: Create WakeupIntelligentvoiceEngine Object JS Framework`);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function releaseWakeupEngine(wakeupEngine, done) {
try {
wakeupEngine.release(err => {
if (err) {
console.info(`${tag} releaseWakeupEngine err: ${JSON.stringify(err)}`);
done();
return;
} else {
console.log(`${tag} releaseWakeupEngine success`);
done();
}
});
} catch (error) {
console.info(`${tag} failed to releaseWakeupEngine: ${JSON.stringify(error)}`);
done();
}
}
function getParameter(wakeupEngine, key, done) {
try {
wakeupEngine.getParameter(key, (err, data) => {
if (err) {
console.info(`${tag} get parameter err: ${JSON.stringify(err)}`);
done();
return;
} else {
console.log(`${tag} get parameter success`);
let param = data;
expect(param).assertEqual('value');
releaseWakeupEngine(wakeupEngine, done);
}
});
} catch (error) {
console.info(`${tag} failed to get parameter: ${JSON.stringify(error)}`);
done();
}
}
function setParameter(wakeupEngine, key, value, done) {
try {
wakeupEngine.setParameter(key, value, err => {
if (err) {
console.info(`${tag} set parameter err: ${JSON.stringify(err)}`);
done();
return;
} else {
console.log(`${tag} set parameter success`);
getParameter(wakeupEngine, 'key', done);
}
});
} catch (error) {
console.info(`${tag} failed to set parameter: ${JSON.stringify(error)}`);
done();
}
}
function setSensibility(wakeupEngine, sensibility, done) {
try {
wakeupEngine.setSensibility(sensibility, err => {
if (err) {
console.info(`${tag} set sensibility err: ${JSON.stringify(err)}`);
done();
return;
} else {
console.log(`${tag} set sensibility success`);
setParameter(wakeupEngine, 'scene', '0', done);
}
});
} catch (error) {
console.info(`${tag} failed to set sensibility: ${JSON.stringify(error)}`);
done();
}
}
function setWakeupHapInfo(wakeupEngine, wakeupHapInfo, done) {
try {
wakeupEngine.setWakeupHapInfo(wakeupHapInfo, err => {
if (err) {
console.info(`${tag} set wakeup hap info err: ${JSON.stringify(err)}`);
done();
return;
} else {
console.log(`${tag} set wakeup hap info success`);
setSensibility(wakeupEngine, intelligentVoice.SensibilityType.MIDDLE_SENSIBILITY, done);
}
});
} catch (error) {
console.info(`${tag} failed to set wakeup hap info: ${JSON.stringify(error)}`);
done();
}
}
function getSupportedRegions(wakeupEngine, done) {
try {
wakeupEngine.getSupportedRegions((err, data) => {
if (err) {
console.log(`${tag} get supported regions err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
} else {
console.log(`${tag} get supported regions success`);
let regions = data;
expect(regions.length).assertEqual(1);
for (let region in regions) {
console.info(`supported region: ${region}`);
}
let wakeupHapInfo = {
bundleName: 'example_bundle_name',
abilityName: 'example_ability_name'
}
setWakeupHapInfo(wakeupEngine, wakeupHapInfo, done);
}
});
} catch (error) {
console.info(`${tag} failed to createEnrollIntelligentVoiceEngine: ${JSON.stringify(error)}`);
done();
}
}
function wakeupAsync(wakeupEngine, done) {
try {
let descriptor = {
needReconfirm: true,
wakeupPhrase: '小艺小艺'
}
intelligentVoice.createWakeupIntelligentVoiceEngine(descriptor, (err, data) => {
if (err) {
console.log(`${tag} createWakeupIntelligentVoiceEngine err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
} else {
console.log(`${tag} createWakeupIntelligentVoiceEngine success`);
wakeupEngine = data;
getSupportedRegions(wakeupEngine, done);
}
});
} catch (error) {
console.info(`${tag} failed to createWakeupIntelligentVoiceEngine: ${JSON.stringify(error)}`);
done();
}
}
async function wakeupPromise(descriptor, done) {
let wakeupEngine = null;
try {
wakeupEngine = await intelligentVoice.createWakeupIntelligentVoiceEngine(descriptor);
console.log(`${tag} createWakeupIntelligentVoiceEngine success`);
} catch (error) {
console.info(`${tag} failed to createWakeupIntelligentVoiceEngine: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
let regions = await wakeupEngine.getSupportedRegions();
console.log(`${tag} get supported regions success`);
expect(regions.length).assertEqual(1);
for (let region in regions) {
console.info(`supported region: ${region}`);
}
} catch (error) {
console.info(`${tag} failed to get supported regions: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
let wakeupHapInfo = {
bundleName: 'example_bundle_name',
abilityName: 'example_ability_name'
}
await wakeupEngine.setWakeupHapInfo(wakeupHapInfo);
console.log(`${tag} set wakeup hap info success`);
} catch (error) {
console.info(`${tag} failed to set wakeup hap info: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
await wakeupEngine.setSensibility(intelligentVoice.SensibilityType.HIGH_SENSIBILITY);
console.log(`${tag} set sensibility success`);
} catch(error) {
console.info(`${tag} failed to set sensibility: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
await wakeupEngine.setParameter('scene', '0');
console.log(`${tag} set parameter success`);
} catch(error) {
console.info(`${tag} failed to set parameter: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
let param = await wakeupEngine.getParameter('key');
console.log(`${tag} get parameter success`);
expect(param).assertEqual('value');
} catch(error) {
console.info(`${tag} failed to get parameter: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
wakeupEngine.on('wakeupIntelligentVoiceEvent', (callback) => {
console.info(`${tag}: wakeup intelligentvoice event`);
for (let prop in callback) {
console.info(`${tag}: intelligentvoice prop: ${prop}`);
}
});
console.log(`${tag} register wakeup event success`);
wakeupEngine.off('wakeupIntelligentVoiceEvent');
console.log(`${tag} unregister wakeup event success`);
expect(true).assertTrue();
done();
} catch(error) {
console.info(`${tag} failed to register wakeup event: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
try {
await wakeupEngine.release();
console.log(`${tag} release WakeupIntelligentVoiceEngine success`);
} catch(error) {
console.info(`${tag} failed to release WakeupIntelligentVoiceEngine: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
return;
}
done();
}
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(async function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
console.info(`${tag}: beforeAll: Prerequisites at the test suite level`);
await sleep(100);
console.info(`${tag}: beforeAll: END`);
})
beforeEach(async function () {
console.info(`${tag}: beforeEach: Prerequisites at the test case level`);
await sleep(100);
})
afterEach(async function () {
console.info(`${tag}: afterEach: Test case-level clearance conditions`);
await sleep(100);
})
afterAll(function () {
console.info(`${tag}: afterAll: Test suite-level cleanup condition`);
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_WAKEUP_PROCESS_ASYNC_0100
*@tc.name : INTELLIGENT_VOICE_WAKEUP_PROCESS_ASYNC
*@tc.desc : INTELLIGENT_VOICE_WAKEUP_PROCESS_ASYNC
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 3
*/
it('SUB_AI_INTELLIGENT_VOICE_WAKEUP_PROCESS_ASYNC_0100', 3, async function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let wakeupEngine = null;
wakeupAsync(wakeupEngine, done);
})
/**
*@tc.number : SUB_AI_INTELLIGENT_VOICE_WAKEUP_PROCESS_PROMISE_0100
*@tc.name : INTELLIGENT_VOICE_WAKEUP_PROCESS_PROMISE
*@tc.desc : INTELLIGENT_VOICE_WAKEUP_PROCESS_PROMISE
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 3
*/
it('SUB_AI_INTELLIGENT_VOICE_WAKEUP_PROCESS_PROMISE_0100', 3, async function (done) {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let descriptor = {
needApAlgEngine: true,
wakeupPhrase: '小艺小艺'
}
wakeupPromise(descriptor, done);
})
})
}
\ No newline at end of file
{
"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",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": 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"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册