Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eb382a27
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看板
未验证
提交
eb382a27
编写于
4月 02, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2945 XTS代码整改
Merge pull request !2945 from ry/master
上级
940d85e8
e753c461
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
860 addition
and
2875 deletion
+860
-2875
appexecfwk/bundle_standard/bundlemanager/actsbmsaccesstokentest/entry/src/main/js/test/ActsBmsAccessTokenTest.test.js
...est/entry/src/main/js/test/ActsBmsAccessTokenTest.test.js
+177
-297
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js
...test/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js
+0
-163
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js
...stest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js
+0
-1307
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js
.../entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js
+87
-161
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js
.../entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js
+156
-54
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js
...r/actsbmsgetinfostest/entry/src/main/js/test/List.test.js
+1
-3
appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js
...etest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js
+188
-197
appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js
...ctsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js
+228
-151
appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js
.../entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js
+23
-43
appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js
...emanagertest/entry/src/main/js/test/ExampleJsunit.test.js
+0
-499
未找到文件。
appexecfwk/bundle_standard/bundlemanager/actsbmsaccesstokentest/entry/src/main/js/test/ActsBmsAccessTokenTest.test.js
浏览文件 @
eb382a27
...
...
@@ -16,8 +16,16 @@
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
const
NAMECOUNT
=
10000
;
const
INSTALL_FLAG
=
1
const
BUNDLE_PATH1
=
[
'
/data/test/bmsAccessTokenTest1.hap
'
];
const
BUNDLE_PATH2
=
[
'
/data/test/bmsAccessTokenTest2.hap
'
];
const
BUNDLE_PATH3
=
[
'
/data/test/bmsAccessTokenTest3.hap
'
];
const
BUNDLE_NAME1
=
'
com.example.bmsaccesstoken1
'
;
const
USERID
=
100
;
let
installParam
=
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
};
describe
(
'
ActsBmsAccessTokenTest
'
,
function
()
{
...
...
@@ -27,36 +35,22 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the accessTokenId
*/
it
(
'
bms_AccessTokenId_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_AccessTokenId_0100 start
'
);
let
bundlePath
=
[
'
/data/test/bmsAccessTokenTest1.hap
'
];
let
bundleName
=
'
com.example.bmsaccesstoken1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getApplicationInfo
(
bundleName
,
0
,
0
).
then
(
applicationInfo
=>
{
console
.
info
(
'
accessTokenId:
'
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
bundleName
);
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getApplicationInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
)
.
then
(
applicationInfo
=>
{
console
.
info
(
'
accessTokenId:
'
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
applicationInfo
.
accessTokenId
).
assertLarger
(
0
);
})
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -66,22 +60,13 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it
(
'
bms_AccessTokenId_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_AccessTokenId_0200 start
'
);
let
bundlePath
=
[
'
/data/test/bmsAccessTokenTest1.hap
'
];
let
bundleName
=
'
com.example.bmsaccesstoken1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getBundleInfo
(
bundleName
,
16
).
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
bundleName
);
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getBundleInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_REQUESTED_PERMISSION
)
.
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
bundleInfo
.
reqPermissions
.
length
).
assertEqual
(
3
);
expect
(
bundleInfo
.
reqPermissions
[
0
]).
assertEqual
(
"
ohos.permission.ALPHA
"
);
expect
(
bundleInfo
.
reqPermissions
[
1
]).
assertEqual
(
"
ohos.permission.BETA
"
);
...
...
@@ -90,18 +75,13 @@ describe('ActsBmsAccessTokenTest', function () {
expect
(
bundleInfo
.
reqPermissionStates
[
0
]).
assertEqual
(
-
1
);
expect
(
bundleInfo
.
reqPermissionStates
[
1
]).
assertEqual
(
-
1
);
expect
(
bundleInfo
.
reqPermissionStates
[
2
]).
assertEqual
(
0
);
})
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -111,33 +91,17 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it
(
'
bms_AccessTokenId_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_AccessTokenId_0300 start
'
);
let
bundlePath1
=
[
'
/data/test/bmsAccessTokenTest1.hap
'
];
let
bundlePath2
=
[
'
/data/test/bmsAccessTokenTest2.hap
'
];
let
bundleName
=
'
com.example.bmsaccesstoken1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
installer
.
install
(
bundlePath2
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUpdateEvent
);
checkInstallOrUninstall
(
err
,
data
);
installer
.
install
(
BUNDLE_PATH2
,
installParam
,
OnReceiveUpdateEvent
);
}
async
function
OnReceiveUpdateEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getBundleInfo
(
bundleName
,
16
).
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
bundleName
);
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getBundleInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_REQUESTED_PERMISSION
)
.
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
bundleInfo
.
reqPermissions
.
length
).
assertEqual
(
5
);
expect
(
bundleInfo
.
reqPermissions
[
0
]).
assertEqual
(
"
ohos.permission.ALPHA
"
);
expect
(
bundleInfo
.
reqPermissions
[
1
]).
assertEqual
(
"
ohos.permission.KEEP_BACKGROUND_RUNNING
"
);
...
...
@@ -150,18 +114,13 @@ describe('ActsBmsAccessTokenTest', function () {
expect
(
bundleInfo
.
reqPermissionStates
[
2
]).
assertEqual
(
-
1
);
expect
(
bundleInfo
.
reqPermissionStates
[
3
]).
assertEqual
(
0
);
expect
(
bundleInfo
.
reqPermissionStates
[
4
]).
assertEqual
(
0
);
})
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -171,33 +130,17 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it
(
'
bms_AccessTokenId_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_AccessTokenId_0400 start
'
);
let
bundlePath1
=
[
'
/data/test/bmsAccessTokenTest1.hap
'
];
let
bundlePath2
=
[
'
/data/test/bmsAccessTokenTest3.hap
'
];
let
bundleName
=
'
com.example.bmsaccesstoken1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
installer
.
install
(
bundlePath2
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
OnReceiveUpdateEvent
);
checkInstallOrUninstall
(
err
,
data
);
installer
.
install
(
BUNDLE_PATH3
,
installParam
,
OnReceiveUpdateEvent
);
}
async
function
OnReceiveUpdateEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getBundleInfo
(
bundleName
,
16
).
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
bundleName
);
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getBundleInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_REQUESTED_PERMISSION
)
.
then
(
bundleInfo
=>
{
expect
(
bundleInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
bundleInfo
.
reqPermissions
.
length
).
assertEqual
(
6
);
expect
(
bundleInfo
.
reqPermissions
[
0
]).
assertEqual
(
"
ohos.permission.ALPHA
"
);
expect
(
bundleInfo
.
reqPermissions
[
1
]).
assertEqual
(
"
ohos.permission.BETA
"
);
...
...
@@ -212,18 +155,13 @@ describe('ActsBmsAccessTokenTest', function () {
expect
(
bundleInfo
.
reqPermissionStates
[
3
]).
assertEqual
(
-
1
);
expect
(
bundleInfo
.
reqPermissionStates
[
4
]).
assertEqual
(
0
);
expect
(
bundleInfo
.
reqPermissionStates
[
5
]).
assertEqual
(
0
);
})
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -233,44 +171,29 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with with a flag
*/
it
(
"
bms_AccessTokenId_0500
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
bms_AccessTokenId_0500 start
"
);
let
bundlePath
=
[
"
/data/test/bmsAccessTokenTest1.hap
"
];
let
bundleName
=
"
com.example.bmsaccesstoken1
"
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getApplicationInfo
(
bundleName
,
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
).
then
((
applicationInfo
)
=>
{
console
.
info
(
"
accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
bundleName
);
expect
(
applicationInfo
.
reqPermissionStates
.
length
).
assertEqual
(
0
);
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getApplicationInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
)
.
then
((
applicationInfo
)
=>
{
console
.
info
(
"
bms_AccessTokenId_0500 accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
applicationInfo
.
accessTokenId
).
assertLarger
(
0
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -280,45 +203,29 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with a flag
*/
it
(
"
bms_AccessTokenId_0600
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
bms_AccessTokenId_0600 start
"
);
let
bundlePath
=
[
"
/data/test/bmsAccessTokenTest1.hap
"
];
let
bundleName
=
"
com.example.bmsaccesstoken1
"
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getApplicationInfo
(
bundleName
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
)
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getApplicationInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
)
.
then
((
applicationInfo
)
=>
{
console
.
info
(
"
accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
bundleName
);
expect
(
applicationInfo
.
reqPermissionStates
.
length
).
assertLarger
(
0
);
console
.
info
(
"
bms_AccessTokenId_0600 accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
applicationInfo
.
accessTokenId
).
assertLarger
(
0
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -328,45 +235,29 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with a flag
*/
it
(
"
bms_AccessTokenId_0700
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
bms_AccessTokenId_0700 start
"
);
let
bundlePath
=
[
"
/data/test/bmsAccessTokenTest1.hap
"
];
let
bundleName
=
"
com.example.bmsaccesstoken1
"
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getApplicationInfo
(
bundleName
,
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
)
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getApplicationInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
)
.
then
((
applicationInfo
)
=>
{
console
.
info
(
"
accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
bundleName
);
expect
(
applicationInfo
.
reqPermissionStates
.
length
).
assertLarger
(
0
);
console
.
info
(
"
bms_AccessTokenId_0700 accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
applicationInfo
.
accessTokenId
).
assertLarger
(
0
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
();
});
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
OnReceiveUninstallEvent
);
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
});
...
...
@@ -376,47 +267,36 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with a flag
*/
it
(
"
bms_AccessTokenId_0800
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
bms_AccessTokenId_0800 start
"
);
let
bundlePath
=
[
"
/data/test/bmsAccessTokenTest1.hap
"
];
let
bundleName
=
"
com.example.bmsaccesstoken1
"
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
BUNDLE_PATH1
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
bundle
.
getApplicationInfo
(
bundleName
,
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
)
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getApplicationInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
)
.
then
((
applicationInfo
)
=>
{
console
.
info
(
"
accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
bundleName
);
expect
(
data
.
reqPermissionStates
.
length
).
assertLarger
(
0
);
expect
(
data
.
reqPermissionStates
[
0
]).
assertEqual
(
0
);
expect
(
data
.
reqPermissionStates
[
1
]).
assertEqual
(
0
);
console
.
info
(
"
bms_AccessTokenId_0800
accessTokenId:
"
+
applicationInfo
.
accessTokenId
);
expect
(
applicationInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
applicationInfo
.
accessTokenId
).
assertLarger
(
0
);
}).
catch
((
err
)
=>
{
expect
(
err
).
assertFail
(
);
});
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
INSTALL_FLAG
,
isKeepData
:
false
,
},
OnReceiveUninstallEvent
);
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
function
OnReceiveUninstallEvent
(
err
,
data
)
{
});
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
"
SUCCESS
"
);
done
();
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
});
});
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js
已删除
100644 → 0
浏览文件 @
940d85e8
/*
* 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
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit
'
const
BUNDLE_PATH1
=
'
/data/test/bmsThirdBundleTest1.hap
'
;
const
BUNDLE_NAME1
=
'
com.example.third1
'
;
describe
(
'
ActsCleancache
'
,
function
()
{
/*
* @tc.number: bms_cleancache_0200
* @tc.name: cleancache callback by other callback
* @tc.desc: 1.cleancache callback
* 2.cleancache for right input
*/
it
(
'
bms_cleancache_0100
'
,
0
,
async
function
(
done
){
console
.
info
(
'
=====================bms_cleancache_0100==================
'
);
let
bundlePath
=
[
BUNDLE_PATH1
]
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
function
onReceiveinstallEvent
(
err
,
data
)
{
console
.
log
(
'
bms_cleancache_0100 install called:
'
+
data
)
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
cleanBundleCacheFiles
(
'
com.example.third1
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
bms_cleancache_0100 test query system app err is
'
+
err
)
expect
(
err
).
assertEqual
(
1
);
}
expect
(
err
).
assertEqual
(
undefined
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
}
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
)
}
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
,
},
onReceiveinstallEvent
);
})
})
/*
* @tc.number: bms_cleancache_0200
* @tc.name: cleancache callback by other callback
* @tc.desc: 1.cleancache callback
* 2.cleancache for null input
*/
it
(
'
bms_cleancache_0200
'
,
0
,
async
function
(
done
){
console
.
info
(
'
=====================bms_cleancache_0100==================
'
);
let
bundlePath
=
[
BUNDLE_PATH1
]
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
function
onReceiveinstallEvent
(
err
,
data
)
{
console
.
log
(
'
bms_cleancache_0100 install called:
'
+
data
)
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
cleanBundleCacheFiles
(
null
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
bms_cleancache_0200 test query system app err is
'
+
err
)
expect
(
err
).
assertEqual
(
2
);
}
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
}
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
)
}
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
,
},
onReceiveinstallEvent
);
})
})
/*
* @tc.number: bms_cleancache_0300
* @tc.name: cleancache callback by other callback
* @tc.desc: 1.cleancache callback
* 2.cleancache for wrong input
*/
it
(
'
bms_cleancache_0300
'
,
0
,
async
function
(
done
){
console
.
info
(
'
=====================bms_cleancache_0100==================
'
);
let
bundlePath
=
[
BUNDLE_PATH1
]
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
function
onReceiveinstallEvent
(
err
,
data
)
{
console
.
log
(
'
bms_cleancache_0300 install called:
'
+
data
)
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
cleanBundleCacheFiles
(
"
wrong bundle name
"
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
bms_cleancache_0300 test query system app err is
'
+
err
)
expect
(
err
).
assertEqual
(
1
);
}
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
}
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
)
}
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
,
},
onReceiveinstallEvent
);
})
})
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js
已删除
100644 → 0
浏览文件 @
940d85e8
/*
* 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
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
BUNDLE_NAME1
=
'
com.example.third1
'
;
const
BUNDLE_NAME2
=
'
com.example.third2
'
;
const
BUNDLE_NAME4
=
'
com.example.third4
'
;
const
BUNDLE_NAME5
=
'
com.example.third5
'
;
const
BUNDLE_NAME6
=
"
com.ohos.callui
"
const
ABILITIY_NAME
=
"
com.ohos.callui.MainAbility
"
const
SYSTEM_BUNDLE
=
'
com.example.system1
'
;
const
VENDOR_BUNDLE
=
'
com.example.vendor1
'
;
const
DESIGHN_WIDTH
=
770
;
const
DEFAULT_DESIGHN_WIDTH
=
720
;
describe
(
'
ActsBmsFormsInfoTest
'
,
function
()
{
function
checkSystemHapForm
(
dataInfo
)
{
console
.
debug
(
'
===system formInfo is
'
+
JSON
.
stringify
(
dataInfo
))
expect
(
dataInfo
.
name
).
assertEqual
(
'
Form_JS1S
'
);
expect
(
dataInfo
.
bundleName
).
assertEqual
(
SYSTEM_BUNDLE
);
expect
(
dataInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
dataInfo
.
abilityName
).
assertEqual
(
SYSTEM_BUNDLE
+
'
.MainAbility
'
);
expect
(
dataInfo
.
description
).
assertEqual
(
'
JS1S Form
'
);
expect
(
dataInfo
.
descriptionId
>=
0
).
assertTrue
();
expect
(
dataInfo
.
type
).
assertEqual
(
bundle
.
FormType
.
JS
);
expect
(
dataInfo
.
colorMode
).
assertEqual
(
bundle
.
ColorMode
.
AUTO_MODE
);
expect
(
dataInfo
.
defaultFlag
).
assertTrue
();
expect
(
dataInfo
.
jsComponentName
).
assertEqual
(
'
JS_name1S
'
);
expect
(
dataInfo
.
formVisibleNotify
).
assertFalse
();
expect
(
dataInfo
.
formConfigAbility
).
assertEqual
(
'
ability://com.example.system1.MainAbility
'
);
expect
(
dataInfo
.
updateDuration
).
assertEqual
(
1
);
expect
(
dataInfo
.
defaultDimension
).
assertEqual
(
4
);
expect
(
JSON
.
stringify
(
dataInfo
.
supportDimensions
)).
assertEqual
(
'
[1,2,3,4]
'
);
expect
(
dataInfo
.
relatedBundleName
).
assertEqual
(
''
);
expect
(
JSON
.
stringify
(
dataInfo
.
customizeDatas
))
.
assertEqual
(
'
[{"name":"originWidgetName1S","value":"com.openharmony.weather.testWidget1S"}]
'
);
expect
(
dataInfo
.
customizeDatas
[
0
].
name
).
assertEqual
(
'
originWidgetName1S
'
);
expect
(
dataInfo
.
customizeDatas
[
0
].
value
).
assertEqual
(
'
com.openharmony.weather.testWidget1S
'
);
expect
(
dataInfo
.
src
).
assertEqual
(
'
/pages/card/index
'
);
expect
(
dataInfo
.
window
.
designWidth
).
assertEqual
(
DESIGHN_WIDTH
);
expect
(
dataInfo
.
window
.
autoDesignWidth
).
assertEqual
(
true
);
}
function
checkVendorHapForm
(
dataInfo
)
{
console
.
debug
(
'
===vendor formInfo is
'
+
JSON
.
stringify
(
dataInfo
))
expect
(
dataInfo
.
name
).
assertEqual
(
'
Form_JS1V
'
);
expect
(
dataInfo
.
bundleName
).
assertEqual
(
VENDOR_BUNDLE
);
expect
(
dataInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
dataInfo
.
abilityName
).
assertEqual
(
VENDOR_BUNDLE
+
'
.MainAbility
'
);
expect
(
dataInfo
.
description
).
assertEqual
(
'
JS1V Form
'
);
expect
(
dataInfo
.
descriptionId
>=
0
).
assertTrue
();
expect
(
dataInfo
.
type
).
assertEqual
(
bundle
.
FormType
.
JAVA
);
expect
(
dataInfo
.
colorMode
).
assertEqual
(
bundle
.
ColorMode
.
DARK_MODE
);
expect
(
dataInfo
.
defaultFlag
).
assertFalse
();
expect
(
dataInfo
.
jsComponentName
).
assertEqual
(
'
JS_name1V
'
);
expect
(
dataInfo
.
formVisibleNotify
).
assertFalse
();
expect
(
dataInfo
.
formConfigAbility
).
assertEqual
(
''
);
expect
(
dataInfo
.
updateDuration
).
assertEqual
(
1
);
expect
(
dataInfo
.
defaultDimension
).
assertEqual
(
0
);
expect
(
JSON
.
stringify
(
dataInfo
.
supportDimensions
)).
assertEqual
(
'
[1,2,3]
'
);
expect
(
dataInfo
.
relatedBundleName
).
assertEqual
(
''
);
expect
(
JSON
.
stringify
(
dataInfo
.
customizeDatas
))
.
assertEqual
(
'
[{"name":"originWidgetName1V","value":"com.openharmony.weather.testWidget1V"}]
'
);
expect
(
dataInfo
.
src
).
assertEqual
(
''
);
expect
(
dataInfo
.
window
.
designWidth
).
assertEqual
(
DEFAULT_DESIGHN_WIDTH
);
expect
(
dataInfo
.
window
.
autoDesignWidth
).
assertEqual
(
true
);
}
/**
* @tc.number: bms_getFormsInfo_0100
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which doesn't exist (by promise)
*/
it
(
'
bms_getFormsInfo_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0100============
'
);
let
data
=
await
bundle
.
getFormsInfo
(
''
);
expect
(
data
.
length
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number: bms_getFormsInfo_0200
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which doesn't exist (by callback)
*/
it
(
'
bms_getFormsInfo_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0200============
'
);
bundle
.
getFormsInfo
(
''
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
length
).
assertEqual
(
0
);
done
();
});
})
/**
* @tc.number: bms_getFormsInfo_0300
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which doesn't have forms (by promise)
*/
it
(
'
bms_getFormsInfo_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0300============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest2.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME2
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME2
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfo_0400
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which doesn't have forms (by callback)
*/
it
(
'
bms_getFormsInfo_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0400============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest2.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME2
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME2
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_0500
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which has two haps (by promise)
*/
it
(
'
bms_getFormsInfo_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0500============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
,
'
/data/test/bmsThirdBundleTest3.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME1
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1
'
,
formsInfo
,
'
1
'
);
checkFormIsExist
(
'
Form_JS3
'
,
formsInfo
,
'
3
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfo_0600
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which has two haps (by callback)
*/
it
(
'
bms_getFormsInfo_0600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0600============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
,
'
/data/test/bmsThirdBundleTest3.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME1
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1
'
,
formsInfo
,
'
1
'
)
checkFormIsExist
(
'
Form_JS3
'
,
formsInfo
,
'
3
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_0700
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check whether the form information of the update app is updated (by promise)
*/
it
(
'
bms_getFormsInfo_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0700============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
install
([
'
/data/test/bmsThirdBundleTestA1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME1
)
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JSA1
'
,
formsInfo
,
'
A1
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_0800
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check whether the form information of the update app is updated (by callback)
*/
it
(
'
bms_getFormsInfo_0800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0800============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
install
([
'
/data/test/bmsThirdBundleTestA1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME1
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JSA1
'
,
formsInfo
,
'
A1
'
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_0900
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which have two forms(by promise)
*/
it
(
'
bms_getFormsInfo_0900
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_0900============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME4
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormByName
(
formsInfo
[
0
],
'
4A
'
);
checkFormByName
(
formsInfo
[
1
],
'
4B
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfo_1000
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which have two forms(by callback)
*/
it
(
'
bms_getFormsInfo_1000
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1000============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME4
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormByName
(
formsInfo
[
0
],
'
4A
'
);
checkFormByName
(
formsInfo
[
1
],
'
4B
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_1100
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which have two abilities,
* and each ability has one forms (by promise)
*/
it
(
'
bms_getFormsInfo_1100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1100============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME5
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS5A
'
,
formsInfo
,
'
5A
'
);
checkFormIsExist
(
'
Form_JS5B
'
,
formsInfo
,
'
5B
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfo_1200
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for a third app which have two abilities,
* and each ability has one forms (by callback)
*/
it
(
'
bms_getFormsInfo_1200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1200============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME5
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS5A
'
,
formsInfo
,
'
5A
'
);
checkFormIsExist
(
'
Form_JS5B
'
,
formsInfo
,
'
5B
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfo_1300
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for vendor and system app (by promise)
*/
it
(
'
bms_getFormsInfo_1300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1300============
'
);
let
data
=
await
bundle
.
getFormsInfo
(
'
com.example.vendor1
'
);
expect
(
data
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1V
'
,
data
,
'
1V
'
,
false
,
true
);
checkFormIsExist
(
'
Form_JS1V2
'
,
data
,
'
1V2
'
);
data
=
await
bundle
.
getFormsInfo
(
'
com.example.system1
'
);
expect
(
data
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1S
'
,
data
,
'
1S
'
,
true
);
done
();
})
/**
* @tc.number: bms_getFormsInfo_1400
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check forms information for vendor and system app(by callback)
*/
it
(
'
bms_getFormsInfo_1400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1400============
'
);
bundle
.
getFormsInfo
(
'
com.example.vendor1
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1V
'
,
data
,
'
1V
'
,
false
,
true
);
checkFormIsExist
(
'
Form_JS1V2
'
,
data
,
'
1V2
'
);
});
bundle
.
getFormsInfo
(
'
com.example.system1
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1S
'
,
data
,
'
1S
'
,
true
);
done
();
});
})
/**
* @tc.number: bms_getFormsInfo_1500
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check whether the form information of the uninstall app is removed (by promise)
*/
it
(
'
bms_getFormsInfo_1500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1500============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfo
(
BUNDLE_NAME4
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfo_1600
* @tc.name: getFormsInfo : get forms information for one app
* @tc.desc: check whether the form information of the uninstall app is removed (by callback)
*/
it
(
'
bms_getFormsInfo_1600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfo_1600============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfo
(
BUNDLE_NAME4
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0100
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by bundle name and module name (by promise)
*/
it
(
'
bms_getFormsInfoByModule_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0100============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
entry
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1
'
,
formsInfo
,
'
1
'
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0200
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by bundle name and module name (by callback)
*/
it
(
'
bms_getFormsInfoByModule_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0200============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
entry
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1
'
,
data
,
'
1
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0300
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by wrong module name (by promise)
*/
it
(
'
bms_getFormsInfoByModule_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0300============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
''
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0400
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by wrong module name (by callback)
*/
it
(
'
bms_getFormsInfoByModule_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0400============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
''
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0500
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by wrong bundle name (by promise)
*/
it
(
'
bms_getFormsInfoByModule_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0500============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
''
,
'
bmsThirdBundle1
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0600
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app by wrong bundle name (by callback)
*/
it
(
'
bms_getFormsInfoByModule_0600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0600============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
''
,
'
bmsThirdBundle1
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
length
).
assertEqual
(
0
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0700
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which has two haps (by promise)
*/
it
(
'
bms_getFormsInfoByModule_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0700============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
,
'
/data/test/bmsThirdBundleTest3.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
bmsThirdBundle3
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS3
'
,
formsInfo
,
'
3
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0800
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which has two haps (by callback)
*/
it
(
'
bms_getFormsInfoByModule_0800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0800============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
,
'
/data/test/bmsThirdBundleTest3.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
bmsThirdBundle3
'
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS3
'
,
formsInfo
,
'
3
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_0900
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which have two forms (by promise)
*/
it
(
'
bms_getFormsInfoByModule_0900
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_0900============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME4
,
'
entry
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS4A
'
,
formsInfo
,
'
4A
'
);
checkFormIsExist
(
'
Form_JS4B
'
,
formsInfo
,
'
4B
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1000
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which have two forms (by callback)
*/
it
(
'
bms_getFormsInfoByModule_1000
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1000============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest4.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME4
,
'
entry
'
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS4A
'
,
formsInfo
,
'
4A
'
);
checkFormIsExist
(
'
Form_JS4B
'
,
formsInfo
,
'
4B
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1100
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which have two abilities,
* and each ability has one forms (by promise)
*/
it
(
'
bms_getFormsInfoByModule_1100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1100============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME5
,
'
entry
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS5A
'
,
formsInfo
,
'
5A
'
);
checkFormIsExist
(
'
Form_JS5B
'
,
formsInfo
,
'
5B
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1200
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for a third app which have two abilities,
* and each ability has one forms (by callback)
*/
it
(
'
bms_getFormsInfoByModule_1200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1200============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME5
,
'
entry
'
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS5A
'
,
formsInfo
,
'
5A
'
);
checkFormIsExist
(
'
Form_JS5B
'
,
formsInfo
,
'
5B
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1300
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for system and vendor app (by promise)
*/
it
(
'
bms_getFormsInfoByModule_1300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1300============
'
);
let
data
=
await
bundle
.
getFormsInfoByModule
(
'
com.example.vendor1
'
,
'
entry
'
);
expect
(
data
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1V
'
,
data
,
'
1V
'
,
false
,
true
);
checkFormIsExist
(
'
Form_JS1V2
'
,
data
,
'
1V2
'
);
data
=
await
bundle
.
getFormsInfoByModule
(
'
com.example.system1
'
,
'
entry
'
);
expect
(
data
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1S
'
,
data
,
'
1S
'
,
true
);
done
();
})
/**
* @tc.number: bms_getFormsInfoByModule_1400
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check forms information for system and vendor app (by callback)
*/
it
(
'
bms_getFormsInfoByModule_1400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1400============
'
);
bundle
.
getFormsInfoByModule
(
'
com.example.vendor1
'
,
'
entry
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
2
);
checkFormIsExist
(
'
Form_JS1V
'
,
data
,
'
1V
'
,
false
,
true
);
checkFormIsExist
(
'
Form_JS1V2
'
,
data
,
'
1V2
'
);
});
bundle
.
getFormsInfoByModule
(
'
com.example.system1
'
,
'
entry
'
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JS1S
'
,
data
,
'
1S
'
,
true
);
done
();
});
})
/**
* @tc.number: bms_getFormsInfoByModule_1500
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check whether the form information of the uninstall app is removed (by promise)
*/
it
(
'
bms_getFormsInfoByModule_1500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1500============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME5
,
'
entry
'
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
done
();
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1600
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check whether the form information of the uninstall app is removed (by callback)
*/
it
(
'
bms_getFormsInfoByModule_1600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1600============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME5
,
'
entry
'
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
formsInfo
.
length
).
assertEqual
(
0
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1700
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check whether the form information of the update app is updated (by promise)
*/
it
(
'
bms_getFormsInfoByModule_1700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1700============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
install
([
'
/data/test/bmsThirdBundleTestA1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
formsInfo
=
await
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
entry
'
)
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JSA1
'
,
formsInfo
,
'
A1
'
)
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
}
})
/**
* @tc.number: bms_getFormsInfoByModule_1800
* @tc.name: getFormsInfoByModule : get forms information for one app
* @tc.desc: check whether the form information of the update app is updated (by callback)
*/
it
(
'
bms_getFormsInfoByModule_1800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
==============bms_getFormsInfoByModule_1800============
'
);
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveinstallEvent
);
function
onReceiveinstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
install
([
'
/data/test/bmsThirdBundleTestA1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getFormsInfoByModule
(
BUNDLE_NAME1
,
'
entry
'
,
(
err
,
formsInfo
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
formsInfo
.
length
).
assertEqual
(
1
);
checkFormIsExist
(
'
Form_JSA1
'
,
formsInfo
,
'
A1
'
);
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
});
});
}
})
function
checkFormIsExist
(
formName
,
dataInfo
,
name
,
system
=
false
,
vendor
=
false
)
{
let
info
=
new
Map
();
for
(
let
i
=
0
,
len
=
dataInfo
.
length
;
i
<
len
;
i
++
)
{
info
.
set
(
dataInfo
[
i
].
name
,
dataInfo
[
i
]);
}
expect
(
info
.
has
(
formName
)).
assertTrue
();
if
(
info
.
has
(
formName
))
{
if
(
system
)
{
checkSystemHapForm
(
info
.
get
(
formName
));
return
;
}
if
(
vendor
)
{
checkVendorHapForm
(
info
.
get
(
formName
));
return
;
}
checkFormByName
(
info
.
get
(
formName
),
name
);
}
}
function
checkFormNoExist
(
dataInfo
,
formName
)
{
let
info
=
new
Map
();
for
(
let
i
=
0
,
len
=
dataInfo
.
length
;
i
<
len
;
i
++
)
{
info
.
set
(
dataInfo
[
i
].
name
,
0
)
}
expect
(
info
.
has
(
formName
)).
assertFalse
();
}
function
checkFormByName
(
dataInfo
,
name
)
{
console
.
info
(
'
=======Form Info========
'
+
JSON
.
stringify
(
dataInfo
))
expect
(
dataInfo
.
name
).
assertEqual
(
'
Form_JS
'
+
name
);
console
.
info
(
'
=============ModuleName is=========
'
+
dataInfo
.
moduleName
);
console
.
info
(
'
=============supportDimensions==============
'
+
JSON
.
stringify
(
dataInfo
.
supportDimensions
));
console
.
info
(
'
=============abilityName==============
'
+
JSON
.
stringify
(
dataInfo
.
abilityName
));
expect
(
dataInfo
.
jsComponentName
).
assertEqual
(
'
JS_name
'
+
name
);
expect
(
dataInfo
.
formVisibleNotify
).
assertFalse
();
expect
(
typeof
dataInfo
.
name
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
bundleName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
moduleName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
abilityName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
description
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
descriptionId
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
type
).
assertEqual
(
'
number
'
);
expect
(
dataInfo
.
colorMode
).
assertEqual
(
bundle
.
ColorMode
.
LIGHT_MODE
);
expect
(
typeof
dataInfo
.
defaultFlag
).
assertEqual
(
'
boolean
'
);
expect
(
typeof
dataInfo
.
jsComponentName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
formVisibleNotify
).
assertEqual
(
'
boolean
'
);
expect
(
typeof
dataInfo
.
formConfigAbility
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
updateDuration
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
defaultDimension
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
supportDimensions
).
assertEqual
(
'
object
'
);
expect
(
typeof
dataInfo
.
relatedBundleName
).
assertEqual
(
'
string
'
);
console
.
debug
(
'
====dataInfo.scheduledUpdateTime====
'
+
dataInfo
.
scheduledUpdateTime
)
expect
(
typeof
dataInfo
.
customizeDatas
).
assertEqual
(
'
object
'
);
for
(
let
j
=
0
,
len
=
dataInfo
.
customizeDatas
.
length
;
j
<
len
;
j
++
)
{
console
.
info
(
'
======customizeDatasName======
'
+
JSON
.
stringify
(
dataInfo
.
customizeDatas
[
j
].
name
));
expect
(
dataInfo
.
customizeDatas
[
j
].
name
).
assertEqual
(
'
originWidgetName
'
+
name
);
expect
(
typeof
dataInfo
.
customizeDatas
[
j
].
name
).
assertEqual
(
'
string
'
);
console
.
info
(
'
======customizeDatasValue=====
'
+
JSON
.
stringify
(
dataInfo
.
customizeDatas
[
j
].
value
));
expect
(
dataInfo
.
customizeDatas
[
j
].
value
).
assertEqual
(
'
com.openharmony.weather.testWidget
'
+
name
);
expect
(
typeof
dataInfo
.
customizeDatas
[
j
].
value
).
assertEqual
(
'
string
'
);
}
expect
(
typeof
dataInfo
.
src
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
window
).
assertEqual
(
'
object
'
);
expect
(
typeof
dataInfo
.
window
.
designWidth
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
window
.
autoDesignWidth
).
assertEqual
(
'
boolean
'
);
expect
(
dataInfo
.
window
.
designWidth
).
assertEqual
(
DEFAULT_DESIGHN_WIDTH
);
expect
(
dataInfo
.
window
.
autoDesignWidth
).
assertEqual
(
false
);
}
/*
* @tc.number: bms_getAbilityIcon_0100
* @tc.name: test getAbilityIcon`
* @tc.desc: get the abilityIcon
*/
it
(
'
bms_getAbilityIcon_0100
'
,
0
,
async
function
(
done
)
{
bundle
.
getAbilityIcon
(
BUNDLE_NAME6
,
ABILITIY_NAME
).
then
(
pixelmap
=>
{
console
.
log
(
'
bms_getAbilityIcon_0100 success:
'
+
pixelmap
);
expect
(
pixelmap
!==
null
).
assertTrue
()
done
()
})
.
catch
(
err
=>
{
console
.
info
(
"
getAbilityIcon fail:
"
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertFail
()
done
()
})
})
/*
* @tc.number: bms_getAbilityIcon_0200
* @tc.name: test getAbilityIcon
* @tc.desc: get the abilityIcon
*/
it
(
'
bms_getAbilityIcon_0200
'
,
0
,
async
function
(
done
)
{
bundle
.
getAbilityIcon
(
BUNDLE_NAME6
,
ABILITIY_NAME
,
(
err
,
pixelmap
)
=>
{
if
(
err
)
{
console
.
info
(
"
getAbilityIcon fail:
"
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertFail
()
}
console
.
info
(
'
bms_getAbilityIcon_0200 success:
'
+
JSON
.
stringify
(
pixelmap
))
expect
(
pixelmap
!==
null
).
assertTrue
()
done
()
})
})
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js
浏览文件 @
eb382a27
...
...
@@ -23,39 +23,37 @@ const BUNDLE_PATH4 = '/data/test/bmsThirdBundleTest4.hap';
const
BUNDLE_PATH5
=
'
/data/test/bmsThirdBundleTest5.hap
'
;
const
BUNDLE_PATH6
=
'
/data/test/bmsThirdBundleTest6.hap
'
;
const
BUNDLE_PATHUPDATE
=
'
/data/test/bmsThirdBundleTestA1.hap
'
;
const
SYSTEM_PATH
=
'
/data/test/bmsSystemBundleTest2.hap
'
;
const
BUNDLE_NAME1
=
'
com.example.third1
'
;
const
BUNDLE_NAME2
=
'
com.example.third2
'
;
const
BUNDLE_NAME4
=
'
com.example.third4
'
;
const
BUNDLE_NAME5
=
'
com.example.third5
'
;
const
BUNDLE_NAME6
=
'
com.example.third6
'
;
const
SYSTEM_NAME
=
'
com.example.system2
'
;
const
ABILITIY_NAME1
=
"
com.example.third5.MainAbilityA
"
;
const
ABILITIY_NAME2
=
"
com.example.third5.MainAbilityB
"
;
const
ABILITIY_NAME3
=
"
com.example.third2.MainAbilityA
"
;
const
ABILITIY_NAME4
=
"
com.example.third4.MainAbility
"
;
const
ABILITIY_NAME5
=
"
com.example.third1.MainAbilityA
"
;
const
ABILITIY_NAME6
=
"
com.example.third3.MainAbilityA
"
;
const
ABILITIY_NAME7
=
"
com.example.third1.AMainAbilityA
"
;
const
NUM_TWO
=
2
;
const
NUM_THREE
=
3
;
const
NUM_FOUR
=
4
;
const
NUM_NINE
=
9
;
let
dataTransfer
=
1
;
let
audioPlayback
=
2
;
let
audioRecording
=
4
;
let
location
=
8
;
let
bluetoothInteraction
=
16
;
let
multiDeviceConnection
=
32
;
let
wifiInteraction
=
64
;
let
voip
=
128
;
let
taskKeeping
=
256
;
const
USERID
=
100
;
const
DATATRANSFER
=
1
;
const
AUDIOPLAYBACK
=
2
;
const
AUDIORECORDING
=
4
;
const
LOCATION
=
8
;
const
BLUETOOTHINTERACTION
=
16
;
const
MULTIDEVICECONNECTION
=
32
;
const
WIFIINTERACTION
=
64
;
const
VOIP
=
128
;
const
TASKKEEPING
=
256
;
let
installParam
=
{
userId
:
USERID
,
installFlag
:
1
,
isKeepData
:
false
}
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
};
describe
(
'
ActsBmsGetBackGroundModes
'
,
function
()
{
...
...
@@ -65,8 +63,7 @@ describe('ActsBmsGetBackGroundModes', function () {
* @tc.desc: Get the information of the background modes from multi-ability application
*/
it
(
'
bms_backGroundModes_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0100==================
'
);
let
bundlePath
=
[
BUNDLE_PATH5
]
let
bundlePath
=
[
BUNDLE_PATH5
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -78,60 +75,39 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME5
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_FOUR
);
if
(
dataInfos
.
length
==
NUM_FOUR
)
{
expect
(
dataInfos
[
NUM_TWO
].
name
).
assertEqual
(
"
com.example.third5.MainAbilityA
"
);
expect
(
dataInfos
[
NUM_TWO
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
expect
(
dataInfos
[
NUM_THREE
].
name
).
assertEqual
(
"
com.example.third5.MainAbilityB
"
);
expect
(
dataInfos
[
NUM_THREE
].
backgroundModes
).
assertEqual
(
dataTransfer
|
voip
);
expect
(
dataInfos
[
NUM_TWO
].
name
).
assertEqual
(
ABILITIY_NAME1
);
expect
(
dataInfos
[
NUM_TWO
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
expect
(
dataInfos
[
NUM_THREE
].
name
).
assertEqual
(
ABILITIY_NAME2
);
expect
(
dataInfos
[
NUM_THREE
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
VOIP
);
}
let
bundleInfos
=
await
bundle
.
getAllBundleInfo
(
1
,
USERID
)
let
bundleInfos
=
await
bundle
.
getAllBundleInfo
(
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
USERID
);
for
(
let
i
=
0
;
i
<
bundleInfos
.
length
;
i
++
)
{
console
.
info
(
"
========>bundleInfos[i].name======
"
+
bundleInfos
[
i
].
name
)
console
.
info
(
"
========>bundleInfos[i]======
"
+
JSON
.
stringify
(
bundleInfos
[
i
]));
if
(
bundleInfos
[
i
].
name
==
BUNDLE_NAME5
)
{
console
.
info
(
"
====bundleInfos[i].abilityinfos===
"
+
JSON
.
stringify
(
bundleInfos
[
i
].
abilityInfos
))
for
(
let
j
=
0
;
j
<
bundleInfos
[
i
].
abilityInfos
.
length
;
j
++
)
{
console
.
info
(
"
========>bundleInfos[i].abilityinfos[j].name======
"
+
bundleInfos
[
i
].
abilityInfos
[
j
].
name
)
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
'
com.example.third5.MainAbilityA
'
)
{
expect
(
bundleInfos
[
i
].
abilityInfos
[
j
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
}
else
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
'
com.example.third5.MainAbilityB
'
)
{
expect
(
bundleInfos
[
i
].
abilityInfos
[
j
].
backgroundModes
).
assertEqual
(
dataTransfer
|
voip
);
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
ABILITIY_NAME1
)
{
expect
(
bundleInfos
[
i
].
abilityInfos
[
j
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
}
else
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
ABILITIY_NAME2
)
{
expect
(
bundleInfos
[
i
].
abilityInfos
[
j
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
VOIP
);
}
}
}
}
let
data3
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME5
,
1
)
console
.
info
(
"
========>data3======
"
+
data3
.
abilityInfos
.
length
)
for
(
let
q
=
0
;
q
<
data3
.
abilityInfos
.
length
;
q
++
)
{
console
.
info
(
"
=====>data3.abilityInfos======
"
+
JSON
.
stringify
(
data3
.
abilityInfos
[
2
].
backgroundModes
))
console
.
info
(
"
=====>data3.abilityInfos======
"
+
JSON
.
stringify
(
data3
.
abilityInfos
[
3
].
backgroundModes
))
}
expect
(
data3
.
abilityInfos
[
2
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
expect
(
data3
.
abilityInfos
[
3
].
backgroundModes
).
assertEqual
(
dataTransfer
|
voip
);
let
data5
=
await
bundle
.
getBundleArchiveInfo
(
BUNDLE_PATH5
,
1
)
console
.
info
(
"
========>data5======
"
+
data5
.
abilityInfos
.
length
)
for
(
let
i
=
0
;
i
<
data5
.
abilityInfos
.
length
;
i
++
)
{
console
.
info
(
"
=====>data5.abilityInfos======
"
+
JSON
.
stringify
(
data5
.
abilityInfos
[
2
].
backgroundModes
))
console
.
info
(
"
=====>data5.abilityInfos======
"
+
JSON
.
stringify
(
data5
.
abilityInfos
[
3
].
backgroundModes
))
}
expect
(
data5
.
abilityInfos
[
2
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
expect
(
data5
.
abilityInfos
[
3
].
backgroundModes
).
assertEqual
(
dataTransfer
|
voip
);
let
data3
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME5
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
);
expect
(
data3
.
abilityInfos
[
2
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
expect
(
data3
.
abilityInfos
[
3
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
VOIP
);
installer
.
uninstall
(
BUNDLE_NAME5
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
;
})
;
/*
* @tc.number: bms_backGroundModes_0200
...
...
@@ -140,8 +116,7 @@ describe('ActsBmsGetBackGroundModes', function () {
* contains one of the background mode
*/
it
(
'
bms_backGroundModes_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0200==================
'
);
let
bundlePath
=
[
BUNDLE_PATH6
]
let
bundlePath
=
[
BUNDLE_PATH6
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -153,19 +128,17 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME6
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_NINE
);
for
(
let
i
=
0
,
len
=
dataInfos
.
length
;
i
<
len
;
i
++
)
{
expect
(
dataInfos
[
i
].
backgroundModes
).
assertEqual
(
1
<<
i
);
console
.
info
(
"
==========dataInfos[i].backgroundModes=========
"
+
dataInfos
[
i
].
backgroundModes
);
console
.
info
(
"
==========dataInfos[1].name=========
"
+
dataInfos
[
i
].
name
);
}
installer
.
uninstall
(
BUNDLE_NAME6
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
;
})
;
/*
* @tc.number: bms_backGroundModes_0300
...
...
@@ -173,8 +146,7 @@ describe('ActsBmsGetBackGroundModes', function () {
* @tc.desc: Read the backgroundModes information of the app's ability and replace invalid attributes
*/
it
(
'
bms_backGroundModes_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0300==================
'
);
let
bundlePath
=
[
BUNDLE_PATH2
]
let
bundlePath
=
[
BUNDLE_PATH2
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -186,46 +158,36 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME2
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_TWO
);
if
(
dataInfos
.
length
==
NUM_TWO
)
{
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
"
com.example.third2.MainAbilityA
"
)
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
ABILITIY_NAME3
)
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
)
}
bundle
.
getAllBundleInfo
(
1
,
USERID
,
(
err
,
bundleInfos
)
=>
{
bundle
.
getAllBundleInfo
(
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
USERID
,
(
err
,
bundleInfos
)
=>
{
for
(
let
i
=
0
;
i
<
bundleInfos
.
length
;
i
++
)
{
console
.
info
(
"
========>bundleInfos[i].name======
"
+
bundleInfos
[
i
].
name
)
console
.
info
(
"
========>bundleInfos[i]======
"
+
JSON
.
stringify
(
bundleInfos
[
i
]));
if
(
bundleInfos
[
i
].
name
==
BUNDLE_NAME2
)
{
console
.
info
(
"
==bundleInfos[i].abilityinfos===
"
+
JSON
.
stringify
(
bundleInfos
[
i
].
abilityInfos
))
for
(
let
j
=
0
;
j
<
bundleInfos
[
i
].
abilityInfos
.
length
;
j
++
)
{
console
.
info
(
"
========>bundleInfos[i].abilityinfos[j].name======
"
+
bundleInfos
[
i
].
abilityInfos
[
j
].
name
)
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
'
com.example.third2.MainAbilityA
'
)
{
if
(
bundleInfos
[
i
].
abilityInfos
[
j
].
name
==
ABILITIY_NAME3
)
{
expect
(
bundleInfos
[
i
].
abilityInfos
[
j
].
backgroundModes
).
assertEqual
(
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
}
}
}
}
})
bundle
.
getBundleInfo
(
BUNDLE_NAME2
,
1
,
(
err
,
data3
)
=>
{
expect
(
data3
.
abilityInfos
[
1
].
backgroundModes
).
assertEqual
(
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
})
bundle
.
getBundleArchiveInfo
(
BUNDLE_PATH2
,
1
,
(
err
,
data5
)
=>
{
expect
(
data5
.
abilityInfos
[
1
].
backgroundModes
).
assertEqual
(
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
})
});
bundle
.
getBundleInfo
(
BUNDLE_NAME2
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
(
err
,
data3
)
=>
{
expect
(
data3
.
abilityInfos
[
1
].
backgroundModes
).
assertEqual
(
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
)
});
installer
.
uninstall
(
BUNDLE_NAME2
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
;
})
;
/*
* @tc.number: bms_backGroundModes_0400
...
...
@@ -233,8 +195,7 @@ describe('ActsBmsGetBackGroundModes', function () {
* @tc.desc: Read the backgroundModes information of the app's ability and replace invalid attributes
*/
it
(
'
bms_backGroundModes_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0400==================
'
);
let
bundlePath1
=
[
BUNDLE_PATH4
]
let
bundlePath1
=
[
BUNDLE_PATH4
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath1
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -246,18 +207,18 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME4
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
1
);
if
(
dataInfos
.
length
==
1
)
{
expect
(
dataInfos
[
0
].
name
).
assertEqual
(
"
com.example.third4.MainAbility
"
)
expect
(
dataInfos
[
0
].
name
).
assertEqual
(
ABILITIY_NAME4
)
expect
(
dataInfos
[
0
].
backgroundModes
).
assertEqual
(
0
)
}
installer
.
uninstall
(
BUNDLE_NAME4
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
;
})
;
/*
* @tc.number: bms_backGroundModes_0500
...
...
@@ -265,7 +226,6 @@ describe('ActsBmsGetBackGroundModes', function () {
* @tc.desc: Get the backgroundModes information of the multi-hap package of the application
*/
it
(
'
bms_backGroundModes_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0500==================
'
);
let
bundlePath
=
[
BUNDLE_PATH1
,
BUNDLE_PATH3
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
installParam
,
async
(
err
,
data
)
=>
{
...
...
@@ -278,23 +238,22 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME1
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_FOUR
);
if
(
dataInfos
.
length
==
NUM_FOUR
)
{
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
"
com.example.third1.MainAbilityA
"
)
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
expect
(
dataInfos
[
3
].
name
).
assertEqual
(
"
com.example.third3.MainAbilityA
"
)
expect
(
dataInfos
[
3
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
ABILITIY_NAME5
)
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
)
expect
(
dataInfos
[
3
].
name
).
assertEqual
(
ABILITIY_NAME6
)
expect
(
dataInfos
[
3
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
)
}
console
.
info
(
"
========dataInfos[0].backgroundModes=======>
"
+
dataInfos
[
0
].
backgroundModes
)
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
;
})
;
/*
* @tc.number: bms_backGroundModes_0600
...
...
@@ -302,9 +261,8 @@ describe('ActsBmsGetBackGroundModes', function () {
* @tc.desc: Get the backgroundModes information of the upgraded application's ability
*/
it
(
'
bms_backGroundModes_0600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_backGroundModes_0600==================
'
);
let
bundlePath1
=
[
BUNDLE_PATH1
]
let
bundlePath2
=
[
BUNDLE_PATHUPDATE
]
let
bundlePath1
=
[
BUNDLE_PATH1
];
let
bundlePath2
=
[
BUNDLE_PATHUPDATE
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath1
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -316,12 +274,12 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME1
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_TWO
);
if
(
dataInfos
.
length
==
NUM_TWO
)
{
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
"
com.example.third1.MainAbilityA
"
)
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
dataTransfer
|
audioPlayback
|
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
)
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
ABILITIY_NAME5
);
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
DATATRANSFER
|
AUDIOPLAYBACK
|
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
}
installer
.
install
(
bundlePath2
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
...
...
@@ -333,56 +291,24 @@ describe('ActsBmsGetBackGroundModes', function () {
bundleName
:
BUNDLE_NAME1
,
abilityName
:
''
,
},
},
0
,
USERID
)
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
NUM_TWO
);
if
(
dataInfos
.
length
==
NUM_TWO
)
{
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
"
com.example.third1.AMainAbilityA
"
);
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
audioRecording
|
location
|
bluetoothInteraction
|
multiDeviceConnection
|
wifiInteraction
|
voip
|
taskKeeping
);
expect
(
dataInfos
[
1
].
name
).
assertEqual
(
ABILITIY_NAME7
);
expect
(
dataInfos
[
1
].
backgroundModes
).
assertEqual
(
AUDIORECORDING
|
LOCATION
|
BLUETOOTHINTERACTION
|
MULTIDEVICECONNECTION
|
WIFIINTERACTION
|
VOIP
|
TASKKEEPING
);
}
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
})
})
})
/*
* @tc.number: bms_queryAbilityByEntities_0100
* @tc.name: Use the implicit query method in queryAbilityByWant to get abilityInfos
* @tc.desc: The entities in the parameter want pass in the new field, and use the implicit query to get abilitInfos
*/
it
(
'
bms_queryAbilityByEntities_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
===========begin bms_queryAbilityByEntities_0100===========
'
);
let
installer
=
await
bundle
.
getBundleInstaller
()
installer
.
install
([
SYSTEM_PATH
],
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
let
dataInfos
=
await
bundle
.
queryAbilityByWant
({
action
:
'
action.system.home
'
,
entities
:
[
"
entity.app.music
"
,
"
entity.app.email
"
,
"
entity.app.contacts
"
,
"
entity.app.maps
"
,
"
entity.app.browser
"
,
"
entity.app.calendar
"
,
"
entity.app.messaging
"
,
"
entity.app.files
"
,
"
entity.app.gallery
"
],
elementName
:
{
deviceId
:
'
0
'
,
bundleName
:
''
,
abilityName
:
''
,
},
},
0
,
USERID
)
console
.
log
(
'
=========ability info is=========
'
+
JSON
.
stringify
(
dataInfos
));
expect
(
dataInfos
.
length
).
assertEqual
(
1
);
expect
(
dataInfos
[
0
].
name
).
assertEqual
(
'
com.example.system2.MainAbility
'
);
installer
.
uninstall
(
SYSTEM_NAME
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
});
})
})
;
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js
浏览文件 @
eb382a27
...
...
@@ -15,60 +15,57 @@
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit
'
const
BUNDLE_PATH1
=
'
/data/test/bmsThirdBundleTest1.hap
'
;
const
BUNDLE_NAME1
=
'
com.example.third1
'
;
const
BUNDLE_PATH1
=
[
'
/data/test/bmsThirdBundleTest1.hap
'
];
const
SYSTEM_PATH
=
'
/data/test/bmsSystemBundleTest2.hap
'
;
const
SYSTEM_NAME
=
'
com.example.system2
'
;
const
ABILITIY_NAME8
=
'
com.example.system2.MainAbility
'
;
const
USERID
=
100
;
let
installParam
=
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
};
describe
(
'
ActsBmsQueryAbilityByWant
'
,
function
()
{
/*
* @tc.number: bms_queryAbilityByWant_0100
* @tc.name: queryAbilityByWant callback by other callback
* @tc.desc: 1.queryAbilityByWant callback
* 2.queryAbilityByWant for third app
*/
it
(
'
bms_queryAbilityByWant_0100
'
,
0
,
async
function
(
done
){
console
.
info
(
'
=====================bms_queryAbilityByWant_0100==================
'
);
let
bundlePath
=
[
BUNDLE_PATH1
]
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
function
onReceiveinstallEvent
(
err
,
data
)
{
console
.
log
(
'
bms_queryAbilityByWant_0100 install called:
'
+
data
)
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
it
(
'
bms_queryAbilityByWant_0100
'
,
0
,
async
function
(
done
)
{
await
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
onReceiveinstallEvent
);
async
function
onReceiveinstallEvent
(
err
,
data
)
{
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
queryAbilityByWant
({
action
:
[
'
action.system.home
'
],
entities
:
[
'
entity.system.home
'
],
bundleName
:
BUNDLE_NAME1
},
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
USERID
).
then
(
data
=>
{
expect
(
data
).
assertFail
();
}).
catch
(
err
=>
{
expect
(
err
).
assertEqual
(
1
);
});
bundle
.
queryAbilityByWant
({
action
:
[
'
action.system.home
'
],
entities
:
[
'
entity.system.home
'
],
bundleName
:
BUNDLE_NAME1
},
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
100
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
'
bms_queryAbilityByWant_0100 test query system app err is
'
+
err
)
},
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
USERID
,
(
err
,
data
)
=>
{
expect
(
err
).
assertEqual
(
1
);
}
installer
.
uninstall
(
BUNDLE_NAME1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
}
,
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
expect
(
data
).
assertEqual
(
"
QueryAbilityInfos failed
"
);
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
});
}
)
}
installer
.
install
([
'
/data/test/bmsThirdBundleTest1.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
,
},
onReceiveinstallEvent
);
})
})
});
});
/*
* @tc.number: bms_queryAbilityByWant_0200
...
...
@@ -76,27 +73,132 @@ describe('ActsBmsQueryAbilityByWant', function () {
* @tc.desc: 1.queryAbilityByWant callback
* 2.queryAbilityByWant for systemapp
*/
it
(
'
bms_queryAbilityByWant_0200
'
,
0
,
async
function
(
done
){
console
.
info
(
'
=====================bms_queryAbilityByWant_0200==================
'
);
bundle
.
queryAbilityByWant
(
it
(
'
bms_queryAbilityByWant_0200
'
,
0
,
async
function
(
done
)
{
await
bundle
.
queryAbilityByWant
(
{
action
:
[
'
action.system.home
'
],
entities
:
[
'
entity.system.home
'
]
},
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
100
).
then
(
data
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
let
jsondata
=
JSON
.
stringify
(
data
[
i
]);
console
.
log
(
'
bms_queryAbilityByWant_0200 test query system app
'
+
jsondata
)
expect
(
data
[
i
].
applicationInfo
.
systemApp
).
assertEqual
(
true
)
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
USERID
).
then
(
data
=>
{
expect
(
data
.
length
).
assertLarger
(
0
);
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
expect
(
data
[
i
].
applicationInfo
.
systemApp
).
assertEqual
(
true
);
}
done
();
}
).
catch
(
err
=>
{
console
.
log
(
'
bms_queryAbilityByWant_0200 test query system app err is
'
+
err
)
expect
(
err
).
assertFail
()
expect
(
err
).
assertFail
();
});
bundle
.
queryAbilityByWant
(
{
action
:
[
'
action.system.home
'
],
entities
:
[
'
entity.system.home
'
]
},
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
bundle
.
BundleFlag
.
GET_ABILITY_INFO_SYSTEMAPP_ONLY
,
USERID
,
(
err
,
data
)
=>
{
if
(
err
)
{
expect
(
err
).
assertFail
();
}
expect
(
data
.
length
).
assertLarger
(
0
);
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
expect
(
data
[
i
].
applicationInfo
.
systemApp
).
assertEqual
(
true
);
}
done
();
});
});
/*
* @tc.number: bms_queryAbilityByEntities_0300
* @tc.name: Use the implicit query method in queryAbilityByWant to get abilityInfos
* @tc.desc: The entities in the parameter want pass in the new field, and use the implicit query to get abilitInfos
*/
it
(
'
bms_queryAbilityByEntities_0300
'
,
0
,
async
function
(
done
)
{
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
SYSTEM_PATH
],
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
let
dataInfos
=
await
bundle
.
queryAbilityByWant
({
action
:
'
action.system.home
'
,
entities
:
[
"
entity.app.music
"
,
"
entity.app.email
"
,
"
entity.app.contacts
"
,
"
entity.app.maps
"
,
"
entity.app.browser
"
,
"
entity.app.calendar
"
,
"
entity.app.messaging
"
,
"
entity.app.files
"
,
"
entity.app.gallery
"
],
elementName
:
{
deviceId
:
'
0
'
,
bundleName
:
''
,
abilityName
:
''
,
},
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
);
expect
(
dataInfos
.
length
).
assertEqual
(
1
);
cheackAbilityInfos
(
dataInfos
[
0
]);
bundle
.
queryAbilityByWant
({
action
:
'
action.system.home
'
,
entities
:
[
"
entity.app.music
"
,
"
entity.app.email
"
,
"
entity.app.contacts
"
,
"
entity.app.maps
"
,
"
entity.app.browser
"
,
"
entity.app.calendar
"
,
"
entity.app.messaging
"
,
"
entity.app.files
"
,
"
entity.app.gallery
"
],
elementName
:
{
deviceId
:
'
0
'
,
bundleName
:
''
,
abilityName
:
''
,
},
},
bundle
.
BundleFlag
.
GET_BUNDLE_DEFAULT
,
USERID
,
(
err
,
data
)
=>
{
expect
(
data
.
length
).
assertEqual
(
1
);
cheackAbilityInfos
(
data
[
0
]);
});
installer
.
uninstall
(
SYSTEM_NAME
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
})
})
});
});
});
async
function
cheackAbilityInfos
(
data
)
{
expect
(
data
.
name
).
assertEqual
(
ABILITIY_NAME8
);
expect
(
data
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
data
.
description
).
assertEqual
(
'
$string:mainability_description
'
);
expect
(
data
.
icon
).
assertEqual
(
"
$media:icon
"
);
expect
(
data
.
srcPath
).
assertEqual
(
""
);
expect
(
data
.
srcLanguage
).
assertEqual
(
"
js
"
);
expect
(
data
.
isVisible
).
assertEqual
(
false
);
expect
(
data
.
permissions
.
length
).
assertEqual
(
0
);
expect
(
data
.
deviceCapabilities
.
length
).
assertEqual
(
0
);
expect
(
data
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
data
.
process
).
assertEqual
(
''
);
expect
(
data
.
uri
).
assertEqual
(
''
);
expect
(
data
.
bundleName
).
assertEqual
(
SYSTEM_NAME
);
expect
(
data
.
moduleName
).
assertEqual
(
"
entry
"
);
expect
(
Object
.
keys
(
data
.
applicationInfo
).
length
).
assertLarger
(
0
);
expect
(
data
.
type
).
assertEqual
(
1
);
expect
(
data
.
orientation
).
assertEqual
(
0
);
expect
(
data
.
launchMode
).
assertEqual
(
1
);
expect
(
data
.
backgroundModes
).
assertEqual
(
0
);
expect
(
data
.
descriptionId
).
assertLarger
(
0
);
expect
(
data
.
formEnabled
).
assertEqual
(
false
);
expect
(
data
.
iconId
).
assertLarger
(
0
);
expect
(
data
.
labelId
).
assertLarger
(
0
);
expect
(
data
.
subType
).
assertEqual
(
0
);
expect
(
data
.
readPermission
).
assertEqual
(
""
);
expect
(
data
.
writePermission
).
assertEqual
(
""
);
expect
(
data
.
targetAbility
).
assertEqual
(
""
);
expect
(
data
.
theme
).
assertEqual
(
""
);
expect
(
data
.
metaData
.
length
).
assertEqual
(
0
);
expect
(
data
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
data
.
enabled
).
assertEqual
(
true
);
}
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js
浏览文件 @
eb382a27
...
...
@@ -12,7 +12,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./ActsBmsFormsInfoTest.test.js
'
)
require
(
'
./ActsBmsQueryAbilityByWant.test.js
'
)
require
(
'
./ActsBmsCleanCacheTest.test.js
'
)
require
(
'
./ActsBmsGetBackGroundModes.test.js
'
)
appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js
浏览文件 @
eb382a27
...
...
@@ -16,6 +16,26 @@
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
BUNDLE_PATH1
=
[
'
/data/test/bmsMainAbilityFirstScene.hap
'
];
const
BUNDLE_PATH2
=
[
'
/data/test/bmsMainAbilityFirstScene.hap
'
,
'
/data/test/bmsMainAbilitySecondScene.hap
'
];
const
BUNDLE_PATH3
=
[
'
/data/test/bmsThirdBundleTest2.hap
'
];
const
BUNDLE_PATH4
=
[
'
/data/test/bmsThirdBundleTest5.hap
'
];
const
BUNDLE_PATH5
=
[
'
/data/test/bmsThirdBundleTest1.hap
'
];
const
BUNDLE_PATH6
=
[
'
/data/test/bmsThirdBundleTestA1.hap
'
];
const
BUNDLE_NAME1
=
'
com.example.bmsmainabilityfirstscene
'
;
const
BUNDLE_NAME2
=
'
com.example.third2
'
;
const
BUNDLE_NAME3
=
'
com.example.third5
'
;
const
BUNDLE_NAME4
=
'
com.example.third1
'
;
const
BUNDLE_NAME5
=
'
com.example.system1
'
;
const
BUNDLE_NAME6
=
"
com.example.bmsmainabilitysecondscene
"
;
const
FIRSTMAINABILITY
=
'
com.example.bmsmainabilityfirstscene.MainAbility
'
;
const
SECONDMAINABILITY
=
'
com.example.bmsmainabilitysecondscene.MainAbility
'
;
let
installParam
=
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
};
describe
(
'
ActsBmsHapModuleTest
'
,
function
()
{
/*
...
...
@@ -24,60 +44,38 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get the module information of the hap with type of entry
*/
it
(
'
bms_getHapModuleInfo_0100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0100===========
'
)
let
bundlePath
=
[
'
/data/test/bmsMainAbilityFirstScene.hap
'
];
let
bundleName
=
'
com.example.bmsmainabilityfirstscene
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
onReceiveInstallEvent
);
function
onReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getBundleInfo
(
bundleName
,
1
,
callback
);
checkInstallOrUninstall
(
err
,
data
);
bundle
.
getBundleInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
callback
);
async
function
callback
(
err
,
result
)
{
expect
(
result
.
hapModuleInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
hapModuleInfos
.
length
>
0
)
{
let
hapModuleInfo
=
result
.
hapModuleInfos
[
0
];
expect
(
hapModuleInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
'
com.example.bmsmainabilityfirstscene.MainAbility
'
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
'
com.example.bmsmainabilityfirstscene.MainAbility
'
);
expect
(
hapModuleInfo
.
name
).
assertEqual
(
'
com.example.bmsmainabilityfirstscene
'
);
expect
(
hapModuleInfo
.
description
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
descriptionId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
hapModuleInfo
.
icon
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
hapModuleInfo
.
labelId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
supportedModes
).
assertEqual
(
0
);
console
.
info
(
'
hapModuleInfo.reqCapabilities
'
+
JSON
.
stringify
(
hapModuleInfo
.
reqCapabilities
));
expect
(
typeof
hapModuleInfo
.
reqCapabilities
).
assertEqual
(
'
object
'
);
console
.
info
(
'
===hapModuleInfo devicetypes===
'
+
JSON
.
stringify
(
hapModuleInfo
.
deviceTypes
));
expect
(
hapModuleInfo
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
console
.
info
(
'
===hapModuleInfo.abilityInfo===
'
+
JSON
.
stringify
(
hapModuleInfo
.
abilityInfo
));
expect
(
typeof
hapModuleInfo
.
abilityInfo
).
assertEqual
(
'
object
'
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
'
com.example.bmsmainabilityfirstscene.MainAbility
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
FIRSTMAINABILITY
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
FIRSTMAINABILITY
);
expect
(
hapModuleInfo
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
hapModuleInfo
.
colorMode
).
assertEqual
(
-
1
);
expect
(
hapModuleInfo
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
installationFree
).
assertEqual
(
false
);
for
(
let
i
=
0
,
len
=
hapModuleInfo
.
reqCapabilities
.
length
;
i
<
len
;
i
++
)
{
expect
(
hapModuleInfo
.
reqCapabilities
[
i
]).
assertEqual
(
''
);
}
for
(
let
j
=
0
,
len
=
hapModuleInfo
.
abilityInfo
.
length
;
j
<
len
;
j
++
)
{
expect
(
hapModuleInfo
.
abilityInfo
[
j
].
name
).
assertEqual
(
'
com.example.bmsmainabilityfirstscene.MainAbility
'
);
}
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
...
...
@@ -90,43 +88,32 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get the module information of the hap with type of feature
*/
it
(
'
bms_getHapModuleInfo_0200
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0200===========
'
)
let
bundlePath
=
[
'
/data/test/bmsMainAbilityFirstScene.hap
'
,
'
/data/test/bmsMainAbilitySecondScene.hap
'
];
let
bundleName
=
'
com.example.bmsmainabilityfirstscene
'
;
let
firstMainAbility
=
'
com.example.bmsmainabilityfirstscene.MainAbility
'
;
let
secondMainAbility
=
'
com.example.bmsmainabilitysecondscene.MainAbility
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getBundleInfo
(
bundleName
,
1
,
async
(
err
,
result
)
=>
{
installer
.
install
(
BUNDLE_PATH2
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
bundle
.
getBundleInfo
(
BUNDLE_NAME1
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
async
(
err
,
result
)
=>
{
expect
(
result
.
hapModuleInfos
.
length
).
assertEqual
(
2
);
if
(
result
.
hapModuleInfos
.
length
==
2
)
{
expect
(
result
.
hapModuleInfos
[
0
].
mainAbilityName
).
assertEqual
(
firstMainAbility
);
expect
(
result
.
hapModuleInfos
[
0
].
moduleName
).
assertEqual
(
'
entry
'
);
checkHapModuleInfo
(
result
.
hapModuleInfos
[
0
]);
expect
(
result
.
hapModuleInfos
[
1
].
mainAbilityName
).
assertEqual
(
secondMainAbility
);
expect
(
result
.
hapModuleInfos
[
1
].
moduleName
).
assertEqual
(
'
bmsmainabilitysecondscene
'
);
checkHapModuleInfo
(
result
.
hapModuleInfos
[
1
]);
let
hapModuleInfo
=
result
.
hapModuleInfos
[
0
];
let
hapModuleInfo1
=
result
.
hapModuleInfos
[
1
];
checkHapMoudleInfos
(
hapModuleInfo
);
checkHapMoudleInfos
(
hapModuleInfo1
);
expect
(
hapModuleInfo
.
name
).
assertEqual
(
BUNDLE_NAME1
);
expect
(
hapModuleInfo1
.
name
).
assertEqual
(
BUNDLE_NAME6
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
FIRSTMAINABILITY
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
FIRSTMAINABILITY
);
expect
(
hapModuleInfo1
.
moduleName
).
assertEqual
(
'
bmsmainabilitysecondscene
'
);
expect
(
hapModuleInfo1
.
mainAbilityName
).
assertEqual
(
SECONDMAINABILITY
);
expect
(
hapModuleInfo1
.
mainElementName
).
assertEqual
(
SECONDMAINABILITY
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
});
});
})
})
;
/*
* @tc.number: bms_getHapModuleInfo_0300
...
...
@@ -134,50 +121,43 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get the module information of the hap without mainAbility
*/
it
(
'
bms_getHapModuleInfo_0300
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0300===========
'
)
let
bundlePath
=
[
'
/data/test/bmsThirdBundleTest2.hap
'
];
let
bundleName
=
'
com.example.third2
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
console
.
log
(
'
========install========
'
+
typeof
installer
);
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
function
onReceiveInstallEvent
(
err
,
data
)
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getBundleInfo
(
bundleName
,
1
,).
then
(
async
(
result
)
=>
{
console
.
debug
(
'
=======get hapModule========
'
+
JSON
.
stringify
(
result
))
installer
.
install
(
BUNDLE_PATH3
,
installParam
,
onReceiveInstallEvent
);
async
function
onReceiveInstallEvent
(
err
,
data
)
{
checkInstallOrUninstall
(
err
,
data
);
await
bundle
.
getBundleInfo
(
BUNDLE_NAME2
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
)
.
then
(
async
(
result
)
=>
{
expect
(
result
.
hapModuleInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
hapModuleInfos
.
length
>
0
)
{
console
.
debug
(
'
=======get hapModule mainAbilityName========
'
+
result
.
hapModuleInfos
[
0
].
mainAbilityName
)
expect
(
result
.
hapModuleInfos
[
0
].
mainAbilityName
).
assertEqual
(
''
);
expect
(
result
.
hapModuleInfos
[
0
].
moduleName
).
assertEqual
(
'
entry
'
);
checkHapModuleInfo
(
result
.
hapModuleInfos
[
0
]);
let
hapModuleInfo
=
result
.
hapModuleInfos
[
0
];
expect
(
hapModuleInfo
.
name
).
assertEqual
(
BUNDLE_NAME2
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
description
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
descriptionId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
hapModuleInfo
.
icon
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
hapModuleInfo
.
labelId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
supportedModes
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
hapModuleInfo
.
colorMode
).
assertEqual
(
-
1
);
expect
(
hapModuleInfo
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
installationFree
).
assertEqual
(
false
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveUninstallEvent
);
function
onReceiveUninstallEvent
(
err
,
data
)
{
console
.
info
(
'
========uninstall Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME2
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
}
});
});
}
})
})
;
/*
* @tc.number: bms_getHapModuleInfo_0400
...
...
@@ -185,45 +165,41 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get the module information of the hap with the added field mainAbility
*/
it
(
'
bms_getHapModuleInfo_0400
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0400===========
'
)
let
bundlePath
=
[
'
/data/test/bmsThirdBundleTest5.hap
'
];
let
bundleName
=
'
com.example.third5
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
console
.
log
(
'
========install========
'
+
typeof
installer
);
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getBundleInfo
(
bundleName
,
1
,
async
(
err
,
result
)
=>
{
console
.
debug
(
'
=======get hapModule========
'
+
JSON
.
stringify
(
result
))
installer
.
install
(
BUNDLE_PATH4
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
bundle
.
getBundleInfo
(
BUNDLE_NAME3
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
async
(
err
,
result
)
=>
{
expect
(
result
.
hapModuleInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
hapModuleInfos
.
length
==
1
)
{
expect
(
result
.
hapModuleInfos
[
0
].
mainAbilityName
).
assertEqual
(
'
com.example.third5.AMainAbility
'
);
expect
(
result
.
hapModuleInfos
[
0
].
moduleName
).
assertEqual
(
'
entry
'
);
checkHapModuleInfo
(
result
.
hapModuleInfos
[
0
]);
let
hapModuleInfo
=
result
.
hapModuleInfos
[
0
];
expect
(
hapModuleInfo
.
name
).
assertEqual
(
BUNDLE_NAME3
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
description
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
descriptionId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
hapModuleInfo
.
icon
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
hapModuleInfo
.
labelId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
supportedModes
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
"
com.example.third5.AMainAbility
"
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
"
com.example.third5.AMainAbility
"
);
expect
(
hapModuleInfo
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
hapModuleInfo
.
colorMode
).
assertEqual
(
-
1
);
expect
(
hapModuleInfo
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
installationFree
).
assertEqual
(
false
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveUninstallEvent
);
function
onReceiveUninstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME3
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
}
});
})
})
});
});
});
/*
* @tc.number: bms_getHapModuleInfo_0500
...
...
@@ -231,48 +207,43 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get the module information of the mainAbility upgrade hap
*/
it
(
'
bms_getHapModuleInfo_0500
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0500===========
'
)
let
bundlePath1
=
[
'
/data/test/bmsThirdBundleTest1.hap
'
];
let
bundlePath2
=
[
'
/data/test/bmsThirdBundleTestA1.hap
'
];
let
bundleName
=
'
com.example.third1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath1
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
install
(
bundlePath2
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
bundle
.
getBundleInfo
(
bundleName
,
1
,
callback
);
})
installer
.
install
(
BUNDLE_PATH5
,
installParam
,
async
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
installer
.
install
(
BUNDLE_PATH6
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
bundle
.
getBundleInfo
(
BUNDLE_NAME4
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
callback
);
})
});
function
callback
(
err
,
result
)
{
expect
(
result
.
hapModuleInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
hapModuleInfos
.
length
==
1
)
{
let
hapModuleInfo
=
result
.
hapModuleInfos
[
0
];
expect
(
hapModuleInfo
.
name
).
assertEqual
(
"
com.example.third1.entry
"
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
'
com.example.third1.AMainAbility
'
);
checkHapModuleInfo
(
hapModuleInfo
);
expect
(
hapModuleInfo
.
description
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
descriptionId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
hapModuleInfo
.
icon
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
hapModuleInfo
.
labelId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
supportedModes
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
"
com.example.third1.AMainAbility
"
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
"
com.example.third1.AMainAbility
"
);
expect
(
hapModuleInfo
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
hapModuleInfo
.
colorMode
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
installationFree
).
assertEqual
(
false
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
})
})
;
}
});
...
...
@@ -282,38 +253,58 @@ describe('ActsBmsHapModuleTest', function () {
* @tc.desc: get module information of mainAbility system application
*/
it
(
'
bms_getHapModuleInfo_0600
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
===========begin bms_getHapModuleInfo_0600===========
'
)
let
bundleName
=
'
com.example.system1
'
;
bundle
.
getBundleInfo
(
bundleName
,
1
,
callback
);
bundle
.
getBundleInfo
(
BUNDLE_NAME5
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
,
callback
);
function
callback
(
err
,
data
)
{
expect
(
data
.
hapModuleInfos
.
length
).
assertEqual
(
1
);
if
(
data
.
hapModuleInfos
.
length
==
1
)
{
let
hapModuleInfo
=
data
.
hapModuleInfos
[
0
];
console
.
debug
(
'
=======get hapModule========
'
+
JSON
.
stringify
(
hapModuleInfo
))
console
.
debug
(
'
=======get hapModule mainAbilityName========
'
+
hapModuleInfo
.
mainAbilityName
)
expect
(
hapModuleInfo
.
name
).
assertEqual
(
BUNDLE_NAME5
);
expect
(
hapModuleInfo
.
moduleName
).
assertEqual
(
'
entry
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
'
com.example.system1.MainAbility
'
);
checkHapModuleInfo
(
hapModuleInfo
);
expect
(
hapModuleInfo
.
description
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
descriptionId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
hapModuleInfo
.
icon
).
assertEqual
(
''
);
expect
(
hapModuleInfo
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
hapModuleInfo
.
labelId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
iconId
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
backgroundImg
).
assertEqual
(
""
);
expect
(
hapModuleInfo
.
supportedModes
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
hapModuleInfo
.
mainAbilityName
).
assertEqual
(
"
com.example.system1.MainAbility
"
);
expect
(
hapModuleInfo
.
mainElementName
).
assertEqual
(
"
com.example.system1.MainAbility
"
);
expect
(
hapModuleInfo
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
hapModuleInfo
.
colorMode
).
assertEqual
(
-
1
);
expect
(
hapModuleInfo
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
hapModuleInfo
.
installationFree
).
assertEqual
(
false
);
}
done
();
}
});
function
checkHapModuleInfo
(
dataInfo
)
{
expect
(
typeof
dataInfo
.
name
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
description
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
descriptionId
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
icon
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
label
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
labelId
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
iconId
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
backgroundImg
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
supportedModes
).
assertEqual
(
'
number
'
);
expect
(
typeof
dataInfo
.
reqCapabilities
).
assertEqual
(
'
object
'
);
expect
(
typeof
dataInfo
.
deviceTypes
).
assertEqual
(
'
object
'
);
expect
(
typeof
dataInfo
.
abilityInfo
).
assertEqual
(
'
object
'
);
expect
(
typeof
dataInfo
.
moduleName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
mainAbilityName
).
assertEqual
(
'
string
'
);
expect
(
typeof
dataInfo
.
installationFree
).
assertEqual
(
'
boolean
'
);
function
checkHapMoudleInfos
(
info
)
{
expect
(
info
.
description
).
assertEqual
(
''
);
expect
(
info
.
descriptionId
).
assertEqual
(
0
);
expect
(
info
.
iconPath
).
assertEqual
(
"
$media:icon
"
);
expect
(
info
.
icon
).
assertEqual
(
''
);
expect
(
info
.
label
).
assertEqual
(
'
$string:app_name
'
);
expect
(
info
.
labelId
).
assertEqual
(
0
);
expect
(
info
.
iconId
).
assertEqual
(
0
);
expect
(
info
.
backgroundImg
).
assertEqual
(
""
);
expect
(
info
.
supportedModes
).
assertEqual
(
0
);
expect
(
info
.
reqCapabilities
.
length
).
assertEqual
(
0
);
expect
(
info
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
info
.
abilityInfo
.
length
).
assertLarger
(
0
);
expect
(
info
.
colorMode
).
assertEqual
(
-
1
);
expect
(
info
.
extensionAbilityInfo
.
length
).
assertEqual
(
0
);
expect
(
info
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
info
.
installationFree
).
assertEqual
(
false
);
}
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js
浏览文件 @
eb382a27
...
...
@@ -14,12 +14,35 @@
*/
import
bundle
from
'
@ohos.bundle
'
import
pkg
from
'
@system.package
'
const
bundleName
=
'
com.ohos.launcher
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
NUM_TWO
=
2
;
const
NUM_FOUR
=
4
;
const
ERR_CODE
=
202
;
const
ERR_MERSSAGE
=
'
value is not an available number
'
;
const
BUNDLE_NAME1
=
'
com.ohos.launcher
'
;
const
BUNDLE_NAME2
=
'
com.example.third2
'
;
const
BUNDLE_NAME3
=
'
com.example.third5
'
;
const
BUNDLE_NAME4
=
'
com.example.js
'
;
const
BUNDLE_NAME5
=
'
com.example.c
'
;
const
ABILITIY_NAME1
=
'
com.example.third2.MainAbility
'
;
const
ABILITIY_NAME2
=
'
com.example.third5.AMainAbility
'
;
const
ABILITIY_NAME3
=
'
com.example.third5.BMainAbility
'
;
const
ABILITIY_NAME4
=
'
com.example.js.MainAbility
'
;
const
ABILITIY_NAME5
=
'
.MainAbility
'
;
const
ABILITIY_NAME6
=
"
com.example.third2.MainAbilityA
"
;
const
ABILITIY_NAME7
=
"
com.example.third5.MainAbilityA
"
;
const
ABILITIY_NAME8
=
"
com.example.third5.MainAbilityB
"
;
const
BUNDLE_PATH1
=
[
'
/data/test/bmsThirdBundleTest2.hap
'
];
const
BUNDLE_PATH2
=
[
'
/data/test/bmsThirdBundleTest5.hap
'
];
const
BUNDLE_PATH3
=
[
'
/data/test/bmsThirdBundleJs.hap
'
];
const
BUNDLE_PATH4
=
[
'
/data/test/bmsThirdBundleC.hap
'
];
let
installParam
=
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
};
describe
(
'
ActsBmsJsTest
'
,
function
()
{
/*
...
...
@@ -29,44 +52,55 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo
*/
it
(
'
bms_getJsAbility_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_getJsAbility_0100==================
'
);
let
bundleName
=
'
com.example.third2
'
;
let
abilityName
=
'
com.example.third2.MainAbility
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest2.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH1
,
installParam
,
onReceiveInstallEvent
);
async
function
onReceiveInstallEvent
(
err
,
data
)
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
result
=
await
bundle
.
getBundleInfo
(
bundleName
,
1
);
checkInstallOrUninstall
(
err
,
data
);
let
result
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME2
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
);
expect
(
result
.
abilityInfos
.
length
).
assertEqual
(
NUM_TWO
);
if
(
result
.
abilityInfos
.
length
==
NUM_TWO
)
{
console
.
debug
(
'
========check abilityName ========
'
+
JSON
.
stringify
(
result
.
abilityInfos
));
expect
(
result
.
abilityInfos
[
0
].
name
).
assertEqual
(
abilityName
);
expect
(
result
.
abilityInfos
[
0
].
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
result
.
abilityInfos
[
0
].
srcPath
).
assertEqual
(
''
);
let
abilityInfo1
=
result
.
abilityInfos
[
0
];
let
abilityInfo2
=
result
.
abilityInfos
[
1
];
expect
(
abilityInfo1
.
name
).
assertEqual
(
ABILITIY_NAME1
);
expect
(
abilityInfo2
.
name
).
assertEqual
(
ABILITIY_NAME6
);
expect
(
abilityInfo1
.
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
abilityInfo1
.
srcPath
).
assertEqual
(
''
);
expect
(
abilityInfo1
.
label
).
assertEqual
(
"
$string:app_name
"
);
expect
(
abilityInfo1
.
description
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
abilityInfo1
.
icon
).
assertEqual
(
"
$media:icon
"
);
expect
(
abilityInfo1
.
isVisible
).
assertEqual
(
true
);
expect
(
abilityInfo1
.
permissions
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
abilityInfo1
.
process
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
uri
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
bundleName
).
assertEqual
(
BUNDLE_NAME2
);
expect
(
abilityInfo1
.
moduleName
).
assertEqual
(
"
entry
"
);
expect
(
Object
.
keys
(
abilityInfo1
.
applicationInfo
).
length
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
type
).
assertEqual
(
1
);
expect
(
abilityInfo2
.
type
).
assertEqual
(
2
);
expect
(
abilityInfo1
.
orientation
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
launchMode
).
assertEqual
(
1
);
expect
(
abilityInfo1
.
backgroundModes
).
assertEqual
(
0
);
expect
(
abilityInfo2
.
backgroundModes
).
assertEqual
(
510
);
expect
(
abilityInfo1
.
descriptionId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
formEnabled
).
assertEqual
(
false
);
expect
(
abilityInfo1
.
iconId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
labelId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
subType
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
readPermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
writePermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
targetAbility
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
theme
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
metaData
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
enabled
).
assertEqual
(
true
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
console
.
info
(
'
========uninstall Finish========
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME2
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
})
})
;
/*
* @tc.number: bms_getJsAbility_0200
...
...
@@ -75,48 +109,36 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo
*/
it
(
'
bms_getJsAbility_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_getJsAbility_0200==================
'
);
let
bundleName
=
'
com.example.third5
'
;
let
abilityName1
=
'
com.example.third5.AMainAbility
'
;
let
abilityName2
=
'
com.example.third5.BMainAbility
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleTest5.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH2
,
installParam
,
onReceiveInstallEvent
);
async
function
onReceiveInstallEvent
(
err
,
data
)
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
result
=
await
bundle
.
getBundleInfo
(
bundleName
,
1
)
console
.
debug
(
'
==========bundleInfo==========
'
+
JSON
.
stringify
(
result
))
checkInstallOrUninstall
(
err
,
data
);
let
result
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME3
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
);
expect
(
result
.
abilityInfos
.
length
).
assertEqual
(
NUM_FOUR
);
if
(
result
.
abilityInfos
.
length
==
NUM_FOUR
)
{
console
.
debug
(
'
========check abilityName ========
'
+
JSON
.
stringify
(
result
.
abilityInfos
));
expect
(
result
.
abilityInfos
[
0
].
name
).
assertEqual
(
abilityName1
);
expect
(
result
.
abilityInfos
[
0
].
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
result
.
abilityInfos
[
0
].
srcPath
).
assertEqual
(
''
);
expect
(
result
.
abilityInfos
[
1
].
name
).
assertEqual
(
abilityName2
);
expect
(
result
.
abilityInfos
[
1
].
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
result
.
abilityInfos
[
1
].
srcPath
).
assertEqual
(
''
);
let
abilityInfo1
=
result
.
abilityInfos
[
0
];
let
abilityInfo2
=
result
.
abilityInfos
[
1
];
let
abilityInfo3
=
result
.
abilityInfos
[
2
];
let
abilityInfo4
=
result
.
abilityInfos
[
3
];
checkAbilityInfos
(
abilityInfo1
);
expect
(
abilityInfo2
.
metaData
.
length
).
assertEqual
(
1
);
expect
(
abilityInfo2
.
metaData
[
0
].
name
).
assertEqual
(
"
Data5B
"
);
expect
(
abilityInfo2
.
metaData
[
0
].
value
).
assertEqual
(
"
float
"
);
expect
(
abilityInfo2
.
metaData
[
0
].
extra
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
abilityInfo2
.
name
).
assertEqual
(
ABILITIY_NAME3
);
expect
(
abilityInfo3
.
name
).
assertEqual
(
ABILITIY_NAME7
);
expect
(
abilityInfo4
.
name
).
assertEqual
(
ABILITIY_NAME8
);
expect
(
abilityInfo3
.
type
).
assertEqual
(
2
);
expect
(
abilityInfo4
.
type
).
assertEqual
(
2
);
expect
(
abilityInfo3
.
backgroundModes
).
assertEqual
(
511
);
expect
(
abilityInfo4
.
backgroundModes
).
assertEqual
(
129
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME3
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
})
})
;
/*
* @tc.number: bms_getJsAbility_0300
...
...
@@ -125,44 +147,51 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo
*/
it
(
'
bms_getJsAbility_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_getJsAbility_0300==================
'
);
let
bundleName
=
'
com.example.js
'
;
let
abilityName
=
'
com.example.js.MainAbility
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleJs.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH3
,
installParam
,
onReceiveInstallEvent
);
async
function
onReceiveInstallEvent
(
err
,
data
)
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
result
=
await
bundle
.
getBundleInfo
(
bundleName
,
1
);
checkInstallOrUninstall
(
err
,
data
);
let
result
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME4
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
);
expect
(
result
.
abilityInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
abilityInfos
.
length
==
1
)
{
console
.
debug
(
'
========check abilityName ========
'
+
JSON
.
stringify
(
result
.
abilityInfos
));
expect
(
result
.
abilityInfos
[
0
].
name
).
assertEqual
(
abilityName
);
expect
(
result
.
abilityInfos
[
0
].
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
result
.
abilityInfos
[
0
].
srcPath
).
assertEqual
(
'
default
'
);
let
abilityInfo1
=
result
.
abilityInfos
[
0
];
expect
(
abilityInfo1
.
name
).
assertEqual
(
ABILITIY_NAME4
);
expect
(
abilityInfo1
.
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
abilityInfo1
.
srcPath
).
assertEqual
(
'
default
'
);
expect
(
abilityInfo1
.
label
).
assertEqual
(
"
$string:app_name
"
);
expect
(
abilityInfo1
.
description
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
abilityInfo1
.
icon
).
assertEqual
(
"
$media:icon
"
);
expect
(
abilityInfo1
.
isVisible
).
assertEqual
(
true
);
expect
(
abilityInfo1
.
permissions
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
abilityInfo1
.
process
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
uri
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
bundleName
).
assertEqual
(
BUNDLE_NAME4
);
expect
(
abilityInfo1
.
moduleName
).
assertEqual
(
"
entry
"
);
expect
(
Object
.
keys
(
abilityInfo1
.
applicationInfo
).
length
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
type
).
assertEqual
(
1
);
expect
(
abilityInfo1
.
orientation
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
launchMode
).
assertEqual
(
1
);
expect
(
abilityInfo1
.
backgroundModes
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
descriptionId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
formEnabled
).
assertEqual
(
false
);
expect
(
abilityInfo1
.
iconId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
labelId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
subType
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
readPermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
writePermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
targetAbility
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
theme
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
metaData
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
enabled
).
assertEqual
(
true
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
console
.
info
(
'
========uninstall Finish========
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME4
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
})
})
;
/*
* @tc.number: bms_getJsAbility_0400
...
...
@@ -171,44 +200,51 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo
*/
it
(
'
bms_getJsAbility_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
=====================bms_getJsAbility_0400==================
'
);
let
bundleName
=
'
com.example.c
'
;
let
abilityName
=
'
.MainAbility
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
([
'
/data/test/bmsThirdBundleC.hap
'
],
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
onReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH4
,
installParam
,
onReceiveInstallEvent
);
async
function
onReceiveInstallEvent
(
err
,
data
)
{
console
.
info
(
'
========install Finish========
'
);
expect
(
typeof
err
).
assertEqual
(
'
object
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
typeof
data
).
assertEqual
(
'
object
'
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
let
result
=
await
bundle
.
getBundleInfo
(
bundleName
,
1
);
checkInstallOrUninstall
(
err
,
data
);
let
result
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME5
,
bundle
.
BundleFlag
.
GET_BUNDLE_WITH_ABILITIES
);
expect
(
result
.
abilityInfos
.
length
).
assertEqual
(
1
);
if
(
result
.
abilityInfos
.
length
==
1
)
{
console
.
debug
(
'
========check abilityName ========
'
+
JSON
.
stringify
(
result
.
abilityInfos
));
expect
(
result
.
abilityInfos
[
0
].
name
).
assertEqual
(
abilityName
);
expect
(
result
.
abilityInfos
[
0
].
srcLanguage
).
assertEqual
(
'
c++
'
);
expect
(
result
.
abilityInfos
[
0
].
srcPath
).
assertEqual
(
'
default/c++/
'
);
let
abilityInfo1
=
result
.
abilityInfos
[
0
];
expect
(
abilityInfo1
.
name
).
assertEqual
(
ABILITIY_NAME5
);
expect
(
abilityInfo1
.
srcLanguage
).
assertEqual
(
'
c++
'
);
expect
(
abilityInfo1
.
srcPath
).
assertEqual
(
'
default/c++/
'
);
expect
(
abilityInfo1
.
label
).
assertEqual
(
"
$string:app_name
"
);
expect
(
abilityInfo1
.
description
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
abilityInfo1
.
icon
).
assertEqual
(
"
$media:icon
"
);
expect
(
abilityInfo1
.
isVisible
).
assertEqual
(
true
);
expect
(
abilityInfo1
.
permissions
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
abilityInfo1
.
process
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
uri
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
bundleName
).
assertEqual
(
BUNDLE_NAME5
);
expect
(
abilityInfo1
.
moduleName
).
assertEqual
(
"
entry
"
);
expect
(
Object
.
keys
(
abilityInfo1
.
applicationInfo
).
length
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
type
).
assertEqual
(
1
);
expect
(
abilityInfo1
.
orientation
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
launchMode
).
assertEqual
(
1
);
expect
(
abilityInfo1
.
backgroundModes
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
descriptionId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
formEnabled
).
assertEqual
(
false
);
expect
(
abilityInfo1
.
iconId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
labelId
).
assertLarger
(
0
);
expect
(
abilityInfo1
.
subType
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
readPermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
writePermission
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
targetAbility
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
theme
).
assertEqual
(
""
);
expect
(
abilityInfo1
.
metaData
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
metadata
.
length
).
assertEqual
(
0
);
expect
(
abilityInfo1
.
enabled
).
assertEqual
(
true
);
}
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
console
.
info
(
'
========uninstall Finish========
'
);
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
installer
.
uninstall
(
BUNDLE_NAME5
,
installParam
,
(
err
,
data
)
=>
{
checkInstallOrUninstall
(
err
,
data
);
done
();
});
}
})
})
;
/**
* @tc.number getNameForUid_0100
...
...
@@ -216,18 +252,18 @@ describe('ActsBmsJsTest', function () {
* @tc.desc Test getBundleInfo interfaces with hap.
*/
it
(
'
getNameForUid_0100
'
,
0
,
async
function
(
done
)
{
bundle
.
getBundleInfo
(
bundleName
).
then
(
dataInfo
=>
{
await
bundle
.
getBundleInfo
(
BUNDLE_NAME1
).
then
(
dataInfo
=>
{
bundle
.
getNameForUid
(
dataInfo
.
uid
).
then
(
data
=>
{
expect
(
data
).
assertEqual
(
bundleName
)
done
()
expect
(
data
).
assertEqual
(
BUNDLE_NAME1
)
done
()
;
})
})
.
catch
(
err
=>
{
console
.
info
(
"
getNameForUid fail:
"
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertFail
()
done
()
})
})
done
();
});
})
;
/**
* @tc.number getNameForUid_0200
...
...
@@ -235,11 +271,11 @@ describe('ActsBmsJsTest', function () {
* @tc.desc Test getBundleInfo interfaces with hap.
*/
it
(
'
getNameForUid_0200
'
,
0
,
async
function
(
done
)
{
let
dataInfo
=
await
bundle
.
getBundleInfo
(
bundleName
)
let
data
=
await
bundle
.
getNameForUid
(
dataInfo
.
uid
)
expect
(
data
).
assertEqual
(
bundleName
)
done
()
})
let
dataInfo
=
await
bundle
.
getBundleInfo
(
BUNDLE_NAME1
);
let
data
=
await
bundle
.
getNameForUid
(
dataInfo
.
uid
)
;
expect
(
data
).
assertEqual
(
BUNDLE_NAME1
);
done
()
;
})
;
/**
* @tc.number hasInstalled_0100
...
...
@@ -262,8 +298,8 @@ describe('ActsBmsJsTest', function () {
expect
().
assertFail
();
}
});
done
()
})
done
()
;
})
;
/**
* @tc.number hasInstalled_0200
...
...
@@ -286,8 +322,8 @@ describe('ActsBmsJsTest', function () {
expect
().
assertFail
();
}
});
done
()
})
done
()
;
})
;
/**
* @tc.number hasInstalled_0300
...
...
@@ -302,8 +338,8 @@ describe('ActsBmsJsTest', function () {
expect
(
data
.
result
).
assertFalse
();
}
});
done
()
})
done
()
;
})
;
/**
* @tc.number hasInstalled_0400
...
...
@@ -326,6 +362,47 @@ describe('ActsBmsJsTest', function () {
console
.
info
(
'
hasInstalled complete function in
'
);
}
});
done
()
})
done
();
});
function
checkAbilityInfos
(
info
)
{
expect
(
info
.
name
).
assertEqual
(
ABILITIY_NAME2
);
expect
(
info
.
srcLanguage
).
assertEqual
(
'
js
'
);
expect
(
info
.
srcPath
).
assertEqual
(
''
);
expect
(
info
.
label
).
assertEqual
(
"
$string:app_name
"
);
expect
(
info
.
description
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
info
.
icon
).
assertEqual
(
"
$media:icon
"
);
expect
(
info
.
isVisible
).
assertEqual
(
true
);
expect
(
info
.
permissions
.
length
).
assertEqual
(
0
);
expect
(
info
.
deviceTypes
[
0
]).
assertEqual
(
'
phone
'
);
expect
(
info
.
process
).
assertEqual
(
""
);
expect
(
info
.
uri
).
assertEqual
(
""
);
expect
(
info
.
bundleName
).
assertEqual
(
BUNDLE_NAME3
);
expect
(
info
.
moduleName
).
assertEqual
(
"
entry
"
);
expect
(
Object
.
keys
(
info
.
applicationInfo
).
length
).
assertLarger
(
0
);
expect
(
info
.
type
).
assertEqual
(
1
);
expect
(
info
.
orientation
).
assertEqual
(
0
);
expect
(
info
.
launchMode
).
assertEqual
(
1
);
expect
(
info
.
backgroundModes
).
assertEqual
(
0
);
expect
(
info
.
descriptionId
).
assertLarger
(
0
);
expect
(
info
.
formEnabled
).
assertEqual
(
false
);
expect
(
info
.
iconId
).
assertLarger
(
0
);
expect
(
info
.
labelId
).
assertLarger
(
0
);
expect
(
info
.
subType
).
assertEqual
(
0
);
expect
(
info
.
readPermission
).
assertEqual
(
""
);
expect
(
info
.
writePermission
).
assertEqual
(
""
);
expect
(
info
.
targetAbility
).
assertEqual
(
""
);
expect
(
info
.
theme
).
assertEqual
(
""
);
expect
(
info
.
metaData
.
length
).
assertEqual
(
1
);
expect
(
info
.
metaData
[
0
].
name
).
assertEqual
(
"
Data5A
"
);
expect
(
info
.
metaData
[
0
].
value
).
assertEqual
(
"
float
"
);
expect
(
info
.
metaData
[
0
].
extra
).
assertEqual
(
"
$string:mainability_description
"
);
expect
(
info
.
enabled
).
assertEqual
(
true
);
}
function
checkInstallOrUninstall
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
}
})
\ No newline at end of file
appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js
浏览文件 @
eb382a27
...
...
@@ -15,16 +15,22 @@
import
bundle
from
'
@ohos.bundle
'
import
innerBundleManager
from
'
@ohos.bundle.innerBundleManager
'
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
const
STATUS_INSTALL_PERMISSION_DENIED
=
0X44
;
const
STATUS_UNINSTALL_PERMISSION_DENIED
=
0X45
;
const
LAUNCHER_BUNDLE_NAME
=
'
com.ohos.launcher
'
;
const
LAUNCHER_MAIN_ABILITY
=
'
com.ohos.launcher.MainAbility
'
;
const
DEFAULT_FLAG
=
0
;
const
DEFAULT_USER_ID
=
100
;
const
INVALID_CODE
=
1
;
const
BUNDLE_PATH
=
[
'
/data/test/bmsJstest1.hap
'
];
const
BUNDLE_NAME1
=
'
com.example.myapplication1
'
;
let
installParam
=
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
};
describe
(
'
ActsBmsJsUnPermissionTest
'
,
function
()
{
...
...
@@ -34,14 +40,8 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test js install
*/
it
(
'
bms_JsInstallPermissionTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_JsInstallPermissionTest start
'
);
let
bundlePath
=
[
'
/data/test/bmsJstest1.hap
'
];
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
install
(
bundlePath
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveInstallEvent
);
installer
.
install
(
BUNDLE_PATH
,
installParam
,
OnReceiveInstallEvent
);
async
function
OnReceiveInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
status
).
assertEqual
(
STATUS_INSTALL_PERMISSION_DENIED
);
...
...
@@ -56,14 +56,8 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test js uninstall
*/
it
(
'
bms_JsUnInstallPermissionTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
bms_JsUnInstallPermissionTest start
'
);
let
bundleName
=
'
com.example.myapplication1
'
;
let
installer
=
await
bundle
.
getBundleInstaller
();
installer
.
uninstall
(
bundleName
,
{
userId
:
100
,
installFlag
:
1
,
isKeepData
:
false
},
OnReceiveUnInstallEvent
);
installer
.
uninstall
(
BUNDLE_NAME1
,
installParam
,
OnReceiveUnInstallEvent
);
async
function
OnReceiveUnInstallEvent
(
err
,
data
)
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
status
).
assertEqual
(
STATUS_UNINSTALL_PERMISSION_DENIED
);
...
...
@@ -78,8 +72,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getApplicationInfo
*/
it
(
'
getApplicationInfoTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getApplicationInfoTest_100 start
'
);
bundle
.
getApplicationInfo
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_FLAG
,
DEFAULT_USER_ID
).
then
(
data
=>
{
await
bundle
.
getApplicationInfo
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_FLAG
,
DEFAULT_USER_ID
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -94,8 +87,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAllApplicationInfo
*/
it
(
'
getAllApplicationInfoTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getAllApplicationInfoTest_100 start
'
);
bundle
.
getAllApplicationInfo
(
DEFAULT_FLAG
,
DEFAULT_USER_ID
).
then
(
data
=>
{
await
bundle
.
getAllApplicationInfo
(
DEFAULT_FLAG
,
DEFAULT_USER_ID
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -110,8 +102,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getBundleInfo
*/
it
(
'
getBundleInfoTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getBundleInfoTest_100 start
'
);
bundle
.
getBundleInfo
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_USER_ID
).
then
(
data
=>
{
await
bundle
.
getBundleInfo
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_USER_ID
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -126,8 +117,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAllBundleInfo
*/
it
(
'
getAllBundleInfoTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getAllBundleInfoTest_100 start
'
);
bundle
.
getAllBundleInfo
(
DEFAULT_FLAG
).
then
(
data
=>
{
await
bundle
.
getAllBundleInfo
(
DEFAULT_FLAG
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -142,8 +132,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test queryAbilityByWant
*/
it
(
'
queryAbilityByWantTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
queryAbilityByWantTest_100 start
'
);
bundle
.
queryAbilityByWant
({
await
bundle
.
queryAbilityByWant
({
bundleName
:
LAUNCHER_BUNDLE_NAME
,
abilityName
:
LAUNCHER_MAIN_ABILITY
},
DEFAULT_FLAG
,
DEFAULT_USER_ID
).
then
(
data
=>
{
...
...
@@ -161,8 +150,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getLaunchWantForBundle
*/
it
(
'
getLaunchWantForBundleTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getLaunchWantForBundleTest_100 start
'
);
bundle
.
getLaunchWantForBundle
(
LAUNCHER_BUNDLE_NAME
).
then
(
data
=>
{
await
bundle
.
getLaunchWantForBundle
(
LAUNCHER_BUNDLE_NAME
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -177,8 +165,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test setApplicationEnabled
*/
it
(
'
setApplicationEnabledTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
setApplicationEnabledTest_100 start
'
);
bundle
.
setApplicationEnabled
(
LAUNCHER_BUNDLE_NAME
,
false
).
then
(
data
=>
{
await
bundle
.
setApplicationEnabled
(
LAUNCHER_BUNDLE_NAME
,
false
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -193,12 +180,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test setAbilityEnabled
*/
it
(
'
setAbilityEnabledTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
setAbilityEnabledTest_100 start
'
);
let
abilityInfo
=
{
bundleName
:
LAUNCHER_BUNDLE_NAME
,
name
:
LAUNCHER_MAIN_ABILITY
};
bundle
.
setAbilityEnabled
(
abilityInfo
,
false
).
then
(
data
=>
{
await
bundle
.
setAbilityEnabled
(
abilityInfo
,
false
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -213,8 +199,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getLauncherAbilityInfos
*/
it
(
'
getLauncherAbilityInfosTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getLauncherAbilityInfosTest_100 start
'
);
innerBundleManager
.
getLauncherAbilityInfos
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_USER_ID
).
then
(
data
=>
{
await
innerBundleManager
.
getLauncherAbilityInfos
(
LAUNCHER_BUNDLE_NAME
,
DEFAULT_USER_ID
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -229,8 +214,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAllLauncherAbilityInfos
*/
it
(
'
getAllLauncherAbilityInfosTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getAllLauncherAbilityInfosTest_100 start
'
);
innerBundleManager
.
getAllLauncherAbilityInfos
(
DEFAULT_USER_ID
).
then
(
data
=>
{
await
innerBundleManager
.
getAllLauncherAbilityInfos
(
DEFAULT_USER_ID
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -245,8 +229,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getShortcutInfos
*/
it
(
'
getShortcutInfosTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getShortcutInfosTest_100 start
'
);
innerBundleManager
.
getShortcutInfos
(
LAUNCHER_BUNDLE_NAME
).
then
(
data
=>
{
await
innerBundleManager
.
getShortcutInfos
(
LAUNCHER_BUNDLE_NAME
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
...
...
@@ -262,7 +245,6 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.level 0
*/
it
(
'
getAbilityLabelTest_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
[getAbilityLabelTest_100] promise START
'
);
await
bundle
.
getAbilityLabel
(
LAUNCHER_BUNDLE_NAME
,
LAUNCHER_MAIN_ABILITY
)
.
then
((
data
)
=>
{
expect
().
assertFail
();
...
...
@@ -280,14 +262,12 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAbilityInfo
*/
it
(
'
getAbilityInfo_100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
getAbilityInfo_100 start
'
);
bundle
.
getAbilityInfo
(
LAUNCHER_BUNDLE_NAME
,
LAUNCHER_MAIN_ABILITY
).
then
(
data
=>
{
await
bundle
.
getAbilityInfo
(
LAUNCHER_BUNDLE_NAME
,
LAUNCHER_MAIN_ABILITY
).
then
(
data
=>
{
expect
().
assertFail
();
done
();
}).
catch
(
err
=>
{
expect
(
err
).
assertEqual
(
INVALID_CODE
);
done
();
});
})
});
})
appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js
浏览文件 @
eb382a27
...
...
@@ -663,505 +663,6 @@ describe('ActsBundleManagerTest', function () {
}
})
/**
* @tc.number getBundleArchiveInfo_0100
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with one hap.
*/
it
(
'
getBundleArchiveInfo_0100
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST1
],
installParam
,
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
let
datainfo
=
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST1
,
1
)
expect
(
datainfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
expect
(
datainfo
.
appInfo
.
supportedModes
).
assertEqual
(
0
)
for
(
let
j
=
0
;
j
<
datainfo
.
appInfo
.
moduleInfos
;
j
++
)
{
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
for
(
let
j
=
0
;
j
<
datainfo
.
abilityInfos
;
j
++
)
{
expect
(
datainfo
.
abilityInfos
[
j
].
name
).
assertEqual
(
"
.MainAbility
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
abilityInfos
[
j
].
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
isVisible
).
assertEqual
(
false
)
expect
(
datainfo
.
abilityInfos
[
j
].
bundleName
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
abilityInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
installData
.
uninstall
(
NAME1
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number getBundleArchiveInfo_0200
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with two haps.
*/
it
(
'
getBundleArchiveInfo_0200
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
();
installData
.
install
([
PATH
+
BMSJSTEST2
,
PATH
+
BMSJSTEST3
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
let
datainfo
=
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST2
,
1
)
expect
(
datainfo
.
name
).
assertEqual
(
NAME2
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
installData
.
uninstall
(
NAME2
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
})
/**
* @tc.number getBundleArchiveInfo_0300
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with three haps.
*/
it
(
'
getBundleArchiveInfo_0300
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST4
,
PATH
+
BMSJSTEST5
,
PATH
+
BMSJSTEST6
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
-
1
);
expect
(
data
.
status
).
assertEqual
(
3
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
STATUS_INSTALL_FAILURE_INVALID
'
);
getInfo
();
});
async
function
getInfo
()
{
let
datainfo
=
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST4
,
1
)
expect
(
datainfo
.
name
).
assertEqual
(
NAME3
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
installData
.
uninstall
(
NAME3
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
installData
.
uninstall
(
NAME4
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
installData
.
uninstall
(
NAME5
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
done
();
});
});
});
}
})
/**
* @tc.number getBundleArchiveInfo_0400
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with error hap.
*/
it
(
'
getBundleArchiveInfo_0400
'
,
0
,
async
function
(
done
)
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
ERROR
,
1
).
then
(
datainfo
=>
{
console
.
info
(
"
getBundleArchiveInfo success
"
+
JSON
.
stringify
(
datainfo
))
expect
(
datainfo
).
assertFail
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
"
getBundleArchiveInfo fail
"
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertEqual
(
1
)
done
()
})
})
/**
* @tc.number getBundleArchiveInfo_0500
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with none hap.
*/
it
(
'
getBundleArchiveInfo_0500
'
,
0
,
async
function
(
done
)
{
let
datainfo
=
await
demo
.
getBundleArchiveInfo
(
'
'
,
1
).
then
(
datainfo
=>
{
console
.
info
(
"
getBundleArchiveInfo success
"
+
JSON
.
stringify
(
datainfo
))
expect
(
datainfo
).
assertFail
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
"
getBundleArchiveInfo fail
"
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertEqual
(
1
)
done
()
})
})
/**
* @tc.number getBundleArchiveInfo_0600
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with none hap.
*/
it
(
'
getBundleArchiveInfo_0600
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST1
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST1
,
1
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
expect
(
datainfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
expect
(
datainfo
.
appInfo
.
supportedModes
).
assertEqual
(
0
)
for
(
let
j
=
0
;
j
<
datainfo
.
appInfo
.
moduleInfos
;
j
++
)
{
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
for
(
let
j
=
0
;
j
<
datainfo
.
abilityInfos
;
j
++
)
{
expect
(
datainfo
.
abilityInfos
[
j
].
name
).
assertEqual
(
"
.MainAbility
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
abilityInfos
[
j
].
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
isVisible
).
assertEqual
(
false
)
expect
(
datainfo
.
abilityInfos
[
j
].
bundleName
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
abilityInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
installData
.
uninstall
(
NAME1
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
}
})
/**
* @tc.number getBundleArchiveInfo_0700
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with two hap.
*/
it
(
'
getBundleArchiveInfo_0700
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
();
installData
.
install
([
PATH
+
BMSJSTEST2
,
PATH
+
BMSJSTEST3
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST2
,
1
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
expect
(
datainfo
.
name
).
assertEqual
(
NAME2
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
installData
.
uninstall
(
NAME2
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
}
})
/**
* @tc.number getBundleArchiveInfo_0800
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with one hap.
*/
it
(
'
getBundleArchiveInfo_0800
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST4
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST4
,
1
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
expect
(
datainfo
.
name
).
assertEqual
(
NAME3
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
installData
.
uninstall
(
NAME3
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
(
err
,
data
)
=>
{
done
();
});
}
}
})
/**
* @tc.number getBundleArchiveInfo_0900
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with error hap.
*/
it
(
'
getBundleArchiveInfo_0900
'
,
0
,
async
function
(
done
)
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
ERROR
,
1
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
if
(
err
)
{
console
.
info
(
"
getBundleArchiveInfo error
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertEqual
(
1
);
done
();
return
;
}
console
.
info
(
"
getBundleArchiveInfo sucess
"
+
JSON
.
stringify
(
datainfo
));
expect
(
datainfo
).
assertFail
();
done
();
}
})
/**
* @tc.number getBundleArchiveInfo_1000
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with none hap.
*/
it
(
'
getBundleArchiveInfo_1000
'
,
0
,
async
function
(
done
)
{
await
demo
.
getBundleArchiveInfo
(
'
'
,
1
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
if
(
err
)
{
console
.
info
(
"
getBundleArchiveInfo error
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertEqual
(
1
);
done
();
return
;
}
console
.
info
(
"
getBundleArchiveInfo sucess
"
+
JSON
.
stringify
(
datainfo
));
expect
(
datainfo
).
assertFail
();
done
();
}
})
/**
* @tc.number getBundleArchiveInfo_1100
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with none hap.
*/
it
(
'
getBundleArchiveInfo_1100
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST1
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST1
,
0
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
expect
(
datainfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
expect
(
datainfo
.
appInfo
.
supportedModes
).
assertEqual
(
0
)
for
(
let
j
=
0
;
j
<
datainfo
.
appInfo
.
moduleInfos
;
j
++
)
{
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
for
(
let
j
=
0
;
j
<
datainfo
.
abilityInfos
;
j
++
)
{
expect
(
datainfo
.
abilityInfos
[
j
].
name
).
assertEqual
(
"
.MainAbility
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
abilityInfos
[
j
].
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
isVisible
).
assertEqual
(
false
)
expect
(
datainfo
.
abilityInfos
[
j
].
bundleName
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
abilityInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
installData
.
uninstall
(
NAME1
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
}
})
/**
* @tc.number getBundleArchiveInfo_1200
* @tc.name BUNDLE::getBundleArchiveInfo
* @tc.desc Test getBundleArchiveInfo interfaces with none hap.
*/
it
(
'
getBundleArchiveInfo_1200
'
,
0
,
async
function
(
done
)
{
let
installData
=
await
demo
.
getBundleInstaller
()
installData
.
install
([
PATH
+
BMSJSTEST1
],
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
await
demo
.
getBundleArchiveInfo
(
PATH
+
BMSJSTEST1
,
0
,
OnReceiveEvent
)
function
OnReceiveEvent
(
err
,
datainfo
)
{
expect
(
datainfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
vendor
).
assertEqual
(
"
example
"
)
expect
(
datainfo
.
versionCode
).
assertEqual
(
1
)
expect
(
datainfo
.
versionName
).
assertLarger
(
0
)
expect
(
datainfo
.
entryModuleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
appInfo
.
name
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
appInfo
.
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
appInfo
.
descriptionId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
appInfo
.
iconId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
appInfo
.
labelId
>=
0
).
assertTrue
()
expect
(
datainfo
.
appInfo
.
systemApp
).
assertEqual
(
false
)
expect
(
datainfo
.
appInfo
.
supportedModes
).
assertEqual
(
0
)
for
(
let
j
=
0
;
j
<
datainfo
.
appInfo
.
moduleInfos
;
j
++
)
{
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
for
(
let
j
=
0
;
j
<
datainfo
.
abilityInfos
;
j
++
)
{
expect
(
datainfo
.
abilityInfos
[
j
].
name
).
assertEqual
(
"
.MainAbility
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
label
).
assertEqual
(
"
$string:app_name
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
description
).
assertEqual
(
DESCRIPTION
)
expect
(
datainfo
.
abilityInfos
[
j
].
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
abilityInfos
[
j
].
isVisible
).
assertEqual
(
false
)
expect
(
datainfo
.
abilityInfos
[
j
].
bundleName
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
abilityInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
}
installData
.
uninstall
(
NAME1
,
{
userId
:
100
,
installFlag
:
0
,
isKeepData
:
false
},
async
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
}
})
/**
* @tc.number getBundleInfo_0200
* @tc.name BUNDLE::getBundleInfo
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录