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

!3075 删除系统api的调用

Merge pull request !3075 from ry/OpenHarmony-3.1-Release
...@@ -25,8 +25,8 @@ group("bundlemanager") { ...@@ -25,8 +25,8 @@ group("bundlemanager") {
"actsbmsmetadatatest:ActsBmsMetaDataTest", "actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest", "actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest", "actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstallTest", "sceneProject/bmsaccesstokenfive:bmsAccessTokenTest5",
"actsbundlemgrmultipleinstalltest:ActsBundleMgrMultipleInstallTest", "sceneProject/bmsaccesstokenfour:bmsAccessTokenTest4",
"sceneProject/bmsaccesstokenone:bmsAccessTokenTest1", "sceneProject/bmsaccesstokenone:bmsAccessTokenTest1",
"sceneProject/bmsaccesstokenthree:bmsAccessTokenTest3", "sceneProject/bmsaccesstokenthree:bmsAccessTokenTest3",
"sceneProject/bmsaccesstokentwo:bmsAccessTokenTest2", "sceneProject/bmsaccesstokentwo:bmsAccessTokenTest2",
......
...@@ -26,13 +26,25 @@ ...@@ -26,13 +26,25 @@
"push": [ "push": [
"bmsAccessTokenTest1.hap->/data/test/bmsAccessTokenTest1.hap", "bmsAccessTokenTest1.hap->/data/test/bmsAccessTokenTest1.hap",
"bmsAccessTokenTest2.hap->/data/test/bmsAccessTokenTest2.hap", "bmsAccessTokenTest2.hap->/data/test/bmsAccessTokenTest2.hap",
"bmsAccessTokenTest3.hap->/data/test/bmsAccessTokenTest3.hap" "bmsAccessTokenTest3.hap->/data/test/bmsAccessTokenTest3.hap",
"bmsAccessTokenTest4.hap->/data/test/bmsAccessTokenTest4.hap",
"bmsAccessTokenTest5.hap->/data/test/bmsAccessTokenTest5.hap"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "bm install -p /data/test/bmsAccessTokenTest1.hap",
"bm install -p /data/test/bmsAccessTokenTest4.hap",
"bm install -p /data/test/bmsAccessTokenTest3.hap",
"bm install -p /data/test/bmsAccessTokenTest2.hap",
"bm install -p /data/test/bmsAccessTokenTest5.hap"
],
"teardown-command":[
"bm uninstall -n com.example.bmsaccesstoken1",
"bm uninstall -n com.example.bmsaccesstoken2",
"bm uninstall -n com.example.bmsaccesstoken3",
"rm -rf /data/test/"
] ]
} }
] ]
......
...@@ -47,10 +47,6 @@ ...@@ -47,10 +47,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -58,18 +54,6 @@ ...@@ -58,18 +54,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from 'deccjsunit/index'
const NAMECOUNT = 10000; const BUNDLE_NAME1 = 'com.example.bmsaccesstoken1';
const INSTALL_FLAG = 1 const BUNDLE_NAME2 = 'com.example.bmsaccesstoken2';
const BUNDLE_NAME3 = 'com.example.bmsaccesstoken3';
const USERID = 100;
describe('ActsBmsAccessTokenTest', function () { describe('ActsBmsAccessTokenTest', function () {
...@@ -27,37 +29,16 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -27,37 +29,16 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the accessTokenId * @tc.desc: get the accessTokenId
*/ */
it('bms_AccessTokenId_0100', 0, async function (done) { it('bms_AccessTokenId_0100', 0, async function (done) {
console.info('bms_AccessTokenId_0100 start'); await bundle.getApplicationInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_DEFAULT, USERID)
var bundlePath = ['/data/test/bmsAccessTokenTest1.hap']; .then(applicationInfo => {
var bundleName = 'com.example.bmsaccesstoken1'; console.info('accessTokenId: ' + applicationInfo.accessTokenId);
let installer = await bundle.getBundleInstaller(); expect(applicationInfo.name).assertEqual(BUNDLE_NAME1);
installer.install(bundlePath, {
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.getApplicationInfo(bundleName, 0, 0).then(applicationInfo => {
console.info('accessTokenId: '+ applicationInfo.accessTokenId);
expect(applicationInfo.name).assertEqual(bundleName);
expect(applicationInfo.accessTokenId).assertLarger(0); expect(applicationInfo.accessTokenId).assertLarger(0);
}) done();
installer.uninstall(bundleName, { }).catch((err) => {
userId: 100, expect(err).assertFail();
installFlag: 1, done();
isKeepData: false });
}, OnReceiveUninstallEvent);
};
function OnReceiveUninstallEvent(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
};
}); });
/* /*
...@@ -66,22 +47,9 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -66,22 +47,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates * @tc.desc: get the reqPermissions and reqPermissionStates
*/ */
it('bms_AccessTokenId_0200', 0, async function (done) { it('bms_AccessTokenId_0200', 0, async function (done) {
console.info('bms_AccessTokenId_0200 start'); await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
var bundlePath = ['/data/test/bmsAccessTokenTest1.hap']; .then(bundleInfo => {
var bundleName = 'com.example.bmsaccesstoken1'; expect(bundleInfo.name).assertEqual(BUNDLE_NAME3);
let installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
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.getBundleInfo(bundleName, 16).then(bundleInfo => {
expect(bundleInfo.name).assertEqual(bundleName);
expect(bundleInfo.reqPermissions.length).assertEqual(3); expect(bundleInfo.reqPermissions.length).assertEqual(3);
expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA"); expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA"); expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA");
...@@ -90,19 +58,11 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -90,19 +58,11 @@ describe('ActsBmsAccessTokenTest', function () {
expect(bundleInfo.reqPermissionStates[0]).assertEqual(-1); expect(bundleInfo.reqPermissionStates[0]).assertEqual(-1);
expect(bundleInfo.reqPermissionStates[1]).assertEqual(-1); expect(bundleInfo.reqPermissionStates[1]).assertEqual(-1);
expect(bundleInfo.reqPermissionStates[2]).assertEqual(0); expect(bundleInfo.reqPermissionStates[2]).assertEqual(0);
}) done();
installer.uninstall(bundleName, { }).catch((err) => {
userId: 100, expect(err).assertFail();
installFlag: 1, done();
isKeepData: false });
}, OnReceiveUninstallEvent);
};
function OnReceiveUninstallEvent(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
};
}); });
/* /*
...@@ -111,33 +71,9 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -111,33 +71,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates * @tc.desc: get the reqPermissions and reqPermissionStates
*/ */
it('bms_AccessTokenId_0300', 0, async function (done) { it('bms_AccessTokenId_0300', 0, async function (done) {
console.info('bms_AccessTokenId_0300 start'); await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
var bundlePath1 = ['/data/test/bmsAccessTokenTest1.hap']; .then(bundleInfo => {
var bundlePath2 = ['/data/test/bmsAccessTokenTest2.hap']; expect(bundleInfo.name).assertEqual(BUNDLE_NAME2);
var bundleName = 'com.example.bmsaccesstoken1';
let installer = await bundle.getBundleInstaller();
installer.install(bundlePath1, {
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");
installer.install(bundlePath2, {
userId: 100,
installFlag: 1,
isKeepData: false
}, 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);
expect(bundleInfo.reqPermissions.length).assertEqual(5); expect(bundleInfo.reqPermissions.length).assertEqual(5);
expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA"); expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING"); expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
...@@ -150,19 +86,11 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -150,19 +86,11 @@ describe('ActsBmsAccessTokenTest', function () {
expect(bundleInfo.reqPermissionStates[2]).assertEqual(-1); expect(bundleInfo.reqPermissionStates[2]).assertEqual(-1);
expect(bundleInfo.reqPermissionStates[3]).assertEqual(0); expect(bundleInfo.reqPermissionStates[3]).assertEqual(0);
expect(bundleInfo.reqPermissionStates[4]).assertEqual(0); expect(bundleInfo.reqPermissionStates[4]).assertEqual(0);
}) done();
installer.uninstall(bundleName, { }).catch((err) => {
userId: 100, expect(err).assertFail();
installFlag: 1, done();
isKeepData: false });
}, OnReceiveUninstallEvent);
}
function OnReceiveUninstallEvent(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
};
}); });
/* /*
...@@ -171,33 +99,9 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -171,33 +99,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates * @tc.desc: get the reqPermissions and reqPermissionStates
*/ */
it('bms_AccessTokenId_0400', 0, async function (done) { it('bms_AccessTokenId_0400', 0, async function (done) {
console.info('bms_AccessTokenId_0400 start'); await bundle.getBundleInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
var bundlePath1 = ['/data/test/bmsAccessTokenTest1.hap']; .then(bundleInfo => {
var bundlePath2 = ['/data/test/bmsAccessTokenTest3.hap']; expect(bundleInfo.name).assertEqual(BUNDLE_NAME1);
var bundleName = 'com.example.bmsaccesstoken1';
let installer = await bundle.getBundleInstaller();
installer.install(bundlePath1, {
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");
installer.install(bundlePath2, {
userId: 100,
installFlag: 0,
isKeepData: false
}, 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);
expect(bundleInfo.reqPermissions.length).assertEqual(6); expect(bundleInfo.reqPermissions.length).assertEqual(6);
expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA"); expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA"); expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA");
...@@ -212,66 +116,29 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -212,66 +116,29 @@ describe('ActsBmsAccessTokenTest', function () {
expect(bundleInfo.reqPermissionStates[3]).assertEqual(-1); expect(bundleInfo.reqPermissionStates[3]).assertEqual(-1);
expect(bundleInfo.reqPermissionStates[4]).assertEqual(0); expect(bundleInfo.reqPermissionStates[4]).assertEqual(0);
expect(bundleInfo.reqPermissionStates[5]).assertEqual(0); expect(bundleInfo.reqPermissionStates[5]).assertEqual(0);
}) done();
installer.uninstall(bundleName, { }).catch((err) => {
userId: 100, expect(err).assertFail();
installFlag: 1, done();
isKeepData: false });
}, OnReceiveUninstallEvent);
}
function OnReceiveUninstallEvent(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
};
}); });
/** /**
* @tc.number bms_AccessTokenId_0500 * @tc.number bms_AccessTokenId_0500
* @tc.name BUNDLE::getBundleInfos * @tc.name BUNDLE::getBundleInfos
* @tc.desc Test getBundleInfos interfaces with with a flag * @tc.desc Test getBundleInfos interfaces with with a flag
*/ */
it("bms_AccessTokenId_0500", 0, async function (done) { it("bms_AccessTokenId_0500", 0, async function (done) {
console.info("bms_AccessTokenId_0500 start"); await bundle.getApplicationInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_DEFAULT)
var bundlePath = ["/data/test/bmsAccessTokenTest1.hap"]; .then((applicationInfo) => {
var bundleName = "com.example.bmsaccesstoken1"; console.info("bms_AccessTokenId_0500 accessTokenId: " + applicationInfo.accessTokenId);
let installer = await bundle.getBundleInstaller(); expect(applicationInfo.name).assertEqual(BUNDLE_NAME1);
installer.install( expect(applicationInfo.accessTokenId).assertLarger(0);
bundlePath, done();
{ }).catch((err) => {
userId: 100, expect(err).assertFail();
installFlag: INSTALL_FLAG, done();
isKeepData: false,
},
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);
}); });
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");
done();
}
}); });
/** /**
...@@ -280,47 +147,17 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -280,47 +147,17 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with a flag * @tc.desc Test getBundleInfos interfaces with a flag
*/ */
it("bms_AccessTokenId_0600", 0, async function (done) { it("bms_AccessTokenId_0600", 0, async function (done) {
console.info("bms_AccessTokenId_0600 start"); await bundle.getApplicationInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES)
var bundlePath = ["/data/test/bmsAccessTokenTest1.hap"];
var bundleName = "com.example.bmsaccesstoken1";
let installer = await bundle.getBundleInstaller();
installer.install(
bundlePath,
{
userId: 100,
installFlag: INSTALL_FLAG,
isKeepData: false,
},
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)
.then((applicationInfo) => { .then((applicationInfo) => {
console.info("accessTokenId: " + applicationInfo.accessTokenId); console.info("bms_AccessTokenId_0600 accessTokenId: " + applicationInfo.accessTokenId);
expect(applicationInfo.name).assertEqual(bundleName); expect(applicationInfo.name).assertEqual(BUNDLE_NAME1);
expect(applicationInfo.reqPermissionStates.length).assertLarger(0); expect(applicationInfo.accessTokenId).assertLarger(0);
done();
}).catch((err) => {
expect(err).assertFail();
done();
}); });
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");
done();
}
}) ;
/** /**
* @tc.number bms_AccessTokenId_0700 * @tc.number bms_AccessTokenId_0700
...@@ -328,95 +165,16 @@ describe('ActsBmsAccessTokenTest', function () { ...@@ -328,95 +165,16 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc Test getBundleInfos interfaces with a flag * @tc.desc Test getBundleInfos interfaces with a flag
*/ */
it("bms_AccessTokenId_0700", 0, async function (done) { it("bms_AccessTokenId_0700", 0, async function (done) {
console.info("bms_AccessTokenId_0700 start"); await bundle.getApplicationInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION)
var bundlePath = ["/data/test/bmsAccessTokenTest1.hap"];
var bundleName = "com.example.bmsaccesstoken1";
let installer = await bundle.getBundleInstaller();
installer.install(
bundlePath,
{
userId: 100,
installFlag: INSTALL_FLAG,
isKeepData: false,
},
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)
.then((applicationInfo) => { .then((applicationInfo) => {
console.info("accessTokenId: " + applicationInfo.accessTokenId); console.info("bms_AccessTokenId_0700 accessTokenId: " + applicationInfo.accessTokenId);
expect(applicationInfo.name).assertEqual(bundleName); expect(applicationInfo.name).assertEqual(BUNDLE_NAME1);
expect(applicationInfo.reqPermissionStates.length).assertLarger(0); expect(applicationInfo.accessTokenId).assertLarger(0);
done();
}).catch((err) => {
expect(err).assertFail();
done();
}); });
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");
done();
}
}); });
/** });
* @tc.number bms_AccessTokenId_0800
* @tc.name BUNDLE::getBundleInfos
* @tc.desc Test getBundleInfos interfaces with a flag
*/
it("bms_AccessTokenId_0800", 0, async function (done) {
console.info("bms_AccessTokenId_0800 start");
var bundlePath = ["/data/test/bmsAccessTokenTest1.hap"];
var bundleName = "com.example.bmsaccesstoken1";
let installer = await bundle.getBundleInstaller();
installer.install(
bundlePath,
{
userId: 100,
installFlag: INSTALL_FLAG,
isKeepData: false,
},
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)
.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);
});
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");
done();
}
});
})
...@@ -33,15 +33,28 @@ ...@@ -33,15 +33,28 @@
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap", "bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleTest6.hap->/data/test/bmsThirdBundleTest6.hap", "bmsThirdBundleTest6.hap->/data/test/bmsThirdBundleTest6.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap", "bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap",
"bmsSystemBundleTest2.hap->/data/test/bmsSystemBundleTest2.hap", "bmsSystemBundleTest2.hap->/data/test/bmsSystemBundleTest2.hap"
"bmsSystemBundleTest2Feature.hap->/data/test/bmsSystemBundleTest2Feature.hap",
"bmsSystemBundleTest2Update.hap->/data/test/bmsSystemBundleTest2Update.hap"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "bm install -p /data/test/bmsThirdBundleTest1.hap",
"bm install -p /data/test/bmsThirdBundleTest2.hap",
"bm install -p /data/test/bmsThirdBundleTest3.hap",
"bm install -p /data/test/bmsThirdBundleTest4.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap",
"bm install -p /data/test/bmsThirdBundleTest6.hap",
"bm install -p /data/test/bmsSystemBundleTest2.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.third2",
"bm uninstall -n com.example.third4",
"bm uninstall -n com.example.third5",
"bm uninstall -n com.example.third6",
"bm uninstall -n com.example.system2",
"rm -rf /data/test/"
] ]
} }
] ]
......
...@@ -47,10 +47,6 @@ ...@@ -47,10 +47,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -58,18 +54,6 @@ ...@@ -58,18 +54,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
/*
* 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==================');
var 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==================');
var 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==================');
var 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
...@@ -15,60 +15,41 @@ ...@@ -15,60 +15,41 @@
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' 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_NAME1 = 'com.example.third1';
const SYSTEM_NAME = 'com.example.system2';
const ABILITIY_NAME8 = 'com.example.system2.MainAbility';
const USERID = 100;
describe('ActsBmsQueryAbilityByWant', function () { describe('ActsBmsQueryAbilityByWant', function () {
/* /*
* @tc.number: bms_queryAbilityByWant_0100 * @tc.number: bms_queryAbilityByWant_0100
* @tc.name: queryAbilityByWant callback by other callback * @tc.name: queryAbilityByWant callback by other callback
* @tc.desc: 1.queryAbilityByWant callback * @tc.desc: 1.queryAbilityByWant callback
* 2.queryAbilityByWant for third app * 2.queryAbilityByWant for third app
*/ */
it('bms_queryAbilityByWant_0100', 0, async function (done){ it('bms_queryAbilityByWant_0100', 0, async function (done) {
console.info('=====================bms_queryAbilityByWant_0100=================='); await bundle.queryAbilityByWant({
var bundlePath = [BUNDLE_PATH1] action: ['action.system.home'],
bundle.getBundleInstaller().then(installer => { entities: ['entity.system.home'],
function onReceiveinstallEvent(err, data) { bundleName: BUNDLE_NAME1
console.log('bms_queryAbilityByWant_0100 install called: ' + data) }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
expect(err.code).assertEqual(0); USERID).then(data => {
expect(data.status).assertEqual(0); expect(data).assertFail();
expect(data.statusMessage).assertEqual('SUCCESS'); }).catch(err => {
expect(err).assertEqual(1);
bundle.queryAbilityByWant({ });
action: ['action.system.home'], bundle.queryAbilityByWant({
entities: ['entity.system.home'], action: ['action.system.home'],
bundleName: BUNDLE_NAME1 entities: ['entity.system.home'],
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION|bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY, bundleName: BUNDLE_NAME1
100, (err, data) => { }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
if (err) { USERID, (err, data) => {
console.log('bms_queryAbilityByWant_0100 test query system app err is ' + err) expect(err).assertEqual(1);
expect(err).assertEqual(1); expect(data).assertEqual("QueryAbilityInfos failed");
} done();
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_queryAbilityByWant_0200 * @tc.number: bms_queryAbilityByWant_0200
...@@ -76,27 +57,120 @@ describe('ActsBmsQueryAbilityByWant', function () { ...@@ -76,27 +57,120 @@ describe('ActsBmsQueryAbilityByWant', function () {
* @tc.desc: 1.queryAbilityByWant callback * @tc.desc: 1.queryAbilityByWant callback
* 2.queryAbilityByWant for systemapp * 2.queryAbilityByWant for systemapp
*/ */
it('bms_queryAbilityByWant_0200', 0, async function (done){ it('bms_queryAbilityByWant_0200', 0, async function (done) {
console.info('=====================bms_queryAbilityByWant_0200=================='); 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,
USERID).then(data => {
expect(data.length).assertLarger(0);
for (let i = 0; i < data.length; ++i) {
expect(data[i].applicationInfo.systemApp).assertEqual(true);
}
}
).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant( bundle.queryAbilityByWant(
{ {
action: ['action.system.home'], action: ['action.system.home'],
entities: ['entity.system.home'] entities: ['entity.system.home']
}, },
bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION|bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
100).then(data => { USERID, (err, data) => {
for(let i = 0; i < data.length; ++i) { if (err) {
var jsondata = JSON.stringify(data[i]); expect(err).assertFail();
console.log('bms_queryAbilityByWant_0200 test query system app ' + jsondata) }
expect(data[i].applicationInfo.systemApp).assertEqual(true) expect(data.length).assertLarger(0);
for (let i = 0; i < data.length; ++i) {
expect(data[i].applicationInfo.systemApp).assertEqual(true);
} }
done(); done();
} });
).catch(err => { });
console.log('bms_queryAbilityByWant_0200 test query system app err is ' + err)
expect(err).assertFail() /*
* @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 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]);
done(); 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);
}
}) })
\ No newline at end of file
...@@ -12,7 +12,5 @@ ...@@ -12,7 +12,5 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./ActsBmsFormsInfoTest.test.js')
require('./ActsBmsQueryAbilityByWant.test.js') require('./ActsBmsQueryAbilityByWant.test.js')
require('./ActsBmsCleanCacheTest.test.js') require('./ActsBmsGetBackGroundModes.test.js')
require('./ActsBmsGetBackGroundModes.test.js')
\ No newline at end of file
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
"push": [ "push": [
"bmsMainAbilityFirstScene.hap->/data/test/bmsMainAbilityFirstScene.hap", "bmsMainAbilityFirstScene.hap->/data/test/bmsMainAbilityFirstScene.hap",
"bmsMainAbilitySecondScene.hap->/data/test/bmsMainAbilitySecondScene.hap", "bmsMainAbilitySecondScene.hap->/data/test/bmsMainAbilitySecondScene.hap",
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap",
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap", "bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap" "bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap"
] ]
...@@ -36,7 +34,17 @@ ...@@ -36,7 +34,17 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "chmod 644 /data/test/*.hap",
"bm install -p /data/test/bmsMainAbilityFirstScene.hap",
"bm install -p /data/test/bmsMainAbilitySecondScene.hap",
"bm install -p /data/test/bmsThirdBundleTest2.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third2",
"bm uninstall -n com.example.third5",
"bm uninstall -n com.example.bmsmainabilityfirstscene",
"rm -rf /data/test/"
] ]
} }
] ]
......
...@@ -47,10 +47,6 @@ ...@@ -47,10 +47,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -58,18 +54,6 @@ ...@@ -58,18 +54,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
...@@ -33,7 +33,18 @@ ...@@ -33,7 +33,18 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "chmod 644 /data/test/*.hap",
"bm install -p /data/test/bmsThirdBundleTest2.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap",
"bm install -p /data/test/bmsThirdBundleJs.hap",
"bm install -p /data/test/bmsThirdBundleC.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third2",
"bm uninstall -n com.example.third5",
"bm uninstall -n com.example.js",
"bm uninstall -n com.example.c",
"rm -rf /data/test/"
] ]
} }
] ]
......
...@@ -48,10 +48,6 @@ ...@@ -48,10 +48,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -59,18 +55,6 @@ ...@@ -59,18 +55,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
...@@ -14,76 +14,30 @@ ...@@ -14,76 +14,30 @@
*/ */
import bundle from '@ohos.bundle' 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_BUNDLE_NAME = 'com.ohos.launcher';
const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility'; const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility';
const DEFAULT_FLAG = 0; const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const DEFAULT_USER_ID = 100; const DEFAULT_USER_ID = 100;
const INVALID_CODE = 1; const INVALID_CODE = 1;
describe('ActsBmsJsUnPermissionTest', function () { describe('ActsBmsJsUnPermissionTest', function () {
/*
* @tc.number: bms_JsInstallPermissionTest_0100
* @tc.name: test js install
* @tc.desc: test js install
*/
it('bms_JsInstallPermissionTest_0100', 0, async function (done) {
console.info('bms_JsInstallPermissionTest start');
var bundlePath = ['/data/test/bmsJstest1.hap'];
let installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 100,
installFlag: 1,
isKeepData: false
}, OnReceiveInstallEvent);
async function OnReceiveInstallEvent(err, data) {
expect(err.code).assertEqual(-1);
expect(data.status).assertEqual(STATUS_INSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_INSTALL_PERMISSION_DENIED");
done();
}
});
/*
* @tc.number: bms_JsUnInstallPermissionTest_0100
* @tc.name: test js uninstall
* @tc.desc: test js uninstall
*/
it('bms_JsUnInstallPermissionTest_0100', 0, async function (done) {
console.info('bms_JsUnInstallPermissionTest start');
var bundleName = 'com.example.myapplication1';
let installer = await bundle.getBundleInstaller();
installer.uninstall(bundleName, {
userId: 100,
installFlag: 1,
isKeepData: false
}, OnReceiveUnInstallEvent);
async function OnReceiveUnInstallEvent(err, data) {
expect(err.code).assertEqual(-1);
expect(data.status).assertEqual(STATUS_UNINSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_UNINSTALL_PERMISSION_DENIED");
done();
}
});
/* /*
* @tc.number: getApplicationInfoTest_100 * @tc.number: getApplicationInfoTest_100
* @tc.name: test getApplicationInfo * @tc.name: test getApplicationInfo
* @tc.desc: test getApplicationInfo * @tc.desc: test getApplicationInfo
*/ */
it('getApplicationInfoTest_100', 0, async function (done) { it('getApplicationInfoTest_100', 0, async function (done) {
console.debug('getApplicationInfoTest_100 start'); await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}); });
...@@ -94,12 +48,14 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -94,12 +48,14 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAllApplicationInfo * @tc.desc: test getAllApplicationInfo
*/ */
it('getAllApplicationInfoTest_100', 0, async function (done) { it('getAllApplicationInfoTest_100', 0, async function (done) {
console.debug('getAllApplicationInfoTest_100 start'); await bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}); });
...@@ -110,12 +66,14 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -110,12 +66,14 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getBundleInfo * @tc.desc: test getBundleInfo
*/ */
it('getBundleInfoTest_100', 0, async function (done) { it('getBundleInfoTest_100', 0, async function (done) {
console.debug('getBundleInfoTest_100 start'); await bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID).then(data => {
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}); });
...@@ -126,12 +84,14 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -126,12 +84,14 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAllBundleInfo * @tc.desc: test getAllBundleInfo
*/ */
it('getAllBundleInfoTest_100', 0, async function (done) { it('getAllBundleInfoTest_100', 0, async function (done) {
console.debug('getAllBundleInfoTest_100 start'); await bundle.getAllBundleInfo(DEFAULT_FLAG).then(data => {
bundle.getAllBundleInfo(DEFAULT_FLAG).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAllBundleInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}); });
...@@ -142,15 +102,21 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -142,15 +102,21 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test queryAbilityByWant * @tc.desc: test queryAbilityByWant
*/ */
it('queryAbilityByWantTest_100', 0, async function (done) { it('queryAbilityByWantTest_100', 0, async function (done) {
console.debug('queryAbilityByWantTest_100 start'); await bundle.queryAbilityByWant({
bundle.queryAbilityByWant({
bundleName: LAUNCHER_BUNDLE_NAME, bundleName: LAUNCHER_BUNDLE_NAME,
abilityName: LAUNCHER_MAIN_ABILITY abilityName: LAUNCHER_MAIN_ABILITY
}, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => { }, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.queryAbilityByWant({
bundleName: LAUNCHER_BUNDLE_NAME,
abilityName: LAUNCHER_MAIN_ABILITY
}, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
console.info("data ===================:" + data);
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual("QueryAbilityInfos failed");
done(); done();
}); });
}); });
...@@ -161,117 +127,37 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -161,117 +127,37 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getLaunchWantForBundle * @tc.desc: test getLaunchWantForBundle
*/ */
it('getLaunchWantForBundleTest_100', 0, async function (done) { it('getLaunchWantForBundleTest_100', 0, async function (done) {
console.debug('getLaunchWantForBundleTest_100 start'); await bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME).then(data => {
bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done();
}); });
}); bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => {
/*
* @tc.number: setApplicationEnabledTest_100
* @tc.name: test setApplicationEnabled
* @tc.desc: test setApplicationEnabled
*/
it('setApplicationEnabledTest_100', 0, async function (done) {
console.debug('setApplicationEnabledTest_100 start');
bundle.setApplicationEnabled(LAUNCHER_BUNDLE_NAME, false).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}); });
/* /*
* @tc.number: setAbilityEnabledTest_100 * @tc.number: getAbilityLabelTest_100
* @tc.name: test setAbilityEnabled * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: test setAbilityEnabled * @tc.desc: Check the return value of the interface
*/ * @tc.level 0
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 => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getLauncherAbilityInfosTest_100
* @tc.name: test getLauncherAbilityInfos
* @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 => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getAllLauncherAbilityInfosTest_100
* @tc.name: test getAllLauncherAbilityInfos
* @tc.desc: test getAllLauncherAbilityInfos
*/
it('getAllLauncherAbilityInfosTest_100', 0, async function (done) {
console.debug('getAllLauncherAbilityInfosTest_100 start');
innerBundleManager.getAllLauncherAbilityInfos(DEFAULT_USER_ID).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getShortcutInfosTest_100
* @tc.name: test getShortcutInfos
* @tc.desc: test getShortcutInfos
*/
it('getShortcutInfosTest_100', 0, async function (done) {
console.debug('getShortcutInfosTest_100 start');
innerBundleManager.getShortcutInfos(LAUNCHER_BUNDLE_NAME).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getAbilityLabelTest_100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('getAbilityLabelTest_100', 0, async function (done) { it('getAbilityLabelTest_100', 0, async function (done) {
console.debug('[getAbilityLabelTest_100] promise START');
await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY) await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY)
.then((data) => { .then((data) => {
expect().assertFail(); expect().assertFail();
done();
}) })
.catch((error) => { .catch((error) => {
expect(error).assertEqual(INVALID_CODE); expect(error).assertEqual(INVALID_CODE);
done();
}); });
bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -280,14 +166,15 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -280,14 +166,15 @@ describe('ActsBmsJsUnPermissionTest', function () {
* @tc.desc: test getAbilityInfo * @tc.desc: test getAbilityInfo
*/ */
it('getAbilityInfo_100', 0, async function (done) { it('getAbilityInfo_100', 0, async function (done) {
console.debug('getAbilityInfo_100 start'); await bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY).then(data => {
bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY).then(data => {
expect().assertFail(); expect().assertFail();
done();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done(); done();
}); });
}) });
}) })
...@@ -27,15 +27,25 @@ ...@@ -27,15 +27,25 @@
"type": "PushKit", "type": "PushKit",
"push": [ "push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap", "bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTest3.hap->/data/test/bmsThirdBundleTest3.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap", "bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap" "bmsSystemBundleTest1.hap->/data/test/bmsSystemBundleTest1.hap",
"bmsVendorBundleTest1.hap->/data/test/bmsVendorBundleTest1.hap"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "bm install -p /data/test/bmsThirdBundleTest1.hap",
"bm install -p /data/test/bmsSystemBundleTest1.hap",
"bm install -p /data/test/bmsVendorBundleTest1.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.system1",
"bm uninstall -n com.example.vendor1",
"bm uninstall -n com.example.third5",
"rm -rf /data/test/"
] ]
} }
] ]
......
...@@ -47,10 +47,6 @@ ...@@ -47,10 +47,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -58,18 +54,6 @@ ...@@ -58,18 +54,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
...@@ -16,6 +16,18 @@ ...@@ -16,6 +16,18 @@
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const BUNDLE_NAME1 = 'com.example.third1';
const BUNDLE_NAME2 = 'com.example.third5';
const BUNDLE_NAME3 = 'com.example.noexist';
const BUNDLE_NAME4 = 'com.example.system1';
const BUNDLE_NAME5 = 'com.example.vendor1';
const ABILITY_NAME1 = 'com.example.third1.MainAbility';
const ABILITY_NAME3 = 'com.example.third5.AMainAbility';
const ABILITY_NAME4 = 'com.example.noexist.MainAbility';
const ABILITY_NAME5 = 'com.example.system1.MainAbility';
const ABILITY_NAME6 = 'com.example.vendor1.MainAbility';
const USERID = 100;
describe('ActsBmsMetaDataTest', function () { describe('ActsBmsMetaDataTest', function () {
/* /*
...@@ -24,133 +36,22 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -24,133 +36,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which contains two HAP packages. * @tc.desc: get an application's meta data which contains two HAP packages.
*/ */
it('bms_getMetaData_0100', 0, async function (done) { it('bms_getMetaData_0100', 0, async function (done) {
console.info('=====================bms_getMetaData_0100=================='); await bundle.queryAbilityByWant(
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'] {
var installer = await bundle.getBundleInstaller(); "bundleName": BUNDLE_NAME1,
let abilityName1 = 'com.example.third1.MainAbility'; "abilityName": ABILITY_NAME1
let dataMap = new Map(); }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
installer.install(bundlePath, { console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
userId: 100, let metaData = dataInfos[0].metaData;
installFlag: 1, expect(metaData[0].name).assertEqual("Data1");
isKeepData: false expect(metaData[0].value).assertEqual("float");
}, async (err, data) => { expect(metaData[0].extra).assertEqual("$string:mainability_description");
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
bundle.queryAbilityByWant(
{
"bundleName": 'com.example.third1',
"abilityName": 'com.example.third1.MainAbility',
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => {
for (let i = 0, len = dataInfos.length; i < len; i++) {
dataMap.set(dataInfos[i].name, dataInfos[i].metaData)
}
})
if (dataMap.has(abilityName1)) {
checkMetaData(dataMap.get(abilityName1), 'Data1');
}
installer.uninstall('com.example.third1', {
userId: 100,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done(); done();
}); }).catch(err => {
}); expect(err).assertFail();
})
/*
* @tc.number: bms_getMetaData_0200
* @tc.name: test to get meta data for an update application.
* @tc.desc: get an application's meta data that is updated.
*/
it('bms_getMetaData_0200', 0, async function (done) {
console.info('=====================bms_getMetaData_0200==================');
var bundlePath1 = ['/data/test/bmsThirdBundleTest1.hap']
var bundlePath2 = ['/data/test/bmsThirdBundleTestA1.hap']
let dataMap = new Map();
let abilityName1 = 'com.example.third1.AMainAbility';
var 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
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
bundle.queryAbilityByWant(
{
"bundleName": 'com.example.third1',
"abilityName": 'com.example.third1.AMainAbility',
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => {
for (let i = 0, len = dataInfos.length; i < len; i++) {
dataMap.set(dataInfos[i].name, dataInfos[i].metaData)
}
})
if (dataMap.has(abilityName1)) {
checkMetaData(dataMap.get(abilityName1), 'DataA1');
}
installer.uninstall('com.example.third1', {
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_getMetaData_0300
* @tc.name: test to get meta data for an uninstalled application.
* @tc.desc: get an application's meta data that is uninstalled.
*/
it('bms_getMetaData_0300', 0, async function (done) {
console.info('=====================bms_getMetaData_0300==================');
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap']
let bundleName = 'com.example.third1';
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
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(bundleName, {
userId: 100,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
bundle.queryAbilityByWant(
{
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility',
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => {
expect(dataInfos.length).assertEqual(0);
});
done(); done();
}); });
}); });
})
/* /*
* @tc.number: bms_getMetaData_0400 * @tc.number: bms_getMetaData_0400
...@@ -158,44 +59,22 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -158,44 +59,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which has one ability. * @tc.desc: get an application's meta data which has one ability.
*/ */
it('bms_getMetaData_0400', 0, async function (done) { it('bms_getMetaData_0400', 0, async function (done) {
console.info('=====================bms_getMetaData_0400=================='); await bundle.queryAbilityByWant(
var bundlePath = ['/data/test/bmsThirdBundleTest5.hap'] {
let dataMap = new Map(); bundleName: BUNDLE_NAME2,
let abilityName1 = 'com.example.third5.AMainAbility'; abilityName: ABILITY_NAME3,
var installer = await bundle.getBundleInstaller(); }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
installer.install(bundlePath, { console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
userId: 100, let metaData = dataInfos[0].metaData;
installFlag: 1, expect(metaData[0].name).assertEqual("Data5A");
isKeepData: false expect(metaData[0].value).assertEqual("float");
}, onReceiveinstallEvent); expect(metaData[0].extra).assertEqual("$string:mainability_description");
async function onReceiveinstallEvent(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
bundle.queryAbilityByWant(
{
bundleName: 'com.example.third5',
abilityName: 'com.example.third5.AMainAbility',
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => {
for (let i = 0, len = dataInfos.length; i < len; i++) {
dataMap.set(dataInfos[i].name, dataInfos[i].metaData)
}
})
if (dataMap.has(abilityName1)) {
checkMetaData(dataMap.get(abilityName1), 'Data5A');
}
installer.uninstall('com.example.third5', {
userId: 100,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done(); done();
}) }).catch(err => {
} expect(err).assertFail();
}) done();
});
});
/* /*
* @tc.number: bms_getMetaData_0500 * @tc.number: bms_getMetaData_0500
...@@ -203,16 +82,19 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -203,16 +82,19 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which does not exist. * @tc.desc: get an application's meta data which does not exist.
*/ */
it('bms_getMetaData_0500', 0, async function (done) { it('bms_getMetaData_0500', 0, async function (done) {
console.info('=====================bms_getMetaData_0500=================='); await bundle.queryAbilityByWant(
bundle.queryAbilityByWant(
{ {
bundleName: 'com.example.noexist', bundleName: BUNDLE_NAME3,
abilityName: 'com.example.noexist.MainAbility', abilityName: ABILITY_NAME4,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => { }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
expect(dataInfos.length).assertEqual(0); expect(dataInfos.length).assertEqual(0);
}) done();
done(); }).catch(err => {
}) console.info("err====: " + err);
expect(err).assertEqual(1);
done();
});
});
/* /*
* @tc.number: bms_getMetaData_0600 * @tc.number: bms_getMetaData_0600
...@@ -220,23 +102,22 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -220,23 +102,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get a system application's meta data. * @tc.desc: get a system application's meta data.
*/ */
it('bms_getMetaData_0600', 0, async function (done) { it('bms_getMetaData_0600', 0, async function (done) {
console.info('=====================bms_getMetaData_0600=================='); await bundle.queryAbilityByWant(
let dataMap = new Map();
let abilityName1 = 'com.example.system1.MainAbility';
bundle.queryAbilityByWant(
{ {
bundleName: 'com.example.system1', bundleName: BUNDLE_NAME4,
abilityName: 'com.example.system1.MainAbility', abilityName: ABILITY_NAME5,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => { }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
for (let i = 0, len = dataInfos.length; i < len; i++) { console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
dataMap.set(dataInfos[i].name, dataInfos[i].metaData) let metaData = dataInfos[0].metaData;
} expect(metaData[0].name).assertEqual("Data1S");
}) expect(metaData[0].value).assertEqual("float");
if (dataMap.has(abilityName1)) { expect(metaData[0].extra).assertEqual("$string:mainability_description");
checkMetaData(dataMap.get(abilityName1), 'Data1S'); done();
} }).catch(err => {
done(); expect(err).assertFail();
}) done();
});
});
/* /*
* @tc.number: bms_getMetaData_0700 * @tc.number: bms_getMetaData_0700
...@@ -244,73 +125,21 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -244,73 +125,21 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get a vendor application's meta data. * @tc.desc: get a vendor application's meta data.
*/ */
it('bms_getMetaData_0700', 0, async function (done) { it('bms_getMetaData_0700', 0, async function (done) {
console.info('=====================bms_getMetaData_0700=================='); await bundle.queryAbilityByWant(
let dataMap = new Map();
let abilityName1 = 'com.example.vendor1.MainAbility';
bundle.queryAbilityByWant(
{ {
bundleName: 'com.example.vendor1', bundleName: BUNDLE_NAME5,
abilityName: 'com.example.vendor1.MainAbility', abilityName: ABILITY_NAME6,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => { }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
for (let i = 0, len = dataInfos.length; i < len; i++) { console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
dataMap.set(dataInfos[i].name, dataInfos[i].metaData) let metaData = dataInfos[0].metaData;
} expect(metaData[0].name).assertEqual("");
expect(metaData[0].value).assertEqual("");
expect(metaData[0].extra).assertEqual("");
done();
}).catch(err => {
expect(err).assertFail();
done();
}); });
if (dataMap.has(abilityName1)) { });
let data = dataMap.get(abilityName1);
var parameters = data.parameters;
var results = data.results;
var customizeDatas = data.customizeDatas;
expect(parameters.length).assertEqual(2);
expect(results.length).assertEqual(1);
expect(customizeDatas.length).assertEqual(1);
console.debug('=====customizeDatas length=====' + customizeDatas.length);
for (let i = 0; i < parameters.length; i++) {
expect(parameters[i].description).assertEqual('$string:mainability_description');
expect(parameters[i].name).assertEqual("Data1V" + i);
expect(parameters[i].type).assertEqual('float');
}
for (let i = 0; i < results.length; i++) {
expect(results[i].description).assertEqual('$string:mainability_description');
expect(results[i].name).assertEqual('Data1V');
expect(results[i].type).assertEqual('float');
}
for (let i = 0; i < customizeDatas.length; i++) {
expect(customizeDatas[i].name).assertEqual('');
expect(customizeDatas[i].value).assertEqual('');
expect(customizeDatas[i].extra).assertEqual('');
}
}
done();
})
function checkMetaData(data, name) {
var parameters = data.parameters;
var results = data.results;
var customizeDatas = data.customizeDatas;
expect(typeof parameters).assertEqual('object');
expect(typeof results).assertEqual('object');
expect(typeof customizeDatas).assertEqual('object');
expect(parameters.length).assertLarger(0);
expect(results.length).assertLarger(0);
expect(customizeDatas.length).assertLarger(0);
for (let i = 0; i < parameters.length; i++) {
expect(typeof parameters[i].description).assertEqual('string');
expect(typeof parameters[i].name).assertEqual('string');
expect(parameters[i].name).assertEqual(name);
expect(typeof parameters[i].type).assertEqual('string');
}
for (let i = 0; i < results.length; i++) {
expect(typeof results[i].description).assertEqual('string');
expect(typeof results[i].name).assertEqual('string');
expect(results[i].name).assertEqual(name);
expect(typeof results[i].type).assertEqual('string');
}
for (let i = 0; i < customizeDatas.length; i++) {
expect(typeof customizeDatas[i].name).assertEqual('string');
expect(typeof customizeDatas[i].value).assertEqual('string');
expect(customizeDatas[i].name).assertEqual(name);
expect(typeof customizeDatas[i].extra).assertEqual('string');
}
}
}) })
\ No newline at end of file
...@@ -13,6 +13,33 @@ ...@@ -13,6 +13,33 @@
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test/"
]
},
{
"type": "PushKit",
"push":[
"bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ",
"first_right.hap -> /data/test/first_right.hap",
"second_right.hap -> /data/second_right.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -p /data/bmsThirdBundleTest1.hap",
"bm install -p /data/test/first_right.hap",
"bm install -p /data/second_right.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.l3jsdemo"
]
} }
] ]
} }
...@@ -12,203 +12,197 @@ ...@@ -12,203 +12,197 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag' const BUNDLE_NAME = 'com.open.harmony.packagemag';
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility';
const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility' const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage';
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility';
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error';
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage' export default function getAbilityLabelJsUnit() {
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' describe('context_getAbilityLabel_test', function () {
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
export default function getAbilityLabelJsUnit() { /*
* @tc.number: context_getAbilityLabel_test_0100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0100', 0, async function (done) {
let mData;
let timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
});
describe('context_getAbilityLabel_test', function () { /*
/* * @tc.number: context_getAbilityLabel_test_0200
* @tc.number: context_getAbilityLabel_test_0100 * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.desc: Check the return value of the interface (by callback)
* @tc.desc: Check the return value of the interface (by promise) * @tc.level 0
* @tc.level 0 */
*/ it('context_getAbilityLabel_test_0200', 0, async function (done) {
it('context_getAbilityLabel_test_0100', 0, async function (done) { let timeOldStamp = await Utils.getNowTime();
let mData; let mData;
var timeOldStamp = await Utils.getNowTime(); Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME) if (error) {
.then((data) => { console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
var timeNewStamp = Utils.getNowTime(); expect(error).assertFail();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp); }
mData = data; let timeNewStamp = Utils.getNowTime();
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data)); Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
}) mData = data;
.catch((error) => { console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error); console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data));
expect(error).assertFail(); });
await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData);
done();
}); });
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
});
/* /*
* @tc.number: context_getAbilityLabel_test_0200 * @tc.number: context_getAbilityLabel_test_0300
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0200', 0, async function (done) { it('context_getAbilityLabel_test_0300', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mData; let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => { await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR).then((data) => {
if(error){ let timeNewStamp = Utils.getNowTime();
console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
expect(error).assertFail(); console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
} }).catch((error) => {
var timeNewStamp = Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp); mError = error;
mData = data; Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error); console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error);
console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data)); expect(mError).assertEqual(1);
}); });
await Utils.sleep(2000); await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData); getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done(); done();
}); });
/* /*
* @tc.number: context_getAbilityLabel_test_0300 * @tc.number: context_getAbilityLabel_test_0400
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0300', 0, async function (done) { it('context_getAbilityLabel_test_0400', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mError; let mError;
await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR) Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
.then((data) => { if (error !== null) {
var timeNewStamp = Utils.getNowTime(); console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); expect(error).assertEqual(1);
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data)); }
}) let timeNewStamp = Utils.getNowTime();
.catch((error) => { Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
var timeNewStamp = Utils.getNowTime(); mError = error;
mError = error; console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); });
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error); await Utils.sleep(2000);
expect(mError).assertEqual(1); getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError);
done();
}); });
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done();
});
/* /*
* @tc.number: context_getAbilityLabel_test_0400 * @tc.number: context_getAbilityLabel_test_0500
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0400', 0, async function (done) { it('context_getAbilityLabel_test_0500', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let mData;
let mError; let mError = null;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => { let timeOldStamp = await Utils.getNowTime();
if(error !== null){ await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME).then((data) => {
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error); let timeNewStamp = Utils.getNowTime();
expect(error).assertEqual(1); Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
} mData = data;
var timeNewStamp = Utils.getNowTime(); expect(mData).assertFail();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp); console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
mError = error; }).catch((error) => {
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data)); mError = error;
}); console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error);
await Utils.sleep(2000); getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError); });
done(); done();
}); });
/* /*
* @tc.number: context_getAbilityLabel_test_0500 * @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0500', 0, async function (done) { it('context_getAbilityLabel_test_0600', 0, async function (done) {
let mData; let timeOldStamp = await Utils.getNowTime();
let mError = null; Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
var timeOldStamp = await Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME) Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
.then((data) => { console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
var timeNewStamp = Utils.getNowTime(); getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error);
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp); expect(data).assertEqual(undefined);
mData = data; });
expect(mData).assertFail(); done();
console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
mError = error;
console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error);
getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
}); });
done();
});
/* /*
* @tc.number: context_getAbilityLabel_test_0600 * @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0600', 0, async function (done) { it('context_getAbilityLabel_test_0700', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => { let mError;
var timeNewStamp = Utils.getNowTime(); Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp); let timeNewStamp = Utils.getNowTime();
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error); mError = error;
expect(data).assertEqual(undefined); if (mError !== null) {
}); console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
done(); }
}); console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError);
done();
});
function getAbilityLabelSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
expect(data).assertEqual("entry_MainAbility");
}
/* function getAbilityLabelFailure(msg, error) {
* @tc.number: context_getAbilityLabel_test_0700 console.log(msg + ' Failure ');
* @tc.name: getAbilityLabel : Gets the specified ability label console.log(msg + ' error ' + JSON.stringify(error));
* @tc.desc: Check the return value of the interface (by callback) expect(typeof (error)).assertEqual('number');
* @tc.level 0 expect(error).assertEqual(1)
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
mError = error;
if(mError !== null){
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
} }
console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError);
done();
});
function getAbilityLabelSuccess(msg, data) { })
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
expect(data).assertEqual("entry_MainAbility");
}
function getAbilityLabelFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error ' + JSON.stringify(error));
expect(typeof (error)).assertEqual('number');
expect(error).assertEqual(1)
}
})
} }
\ No newline at end of file
...@@ -14,27 +14,42 @@ ...@@ -14,27 +14,42 @@
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
}, },
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test/"
]
},
{ {
"type": "PushKit", "type": "PushKit",
"push": [ "push": [
"bmsJstest1.hap->/data/bmsJstest1.hap", "bmsJstest1.hap->/data/test/bmsJstest1.hap",
"bmsJstest2.hap->/data/bmsJstest2.hap", "bmsJstest2.hap->/data/test/bmsJstest2.hap",
"bmsJstest3.hap->/data/bmsJstest3.hap", "bmsJstest3.hap->/data/test/bmsJstest3.hap",
"bmsJstest4.hap->/data/bmsJstest4.hap", "bmsJstest4.hap->/data/test/bmsJstest4.hap",
"bmsJstest5.hap->/data/bmsJstest5.hap", "bmsJstest5.hap->/data/test/bmsJstest5.hap",
"bmsJstest6.hap->/data/bmsJstest6.hap", "bmsJstest6.hap->/data/test/bmsJstest6.hap"
"bmsJstest7.hap->/data/bmsJstest7.hap",
"bmsJstest8.hap->/data/bmsJstest8.hap",
"bmsJstest9.hap->/data/bmsJstest9.hap"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/*.hap", "bm install -p /data/test/bmsJstest1.hap",
"chmod 600 /data/bmsJstest7.hap" "bm install -p /data/test/bmsJstest2.hap",
"bm install -p /data/test/bmsJstest3.hap",
"bm install -p /data/test/bmsJstest4.hap",
"bm install -p /data/test/bmsJstest5.hap",
"bm install -p /data/test/bmsJstest6.hap"
],
"teardown-command":[
"bm uninstall -n com.example.myapplication1",
"bm uninstall -n com.example.myapplication2",
"bm uninstall -n com.example.myapplication4",
"bm uninstall -n com.example.myapplication5",
"bm uninstall -n com.example.myapplication6",
"rm -rf /data/test/"
] ]
} }
] ]
} }
...@@ -70,10 +70,6 @@ ...@@ -70,10 +70,6 @@
} }
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
...@@ -81,18 +77,6 @@ ...@@ -81,18 +77,6 @@
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
} }
], ],
"js": [ "js": [
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsbundlemanageruninstall",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsBundleManagerUninstallTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "PushKit",
"push": [
"bmsJstest1.hap->/data/bmsJstest1.hap",
"bmsJstest3.hap->/data/bmsJstest3.hap",
"bmsJstest4.hap->/data/bmsJstest4.hap",
"bmsJstest5.hap->/data/bmsJstest5.hap",
"bmsJstest6.hap->/data/bmsJstest6.hap",
"bmsJstest8.hap->/data/bmsJstest8.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册