Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
28737d97
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看板
提交
28737d97
编写于
2月 28, 2022
作者:
D
dy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add actsbundlemanageretstest and actsabilitymanageretstest tests
Signed-off-by:
N
dy
<
dingyao5@huawei.com
>
上级
b8af5bd0
变更
48
展开全部
隐藏空白更改
内联
并排
Showing
48 changed file
with
5697 addition
and
3 deletion
+5697
-3
aafwk/aafwk_standard/BUILD.gn
aafwk/aafwk_standard/BUILD.gn
+2
-2
aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn
aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn
+32
-0
aafwk/aafwk_standard/actsabilitymanageretstest/Test.json
aafwk/aafwk_standard/actsabilitymanageretstest/Test.json
+18
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json
...dard/actsabilitymanageretstest/entry/src/main/config.json
+143
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/app.ets
...itymanageretstest/entry/src/main/ets/MainAbility2/app.ets
+22
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/pages/index.ets
...eretstest/entry/src/main/ets/MainAbility2/pages/index.ets
+66
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/List.test.ets
...tstest/entry/src/main/ets/MainAbility2/test/List.test.ets
+20
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/Utils.ets
...geretstest/entry/src/main/ets/MainAbility2/test/Utils.ets
+48
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets
...main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets
+219
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility/service.ts
...nageretstest/entry/src/main/ets/ServiceAbility/service.ts
+52
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts
...ageretstest/entry/src/main/ets/ServiceAbility2/service.ts
+122
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts
...ageretstest/entry/src/main/ets/ServiceAbility3/service.ts
+122
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts
...ageretstest/entry/src/main/ets/ServiceAbility4/service.ts
+114
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts
...ageretstest/entry/src/main/ets/ServiceAbility5/service.ts
+137
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/app.ets
...sabilitymanageretstest/entry/src/main/ets/default/app.ets
+22
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/pages/index.ets
...manageretstest/entry/src/main/ets/default/pages/index.ets
+135
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/ContextJsunit.test.ets
...st/entry/src/main/ets/default/test/ContextJsunit.test.ets
+249
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/DataAbility.test.ets
...test/entry/src/main/ets/default/test/DataAbility.test.ets
+458
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/List.test.ets
...ageretstest/entry/src/main/ets/default/test/List.test.ets
+32
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/Utils.ets
...ymanageretstest/entry/src/main/ets/default/test/Utils.ets
+47
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/addContextAndAbilityJsunit.test.ets
...main/ets/default/test/addContextAndAbilityJsunit.test.ets
+235
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getAbilityInfoJsunit.test.ets
...y/src/main/ets/default/test/getAbilityInfoJsunit.test.ets
+305
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getAppVersionInfoJsunit.test.ets
...rc/main/ets/default/test/getAppVersionInfoJsunit.test.ets
+92
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getApplicationContextJsunit.test.ets
...ain/ets/default/test/getApplicationContextJsunit.test.ets
+46
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getHapModuleInfoJsunit.test.ets
...src/main/ets/default/test/getHapModuleInfoJsunit.test.ets
+132
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json
...etstest/entry/src/main/resources/base/element/string.json
+40
-0
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/media/icon.png
...nageretstest/entry/src/main/resources/base/media/icon.png
+0
-0
aafwk/aafwk_standard/actsabilitymanageretstest/signature/openharmony_sx.p7b
...rd/actsabilitymanageretstest/signature/openharmony_sx.p7b
+0
-0
appexecfwk/bundle_standard/bundlemanager/BUILD.gn
appexecfwk/bundle_standard/bundlemanager/BUILD.gn
+2
-1
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/BUILD.gn
..._standard/bundlemanager/actsbundlemanageretstest/BUILD.gn
+32
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json
...standard/bundlemanager/actsbundlemanageretstest/Test.json
+18
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json
...nager/actsbundlemanageretstest/entry/src/main/config.json
+85
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/app.ets
...ndlemanageretstest/entry/src/main/ets/MainAbility/app.ets
+23
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets
...geretstest/entry/src/main/ets/MainAbility/pages/index.ets
+83
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/second.ets
...eretstest/entry/src/main/ets/MainAbility/pages/second.ets
+44
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets
.../main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets
+236
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets
...rc/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets
+199
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets
...try/src/main/ets/MainAbility/test/GetabilityInfo.test.ets
+337
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets
...src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets
+313
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets
...main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets
+228
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets
...etstest/entry/src/main/ets/MainAbility/test/List.test.ets
+33
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets
...ageretstest/entry/src/main/ets/MainAbility/test/Utils.ets
+130
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets
...ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets
+403
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets
...in/ets/MainAbility/test/getApplicationInfoJsunit.test.ets
+590
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/ServiceAbility/service.ts
...nageretstest/entry/src/main/ets/ServiceAbility/service.ts
+11
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json
...etstest/entry/src/main/resources/base/element/string.json
+20
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/media/icon.png
...nageretstest/entry/src/main/resources/base/media/icon.png
+0
-0
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/signature/openharmony_sx.p7b
...ger/actsbundlemanageretstest/signature/openharmony_sx.p7b
+0
-0
未找到文件。
aafwk/aafwk_standard/BUILD.gn
浏览文件 @
28737d97
...
...
@@ -9,7 +9,7 @@
# 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.
# limitations under the License.
import("//build/ohos_var.gni")
...
...
@@ -20,6 +20,7 @@ group("aafwk_standard") {
"abilitymanager:actsabilitymanagertest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest",
"amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton",
"amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS",
...
...
@@ -51,7 +52,6 @@ group("aafwk_standard") {
"serviceability/stserviceabilityserver:amsStServiceAilityServer",
"serviceability/stserviceabilityserversecond:ActsAmsStServiceAilityServerSecondTest",
"setshowonlockscreen:setshowonlockscreen",
"stage:stage",
"want:want",
]
}
...
...
aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn
0 → 100644
浏览文件 @
28737d97
# 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("ActsAbilityManagerEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityManagerEtsTest"
}
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
aafwk/aafwk_standard/actsabilitymanageretstest/Test.json
0 → 100644
浏览文件 @
28737d97
{
"description"
:
"Configuration for aceceshi Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"600000"
,
"package"
:
"com.ohos.acecollaboration"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsAbilityManagerEtsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json
0 → 100644
浏览文件 @
28737d97
{
"app"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"vendor"
:
"ohos"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"com.ohos.acecollaboration"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"com.ohos.acecollaboration.MainAbility"
,
"deviceType"
:
[
"phone"
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO"
}
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"visible"
:
true
,
"srcPath"
:
"default"
,
"srcLanguage"
:
"ets"
,
"name"
:
"com.ohos.acecollaboration.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"launchType"
:
"standard"
},
{
"orientation"
:
"unspecified"
,
"srcPath"
:
"MainAbility2"
,
"name"
:
".MainAbility2"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:description_mainability2"
,
"formsEnabled"
:
false
,
"label"
:
"$string:entry_MainAbility2"
,
"type"
:
"page"
,
"launchType"
:
"standard"
},
{
"srcPath"
:
"ServiceAbility"
,
"name"
:
".ServiceAbility"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability"
,
"type"
:
"service"
},
{
"srcPath"
:
"ServiceAbility2"
,
"name"
:
".ServiceAbility2"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability2"
,
"type"
:
"service"
},
{
"srcPath"
:
"ServiceAbility3"
,
"name"
:
".ServiceAbility3"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability3"
,
"type"
:
"service"
},
{
"srcPath"
:
"ServiceAbility4"
,
"name"
:
".ServiceAbility4"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability4"
,
"type"
:
"service"
},
{
"srcPath"
:
"ServiceAbility5"
,
"name"
:
".ServiceAbility5"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability5"
,
"type"
:
"service"
}
],
"js"
:
[
{
"mode"
:
{
"syntax"
:
"ets"
,
"type"
:
"pageAbility"
},
"pages"
:
[
"pages/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
},
{
"mode"
:
{
"syntax"
:
"ets"
,
"type"
:
"pageAbility"
},
"pages"
:
[
"pages/index"
],
"name"
:
".MainAbility2"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
],
"defPermissions"
:
[
{
"name"
:
"com.ohos.acecollaboration.DataAbilityShellProvider.PROVIDER"
}
]
}
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/app.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/pages/index.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 featureAbility from "@ohos.ability.featureAbility";
import testsuite2 from "../test/List.test.ets";
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets";
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase2!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters2---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite2();
core.execute();
console.info('Operation successful2. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed2. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/List.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 getAbilityInfoJsunit from './getAbilityInfoJsunit2.test.ets';
export default function testsuite2() {
getAbilityInfoJsunit();
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/Utils.ets
0 → 100644
浏览文件 @
28737d97
// @ts-nocheck
/**
* 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.
*/
export default class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
/**
* 接口调用时间
* @param startTime 接口调用开始时间
* @param endTime 接口调用结束时间
*/
static getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAbilityInfo_test_0300
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0300', 0, async function (done) {
try{
console.info('[context_getAbilityInfo_test_0300] START2');
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo((error, data)=>{
var timeNewStamp= Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0300',timeOldStamp,timeNewStamp);
console.info('[context_getAbilityInfo_test_0300] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
} catch (error){
console.error('[context_getAbilityInfo_test_0300] failed: ' + JSON.stringify(error));
}
var callback = await context.getAbilityInfo();
console.info('---[context_getAbilityInfo_test_0300] check---');
checkAbilityInfo2('context_getAbilityInfo_test_0300',callback);
console.info('[context_getAbilityInfo_test_0300] FINISH');
done();
})
function checkAbilityInfo2(msg,data) {
console.log(msg+ "checkAbilityInfo2 start " + JSON.stringify(data));
console.log(msg+ "checkAbilityInfo2 bundleName : " + data.bundleName);
console.log(msg+ "checkAbilityInfo2 name : " + data.name);
console.log(msg+ "checkAbilityInfo2 label : " + data.label);
console.log(msg+ "checkAbilityInfo2 description : " + data.description);
console.log(msg+ "checkAbilityInfo2 icon : " + data.icon);
console.log(msg+ "checkAbilityInfo2 descriptionId : " + data.descriptionId);
console.log(msg+ "checkAbilityInfo2 iconId : " + data.iconId);
console.log(msg+ "checkAbilityInfo2 moduleName : " + data.moduleName);
console.log(msg+ "checkAbilityInfo2 process : " + data.process);
console.log(msg+ "checkAbilityInfo2 targetAbility : " + data.targetAbility);
console.log(msg+ "checkAbilityInfo2 backgroundModes : " + data.backgroundModes);
console.log(msg+ "checkAbilityInfo2 isVisible : " + data.isVisible);
console.log(msg+ "checkAbilityInfo2 formEnabled : " + data.formEnabled);
console.log(msg+ "checkAbilityInfo2 type : " + data.type)
console.log(msg+ "checkAbilityInfo2 orientation : " + data.orientation);
console.log(msg+ "checkAbilityInfo2 launchMode : " + data.launchMode);
console.log(msg+ "checkAbilityInfo2 permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log(msg+ "getAbilityInfo2 data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log(msg+ "checkAbilityInfo2 deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg+ "getAbilityInfo2 data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg+ "checkAbilityInfo2 deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log(msg+ "getAbilityInfo2 data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log(msg+ "checkAbilityInfo2 readPermission : " + data.readPermission);
console.log(msg+ "checkAbilityInfo2 writePermission : " + data.writePermission);
console.log(msg+ "checkAbilityInfo2 formEntity : " + data.formEntity);
console.log(msg+ "checkAbilityInfo2 minFormHeight : " + data.minFormHeight);
console.log(msg+ "checkAbilityInfo2 defaultFormHeight : " + data.defaultFormHeight);
console.log(msg+ "checkAbilityInfo2 minFormWidth : " + data.minFormWidth);
console.log(msg+ "checkAbilityInfo2 defaultFormWidth : " + data.defaultFormWidth);
console.log(msg+ "checkAbilityInfo2 uri : " + data.uri);
console.log(msg+ "checkAbilityInfo2 customizeData : " + data.customizeData);
console.log(msg+ "checkAbilityInfo2 labelId : " + data.labelId);
console.log(msg+ "checkAbilityInfo2 subType : " + data.subType);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.targetAbility)).assertEqual("string");
expect(typeof (data.backgroundModes)).assertEqual("number");
expect(typeof (data.isVisible)).assertEqual("boolean");
expect(typeof (data.formEnabled)).assertEqual("boolean");
expect(typeof (data.type)).assertEqual("number");
expect(typeof (data.subType)).assertEqual("number");
expect(typeof (data.orientation)).assertEqual("number");
expect(typeof (data.launchMode)).assertEqual("number");
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (data.readPermission)).assertEqual("string");
expect(typeof (data.writePermission)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (data.formEntity)).assertEqual("number");
expect(typeof (data.minFormHeight)).assertEqual("number");
expect(typeof (data.defaultFormHeight)).assertEqual("number");
expect(typeof (data.minFormWidth)).assertEqual("number");
expect(typeof (data.defaultFormWidth)).assertEqual("number");
expect(typeof (data.uri)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility2");
expect(data.label).assertEqual("$string:entry_MainAbility2");
expect(data.description).assertEqual("$string:description_mainability2");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(false);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo2(msg,data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId >0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg+ "---checkAbilityInfo End--- ");
}
function checkApplicationInfo2(msg,info) {
console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg+ "checkApplicationInfo name : " + info.name);
console.log(msg+ "checkApplicationInfo description : " + info.description);
console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg+ "checkApplicationInfo enabled : " + info.enabled);
console.log(msg+ "checkApplicationInfo label : " + info.label);
console.log(msg+ "checkApplicationInfo labelId : " + info.labelId);
console.log(msg+ "checkApplicationInfo icon : " + info.icon);
console.log(msg+ "checkApplicationInfo iconId : " + info.iconId);
console.log(msg+ "checkApplicationInfo process : " + info.process);
console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName);
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir);
}
console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
console.log(msg+ "---checkApplicationInfo End--- ");
}
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility/service.ts
0 → 100644
浏览文件 @
28737d97
/**
* 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
rpc
from
'
@ohos.rpc
'
;
class
StubTest
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
)
}
onRemoteRequest
(
code
,
data
,
reply
,
option
)
{
console
.
info
(
'
ServiceAbility onRemoteRequest
'
);
if
(
code
===
1
)
{
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
reply
.
writeInt
(
op1
+
op2
);
console
.
info
(
'
ServiceAbility op1:
'
+
op1
+
'
op2:
'
+
op2
);
}
return
true
;
}
}
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility onCommand
'
);
},
onConnect
(
want
)
{
console
.
info
(
'
ServiceAbility onConnect
'
);
return
new
StubTest
(
"
test
"
);
},
onDisConnect
(
want
)
{
console
.
info
(
'
ServiceAbility onDisConnect
'
);
},
};
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts
0 → 100644
浏览文件 @
28737d97
/**
* 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
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
rpc
from
'
@ohos.rpc
'
class
StubTest2
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
)
}
onRemoteRequest
(
code
,
data
,
reply
,
option
)
{
console
.
info
(
'
ServiceAbility2 onRemoteRequest
'
);
if
(
code
===
1
)
{
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
reply
.
writeInt
(
op1
+
op2
);
console
.
info
(
'
ServiceAbility2 op1:
'
+
op1
+
'
op2:
'
+
op2
);
}
return
true
;
}
}
async
function
sleep
(
time
:
any
)
{
var
now
=
new
Date
();
var
exitTime
=
now
.
getTime
()
+
time
;
while
(
true
)
{
now
=
new
Date
();
if
(
now
.
getTime
()
>
exitTime
)
break
;
}
console
.
info
(
`sleep
${
time
}
over...`
);
}
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility2 onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility2 onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility2 onCommand
'
);
let
request
=
{
"
bundleName
"
:
"
com.ohos.acecollaboration
"
,
"
abilityName
"
:
"
com.ohos.acecollaboration.ServiceAbility
"
,
}
let
options
=
{
onConnect
:
function
(
element
:
any
,
proxy
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.deviceId :
'
+
JSON
.
stringify
(
element
.
deviceId
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.bundleName :
'
+
JSON
.
stringify
(
element
.
bundleName
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.abilityName :
'
+
JSON
.
stringify
(
element
.
abilityName
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.uri :
'
+
JSON
.
stringify
(
element
.
uri
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.shortName :
'
+
JSON
.
stringify
(
element
.
shortName
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onConnect proxy :
'
+
JSON
.
stringify
(
proxy
));
},
onDisconnect
:
function
(
element1
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.deviceId :
'
+
JSON
.
stringify
(
element1
.
deviceId
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.bundleName :
'
+
JSON
.
stringify
(
element1
.
bundleName
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.abilityName:
'
+
JSON
.
stringify
(
element1
.
abilityName
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.uri :
'
+
JSON
.
stringify
(
element1
.
uri
));
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.shortName :
'
+
JSON
.
stringify
(
element1
.
shortName
));
},
onFailed
:
function
(
code
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0100 ConnectAbility onFailed errCode :
'
+
code
);
},
}
let
connection_succeeded
:
any
;
async
function
connectAbility_service
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0100 start
'
);
var
connection
=
particleAbility
.
connectAbility
(
request
,
options
);
connection_succeeded
=
connection
;
console
.
info
(
'
particleAbility_connectAbility_test_0100 service request is:
'
+
JSON
.
stringify
(
request
));
console
.
info
(
'
particleAbility_connectAbility_test_0100 options is:
'
+
JSON
.
stringify
(
options
));
console
.
info
(
'
particleAbility_connectAbility_test_0100 data is:
'
+
JSON
.
stringify
(
connection
));
console
.
info
(
'
particleAbility_connectAbility_test_0100 connection=:
'
+
connection
);
}
async
function
disconnectAbility_promise
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0100 disconnectability start
'
);
await
particleAbility
.
disconnectAbility
(
connection_succeeded
).
then
((
data
:
any
)
=>
{
console
.
info
(
'
particleAbility_connectAbility_test_0100 disconnectability succeeded:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
:
any
)
=>
{
console
.
error
(
'
particleAbility_connectAbility_test_0100 disconnectability failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
}
connectAbility_service
();
console
.
info
(
'
particleAbility_connectAbility_test_0100 sleep start
'
);
sleep
(
5000
);
console
.
info
(
'
particleAbility_connectAbility_test_0100 sleep flish
'
);
disconnectAbility_promise
();
},
onConnect
(
want
)
{
console
.
info
(
'
ServiceAbility2 onConnect
'
);
return
new
StubTest2
(
"
test
"
);
},
};
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts
0 → 100644
浏览文件 @
28737d97
/**
* 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
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
rpc
from
'
@ohos.rpc
'
;
class
StubTest3
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
)
}
onRemoteRequest
(
code
,
data
,
reply
,
option
)
{
console
.
info
(
'
ServiceAbility3 onRemoteRequest
'
);
if
(
code
===
1
)
{
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
reply
.
writeInt
(
op1
+
op2
);
console
.
info
(
'
ServiceAbility3 op1:
'
+
op1
+
'
op2:
'
+
op2
);
}
return
true
;
}
}
async
function
sleep
(
time
:
any
)
{
var
now
=
new
Date
();
var
exitTime
=
now
.
getTime
()
+
time
;
while
(
true
)
{
now
=
new
Date
();
if
(
now
.
getTime
()
>
exitTime
)
break
;
}
console
.
info
(
`sleep
${
time
}
over...`
);
}
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility3 onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility3 onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility3 onCommand
'
);
let
request
=
{
"
bundleName
"
:
"
com.ohos.acecollaboration
"
,
"
abilityName
"
:
"
com.ohos.acecollaboration.ServiceAbility
"
,
}
let
options
=
{
onConnect
:
async
function
(
element
:
any
,
proxy
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.deviceId :
'
+
JSON
.
stringify
(
element
.
deviceId
))
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.bundleName :
'
+
JSON
.
stringify
(
element
.
bundleName
))
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.abilityName :
'
+
JSON
.
stringify
(
element
.
abilityName
))
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.uri :
'
+
JSON
.
stringify
(
element
.
uri
))
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.shortName :
'
+
JSON
.
stringify
(
element
.
shortName
))
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onConnect proxy :
'
+
JSON
.
stringify
(
proxy
));
},
onDisconnect
:
function
(
element1
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.deviceId :
'
+
JSON
.
stringify
(
element1
.
deviceId
));
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.bundleName :
'
+
JSON
.
stringify
(
element1
.
bundleName
));
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.abilityName :
'
+
JSON
.
stringify
(
element1
.
abilityName
));
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.uri :
'
+
JSON
.
stringify
(
element1
.
uri
));
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.shortName :
'
+
JSON
.
stringify
(
element1
.
shortName
));
},
onFailed
:
function
(
code
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0200 ConnectAbility onFailed errCode:
'
+
code
)
},
}
let
connection_succeeded
:
any
;
async
function
connectAbility_service
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0200 start
'
);
var
connection
=
particleAbility
.
connectAbility
(
request
,
options
);
connection_succeeded
=
connection
;
console
.
info
(
'
particleAbility_connectAbility_test_0200 service request is:
'
+
JSON
.
stringify
(
request
));
console
.
info
(
'
particleAbility_connectAbility_test_0200 options is:
'
+
JSON
.
stringify
(
options
));
console
.
info
(
'
particleAbility_connectAbility_test_0200 data is:
'
+
JSON
.
stringify
(
connection
));
console
.
info
(
'
particleAbility_connectAbility_test_0200 connection=:
'
+
connection
);
}
async
function
disconnectAbility_callback
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0200 disconnectability start
'
);
particleAbility
.
disconnectAbility
(
connection_succeeded
).
then
((
data
:
any
)
=>
{
console
.
info
(
'
particleAbility_connectAbility_test_0200 disconnectability succeeded:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
:
any
)
=>
{
console
.
error
(
'
particleAbility_connectAbility_test_0200 disconnectability failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
}
connectAbility_service
();
sleep
(
5000
);
disconnectAbility_callback
();
sleep
(
5000
);
},
onConnect
(
want
)
{
console
.
info
(
'
ServiceAbility3 onConnect
'
);
return
new
StubTest3
(
"
test
"
);
},
};
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts
0 → 100644
浏览文件 @
28737d97
/**
* 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
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
rpc
from
'
@ohos.rpc
'
class
StubTest4
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
)
}
onRemoteRequest
(
code
,
data
,
reply
,
option
)
{
console
.
info
(
'
ServiceAbility4 onRemoteRequest
'
);
if
(
code
===
1
)
{
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
reply
.
writeInt
(
op1
+
op2
);
console
.
info
(
'
ServiceAbility4 op1:
'
+
op1
+
'
op2:
'
+
op2
);
}
return
true
;
}
}
async
function
sleep
(
time
:
any
)
{
var
now
=
new
Date
();
var
exitTime
=
now
.
getTime
()
+
time
;
while
(
true
)
{
now
=
new
Date
();
if
(
now
.
getTime
()
>
exitTime
)
break
;
}
console
.
info
(
`sleep
${
time
}
over...`
);
}
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility4 onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility4 onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility4 onCommand
'
);
let
request
=
{
"
bundleName
"
:
"
com.open.harmony.packagemag
"
,
"
abilityName
"
:
"
com.open.harmony.packagemag.packServiceAbility
"
,
}
let
options
=
{
onConnect
:
async
function
(
element
:
any
,
proxy
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility service onConnect element.deviceId :
'
+
JSON
.
stringify
(
element
.
deviceId
))
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.bundleName :
'
+
JSON
.
stringify
(
element
.
bundleName
))
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.abilityName :
'
+
JSON
.
stringify
(
element
.
abilityName
))
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.uri :
'
+
JSON
.
stringify
(
element
.
uri
))
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.shortName :
'
+
JSON
.
stringify
(
element
.
shortName
))
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onConnect proxy :
'
+
JSON
.
stringify
(
proxy
));
},
onDisconnect
:
function
(
element1
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.deviceId :
'
+
JSON
.
stringify
(
element1
.
deviceId
));
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.bundleName :
'
+
JSON
.
stringify
(
element1
.
bundleName
));
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.abilityName :
'
+
JSON
.
stringify
(
element1
.
abilityName
));
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.uri :
'
+
JSON
.
stringify
(
element1
.
uri
));
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.shortName :
'
+
JSON
.
stringify
(
element1
.
shortName
));
},
onFailed
:
function
(
code
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0300 ConnectAbility service onFailed errCode :
'
+
code
)
},
}
let
connection_succeeded
:
any
;
async
function
connectAbility_service
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0300 start
'
);
var
connection
=
particleAbility
.
connectAbility
(
request
,
options
);
connection_succeeded
=
connection
;
console
.
info
(
'
particleAbility_connectAbility_test_0300 service request is:
'
+
JSON
.
stringify
(
request
));
console
.
info
(
'
particleAbility_connectAbility_test_0300 options is:
'
+
JSON
.
stringify
(
options
));
console
.
info
(
'
particleAbility_connectAbility_test_0300 data is:
'
+
JSON
.
stringify
(
connection
));
console
.
info
(
'
particleAbility_connectAbility_test_0300 connection=:
'
+
connection
);
}
async
function
disconnectAbility_promise
()
{
try
{
console
.
info
(
'
particleAbility_connectAbility_test_0300 disconnectability start
'
);
await
particleAbility
.
disconnectAbility
(
connection_succeeded
).
then
((
data
:
any
)
=>
{
console
.
info
(
'
particleAbility_connectAbility_test_0300 disconnectability succeeded:
'
+
JSON
.
stringify
(
data
));
})
}
catch
(
error
:
any
)
{
console
.
error
(
'
particleAbility_connectAbility_test_0300 disconnectability failed. Cause:
'
+
JSON
.
stringify
(
error
));
}
}
connectAbility_service
();
sleep
(
5000
);
disconnectAbility_promise
();
sleep
(
5000
);
},
onConnect
(
want
)
{
console
.
info
(
'
ServiceAbility4 onConnect
'
);
return
new
StubTest4
(
"
test
"
);
},
};
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts
0 → 100644
浏览文件 @
28737d97
/**
* 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
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
rpc
from
'
@ohos.rpc
'
class
StubTest5
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
)
}
onRemoteRequest
(
code
,
data
,
reply
,
option
)
{
console
.
info
(
'
ServiceAbility5 onRemoteRequest
'
);
if
(
code
===
1
)
{
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
reply
.
writeInt
(
op1
+
op2
);
console
.
info
(
'
ServiceAbility5 op1:
'
+
op1
+
'
op2:
'
+
op2
);
}
return
true
;
}
}
async
function
sleep
(
time
:
any
)
{
var
now
=
new
Date
();
var
exitTime
=
now
.
getTime
()
+
time
;
while
(
true
)
{
now
=
new
Date
();
if
(
now
.
getTime
()
>
exitTime
)
break
;
}
console
.
info
(
`sleep
${
time
}
over...`
);
}
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility5 onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility5 onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility5 onCommand
'
);
let
request
=
{
"
bundleName
"
:
""
,
"
abilityName
"
:
""
,
}
let
options
=
{
onConnect
:
async
function
(
element
:
any
,
proxy
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.deviceId :
'
+
JSON
.
stringify
(
element
.
deviceId
))
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.bundleName :
'
+
JSON
.
stringify
(
element
.
bundleName
))
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.abilityName :
'
+
JSON
.
stringify
(
element
.
abilityName
))
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.uri :
'
+
JSON
.
stringify
(
element
.
uri
))
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.shortName :
'
+
JSON
.
stringify
(
element
.
shortName
))
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onConnect proxy :
'
+
JSON
.
stringify
(
proxy
));
},
onDisconnect
:
function
(
element1
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.deviceId :
'
+
JSON
.
stringify
(
element1
.
deviceId
));
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.bundleName:
'
+
JSON
.
stringify
(
element1
.
bundleName
));
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.abilityName:
'
+
JSON
.
stringify
(
element1
.
abilityName
));
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.uri :
'
+
JSON
.
stringify
(
element1
.
uri
));
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.shortName :
'
+
JSON
.
stringify
(
element1
.
shortName
));
},
onFailed
:
function
(
code
:
any
)
{
console
.
log
(
'
particleAbility_connectAbility_test_0400 ConnectAbility service onFailed errCode:
'
+
code
)
},
}
let
connection_succeeded
:
any
;
async
function
connectAbility_service
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0400 start
'
);
var
connection
=
particleAbility
.
connectAbility
(
request
,
options
);
connection_succeeded
=
connection
;
console
.
info
(
'
particleAbility_connectAbility_test_0400 service request is:
'
+
JSON
.
stringify
(
request
));
console
.
info
(
'
particleAbility_connectAbility_test_0400 options is:
'
+
JSON
.
stringify
(
options
));
console
.
info
(
'
particleAbility_connectAbility_test_0400 data is:
'
+
JSON
.
stringify
(
connection
));
console
.
info
(
'
particleAbility_connectAbility_test_0400 connection=:
'
+
connection
);
}
async
function
disconnectAbility_promise
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0400 disconnectability start
'
);
await
particleAbility
.
disconnectAbility
(
connection_succeeded
).
then
((
data
:
any
)
=>
{
console
.
info
(
'
particleAbility_connectAbility_test_0400 disconnectability succeeded:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
:
any
)
=>
{
console
.
error
(
'
particleAbility_connectAbility_test_0400 disconnectability failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
}
async
function
disconnectAbility_fail
()
{
console
.
info
(
'
particleAbility_connectAbility_test_0400 disconnectability_fail start
'
);
try
{
await
particleAbility
.
disconnectAbility
(
-
1
).
then
((
data
:
any
)
=>
{
console
.
info
(
'
particleAbility_connectAbility_test_0400 disconnectability_fail succeeded:
'
+
JSON
.
stringify
(
data
));
})
}
catch
(
error
:
any
)
{
console
.
error
(
'
particleAbility_connectAbility_test_0400 disconnectability_fail failed. Cause:
'
+
JSON
.
stringify
(
error
));
}
}
connectAbility_service
();
sleep
(
5000
);
disconnectAbility_promise
();
sleep
(
5000
);
disconnectAbility_fail
();
},
onConnect
(
want
)
{
console
.
info
(
'
ServiceAbility5 onConnect
'
);
return
new
StubTest5
(
"
test
"
);
},
};
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/app.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/pages/index.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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
file
from
'@system.file'
;
import
{
Core
,
ExpectExtend
,
ReportExtend
}
from
"deccjsunit/index.ets"
;
import
testsuite
from
"../test/List.test.ets"
;
import
featureAbility
from
"@ohos.ability.featureAbility"
;
async
function
startService2
()
{
var
str
=
{
"want"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"abilityName"
:
"com.ohos.acecollaboration.ServiceAbility2"
,
},
};
var
data
=
featureAbility
.
startAbility
(
str
);
console
.
info
(
'particleAbility_connectAbility_test_0100 startAbility succeeded: '
+
JSON
.
stringify
(
data
));
}
async
function
startService3
()
{
var
str
=
{
"want"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"abilityName"
:
"com.ohos.acecollaboration.ServiceAbility3"
,
},
};
var
data
=
featureAbility
.
startAbility
(
str
);
console
.
info
(
'particleAbility_connectAbility_test_0200 startAbility succeeded: '
+
JSON
.
stringify
(
data
));
}
async
function
startService4
()
{
var
str
=
{
"want"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"abilityName"
:
"com.ohos.acecollaboration.ServiceAbility4"
,
},
};
var
data
=
featureAbility
.
startAbility
(
str
);
console
.
info
(
'particleAbility_connectAbility_test_0300 startAbility succeeded: '
+
JSON
.
stringify
(
data
));
}
async
function
startService5
()
{
var
str
=
{
"want"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"abilityName"
:
"com.ohos.acecollaboration.ServiceAbility5"
,
},
};
var
data
=
featureAbility
.
startAbility
(
str
);
console
.
info
(
'particleAbility_connectAbility_test_0400 startAbility succeeded: '
+
JSON
.
stringify
(
data
));
}
@
Entry
@
Component
struct
MyComponent
{
aboutToAppear
()
{
console
.
info
(
"start run testcase!!!!"
)
featureAbility
.
getWant
()
.
then
((
Want
)
=>
{
const
core
=
Core
.
getInstance
();
const
expectExtend
=
new
ExpectExtend
({
'id'
:
'extend'
});
core
.
addService
(
'expect'
,
expectExtend
);
const
reportExtend
=
new
ReportExtend
(
file
);
core
.
addService
(
'report'
,
reportExtend
);
core
.
init
();
core
.
subscribeEvent
(
'task'
,
reportExtend
);
const
configService
=
core
.
getDefaultService
(
'config'
);
console
.
info
(
'parameters---->'
+
JSON
.
stringify
(
Want
.
parameters
));
configService
.
setConfig
(
Want
.
parameters
);
testsuite
();
core
.
execute
();
console
.
info
(
'Operation successful. Data: '
+
JSON
.
stringify
(
Want
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'Operation failed. Cause: '
+
JSON
.
stringify
(
error
));
})
}
build
()
{
Flex
({
direction
:
FlexDirection
.
Column
,
alignItems
:
ItemAlign
.
Center
,
justifyContent
:
FlexAlign
.
Center
})
{
Text
(
'ACE ETS TEST 组件协同'
)
.
fontSize
(
50
)
.
fontWeight
(
FontWeight
.
Bold
)
Button
(
'disconnectAbility_promise'
)
.
fontSize
(
40
)
.
height
(
40
)
.
margin
({
top
:
20
})
.
fontWeight
(
FontWeight
.
Bold
)
.
onClick
(()
=>
{
startService2
();
});
Button
(
'disconnectAbility_callback'
)
.
fontSize
(
40
)
.
height
(
40
)
.
margin
({
top
:
20
})
.
fontWeight
(
FontWeight
.
Bold
)
.
onClick
(()
=>
{
startService3
();
});
Button
(
'connectotherAbility'
)
.
fontSize
(
40
)
.
height
(
40
)
.
margin
({
top
:
20
})
.
fontWeight
(
FontWeight
.
Bold
)
.
onClick
(()
=>
{
startService4
();
});
Button
(
'connectnull'
)
.
fontSize
(
40
)
.
height
(
40
)
.
margin
({
top
:
20
})
.
fontWeight
(
FontWeight
.
Bold
)
.
onClick
(()
=>
{
startService5
();
});
}
.
width
(
'100%'
)
.
height
(
'100%'
)
}
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/ContextJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
export default function contextJsunit() {
describe('appInfoTest', function () {
beforeEach(async function (done) {
console.info("context before each called");
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info("context after each called");
});
/*
* @tc.number: context_getCacheDir_test_0100
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getCacheDir_test_0100", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0100: CacheDir is " + data);
})
} catch (error) {
console.log("logMessage context_getCacheDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0100-------------------");
});
/*
* @tc.number: context_getCacheDir_test_0200
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getCacheDir_test_0200", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0200: getCacheDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getCacheDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0200-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0100
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getFilesDir_test_0100", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0100:FilesDir is " + data);
})
} catch (error) {
console.log("logMessage context_getFilesDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0100-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0200
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getFilesDir_test_0200", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0200: getFilesDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getFilesDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0200-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_test_0100
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0100", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0100', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0100: DistributedDir is " + data);
})
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0100: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributed/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributed/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0100-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_0200
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0200", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0200', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0200: getOrCreateDistributedDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0200: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributed/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributed/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0200-------------------");
});
/*
* @tc.number: context_getAppType_0100
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getAppType_0100", 0, async function (done) {
console.log("------------------start context_getAppType_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0100_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0100: AppType is " + data);
})
} catch (error) {
console.log("logMessage context_getAppType_0100: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0100-------------------");
});
/*
* @tc.number: context_getAppType_0200
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getAppType_0200", 0, async function (done) {
console.log("------------------start context_getAppType_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0200_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0200: getAppType successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getAppType_0200: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0200-------------------");
});
})
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/DataAbility.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 featureAbility from '@ohos.ability.featureAbility'
import {describe, expect, it} from 'deccjsunit/index.ets'
const URI_CONTACTS = 'dataability:///com.ohos.contactsdataability';
const contactUri = 'dataability:///com.ohos.contactsdataability/contacts/groups';
const INSERT_ONE = 'dataAbility_insert_test ';
const QUERY_TWO = 'dataAbility_query_test ';
const UPDATE_THREE = 'dataAbility_update_test ';
const DELETE_FOUR = 'dataAbility_delete_test ';
export default function dataAbilityHelperJsunit() {
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS);
var pacMap = {
'group_name': 'test1',
'ringtone_modify_time': 28
};
var pacMap_3 = {
'group_name': 'test3',
'ringtone_modify_time': 20
};
var pacMap_4 = {
'group_name': 'test4',
'ringtone_modify_time': 40
};
describe('appInfoTest', function () {
console.log('-----------------------ScreenlockTest is starting-----------------------');
function sleep(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
/*
* @tc.number: dataAbility_insert_test_001
* @tc.name: call : Inserts a single data record into the database.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(INSERT_ONE + '001', 0, async function (done) {
console.log(INSERT_ONE + '001 start......');
dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => {
if (err) {
console.error(INSERT_ONE + '001 error: ' + JSON.stringify(err));
return;
}
console.info(INSERT_ONE + '001 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("number");
expect(data.result > 0).assertTrue();
});
done();
console.log(INSERT_ONE + '001 end ......');
});
/*
* @tc.number: dataAbility_insert_test_002
* @tc.name: call : Inserts a single data record into the database.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(INSERT_ONE + '002', 0, async function (done) {
console.log(INSERT_ONE + '002 start......');
pacMap.group_name = 'test2';
dataAbilityHelper.call(contactUri, 'insert', '', pacMap).then((data) => {
console.info(INSERT_ONE + '002 succeeded data: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("number");
expect(data.result > 0).assertTrue();
}).catch((error) => {
console.error(INSERT_ONE + '002 error: ' + JSON.stringify(error));
});
done();
console.log(INSERT_ONE + '002 end......');
});
/*
* @tc.number: dataAbility_query_test_001
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(QUERY_TWO + '001', 0, async function (done) {
console.log(QUERY_TWO + '001 start......');
let arg = "{\"equalTo\": \"group_name\"}";
let pacMap = {
"group_name": "test1",
"columns": "group_name,ringtone_modify_time"
};
dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error(QUERY_TWO + '001 error: ' + JSON.stringify(err));
return;
}
console.info(QUERY_TWO + '001 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("string");
});
done();
console.log(QUERY_TWO + '001 end......');
});
/*
* @tc.number: dataAbility_query_test_002
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(QUERY_TWO + '002', 0, async function (done) {
console.log(QUERY_TWO + '002 start......');
let arg = "{\"between\": \"ringtone_modify_time\"}";
let pacMap = {
'ringtone_modify_time': "15, 30",
"columns": "group_name,ringtone_modify_time"
};
dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error(QUERY_TWO + '002 error: ' + JSON.stringify(err));
return;
}
console.info(QUERY_TWO + '002 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("string");
});
done();
console.log(QUERY_TWO + '002 end......');
});
/*
* @tc.number: dataAbility_query_test_003
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(QUERY_TWO + '003', 0, async function (done) {
console.log(QUERY_TWO + '003 start......');
let arg = {
'like': 'group_name'
};
let pacMap = {
'group_name': '%test3%',
'columns': 'group_name,ringtone_modify_time'
};
dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error(QUERY_TWO + '003 error: ' + JSON.stringify(err));
return;
}
console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual('object');
expect(typeof (data.result)).assertEqual('string');
});
done();
console.log(QUERY_TWO + '003 end......');
});
/*
* @tc.number: dataAbility_query_test_004
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(QUERY_TWO + '004', 0, async function (done) {
console.log(QUERY_TWO + '004 start......');
let arg = {
'greaterThanOrEqualTo': 'ringtone_modify_time'
};
let pacMap = {
'ringtone_modify_time': 40,
'columns': 'group_name,ringtone_modify_time'
};
dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error(QUERY_TWO + '004 error: ' + JSON.stringify(err));
return;
}
console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual('object');
expect(typeof (data.result)).assertEqual('string');
});
done();
console.log(QUERY_TWO + '003 end......');
});
/*
* @tc.number: dataAbility_update_test_001
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(UPDATE_THREE + '001', 0, async function (done) {
console.log(UPDATE_THREE + '001 start......');
let arg = "{\"equalTo\": \"ringtone_modify_time\"}";
let pacMap = {
'ringtone_modify_time': 28,
'group_name': 'testupdata1'
};
dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error(UPDATE_THREE + '001 error: ' + JSON.stringify(err));
return;
}
console.info(UPDATE_THREE + '001 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("number");
expect(data.result).assertEqual(0);
});
done();
console.log(UPDATE_THREE + '001 end......');
});
/*
* @tc.number: dataAbility_update_test_002
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(UPDATE_THREE + '002', 0, async function (done) {
console.log(UPDATE_THREE + '002 start......');
let arg = "{\"between\": \"ringtone_modify_time\"}";
let pacMap = {
'ringtone_modify_time': "15, 30",
'group_name': 'testupdata2'
};
dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error(UPDATE_THREE + '002 error: ' + JSON.stringify(err));
return;
}
console.info(UPDATE_THREE + '002 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("number");
expect(data.result).assertEqual(0);
});
done();
console.log(UPDATE_THREE + '002 end......');
});
/*
* @tc.number: dataAbility_update_test_003
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(UPDATE_THREE + '003', 0, async function (done) {
console.log(UPDATE_THREE + '003 start......');
let arg = {
'contains': 'group_name'
};
let pacMap = {
'group_name': 'ata2',
'ringtone_modify_time': 100
};
dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error(UPDATE_THREE + '003 error: ' + JSON.stringify(err));
return;
}
console.info(UPDATE_THREE + '003 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual('object');
expect(typeof (data.result)).assertEqual('number');
expect(data.result).assertEqual(0);
});
done();
console.log(UPDATE_THREE + '003 end......');
});
/*
* @tc.number: dataAbility_update_test_004
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(UPDATE_THREE + '004', 0, async function (done) {
console.log(UPDATE_THREE + '004 start......');
let arg = {
'lessThan': 'ringtone_modify_time'
};
let pacMap = {
'ringtone_modify_time': 32,
'group_name': 'testupdata2'
};
dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error(UPDATE_THREE + '004 error: ' + JSON.stringify(err));
return;
}
console.info(UPDATE_THREE + '004 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual('object');
expect(typeof (data.result)).assertEqual('number');
expect(data.result).assertEqual(0);
});
done();
console.log(UPDATE_THREE + '004 end......');
});
/*
* @tc.number: dataAbility_delete_test_001
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
//insert one record1
dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => {
if (err) {
console.error('Operation failed1. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation succeeded1: ' + JSON.stringify(data));
});
it(DELETE_FOUR + '001', 0, async function (done) {
console.log(DELETE_FOUR + '001 start......');
let arg2 = "{\"equalTo\": \"group_name\"}";
let pacMap2 = {
'group_name': 'test1'
};
dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => {
if (err2) {
console.error(DELETE_FOUR + '001 error: ' + JSON.stringify(err2));
return;
}
console.info(DELETE_FOUR + '001 succeeded: ' + JSON.stringify(data2));
expect(typeof (data2)).assertEqual("object");
expect(typeof (data2.result)).assertEqual("number");
expect(data2.result).assertEqual(0);
});
done();
console.log(DELETE_FOUR + '001 end......');
});
/*
* @tc.number: dataAbility_delete_test_002
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it(DELETE_FOUR + '002', 0, async function (done) {
console.log(DELETE_FOUR + '002 start......');
let arg = "{\"lessThan\": \"ringtone_modify_time\"}";
let pacMap = {
'ringtone_modify_time': 32,
};
dataAbilityHelper.call(contactUri, 'delete', arg, pacMap, (err, data) => {
if (err) {
console.error(DELETE_FOUR + '002 error: ' + JSON.stringify(err));
return;
}
console.info(DELETE_FOUR + '002 succeeded: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(typeof (data.result)).assertEqual("number");
expect(data.result).assertEqual(0);
});
done();
console.log(DELETE_FOUR + '002 end......');
});
/*
* @tc.number: dataAbility_delete_test_003
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
//insert one record3
dataAbilityHelper.call(contactUri, 'insert', '', pacMap_3, (err, data) => {
if (err) {
console.error('Operation failed3. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation succeeded3: ' + JSON.stringify(data));
});
it(DELETE_FOUR + '003', 0, async function (done) {
console.log(DELETE_FOUR + '003 start......');
let arg2 = {
'like': 'group_name'
};
let pacMap2 = {
'group_name': '%test3%'
};
dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => {
if (err2) {
console.error(DELETE_FOUR + '003 error: ' + JSON.stringify(err2));
return;
}
console.info(DELETE_FOUR + '003 delete succeeded: ' + JSON.stringify(data2));
expect(typeof (data2)).assertEqual('object');
expect(typeof (data2.result)).assertEqual('number');
expect(data2.result).assertEqual(0);
});
done();
console.log(DELETE_FOUR + '003 delete end......');
});
/*
* @tc.number: dataAbility_delete_test_004
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
//insert one record4
dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => {
if (err) {
console.error('Operation failed4. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation succeeded4: ' + JSON.stringify(data));
});
it(DELETE_FOUR + '004', 0, async function (done) {
console.log(DELETE_FOUR + '004 start......');
let arg2 = {
'greaterThanOrEqualTo': 'ringtone_modify_time'
};
let pacMap2 = {
'ringtone_modify_time': 40
};
dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => {
if (err2) {
console.error(DELETE_FOUR + '004 error: ' + JSON.stringify(err2));
return;
}
console.info(DELETE_FOUR + '004 delete succeeded: ' + JSON.stringify(data2));
expect(typeof (data2)).assertEqual('object');
expect(typeof (data2.result)).assertEqual('number');
expect(data2.result).assertEqual(0);
});
done();
console.log(DELETE_FOUR + '004 delete end......');
});
})
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/List.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 addContextAndAbilityJsunit from './addContextAndAbilityJsunit.test.ets';
import getHapModuleInfoJsunit from './getHapModuleInfoJsunit.test.ets';
import getAbilityInfoJsunit from './getAbilityInfoJsunit.test.ets';
import getApplicationContext from './getApplicationContextJsunit.test.ets';
import getAppVersionInfoJsunit from './getAppVersionInfoJsunit.test.ets';
import ContextJsunit from './ContextJsunit.test.ets';
import dataAbilityHelperJsunit from './DataAbility.test.ets';
export default function testsuite() {
addContextAndAbilityJsunit();
getHapModuleInfoJsunit();
getAbilityInfoJsunit();
getApplicationContext();
getAppVersionInfoJsunit();
ContextJsunit();
dataAbilityHelperJsunit();
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/Utils.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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.
*/
export default class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(reject)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
/**
* 接口调用时间
* @param startTime 接口调用开始时间
* @param endTime 接口调用结束时间
*/
static getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
}
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/addContextAndAbilityJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
import abilitymanager from "@ohos.app.abilitymanager"
const TAG_TEST_0100 = ' context_isUpdatingConfigurations_test_0100 ';
const TAG_TEST_0200 = ' context_isUpdatingConfigurations_test_0200 ';
const TAG_TEST_0300 = ' context_printDrawnCompleted_test_0100 ';
const TAG_TEST_0400 = ' context_printDrawnCompleted_test_0200 ';
const TAG_TEST_0500 = ' context_getAppMemorySize_test_0100 ';
const TAG_TEST_0600 = ' context_getAppMemorySize_test_0200 ';
const TAG_TEST_0700 = ' context_isRamConstrainedDevice_test_0100 ';
const TAG_TEST_0800 = ' context_isRamConstrainedDevice_test_0200 ';
export default function addContextAndAbilityJsunit() {
describe('appInfoTest', function () {
/*
* @tc.number: context_isUpdatingConfigurations_test_0100
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0100, 0, async function (done) {
console.info(TAG_TEST_0100 + 'promise START');
let datas;
let errors;
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.isUpdatingConfigurations()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100, startTime, endTime)
console.info(TAG_TEST_0100 + ' promise in');
console.info(TAG_TEST_0100 + ' promise data is:' + JSON.stringify(data));
datas = data;
expect(typeof (datas)).assertEqual("boolean");
expect(datas).assertEqual(false);
}).catch((error) => {
console.error(TAG_TEST_0100 + 'promise errors is: ' + JSON.stringify(error));
errors = error;
})
console.info(TAG_TEST_0100 + ' promise datas is:' + JSON.stringify(datas));
console.info(TAG_TEST_0100 + ' promise errors is:' + errors);
done();
console.log('------------------ ' + TAG_TEST_0100 + ' end -------------------');
});
/*
* @tc.number: context_isUpdatingConfigurations_test_0200
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0200, 0, async function (done) {
console.info(TAG_TEST_0200 + 'callBack START');
let datas;
let errors;
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.isUpdatingConfigurations((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200, startTime, endTime)
console.info(TAG_TEST_0200 + ' callBack in');
console.info(TAG_TEST_0200 + ' callBack data is:' + JSON.stringify(data));
datas = data;
expect(typeof (datas)).assertEqual("boolean");
expect(datas).assertEqual(false);
})
await Utils.sleep(2000);
console.info(TAG_TEST_0200 + ' callBack datas is:' + JSON.stringify(datas));
console.info(TAG_TEST_0200 + ' callBack errors is:' + errors);
done();
console.log('------------------ ' + TAG_TEST_0200 + ' end -------------------');
});
/*
* @tc.number: context_printDrawnCompleted_test_0100
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page capability.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0300, 0, async function (done) {
console.info(TAG_TEST_0300 + 'callBack START');
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.printDrawnCompleted()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
console.info(TAG_TEST_0300 + ' promise in');
console.info(TAG_TEST_0300 + ' promise data is:' + JSON.stringify(data));
}).catch((error) => {
console.error(TAG_TEST_0300 + 'promise error is: ' + JSON.stringify(error));
});
done();
console.log('------------------ ' + TAG_TEST_0300 + ' end -------------------');
})
/*
* @tc.number: context_printDrawnCompleted_test_0200
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page capability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0400, 0, async function (done) {
console.info(TAG_TEST_0400 + 'callBack START');
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.printDrawnCompleted((error, data) => {
if (error) {
console.error('[TAG_TEST_0400]Operation failed. Cause: ' + JSON.stringify(error));
return;
}
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
console.info(TAG_TEST_0400 + ' callBack error is:' + error);
console.info(TAG_TEST_0400 + ' callBack data is:' + JSON.stringify(data));
done();
})
console.log('------------------ ' + TAG_TEST_0400 + ' end -------------------');
})
/*
* @tc.number: context_getAppMemorySize_test_0100
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500, 0, async function (done) {
console.info(TAG_TEST_0500 + 'promise START');
let datas;
let errors;
var startTime = await Utils.getNowTime();
await abilitymanager.getAppMemorySize()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0500 + ' promise in');
console.info(TAG_TEST_0500 + ' promise data is:' + JSON.stringify(data));
datas = data;
expect(typeof (datas)).assertEqual("number");
expect(datas).assertEqual(512); //TODO:
}).catch((error) => {
console.error(TAG_TEST_0500 + 'promise errors is: ' + JSON.stringify(error));
errors = error;
})
console.info(TAG_TEST_0500 + ' promise datas is:' + JSON.stringify(datas));
console.info(TAG_TEST_0500 + ' promise errors is:' + errors);
done();
console.log('------------------ ' + TAG_TEST_0500 + ' end -------------------');
});
/*
* @tc.number: context_getAppMemorySize_test_0200
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0600, 0, async function (done) {
console.info(TAG_TEST_0600 + 'callBack START');
var startTime = await Utils.getNowTime();
abilitymanager.getAppMemorySize((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0600 + ' callBack error is: ' + JSON.stringify(error));
console.info(TAG_TEST_0600 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("number");
expect(data).assertEqual(512); //TODO:
console.log('------------------ ' + TAG_TEST_0600 + ' end -------------------');
done();
})
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0100
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0700, 0, async function (done) {
console.info(TAG_TEST_0700 + 'promise START');
var startTime = await Utils.getNowTime();
await abilitymanager.isRamConstrainedDevice()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0700 + ' promise in');
console.info(TAG_TEST_0700 + ' promise data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("boolean");
expect(data).assertEqual(false);
}).catch((error) => {
console.error(TAG_TEST_0700 + 'promise errors is: ' + JSON.stringify(error));
})
done();
console.log('------------------ ' + TAG_TEST_0700 + ' end -------------------');
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0200
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0800, 0, async function (done) {
console.info(TAG_TEST_0800 + 'callBack START');
var startTime = await Utils.getNowTime();
abilitymanager.isRamConstrainedDevice((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0800 + ' callBack error is:' + error);
console.info(TAG_TEST_0800 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("boolean");
expect(data).assertEqual(false);
done();
})
console.log('------------------ ' + TAG_TEST_0800 + ' end -------------------');
});
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getAbilityInfoJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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
{
describe
,
it
,
expect
}
from
"deccjsunit/index.ets"
;
import
Utils
from
'./Utils'
;
import
ability_featureAbility
from
'@ohos.ability.featureAbility'
;
export
default
function
getHapModuleInfoJsunit
()
{
describe
(
'appInfoTest'
,
function
()
{
/**
* @tc.number: context_getAbilityInfo_test_0100
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it
(
'context_getAbilityInfo_test_0100'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[context_getAbilityInfo_test_0100] START'
);
await
Utils
.
sleep
(
1000
);
var
timeOldStamp
=
await
Utils
.
getNowTime
();
var
context
=
ability_featureAbility
.
getContext
();
await
context
.
getAbilityInfo
()
.
then
((
data
)
=>
{
var
timeNewStamp
=
Utils
.
getNowTime
();
Utils
.
getDurationTime
(
'context_getAbilityInfo_test_0100'
,
timeOldStamp
,
timeNewStamp
);
console
.
info
(
'[context_getAbilityInfo_test_0100] data is:'
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
))
.
assertEqual
(
"object"
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'[context_getAbilityInfo_test_0100] failed:'
+
JSON
.
stringify
(
error
));
})
var
promise
=
await
context
.
getAbilityInfo
();
console
.
info
(
'--[context_getAbilityInfo_test_0100] check---'
);
checkAbilityInfo
(
'context_getAbilityInfo_test_0100'
,
promise
);
console
.
info
(
'[context_getAbilityInfo_test_0100] FINISH'
);
done
();
});
async
function
startAbility2
()
{
var
str
=
{
"want"
:
{
"bundleName"
:
"com.ohos.acecollaboration"
,
"abilityName"
:
"com.ohos.acecollaboration.MainAbility2"
,
},
};
ability_featureAbility
.
startAbility
(
str
)
.
then
((
data
)
=>
{
console
.
info
(
'context_getAbilityInfo_test_0300 startMainAbility2 succeeded: '
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'context_getAbilityInfo_test_0300 startMainAbility2 failed. Cause: '
+
JSON
.
stringify
(
error
));
});
}
/**
* @tc.number: context_getAbilityInfo_test_0200
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it
(
'context_getAbilityInfo_test_0200'
,
0
,
async
function
(
done
)
{
try
{
console
.
info
(
'[context_getAbilityInfo_test_0200] START'
);
await
Utils
.
sleep
(
1000
);
var
timeOldStamp
=
await
Utils
.
getNowTime
();
var
context
=
ability_featureAbility
.
getContext
();
context
.
getAbilityInfo
((
error
,
data
)
=>
{
var
timeNewStamp
=
Utils
.
getNowTime
();
Utils
.
getDurationTime
(
'context_getAbilityInfo_test_0200'
,
timeOldStamp
,
timeNewStamp
);
console
.
info
(
'[context_getAbilityInfo_test_0200] data is:'
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
))
.
assertEqual
(
"object"
);
});
}
catch
(
error
)
{
console
.
error
(
'[context_getAbilityInfo_test_0200] failed: '
+
JSON
.
stringify
(
error
));
}
var
callback
=
await
context
.
getAbilityInfo
();
console
.
info
(
'---[context_getAbilityInfo_test_0200] check---'
);
checkAbilityInfo
(
'context_getAbilityInfo_test_0200'
,
callback
);
console
.
info
(
'[context_getAbilityInfo_test_0200] FINISH'
);
done
();
})
/**
* @tc.number: context_getAbilityInfo_test_0300_1
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it
(
'context_getAbilityInfo_test_0300_1'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[context_getAbilityInfo_test_0300] STARTability'
);
startAbility2
();
done
();
});
/**
* @tc.number: context_getAbilityInfo_test_0400
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it
(
'context_getAbilityInfo_test_0400'
,
0
,
async
function
(
done
)
{
console
.
info
(
'[context_getAbilityInfo_test_0400] START'
);
await
Utils
.
sleep
(
1000
);
var
timeOldStamp
=
await
Utils
.
getNowTime
();
var
context
=
ability_featureAbility
.
getContext
();
await
context
.
getAbilityInfo
()
.
then
((
data
)
=>
{
var
timeNewStamp
=
Utils
.
getNowTime
();
Utils
.
getDurationTime
(
'context_getAbilityInfo_test_0400'
,
timeOldStamp
,
timeNewStamp
);
console
.
info
(
'[context_getAbilityInfo_test_0400] data is:'
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
))
.
assertEqual
(
"object"
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'[context_getAbilityInfo_test_0400] failed:'
+
JSON
.
stringify
(
error
));
})
var
promise
=
await
context
.
getAbilityInfo
();
console
.
info
(
'--[context_getAbilityInfo_test_0400] check---'
);
checkAbilityInfo
(
'context_getAbilityInfo_test_0400'
,
promise
);
console
.
info
(
'[context_getAbilityInfo_test_0400] FINISH'
);
done
();
});
function
checkAbilityInfo
(
msg
,
data
)
{
console
.
log
(
msg
+
"checkAbilityInfo start "
+
JSON
.
stringify
(
data
));
console
.
log
(
msg
+
"checkAbilityInfo bundleName : "
+
data
.
bundleName
);
console
.
log
(
msg
+
"checkAbilityInfo name : "
+
data
.
name
);
console
.
log
(
msg
+
"checkAbilityInfo label : "
+
data
.
label
);
console
.
log
(
msg
+
"checkAbilityInfo description : "
+
data
.
description
);
console
.
log
(
msg
+
"checkAbilityInfo icon : "
+
data
.
icon
);
console
.
log
(
msg
+
"checkAbilityInfo descriptionId : "
+
data
.
descriptionId
);
console
.
log
(
msg
+
"checkAbilityInfo iconId : "
+
data
.
iconId
);
console
.
log
(
msg
+
"checkAbilityInfo moduleName : "
+
data
.
moduleName
);
console
.
log
(
msg
+
"checkAbilityInfo process : "
+
data
.
process
);
console
.
log
(
msg
+
"checkAbilityInfo targetAbility : "
+
data
.
targetAbility
);
console
.
log
(
msg
+
"checkAbilityInfo backgroundModes : "
+
data
.
backgroundModes
);
console
.
log
(
msg
+
"checkAbilityInfo isVisible : "
+
data
.
isVisible
);
console
.
log
(
msg
+
"checkAbilityInfo formEnabled : "
+
data
.
formEnabled
);
console
.
log
(
msg
+
"checkAbilityInfo type : "
+
data
.
type
)
console
.
log
(
msg
+
"checkAbilityInfo orientation : "
+
data
.
orientation
);
console
.
log
(
msg
+
"checkAbilityInfo launchMode : "
+
data
.
launchMode
);
console
.
log
(
msg
+
"checkAbilityInfo permissions length : "
+
data
.
permissions
.
length
);
for
(
var
j
=
0
;
j
<
data
.
permissions
.
length
;
j
++
)
{
console
.
log
(
msg
+
"getAbilityInfo data.permissions["
+
j
+
"] : "
+
data
.
permissions
[
j
]);
}
console
.
log
(
msg
+
"checkAbilityInfo deviceTypes length : "
+
data
.
deviceTypes
.
length
);
for
(
var
k
=
0
;
k
<
data
.
deviceTypes
.
length
;
k
++
)
{
console
.
log
(
msg
+
"getAbilityInfo data.deviceTypes["
+
k
+
"] : "
+
data
.
deviceTypes
[
k
]);
}
console
.
log
(
msg
+
"checkAbilityInfo deviceCapabilities length : "
+
data
.
deviceCapabilities
.
length
);
for
(
var
i
=
0
;
i
<
data
.
deviceCapabilities
.
length
;
i
++
)
{
console
.
log
(
msg
+
"getAbilityInfo data.deviceCapabilities["
+
i
+
"] : "
+
data
.
deviceCapabilities
[
i
]);
}
console
.
log
(
msg
+
"checkAbilityInfo readPermission : "
+
data
.
readPermission
);
console
.
log
(
msg
+
"checkAbilityInfo writePermission : "
+
data
.
writePermission
);
console
.
log
(
msg
+
"checkAbilityInfo formEntity : "
+
data
.
formEntity
);
console
.
log
(
msg
+
"checkAbilityInfo minFormHeight : "
+
data
.
minFormHeight
);
console
.
log
(
msg
+
"checkAbilityInfo defaultFormHeight : "
+
data
.
defaultFormHeight
);
console
.
log
(
msg
+
"checkAbilityInfo minFormWidth : "
+
data
.
minFormWidth
);
console
.
log
(
msg
+
"checkAbilityInfo defaultFormWidth : "
+
data
.
defaultFormWidth
);
console
.
log
(
msg
+
"checkAbilityInfo uri : "
+
data
.
uri
);
console
.
log
(
msg
+
"checkAbilityInfo customizeData : "
+
data
.
customizeData
);
console
.
log
(
msg
+
"checkAbilityInfo labelId : "
+
data
.
labelId
);
console
.
log
(
msg
+
"checkAbilityInfo subType : "
+
data
.
subType
);
expect
(
typeof
(
data
))
.
assertEqual
(
"object"
);
expect
(
typeof
(
data
.
bundleName
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
name
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
label
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
description
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
icon
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
labelId
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
descriptionId
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
iconId
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
moduleName
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
process
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
targetAbility
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
backgroundModes
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
isVisible
))
.
assertEqual
(
"boolean"
);
expect
(
typeof
(
data
.
formEnabled
))
.
assertEqual
(
"boolean"
);
expect
(
typeof
(
data
.
type
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
subType
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
orientation
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
launchMode
))
.
assertEqual
(
"number"
);
expect
(
Array
.
isArray
(
data
.
permissions
))
.
assertEqual
(
true
);
expect
(
Array
.
isArray
(
data
.
deviceTypes
))
.
assertEqual
(
true
);
expect
(
Array
.
isArray
(
data
.
deviceCapabilities
))
.
assertEqual
(
true
);
expect
(
typeof
(
data
.
readPermission
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
writePermission
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
data
.
applicationInfo
))
.
assertEqual
(
"object"
);
expect
(
typeof
(
data
.
formEntity
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
minFormHeight
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
defaultFormHeight
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
minFormWidth
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
defaultFormWidth
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
data
.
uri
))
.
assertEqual
(
"string"
);
expect
(
data
.
bundleName
)
.
assertEqual
(
"com.ohos.acecollaboration"
);
expect
(
data
.
name
)
.
assertEqual
(
"com.ohos.acecollaboration.MainAbility"
);
expect
(
data
.
label
)
.
assertEqual
(
"
$string
:entry_MainAbility"
);
expect
(
data
.
description
)
.
assertEqual
(
"
$string
:mainability_description"
);
expect
(
data
.
icon
)
.
assertEqual
(
"
$media
:icon"
);
expect
(
data
.
descriptionId
>
0
)
.
assertTrue
();
expect
(
data
.
iconId
>
0
)
.
assertTrue
();
expect
(
data
.
moduleName
)
.
assertEqual
(
"entry"
);
expect
(
data
.
process
)
.
assertEqual
(
""
);
expect
(
data
.
targetAbility
)
.
assertEqual
(
""
);
expect
(
data
.
backgroundModes
)
.
assertEqual
(
0
);
expect
(
data
.
isVisible
)
.
assertEqual
(
true
);
expect
(
data
.
formEnabled
)
.
assertEqual
(
false
);
expect
(
data
.
type
)
.
assertEqual
(
1
);
expect
(
data
.
orientation
)
.
assertEqual
(
0
);
expect
(
data
.
launchMode
)
.
assertEqual
(
1
);
expect
(
data
.
deviceTypes
[
0
])
.
assertEqual
(
"phone"
);
expect
(
data
.
readPermission
)
.
assertEqual
(
""
);
expect
(
data
.
writePermission
)
.
assertEqual
(
""
);
checkApplicationInfo
(
msg
,
data
.
applicationInfo
);
expect
(
data
.
formEntity
)
.
assertEqual
(
0
);
expect
(
data
.
minFormHeight
)
.
assertEqual
(
0
);
expect
(
data
.
defaultFormHeight
)
.
assertEqual
(
0
);
expect
(
data
.
minFormWidth
)
.
assertEqual
(
0
);
expect
(
data
.
defaultFormWidth
)
.
assertEqual
(
0
);
expect
(
data
.
uri
)
.
assertEqual
(
""
);
expect
(
data
.
labelId
>
0
)
.
assertTrue
();
expect
(
data
.
subType
)
.
assertEqual
(
0
);
console
.
log
(
msg
+
"---checkAbilityInfo End--- "
);
}
function
checkApplicationInfo
(
msg
,
info
)
{
console
.
log
(
msg
+
"checkApplicationInfo start : "
+
JSON
.
stringify
(
info
));
console
.
log
(
msg
+
"checkApplicationInfo name : "
+
info
.
name
);
console
.
log
(
msg
+
"checkApplicationInfo description : "
+
info
.
description
);
console
.
log
(
msg
+
"checkApplicationInfo descriptionId : "
+
info
.
descriptionId
);
console
.
log
(
msg
+
"checkApplicationInfo systemApp : "
+
info
.
systemApp
);
console
.
log
(
msg
+
"checkApplicationInfo enabled : "
+
info
.
enabled
);
console
.
log
(
msg
+
"checkApplicationInfo label : "
+
info
.
label
);
console
.
log
(
msg
+
"checkApplicationInfo labelId : "
+
info
.
labelId
);
console
.
log
(
msg
+
"checkApplicationInfo icon : "
+
info
.
icon
);
console
.
log
(
msg
+
"checkApplicationInfo iconId : "
+
info
.
iconId
);
console
.
log
(
msg
+
"checkApplicationInfo process : "
+
info
.
process
);
console
.
log
(
msg
+
"checkApplicationInfo supportedModes : "
+
info
.
supportedModes
);
console
.
log
(
msg
+
"checkApplicationInfo moduleSourceDirs length : "
+
info
.
moduleSourceDirs
.
length
);
for
(
var
j
=
0
;
j
<
info
.
moduleSourceDirs
.
length
;
j
++
)
{
console
.
log
(
msg
+
"checkApplicationInfo info.moduleSourceDirs["
+
j
+
"] : "
+
info
.
moduleSourceDirs
[
j
]);
}
console
.
log
(
msg
+
"checkApplicationInfo permissions length : "
+
info
.
permissions
.
length
);
for
(
var
k
=
0
;
k
<
info
.
permissions
.
length
;
k
++
)
{
console
.
log
(
msg
+
"checkApplicationInfo info.permissions["
+
k
+
"] : "
+
info
.
permissions
[
k
]);
}
console
.
log
(
msg
+
"checkApplicationInfo moduleInfos length : "
+
info
.
moduleInfos
.
length
);
for
(
var
i
=
0
;
i
<
info
.
moduleInfos
.
length
;
i
++
)
{
console
.
log
(
msg
+
"checkApplicationInfo info.moduleInfos["
+
i
+
"].moduleName : "
+
info
.
moduleInfos
[
i
]
.
moduleName
);
console
.
log
(
msg
+
"checkApplicationInfo info.moduleInfos["
+
i
+
"].moduleSourceDir : "
+
info
.
moduleInfos
[
i
]
.
moduleSourceDir
);
}
console
.
log
(
msg
+
"checkApplicationInfo entryDir : "
+
info
.
entryDir
);
expect
(
typeof
(
info
))
.
assertEqual
(
"object"
);
expect
(
typeof
(
info
.
name
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
description
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
descriptionId
))
.
assertEqual
(
"number"
);
expect
(
typeof
(
info
.
systemApp
))
.
assertEqual
(
"boolean"
);
expect
(
typeof
(
info
.
enabled
))
.
assertEqual
(
"boolean"
);
expect
(
typeof
(
info
.
label
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
labelId
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
icon
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
iconId
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
process
))
.
assertEqual
(
"string"
);
expect
(
typeof
(
info
.
supportedModes
))
.
assertEqual
(
"number"
);
expect
(
Array
.
isArray
(
info
.
moduleSourceDirs
))
.
assertEqual
(
true
);
expect
(
Array
.
isArray
(
info
.
permissions
))
.
assertEqual
(
true
);
expect
(
Array
.
isArray
(
info
.
moduleInfos
))
.
assertEqual
(
true
);
expect
(
typeof
(
info
.
entryDir
))
.
assertEqual
(
"string"
);
expect
(
info
.
name
)
.
assertEqual
(
"com.ohos.acecollaboration"
);
expect
(
info
.
description
)
.
assertEqual
(
"
$string
:mainability_description"
);
expect
(
info
.
descriptionId
>
0
)
.
assertTrue
();
expect
(
info
.
systemApp
)
.
assertEqual
(
true
);
expect
(
info
.
enabled
)
.
assertEqual
(
true
);
expect
(
info
.
label
)
.
assertEqual
(
"
$string
:entry_MainAbility"
);
expect
(
info
.
icon
)
.
assertEqual
(
"
$media
:icon"
);
expect
(
info
.
process
)
.
assertEqual
(
""
);
expect
(
info
.
supportedModes
)
.
assertEqual
(
0
);
expect
(
info
.
moduleSourceDirs
[
0
])
.
assertEqual
(
"/data/app/el1/bundle/public/"
+
"com.ohos.acecollaboration/com.ohos.acecollaboration"
);
expect
(
info
.
moduleInfos
[
0
]
.
moduleName
)
.
assertEqual
(
"entry"
);
expect
(
info
.
moduleInfos
[
0
]
.
moduleSourceDir
)
.
assertEqual
(
"/data/app/el1/bundle/public/"
+
"com.ohos.acecollaboration/com.ohos.acecollaboration"
);
expect
(
info
.
entryDir
)
.
assertEqual
(
"/data/app/el1/bundle/public/"
+
"com.ohos.acecollaboration/com.ohos.acecollaboration"
);
console
.
log
(
msg
+
"---checkApplicationInfo End--- "
);
}
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getAppVersionInfoJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAppVersionInfo_test_0100
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Promise)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0100', 0, async function (done) {
console.info('[context_getAppVersionInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAppVersionInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0100] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0100', promise);
console.info('[context_getAppVersionInfo_test_0100] FINISH');
done();
});
/**
* @tc.number: context_getAppVersionInfo_test_0200
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getAppVersionInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
}
catch (error) {
console.error('[context_getAppVersionInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0200] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0200', callback);
console.info('[context_getAppVersionInfo_test_0200] FINISH');
done();
});
function checkAppVersionInfo(msg, data) {
console.log(msg + "checkAppVersionInfo start : " + JSON.stringify(data));
console.log(msg + "checkAppVersionInfo appName : " + data.appName);
console.log(msg + "checkAppVersionInfo versionCode : " + data.versionCode);
console.log(msg + "checkAppVersionInfo versionName : " + data.versionName);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.appName)).assertEqual("string");
expect(typeof (data.versionCode)).assertEqual("number");
expect(typeof (data.versionName)).assertEqual("string");
expect(data.appName).assertEqual("");
expect(data.versionCode).assertEqual(1000000);
expect(data.versionName).assertEqual("1.0.0");
console.log(msg + "---checkAppVersionInfo End--- ");
}
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getApplicationContextJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getApplicationContext_test_0100
* @tc.name: getApplicationContext:Gets the application context information.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getApplicationContext_test_0100', 0, async function (done) {
try {
console.info('[context_getApplicationContext_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext().getApplicationContext();
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getApplicationContext_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getApplicationContext_test_0100] data is:' + JSON.stringify(context));
}
catch (error) {
console.error('[context_getApplicationContext_test_0100] failed:' + JSON.stringify(error));
}
expect(typeof (context)).assertEqual("object");
console.info('[context_getApplicationContext_test_0100] FINISH');
done();
});
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/default/test/getHapModuleInfoJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getHapModuleInfo_test_0100
* @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application.
* @tc.desc: Check the return type of the interface (by Promise)
* @tc.level 0
*/
it('context_getHapModuleInfo_test_0100', 0, async function (done) {
console.info('[context_getHapModuleInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getHapModuleInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getHapModuleInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getHapModuleInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
})
.catch((error) => {
console.error('[context_getHapModuleInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getHapModuleInfo();
console.info('---[context_getHapModuleInfo_test_0100] check---');
checkHapModuleInfo('context_getHapModuleInfo_test_0100', promise);
console.info('[context_getHapModuleInfo_test_0100] FINISH');
done();
});
/**
* @tc.number: context_getHapModuleInfo_test_0200
* @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getHapModuleInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getHapModuleInfo_test_0200] START');
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getHapModuleInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getHapModuleInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getHapModuleInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
} catch (error) {
console.error('[context_getHapModuleInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getHapModuleInfo();
console.info('---[context_getHapModuleInfo_test_0200] check---');
checkHapModuleInfo('context_getHapModuleInfo_test_0200', callback);
console.info('[context_getHapModuleInfo_test_0200] FINISH');
done();
});
function checkHapModuleInfo(msg, data) {
console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data));
console.log(msg + "checkHapModuleInfo name : " + data.name);
console.log(msg + "checkHapModuleInfo description : " + data.description);
console.log(msg + "checkHapModuleInfo descriptionId : " + data.descriptionId);
console.log(msg + "checkHapModuleInfo icon : " + data.icon);
console.log(msg + "checkHapModuleInfo label : " + data.label);
console.log(msg + "checkHapModuleInfo labelId : " + data.labelId);
console.log(msg + "checkHapModuleInfo iconId : " + data.iconId);
console.log(msg + "checkHapModuleInfo backgroundImg : " + data.backgroundImg);
console.log(msg + "checkHapModuleInfo supportedModes : " + data.supportedModes);
console.log(msg + "checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length);
for (var j = 0; j < data.reqCapabilities.length; j++) {
console.log(msg + "getHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]);
}
console.log(msg + "checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length);
console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName);
console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName);
console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.backgroundImg)).assertEqual("string");
expect(typeof (data.supportedModes)).assertEqual("number");
expect(Array.isArray(data.reqCapabilities)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.abilityInfos)).assertEqual(true);
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.mainAbilityName)).assertEqual("string");
expect(typeof (data.installationFree)).assertEqual("boolean");
expect(data.name).assertEqual("com.ohos.acecollaboration");
expect(data.description).assertEqual("");
expect(data.descriptionId).assertEqual(0);
expect(data.icon).assertEqual("$media:icon");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(data.labelId).assertEqual(0);
expect(data.iconId).assertEqual(0);
expect(data.backgroundImg).assertEqual("");
expect(data.supportedModes).assertEqual(0);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.moduleName).assertEqual("entry")
expect(data.mainAbilityName).assertEqual("");
expect(data.installationFree).assertEqual(false);
console.log(msg + "---checkHapModuleInfo End---");
}
})
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
28737d97
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"mainability_description"
,
"value"
:
"eTS_Empty Ability"
},
{
"name"
:
"description_serviceability"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"description_serviceability2"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"description_serviceability3"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"description_serviceability4"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"description_serviceability5"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"description_mainability2"
,
"value"
:
"eTS_Empty Ability2"
},
{
"name"
:
"entry_MainAbility2"
,
"value"
:
"MainAbility2"
}
]
}
\ No newline at end of file
aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
28737d97
6.6 KB
aafwk/aafwk_standard/actsabilitymanageretstest/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
28737d97
文件已添加
appexecfwk/bundle_standard/bundlemanager/BUILD.gn
浏览文件 @
28737d97
...
...
@@ -9,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
...
...
@@ -26,6 +26,7 @@ group("bundlemanager") {
"actsbmskittest:ActsBmsKitTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstallTest",
"actsbundlemgrmultipleinstalltest:ActsBundleMgrMultipleInstallTest",
...
...
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/BUILD.gn
0 → 100644
浏览文件 @
28737d97
# 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("ActsBundleManagerEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBundleManagerEtsTest"
}
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json
0 → 100644
浏览文件 @
28737d97
{
"description"
:
"Configuration for actsbundleetsgetinfotest Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"600000"
,
"package"
:
"com.open.harmony.packagemag"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsBundleManagerEtsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json
0 → 100644
浏览文件 @
28737d97
{
"app"
:
{
"bundleName"
:
"com.open.harmony.packagemag"
,
"vendor"
:
"ohos"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"com.open.harmony.packagemag"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"com.open.harmony.packagemag.MainAbility"
,
"deviceType"
:
[
"phone"
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO"
},
{
"name"
:
"ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
}
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"visible"
:
true
,
"srcPath"
:
"MainAbility"
,
"name"
:
".MainAbility"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"formsEnabled"
:
false
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"launchType"
:
"standard"
},
{
"srcPath"
:
"ServiceAbility"
,
"name"
:
".ServiceAbility"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_serviceability"
,
"type"
:
"service"
}
],
"js"
:
[
{
"mode"
:
{
"syntax"
:
"ets"
,
"type"
:
"pageAbility"
},
"pages"
:
[
"pages/index"
,
"pages/second"
],
"name"
:
".MainAbility"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/app.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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
router
from
'@system.router'
;
import
file
from
'@system.file'
;
import
{
Core
,
ExpectExtend
,
InstrumentLog
,
ReportExtend
}
from
"deccjsunit/index.ets"
;
import
testsuite
from
"../test/List.test.ets"
;
import
featureAbility
from
"@ohos.ability.featureAbility"
;
async
function
routePage
()
{
let
options
=
{
uri
:
'pages/second'
}
try
{
await
router
.
push
(
options
)
}
catch
(
err
)
{
console
.
error
(
`fail callback, code: ${err.code}, msg: ${err.msg}`
)
}
}
@
Entry
@
Component
struct
Index
{
aboutToAppear
()
{
console
.
info
(
"start run testcase!!!!"
)
featureAbility
.
getWant
()
.
then
((
Want
)
=>
{
const
core
=
Core
.
getInstance
();
const
expectExtend
=
new
ExpectExtend
({
'id'
:
'extend'
});
core
.
addService
(
'expect'
,
expectExtend
);
const
reportExtend
=
new
ReportExtend
(
file
);
core
.
addService
(
'report'
,
reportExtend
);
core
.
init
();
core
.
subscribeEvent
(
'task'
,
reportExtend
);
const
configService
=
core
.
getDefaultService
(
'config'
);
console
.
info
(
'parameters---->'
+
JSON
.
stringify
(
Want
.
parameters
));
configService
.
setConfig
(
Want
.
parameters
);
testsuite
();
core
.
execute
();
console
.
info
(
'Operation successful. Data: '
+
JSON
.
stringify
(
Want
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'Operation failed. Cause: '
+
JSON
.
stringify
(
error
));
})
}
build
()
{
Flex
({
direction
:
FlexDirection
.
Column
,
alignItems
:
ItemAlign
.
Center
,
justifyContent
:
FlexAlign
.
Center
})
{
Text
(
'Hello World'
)
.
fontSize
(
50
)
.
fontWeight
(
FontWeight
.
Bold
)
Button
()
{
Text
(
'ACE ETS TEST 包管理 2 '
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}
.
type
(
ButtonType
.
Capsule
)
.
margin
({
top
:
20
})
.
backgroundColor
(
'#0D9FFB'
)
.
onClick
(()
=>
{
routePage
()
})
}
.
width
(
'100%'
)
.
height
(
'100%'
)
}
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/second.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility'
const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility'
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage'
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
export default function getAbilityLabelJsUnit() {
describe('context_getAbilityLabel_test', function () {
beforeEach(async function (done) {
console.info('context_getAbilityLabel_test before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('context_getAbilityLabel_test after each called');
});
/*
* @tc.number: context_getAbilityLabel_test_0100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0100', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0100] promise START');
await Utils.sleep(1000);
let mData;
var timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0100] promise in ');
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error.code);
});
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0200
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0200', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0200] callBack in');
console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error.code);
console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0300
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0300', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise in ');
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
getAbilityLabelSuccess('[context_getAbilityLabel_test_0300]', data);
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
mError = error.code;
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error.code);
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0400
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0400', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
mError = error.code;
console.info('[context_getAbilityLabel_test_0400] callBack in');
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error.code);
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0500
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0500', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0500] promise START');
await Utils.sleep(1000);
let mData;
var timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0500] promise in ');
console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error.code);
});
getAbilityLabelSuccess('[context_getAbilityLabel_test_0500]', mData);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0600', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0600] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0600] callBack in');
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error.code);
console.info('[context_getAbilityLabel_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0600]', mData);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0700] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
mError = error;
console.info('[context_getAbilityLabel_test_0700] callBack in');
console.info('[context_getAbilityLabel_test_0700] callBack error: ' + error.code);
console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError);
done();
});
function getAbilityLabelSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
}
function getAbilityLabelFailure(msg, error) {
console.log(msg + ' Failure ');
expect(typeof (error)).assertEqual('number');
}
})
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
export default function bundleGidsJsUnit() {
describe('context_getBundleGids_test', function () {
beforeEach(async function (done) {
console.info('context_getBundleGids_test before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('context_getBundleGids_test after each called');
});
/*
* @tc.number: context_getBundleGids_test_0100
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0100', 0, async function (done) {
console.info('[context_getBundleGids_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.getBundleGids(BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getBundleGids_test_0100] promise error is: ' + error.code);
});
getGidsSuccess('[context_getBundleGids_test_0100]', mData);
done();
});
/*
* @tc.number: context_getBundleGids_test_0200
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0200', 0, async function (done) {
console.info('[context_getBundleGids_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getBundleGids(BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0200] callBack in');
console.info('[context_getBundleGids_test_0200] callBack error: ' + error.code);
console.info('[context_getBundleGids_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getGidsSuccess('[context_getBundleGids_test_0200]', mData);
done();
});
/*
* @tc.number: context_getBundleGids_test_0300
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0300', 0, async function (done) {
console.info('[context_getBundleGids_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
await Bundle.getBundleGids(BUNDLE_NAME_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getBundleGids_test_0300] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
mError = error.code;
Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getBundleGids_test_0300] promise error is: ' + error.code);
});
getGidsFailure('[context_getBundleGids_test_0300]', mError);
done();
});
/*
* @tc.number: context_getBundleGids_test_0400
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0400', 0, async function (done) {
console.info('[context_getBundleGids_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getBundleGids(BUNDLE_NAME_ERROR, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0400]', timeOldStamp, timeNewStamp);
mError = error.code;
console.info('[context_getBundleGids_test_0400] callBack in');
console.info('[context_getBundleGids_test_0400] callBack error: ' + error.code);
console.info('[context_getBundleGids_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getGidsFailure('[context_getBundleGids_test_0400]', mError);
done();
});
/*
* @tc.number: context_getBundleGids_test_0500
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0500', 0, async function (done) {
console.info('[context_getBundleGids_test_0500] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.getBundleGids(OTHER_BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getBundleGids_test_0500] promise error is: ' + error.code);
});
getGidsSuccess('[context_getBundleGids_test_0500]', mData);
done();
});
/*
* @tc.number: context_getBundleGids_test_0600
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0600', 0, async function (done) {
console.info('[context_getBundleGids_test_0600] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getBundleGids(OTHER_BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0600] callBack in');
console.info('[context_getBundleGids_test_0600] callBack error: ' + error.code);
console.info('[context_getBundleGids_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getGidsSuccess('[context_getBundleGids_test_0600]', mData);
done();
});
function getGidsSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
for (var j = 0; j < data.length; j++) {
console.log(msg + 'data[' + j + '] : ' + data[j]);
expect((data[j] > 0)).assertEqual(true);
}
expect(Array.isArray(data)).assertEqual(true);
}
function getGidsFailure(msg, error) {
console.log(msg + ' Failure ');
expect(typeof (error)).assertEqual('number');
}
})
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import bundleManager from '@ohos.bundle';
export default function GetabilityInfo() {
describe('GetabilityInfo', function () {
let bundleName = "com.open.harmony.packagemag";
let abilityName = "com.open.harmony.packagemag.MainAbility";
let bundleName_other = "com.ohos.acecollaboration";
let abilityName_other = "com.ohos.acecollaboration.MainAbility";
beforeEach(async function (done) {
console.info('GetabilityInfo before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('GetabilityInfo after each called');
});
/*
* @tc.number: bundle_GetabilityInfo_test_0100
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0100', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName, abilityName)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp)
console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo in ');
console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo data is: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error));
})
var promise = await bundleManager.getAbilityInfo(bundleName, abilityName);
checkAbilityInfo(promise);
done();
});
/*
* @tc.number: bundle_GetabilityInfo_test_0200
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0200', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName, abilityName, (err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp)
if (err) {
console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err));
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
return;
}
console.info('[bundle_GetabilityInfo_test_0200]Operation successful. Data:' + JSON.stringify(data));
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
})
var callback = await bundleManager.getAbilityInfo(bundleName, abilityName);
checkAbilityInfo(callback)
done();
});
/*
* @tc.number: bundle_GetabilityInfo_test_0300
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0300', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0300] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName_other, abilityName_other)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0300',timeOldStamp,timeNewStamp)
console.info('[bundle_GetabilityInfo_test_0300] getApplicationInfo in ');
console.info('[bundle_GetabilityInfo_test_0300] getApplicationInfo data is: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility");
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error));
})
var promise = await bundleManager.getAbilityInfo(bundleName_other, abilityName_other);
checkAbilityInfo(promise);
done();
});
/*
* @tc.number: bundle_GetabilityInfo_test_0400
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
let bundleName1 = "com.harmony.packagemag";
it('bundle_GetabilityInfo_test_0400', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0400] START');
let error1;
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName1, abilityName)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp)
console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo in ');
console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
error1 = error;
})
await Utils.sleep(1000);
await expect(error1).assertEqual(1);
done();
});
/*
* @tc.number: bundle_GetabilityInfo_test_0500
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
let abilityName1 = "com.harmony.packagemag1.MainAbility";
it('bundle_GetabilityInfo_test_0500', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0500] START');
let error;
let datas;
bundleManager.getAbilityInfo(bundleName, abilityName1, (err, data) => {
console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err));
console.info('[bundle_GetabilityInfo_test_0500] data = ' + JSON.stringify(data));
datas = data;
error = err
});
await Utils.sleep(2000);
console.info('[bundle_GetabilityInfo_test_0500] error = ' + error);
console.info('[bundle_GetabilityInfo_test_0500] datas = ' + JSON.stringify(datas));
console.info('[bundle_GetabilityInfo_test_0500] END');
done();
});
/*
* @tc.number: bundle_GetabilityInfo_test_0600
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
let bundleName2 = "";
it('bundle_GetabilityInfo_test_0600', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0600] START');
let error1;
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName2, abilityName)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp)
console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo in ');
console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data is: ' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error));
error1 = error;
})
await Utils.sleep(1000);
await expect(error1).assertEqual(1);
done();
});
/**
* 打印AbilityInfo属性信息
* @param data
*/
function checkAbilityInfo(data) {
console.log("checkAbilityInfo start " + JSON.stringify(data));
console.log("checkAbilityInfo bundleName : " + data.bundleName);
console.log("checkAbilityInfo name : " + data.name);
console.log("checkAbilityInfo label : " + data.label);
console.log("checkAbilityInfo description : " + data.description);
console.log("checkAbilityInfo icon : " + data.icon);
console.log("checkAbilityInfo descriptionId : " + data.descriptionId);
console.log("checkAbilityInfo iconId : " + data.iconId);
console.log("checkAbilityInfo moduleName : " + data.moduleName);
console.log("checkAbilityInfo process : " + data.process);
console.log("checkAbilityInfo targetAbility : " + data.targetAbility);
console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log("checkAbilityInfo isVisible : " + data.isVisible);
console.log("checkAbilityInfo formEnabled : " + data.formEnabled);
console.log("checkAbilityInfo type : " + data.type)
console.log("checkAbilityInfo orientation : " + data.orientation);
console.log("checkAbilityInfo launchMode : " + data.launchMode);
console.log("checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log("getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log("getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log("checkAbilityInfo readPermission : " + data.readPermission);
console.log("checkAbilityInfo writePermission : " + data.writePermission);
console.log("checkAbilityInfo formEntity : " + data.formEntity);
console.log("checkAbilityInfo minFormHeight : " + data.minFormHeight);
console.log("checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight);
console.log("checkAbilityInfo minFormWidth : " + data.minFormWidth);
console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log("checkAbilityInfo uri : " + data.uri);
console.log("checkAbilityInfo labelId : " + data.labelId);
console.log("checkAbilityInfo subType : " + data.subType);
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(typeof (data.label)).assertEqual("string");
expect(data.description).assertEqual("$string:mainability_description");
expect(typeof (data.description)).assertEqual("string");
expect(data.icon).assertEqual("$media:icon");
expect(typeof (data.icon)).assertEqual("string");
expect(data.srcPath).assertEqual("default");
expect(typeof (data.srcPath)).assertEqual("string");
expect(data.srcLanguage).assertEqual("ets");
expect(typeof (data.srcLanguage)).assertEqual("string");
expect(data.isVisible).assertEqual(true);
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.uri)).assertEqual("string");
expect(data.uri).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.moduleName).assertEqual("entry");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
checkApplicationInfo(data.applicationInfo);
console.log("---checkAbilityInfo End--- ");
}
/**
* 打印ApplicationInfo属性信息
* @param data
*/
function checkApplicationInfo(info) {
console.log("checkApplicationInfo getApplicationInfo : " + JSON.stringify(info));
console.log("checkApplicationInfo name : " + info.name);
console.log("checkApplicationInfo description : " + info.description);
console.log("checkApplicationInfo descriptionId : " + info.descriptionId);
console.log("checkApplicationInfo systemApp : " + info.systemApp);
console.log("checkApplicationInfo enabled : " + info.enabled);
console.log("checkApplicationInfo label : " + info.label);
console.log("checkApplicationInfo labelId : " + info.labelId);
console.log("checkApplicationInfo icon : " + info.icon);
console.log("checkApplicationInfo process : " + info.process);
console.log("checkApplicationInfo supportedModes : " + info.supportedModes);
console.log("checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log("checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log("checkApplicationInfo permissions length : " + info.permissions.length);
for (var j = 0; j < info.permissions.length; j++) {
console.log("checkApplicationInfo info.permissions[" + j + "] : " + info.permissions[j]);
}
console.log("checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var j = 0; j < info.moduleInfos.length; j++) {
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleName : " + info.moduleInfos[j].moduleName);
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleSourceDir : " + info.moduleInfos[j].moduleSourceDir);
}
console.log("checkApplicationInfo entryDir : " + info.entryDir);
//
//
//断研 callback
expect(typeof (info)).assertEqual("object")
expect(info.name).assertEqual("com.open.harmony.packagemag")
expect(typeof (info.name)).assertEqual("string")
expect(typeof (info.codePath)).assertEqual("string")
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag")
expect(info.accessTokenId > 0).assertTrue()
expect(typeof (info.accessTokenId)).assertEqual("number")
expect(typeof (info.description)).assertEqual("string")
expect(info.description).assertEqual("$string:mainability_description")
expect(info.descriptionId > 0).assertTrue()
expect(typeof (info.descriptionId)).assertEqual("number")
expect(typeof (info.icon)).assertEqual("string")
expect(info.icon).assertEqual("$media:icon")
expect(info.iconId > 0).assertTrue()
expect(typeof (info.iconId)).assertEqual("number")
expect(typeof (info.label)).assertEqual("string")
expect(info.label).assertEqual("$string:entry_MainAbility")
expect(info.labelId > 0).assertTrue()
expect(typeof (info.labelId)).assertEqual("number")
expect(info.systemApp).assertEqual(true)
expect(typeof (info.entryDir)).assertEqual("string")
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag")
expect(info.supportedModes).assertEqual(0)
expect(typeof (info.supportedModes)).assertEqual("number")
expect(typeof (info.process)).assertEqual("string")
expect(info.process).assertEqual("")
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
}
});
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility'
const ABILITY = {
bundleName: BUNDLE_NAME,
name: ABILITY_NAME
}
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
const ABILITY_ERROR = {
bundleName: BUNDLE_NAME_ERROR,
name: ABILITY_NAME_ERROR
}
export default function isAbilityEnabledETSUnit() {
describe('context_isAbilityEnabled_test', function () {
beforeEach(async function (done) {
console.info('context_isAbilityEnabled_test before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('context_isAbilityEnabled_test after each called');
});
/*
* @tc.number: context_isAbilityEnabled_test_0100
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0100', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0100] promise in ');
console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error.code);
});
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0200
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0200', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0200] callBack in');
console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error.code);
console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0300
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0300', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0300] promise in ');
console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error.code);
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0400
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0400', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
console.info('[context_isAbilityEnabled_test_0400] start c++ callBack ');
Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isAbilityEnabled_test_0400] callBack in');
mData = data;
console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error.code);
console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data));
});
console.info('[context_isAbilityEnabled_test_0400] end c++ callBack ');
await Utils.sleep(2000);
console.info('[context_isAbilityEnabled_test_0400] Failure ');
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0500
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0500', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0500] promise START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, true)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0500] set enable true ');
console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error);
})
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0500] promise in ');
console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error.code);
});
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0600
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0600', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0600] promise START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, false)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0600] set enable false ');
console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error);
})
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0600] promise in ');
console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error.code);
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0700
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0700', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0700] callBack START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, true)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0700] set enable true ');
console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error);
})
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0700] callBack in');
console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error.code);
console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0800
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0800', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0800] callBack START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, false)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0800] set enable false ');
console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error);
})
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0800] callBack in');
console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error.code);
console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData);
done();
});
function getAbilityEnabledSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' data : ' + data);
expect(typeof (data)).assertEqual('boolean')
}
function getAbilityEnabledTrue(msg, data) {
getAbilityEnabledSuccess(msg, data);
expect(data).assertEqual(true);
}
function getAbilityEnabledFalse(msg, data) {
getAbilityEnabledSuccess(msg, data);
expect(data).assertEqual(false);
}
function getAbilityEnabledFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error : ' + error);
expect(typeof (error)).assertEqual('number')
}
})
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
export default function IsApplicationEnabledETSUnit() {
describe('context_isApplicationEnabled_test', function () {
beforeEach(async function (done) {
console.info('context_isApplicationEnabled_test before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('context_isApplicationEnabled_test after each called');
});
/*
* @tc.number: context_isApplicationEnabled_test_0100
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0100', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0100] promise in ');
console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error.code);
});
getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData);
done();
});
/*
* @tc.number: context_isApplicationEnabled_test_0200
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0200', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0200] callBack in');
console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error.code);
console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData);
done();
});
/*
* @tc.number: context_isApplicationEnabled_test_0300
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0300', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0300] promise in ');
console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error.code);
});
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
done();
});
/*
* @tc.number: context_isApplicationEnabled_test_0400
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0400', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0400] callBack in');
console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error.code);
console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
console.info('[context_isApplicationEnabled_test_0400] Failure ');
done();
});
/*
* @tc.number: context_isApplicationEnabled_test_0500
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0500', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0500] promise START');
await Bundle.setApplicationEnabled(BUNDLE_NAME, true)
.then((data) => {
console.info('[context_isApplicationEnabled_test_0500] set enable true ');
console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error);
});
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0500] promise in ');
console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error.code);
});
getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData);
done();
});
/*
* @tc.number: context_isApplicationEnabled_test_0600
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0600', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0600] callBack START');
await Bundle.setApplicationEnabled(BUNDLE_NAME, false)
.then((data) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false ');
console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error);
});
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0600] callBack in');
console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error.code);
console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData);
done();
});
function getApplicationEnabledSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' data : ' + data);
expect(typeof (data)).assertEqual('boolean')
}
function getApplicationEnabledTrue(msg, data) {
getApplicationEnabledSuccess(msg, data);
expect(data).assertEqual(true);
}
function getApplicationEnabledFalse(msg, data) {
getApplicationEnabledSuccess(msg, data);
expect(data).assertEqual(false);
}
function getApplicationEnabledFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error : ' + error);
expect(typeof (error)).assertEqual('number')
}
})
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets
0 → 100644
浏览文件 @
28737d97
/**
* 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 getabilityInfo from './GetabilityInfo.test.ets';
import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets';
import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets';
import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets";
import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets";
import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets";
export default function testsuite() {
//RM.007
getApplicationInfoJsunit();
getAllAppInfoJsunit();
//RM.006
getabilityInfo();
//RM.014
getAbilityLabelJsUnit();
//RM.017
isAbilityEnableETSUnit();
isApplicationEnabledETSUnit();
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets
0 → 100644
浏览文件 @
28737d97
// @ts-nocheck
/**
* 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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
static getNowTime() {
return new Date().getTime();
}
static getDurationTime(log,startTime, endTime) {
console.info("Get Interface startTime: " + startTime);
console.info("Get Interface endTime: " + endTime);
var duration = (endTime - startTime);
console.info("Get Interface duration: " + duration);
return duration;
}
}
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
此差异已折叠。
点击以展开。
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets
0 → 100644
浏览文件 @
28737d97
此差异已折叠。
点击以展开。
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/ServiceAbility/service.ts
0 → 100644
浏览文件 @
28737d97
export
default
{
onStart
()
{
console
.
info
(
'
ServiceAbility onStart
'
);
},
onStop
()
{
console
.
info
(
'
ServiceAbility onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
'
ServiceAbility onCommand
'
);
}
};
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
28737d97
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"description_mainability"
,
"value"
:
"eTS_Empty Ability"
},
{
"name"
:
"mainability_description"
,
"value"
:
"eTS_Empty Ability"
},
{
"name"
:
"description_serviceability"
,
"value"
:
"hap sample empty service"
}
]
}
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
28737d97
6.6 KB
appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
28737d97
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录