提交 41accc39 编写于 作者: I inter515

删除系统api

Signed-off-by: Ninter515 <ry.renyi@huawei.com>
上级 e3851ff2
......@@ -25,8 +25,8 @@ group("bundlemanager") {
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstallTest",
"actsbundlemgrmultipleinstalltest:ActsBundleMgrMultipleInstallTest",
"sceneProject/bmsaccesstokenfive:bmsAccessTokenTest5",
"sceneProject/bmsaccesstokenfour:bmsAccessTokenTest4",
"sceneProject/bmsaccesstokenone:bmsAccessTokenTest1",
"sceneProject/bmsaccesstokenthree:bmsAccessTokenTest3",
"sceneProject/bmsaccesstokentwo:bmsAccessTokenTest2",
......
......@@ -26,13 +26,25 @@
"push": [
"bmsAccessTokenTest1.hap->/data/test/bmsAccessTokenTest1.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",
"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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -58,18 +54,6 @@
{
"name":"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": [
......
......@@ -16,8 +16,10 @@
import bundle from '@ohos.bundle'
import { describe, it, expect } from 'deccjsunit/index'
const NAMECOUNT = 10000;
const INSTALL_FLAG = 1
const BUNDLE_NAME1 = 'com.example.bmsaccesstoken1';
const BUNDLE_NAME2 = 'com.example.bmsaccesstoken2';
const BUNDLE_NAME3 = 'com.example.bmsaccesstoken3';
const USERID = 100;
describe('ActsBmsAccessTokenTest', function () {
......@@ -27,37 +29,16 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the accessTokenId
*/
it('bms_AccessTokenId_0100', 0, async function (done) {
console.info('bms_AccessTokenId_0100 start');
var bundlePath = ['/data/test/bmsAccessTokenTest1.hap'];
var bundleName = 'com.example.bmsaccesstoken1';
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.getApplicationInfo(bundleName, 0, 0).then(applicationInfo => {
console.info('accessTokenId: '+ applicationInfo.accessTokenId);
expect(applicationInfo.name).assertEqual(bundleName);
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");
done();
};
done();
}).catch((err) => {
expect(err).assertFail();
done();
});
});
/*
......@@ -66,22 +47,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it('bms_AccessTokenId_0200', 0, async function (done) {
console.info('bms_AccessTokenId_0200 start');
var bundlePath = ['/data/test/bmsAccessTokenTest1.hap'];
var bundleName = 'com.example.bmsaccesstoken1';
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);
await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
.then(bundleInfo => {
expect(bundleInfo.name).assertEqual(BUNDLE_NAME3);
expect(bundleInfo.reqPermissions.length).assertEqual(3);
expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA");
......@@ -90,19 +58,11 @@ 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");
done();
};
done();
}).catch((err) => {
expect(err).assertFail();
done();
});
});
/*
......@@ -111,33 +71,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it('bms_AccessTokenId_0300', 0, async function (done) {
console.info('bms_AccessTokenId_0300 start');
var bundlePath1 = ['/data/test/bmsAccessTokenTest1.hap'];
var bundlePath2 = ['/data/test/bmsAccessTokenTest2.hap'];
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);
await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
.then(bundleInfo => {
expect(bundleInfo.name).assertEqual(BUNDLE_NAME2);
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,19 +86,11 @@ 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");
done();
};
done();
}).catch((err) => {
expect(err).assertFail();
done();
});
});
/*
......@@ -171,33 +99,9 @@ describe('ActsBmsAccessTokenTest', function () {
* @tc.desc: get the reqPermissions and reqPermissionStates
*/
it('bms_AccessTokenId_0400', 0, async function (done) {
console.info('bms_AccessTokenId_0400 start');
var bundlePath1 = ['/data/test/bmsAccessTokenTest1.hap'];
var bundlePath2 = ['/data/test/bmsAccessTokenTest3.hap'];
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);
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,66 +116,29 @@ 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");
done();
};
done();
}).catch((err) => {
expect(err).assertFail();
done();
});
});
/**
* @tc.number bms_AccessTokenId_0500
* @tc.name BUNDLE::getBundleInfos
* @tc.desc Test getBundleInfos interfaces with with a flag
*/
it("bms_AccessTokenId_0500", 0, async function (done) {
console.info("bms_AccessTokenId_0500 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_BUNDLE_DEFAULT).then((applicationInfo) => {
console.info("accessTokenId: " + applicationInfo.accessTokenId);
expect(applicationInfo.name).assertEqual(bundleName);
expect(applicationInfo.reqPermissionStates.length).assertEqual(0);
it("bms_AccessTokenId_0500", 0, async function (done) {
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);
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();
}
});
/**
......@@ -280,47 +147,17 @@ 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");
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)
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);
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
......@@ -328,95 +165,16 @@ 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");
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)
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);
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 @@
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleTest6.hap->/data/test/bmsThirdBundleTest6.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap",
"bmsSystemBundleTest2.hap->/data/test/bmsSystemBundleTest2.hap",
"bmsSystemBundleTest2Feature.hap->/data/test/bmsSystemBundleTest2Feature.hap",
"bmsSystemBundleTest2Update.hap->/data/test/bmsSystemBundleTest2Update.hap"
"bmsSystemBundleTest2.hap->/data/test/bmsSystemBundleTest2.hap"
]
},
{
"type": "ShellKit",
"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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -58,18 +54,6 @@
{
"name":"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": [
......
/*
* 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 @@
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 SYSTEM_NAME = 'com.example.system2';
const ABILITIY_NAME8 = 'com.example.system2.MainAbility';
const USERID = 100;
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==================');
var 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');
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)
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);
})
})
it('bms_queryAbilityByWant_0100', 0, async function (done) {
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,
USERID, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("QueryAbilityInfos failed");
done();
});
});
/*
* @tc.number: bms_queryAbilityByWant_0200
......@@ -76,27 +57,120 @@ 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==================');
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,
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(
{
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) {
var 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, (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();
}
).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();
})
})
});
});
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 @@
* 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')
\ No newline at end of file
require('./ActsBmsGetBackGroundModes.test.js')
......@@ -27,8 +27,6 @@
"push": [
"bmsMainAbilityFirstScene.hap->/data/test/bmsMainAbilityFirstScene.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",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap"
]
......@@ -36,7 +34,17 @@
{
"type": "ShellKit",
"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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -58,18 +54,6 @@
{
"name":"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": [
......
......@@ -33,7 +33,18 @@
{
"type": "ShellKit",
"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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -59,18 +55,6 @@
{
"name":"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": [
......
......@@ -14,78 +14,34 @@
*/
import bundle from '@ohos.bundle'
import innerBundleManager from '@ohos.bundle.innerBundleManager'
import {describe, it, expect} from 'deccjsunit/index'
const STATUS_INSTALL_PERMISSION_DENIED = 0X44;
const STATUS_UNINSTALL_PERMISSION_DENIED = 0X45;
import { describe, it, expect } from 'deccjsunit/index'
const LAUNCHER_BUNDLE_NAME = 'com.ohos.launcher';
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 INVALID_CODE = 1;
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.name: test getApplicationInfo
* @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 => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
......@@ -94,14 +50,18 @@ 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 => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
......@@ -110,14 +70,18 @@ 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 => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
......@@ -126,14 +90,18 @@ 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 => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getAllBundleInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
......@@ -142,8 +110,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 => {
......@@ -153,6 +120,15 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE);
done();
});
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();
});
});
/*
......@@ -161,14 +137,18 @@ 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 => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
......@@ -177,8 +157,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,60 +172,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 => {
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 => {
await bundle.setAbilityEnabled(abilityInfo, false).then(data => {
expect().assertFail();
done();
}).catch(err => {
......@@ -256,13 +186,12 @@ describe('ActsBmsJsUnPermissionTest', function () {
});
/*
* @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
*/
* @tc.number: getAbilityLabelTest_100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface
* @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();
......@@ -272,6 +201,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
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 +214,17 @@ 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();
});
})
bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
})
......@@ -27,15 +27,25 @@
"type": "PushKit",
"push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTest3.hap->/data/test/bmsThirdBundleTest3.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",
"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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -58,18 +54,6 @@
{
"name":"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": [
......
......@@ -16,6 +16,18 @@
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.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 () {
/*
......@@ -24,133 +36,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which contains two HAP packages.
*/
it('bms_getMetaData_0100', 0, async function (done) {
console.info('=====================bms_getMetaData_0100==================');
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap']
var installer = await bundle.getBundleInstaller();
let abilityName1 = 'com.example.third1.MainAbility';
let dataMap = new Map();
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.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');
await bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
});
});
})
/*
* @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);
});
}).catch(err => {
expect(err).assertFail();
done();
});
});
})
});
/*
* @tc.number: bms_getMetaData_0400
......@@ -158,44 +59,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which has one ability.
*/
it('bms_getMetaData_0400', 0, async function (done) {
console.info('=====================bms_getMetaData_0400==================');
var bundlePath = ['/data/test/bmsThirdBundleTest5.hap']
let dataMap = new Map();
let abilityName1 = 'com.example.third5.AMainAbility';
var 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.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');
await bundle.queryAbilityByWant(
{
bundleName: BUNDLE_NAME2,
abilityName: ABILITY_NAME3,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data5A");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
})
}
})
}).catch(err => {
expect(err).assertFail();
done();
});
});
/*
* @tc.number: bms_getMetaData_0500
......@@ -203,16 +82,19 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get an application's meta data which does not exist.
*/
it('bms_getMetaData_0500', 0, async function (done) {
console.info('=====================bms_getMetaData_0500==================');
bundle.queryAbilityByWant(
await bundle.queryAbilityByWant(
{
bundleName: 'com.example.noexist',
abilityName: 'com.example.noexist.MainAbility',
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, 100).then(dataInfos => {
bundleName: BUNDLE_NAME3,
abilityName: ABILITY_NAME4,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
expect(dataInfos.length).assertEqual(0);
})
done();
})
done();
}).catch(err => {
console.info("err====: " + err);
expect(err).assertEqual(1);
done();
});
});
/*
* @tc.number: bms_getMetaData_0600
......@@ -220,23 +102,22 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get a system application's meta data.
*/
it('bms_getMetaData_0600', 0, async function (done) {
console.info('=====================bms_getMetaData_0600==================');
let dataMap = new Map();
let abilityName1 = 'com.example.system1.MainAbility';
bundle.queryAbilityByWant(
await bundle.queryAbilityByWant(
{
bundleName: 'com.example.system1',
abilityName: 'com.example.system1.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), 'Data1S');
}
done();
})
bundleName: BUNDLE_NAME4,
abilityName: ABILITY_NAME5,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1S");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
}).catch(err => {
expect(err).assertFail();
done();
});
});
/*
* @tc.number: bms_getMetaData_0700
......@@ -244,73 +125,21 @@ describe('ActsBmsMetaDataTest', function () {
* @tc.desc: get a vendor application's meta data.
*/
it('bms_getMetaData_0700', 0, async function (done) {
console.info('=====================bms_getMetaData_0700==================');
let dataMap = new Map();
let abilityName1 = 'com.example.vendor1.MainAbility';
bundle.queryAbilityByWant(
await bundle.queryAbilityByWant(
{
bundleName: 'com.example.vendor1',
abilityName: 'com.example.vendor1.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)
}
bundleName: BUNDLE_NAME5,
abilityName: ABILITY_NAME6,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].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 @@
],
"type": "AppInstallKit",
"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 @@
* See the License for the specific language governing permissions and
* 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 Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility'
const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility'
const BUNDLE_NAME = 'com.open.harmony.packagemag';
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility';
const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage';
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility';
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error';
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage'
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility'
export default function getAbilityLabelJsUnit() {
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
describe('context_getAbilityLabel_test', function () {
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_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;
var timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error);
expect(error).assertFail();
/*
* @tc.number: context_getAbilityLabel_test_0200
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0200', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
if (error) {
console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data));
});
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.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0200', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
if(error){
console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0300
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0300', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mError;
await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
let timeNewStamp = Utils.getNowTime();
mError = error;
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error);
expect(mError).assertEqual(1);
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0300
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0300', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mError;
await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
mError = error;
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error);
expect(mError).assertEqual(1);
/*
* @tc.number: context_getAbilityLabel_test_0400
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0400', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
if (error !== null) {
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
expect(error).assertEqual(1);
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
mError = error;
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
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.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0400', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
if(error !== null){
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
expect(error).assertEqual(1);
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
mError = error;
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError);
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0500
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0500', 0, async function (done) {
let mData;
let mError = null;
let timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
expect(mData).assertFail();
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_0500
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0500', 0, async function (done) {
let mData;
let mError = null;
var timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
expect(mData).assertFail();
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);
/*
* @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0600', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error);
expect(data).assertEqual(undefined);
});
done();
});
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0600', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error);
expect(data).assertEqual(undefined);
});
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
let 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");
}
/*
* @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_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);
function getAbilityLabelFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error ' + JSON.stringify(error));
expect(typeof (error)).assertEqual('number');
expect(error).assertEqual(1)
}
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 @@
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test/"
]
},
{
"type": "PushKit",
"push": [
"bmsJstest1.hap->/data/bmsJstest1.hap",
"bmsJstest2.hap->/data/bmsJstest2.hap",
"bmsJstest3.hap->/data/bmsJstest3.hap",
"bmsJstest4.hap->/data/bmsJstest4.hap",
"bmsJstest5.hap->/data/bmsJstest5.hap",
"bmsJstest6.hap->/data/bmsJstest6.hap",
"bmsJstest7.hap->/data/bmsJstest7.hap",
"bmsJstest8.hap->/data/bmsJstest8.hap",
"bmsJstest9.hap->/data/bmsJstest9.hap"
"bmsJstest1.hap->/data/test/bmsJstest1.hap",
"bmsJstest2.hap->/data/test/bmsJstest2.hap",
"bmsJstest3.hap->/data/test/bmsJstest3.hap",
"bmsJstest4.hap->/data/test/bmsJstest4.hap",
"bmsJstest5.hap->/data/test/bmsJstest5.hap",
"bmsJstest6.hap->/data/test/bmsJstest6.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap",
"chmod 600 /data/bmsJstest7.hap"
"bm install -p /data/test/bmsJstest1.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 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......@@ -81,18 +77,6 @@
{
"name":"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": [
......
......@@ -10,22 +10,25 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBundleManagerUninstallTest") {
hap_profile = "./entry/src/main/config.json"
ohos_hap("bmsAccessTokenTest5") {
hap_profile = "./src/main/config.json"
hap_name = "bmsAccessTokenTest5"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBundleManagerUninstallTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
sources = [ "./src/main/js/resources" ]
hap_profile = "./src/main/config.json"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册