Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
34e4e0d2
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
34e4e0d2
编写于
8月 10, 2023
作者:
L
lvqiang214
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add xts case
Signed-off-by:
N
lvqiang214
<
lvqiang1@huawei.com
>
上级
4058cdf1
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
1300 addition
and
0 deletion
+1300
-0
ai/BUILD.gn
ai/BUILD.gn
+1
-0
ai/intelligent_voice_framework/AppScope/app.json
ai/intelligent_voice_framework/AppScope/app.json
+21
-0
ai/intelligent_voice_framework/AppScope/resources/base/element/string.json
...ice_framework/AppScope/resources/base/element/string.json
+8
-0
ai/intelligent_voice_framework/AppScope/resources/base/media/app_icon.png
...oice_framework/AppScope/resources/base/media/app_icon.png
+0
-0
ai/intelligent_voice_framework/BUILD.gn
ai/intelligent_voice_framework/BUILD.gn
+42
-0
ai/intelligent_voice_framework/Test.json
ai/intelligent_voice_framework/Test.json
+39
-0
ai/intelligent_voice_framework/signature/openharmony_sx.p7b
ai/intelligent_voice_framework/signature/openharmony_sx.p7b
+0
-0
ai/intelligent_voice_framework/src/main/ets/TestAbility/TestAbility.ets
..._voice_framework/src/main/ets/TestAbility/TestAbility.ets
+50
-0
ai/intelligent_voice_framework/src/main/ets/TestAbility/pages/Index.ets
..._voice_framework/src/main/ets/TestAbility/pages/Index.ets
+34
-0
ai/intelligent_voice_framework/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...ramework/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+49
-0
ai/intelligent_voice_framework/src/main/ets/test/EnrollIntelligentVoiceEngine.test.ets
...k/src/main/ets/test/EnrollIntelligentVoiceEngine.test.ets
+526
-0
ai/intelligent_voice_framework/src/main/ets/test/IntelligentVoiceManagerApi10.test.ets
...k/src/main/ets/test/IntelligentVoiceManagerApi10.test.ets
+142
-0
ai/intelligent_voice_framework/src/main/ets/test/List.test.ets
...telligent_voice_framework/src/main/ets/test/List.test.ets
+9
-0
ai/intelligent_voice_framework/src/main/ets/test/WakeupIntelligentVoiceEngine.test.ets
...k/src/main/ets/test/WakeupIntelligentVoiceEngine.test.ets
+305
-0
ai/intelligent_voice_framework/src/main/module.json
ai/intelligent_voice_framework/src/main/module.json
+37
-0
ai/intelligent_voice_framework/src/main/resources/base/element/color.json
...oice_framework/src/main/resources/base/element/color.json
+8
-0
ai/intelligent_voice_framework/src/main/resources/base/element/string.json
...ice_framework/src/main/resources/base/element/string.json
+24
-0
ai/intelligent_voice_framework/src/main/resources/base/media/icon.png
...nt_voice_framework/src/main/resources/base/media/icon.png
+0
-0
ai/intelligent_voice_framework/src/main/resources/base/profile/test_pages.json
...framework/src/main/resources/base/profile/test_pages.json
+5
-0
未找到文件。
ai/BUILD.gn
浏览文件 @
34e4e0d2
...
...
@@ -21,6 +21,7 @@ group("ai") {
deps += [
"mindspore/mindsporectest:ActsMindSporeTest",
"mindspore/mindsporejstest:ActsMindsporeJSTest",
"intelligent_voice_framework:intelligentvoice_js_hap",
]
}
}
ai/intelligent_voice_framework/AppScope/app.json
0 → 100755
浏览文件 @
34e4e0d2
{
"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
}
}
}
ai/intelligent_voice_framework/AppScope/resources/base/element/string.json
0 → 100755
浏览文件 @
34e4e0d2
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"ohosProject"
}
]
}
ai/intelligent_voice_framework/AppScope/resources/base/media/app_icon.png
0 → 100755
浏览文件 @
34e4e0d2
6.6 KB
ai/intelligent_voice_framework/BUILD.gn
0 → 100755
浏览文件 @
34e4e0d2
# 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"
}
ai/intelligent_voice_framework/Test.json
0 → 100755
浏览文件 @
34e4e0d2
{
"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
ai/intelligent_voice_framework/signature/openharmony_sx.p7b
0 → 100755
浏览文件 @
34e4e0d2
文件已添加
ai/intelligent_voice_framework/src/main/ets/TestAbility/TestAbility.ets
0 → 100755
浏览文件 @
34e4e0d2
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
ai/intelligent_voice_framework/src/main/ets/TestAbility/pages/Index.ets
0 → 100755
浏览文件 @
34e4e0d2
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
ai/intelligent_voice_framework/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100755
浏览文件 @
34e4e0d2
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
ai/intelligent_voice_framework/src/main/ets/test/EnrollIntelligentVoiceEngine.test.ets
0 → 100755
浏览文件 @
34e4e0d2
此差异已折叠。
点击以展开。
ai/intelligent_voice_framework/src/main/ets/test/IntelligentVoiceManagerApi10.test.ets
0 → 100755
浏览文件 @
34e4e0d2
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
ai/intelligent_voice_framework/src/main/ets/test/List.test.ets
0 → 100755
浏览文件 @
34e4e0d2
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
ai/intelligent_voice_framework/src/main/ets/test/WakeupIntelligentVoiceEngine.test.ets
0 → 100755
浏览文件 @
34e4e0d2
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
=
{
needApAlgEngine
:
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
ai/intelligent_voice_framework/src/main/module.json
0 → 100755
浏览文件 @
34e4e0d2
{
"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"
]
}
]
}
]
}
}
ai/intelligent_voice_framework/src/main/resources/base/element/color.json
0 → 100755
浏览文件 @
34e4e0d2
{
"color"
:
[
{
"name"
:
"start_window_background"
,
"value"
:
"#FFFFFF"
}
]
}
\ No newline at end of file
ai/intelligent_voice_framework/src/main/resources/base/element/string.json
0 → 100755
浏览文件 @
34e4e0d2
{
"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
ai/intelligent_voice_framework/src/main/resources/base/media/icon.png
0 → 100755
浏览文件 @
34e4e0d2
6.6 KB
ai/intelligent_voice_framework/src/main/resources/base/profile/test_pages.json
0 → 100755
浏览文件 @
34e4e0d2
{
"src"
:
[
"TestAbility/pages/Index"
]
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录