提交 d7f749f4 编写于 作者: Z zhaoyuan17

Update test case

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 97c97eb0
...@@ -381,6 +381,7 @@ describe('ActsAmsTestFourthScene', function () { ...@@ -381,6 +381,7 @@ describe('ActsAmsTestFourthScene', function () {
* @tc.desc : Get All Active Processes Info(by Promise) * @tc.desc : Get All Active Processes Info(by Promise)
*/ */
it('Acts_Ams_test_8400', 0, async function (done) { it('Acts_Ams_test_8400', 0, async function (done) {
sleep(5000);
var info = await abilitymanager.getActiveProcessInfos(); var info = await abilitymanager.getActiveProcessInfos();
console.info('Acts_Ams_test_8400 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); console.info('Acts_Ams_test_8400 getActiveProcessInfos JSON String: ' + JSON.stringify(info));
expect(Array.isArray(info)).assertEqual(true); expect(Array.isArray(info)).assertEqual(true);
......
...@@ -21,13 +21,16 @@ group("bundlemanager") { ...@@ -21,13 +21,16 @@ group("bundlemanager") {
"actsbmscheckpermissiontest:ActsBmsCheckPermissionTest", "actsbmscheckpermissiontest:ActsBmsCheckPermissionTest",
"actsbmshapmoduletest:ActsBmsHapModuleTest", "actsbmshapmoduletest:ActsBmsHapModuleTest",
"actsbmsjstest:ActsBmsJsTest", "actsbmsjstest:ActsBmsJsTest",
"actsbmskittest:ActsBmsKitTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest", "actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest", "actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest",
"actsbundlemanagertest:ActsBundleManagerTest", "actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstall", "actsbundlemanageruninstall:ActsBundleManagerUninstall",
"bmscheckpermissiontest:BmsCheckPermissionTest",
"sceneProject/bmsgetinfosfifthscene:bmsThirdBundleTest5", "sceneProject/bmsgetinfosfifthscene:bmsThirdBundleTest5",
"sceneProject/bmsgetinfosfirstscene:bmsThirdBundleTest1", "sceneProject/bmsgetinfosfirstscene:bmsThirdBundleTest1",
"sceneProject/bmsgetinfosfirstsceneupdate:bmsThirdBundleTestA1", "sceneProject/bmsgetinfosfirstsceneupdate:bmsThirdBundleTestA1",
"sceneProject/bmsgetinfoshapc:bmsThirdBundleC",
"sceneProject/bmsgetinfosfourthscene:bmsThirdBundleTest4", "sceneProject/bmsgetinfosfourthscene:bmsThirdBundleTest4",
"sceneProject/bmsgetinfosjsscene:bmsThirdBundleJs", "sceneProject/bmsgetinfosjsscene:bmsThirdBundleJs",
"sceneProject/bmsgetinfosscenesystem:bmsSystemBundleTest1", "sceneProject/bmsgetinfosscenesystem:bmsSystemBundleTest1",
......
...@@ -31,11 +31,39 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -31,11 +31,39 @@ describe('ActsBmsAllShortcutInfoTest', function () {
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap']; var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'];
await install(bundlePath); await install(bundlePath);
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
bundle.getAllShortcutInfo(bundleName).then((data) => { bundle.getAllShortcutInfo(bundleName).then(async(data) => {
for (var i = 0; i < data.length; i++) {
expect(data[i].id).assertEqual('id.third1');
console.info('==========data[i].id==========' + data[i].id)
expect(data[i].bundleName).assertEqual('com.example.third1');
console.info('==========data[i].bundleName==========' + data[i].bundleName)
expect(data[i].hostAbility).assertEqual("");
console.info('==========data[i].hostAbility==========' + data[i].hostAbility)
expect(data[i].icon).assertEqual('$media:icon');
console.info('==========data[i].icon==========' + data[i].icon)
expect(data[i].label).assertEqual('$string:app_name');
console.info('==========data[i].label==========' + data[i].label)
expect(data[i].disableMessage).assertEqual("");
console.info('==========data[i].disableMessage==========' + data[i].disableMessage)
expect(data[i].isStatic).assertEqual(false);
console.info('==========data[i].isStatic==========' + data[i].isStatic)
expect(data[i].isHomeShortcut).assertEqual(false);
console.info('==========data[i].isHomeShortcut==========' + data[i].isHomeShortcut)
expect(data[i].isEnabled).assertEqual(false);
console.info('==========data[i].isEnabled==========' + data[i].isEnabled)
for (var j = 0; j < data[i].wants.length; j++) {
console.info('==========data[i].wants[j].targetClass==========' + data[i].wants[j].targetClass)
expect(data[i].wants[j].targetClass).assertEqual('com.example.third1.MainAbility');
console.info('==========data[i].wants[j].targetBundle==========' + data[i].wants[j].targetBundle)
expect(data[i].wants[j].targetBundle).assertEqual('com.example.third1');
}
}
expect(typeof data).assertEqual('object'); expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(1); expect(data.length).assertEqual(1);
checkShortcutIsExist(data, 'id.third1', 'third1'); checkShortcutIsExist(data, 'id.third1', 'third1');
await uninstall('com.example.third1');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getAllShortcutInfo_0100==================end'); console.info('=====================bms_getAllShortcutInfo_0100==================end');
...@@ -49,11 +77,14 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -49,11 +77,14 @@ describe('ActsBmsAllShortcutInfoTest', function () {
*/ */
it('bms_getAllShortcutInfo_0200', 0, async function (done) { it('bms_getAllShortcutInfo_0200', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_0200=================='); console.info('=====================bms_getAllShortcutInfo_0200==================');
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'];
await install(bundlePath);
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
bundle.getAllShortcutInfo(bundleName, (result, data) => { bundle.getAllShortcutInfo(bundleName, async(result, data) => {
expect(result.code).assertEqual(0); expect(result.code).assertEqual(0);
expect(data.length).assertEqual(1); expect(data.length).assertEqual(1);
checkShortcutIsExist(data, 'id.third1', 'third1'); checkShortcutIsExist(data, 'id.third1', 'third1');
await uninstall('com.example.third1');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
...@@ -70,13 +101,14 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -70,13 +101,14 @@ describe('ActsBmsAllShortcutInfoTest', function () {
it('bms_getAllShortcutInfo_0300', 0, async function (done) { it('bms_getAllShortcutInfo_0300', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_0300=================='); console.info('=====================bms_getAllShortcutInfo_0300==================');
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
var bundlePath = ['/data/test/bmsThirdBundleTest3.hap']; var bundlePath = ['/data/test/bmsThirdBundleTest1.hap', '/data/test/bmsThirdBundleTest3.hap'];
await install(bundlePath); await install(bundlePath);
var data = await bundle.getAllShortcutInfo(bundleName); var data = await bundle.getAllShortcutInfo(bundleName);
expect(typeof data).assertEqual('object'); expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(2); expect(data.length).assertEqual(2);
checkShortcutIsExist(data, 'id.third1', 'third1'); checkShortcutIsExist(data, 'id.third1', 'third1');
checkShortcutIsExist(data, 'id.third3', 'third3'); checkShortcutIsExist(data, 'id.third3', 'third3');
await uninstall('com.example.third1');
done(); done();
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getAllShortcutInfo_0300==================end'); console.info('=====================bms_getAllShortcutInfo_0300==================end');
...@@ -90,13 +122,15 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -90,13 +122,15 @@ describe('ActsBmsAllShortcutInfoTest', function () {
*/ */
it('bms_getAllShortcutInfo_0400', 0, async function (done) { it('bms_getAllShortcutInfo_0400', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_0400=================='); console.info('=====================bms_getAllShortcutInfo_0400==================');
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap', '/data/test/bmsThirdBundleTest3.hap'];
await install(bundlePath);
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
bundle.getAllShortcutInfo(bundleName, async (result, data) => { bundle.getAllShortcutInfo(bundleName, async (result, data) => {
expect(result.code).assertEqual(0); expect(result.code).assertEqual(0);
expect(data.length).assertEqual(2); expect(data.length).assertEqual(2);
checkShortcutIsExist(data, 'id.third1', 'third1'); checkShortcutIsExist(data, 'id.third1', 'third1');
checkShortcutIsExist(data, 'id.third3', 'third3'); checkShortcutIsExist(data, 'id.third3', 'third3');
await uninstall(bundleName); await uninstall('com.example.third1');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
...@@ -172,6 +206,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -172,6 +206,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
} }
} }
} }
await uninstall('com.example.third1')
done(); done();
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getAllShortcutInfo_0700==================end'); console.info('=====================bms_getAllShortcutInfo_0700==================end');
...@@ -186,6 +221,10 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -186,6 +221,10 @@ describe('ActsBmsAllShortcutInfoTest', function () {
it('bms_getAllShortcutInfo_0800', 0, async function (done) { it('bms_getAllShortcutInfo_0800', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_0800=================='); console.info('=====================bms_getAllShortcutInfo_0800==================');
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
var bundlePath1 = ['/data/test/bmsThirdBundleTest1.hap'];
await install(bundlePath1);
var bundlePath2 = ['/data/test/bmsThirdBundleTestA1.hap'];
await install(bundlePath2);
bundle.getAllShortcutInfo(bundleName, async (result, data) => { bundle.getAllShortcutInfo(bundleName, async (result, data) => {
expect(result.code).assertEqual(0); expect(result.code).assertEqual(0);
expect(data.length).assertEqual(1); expect(data.length).assertEqual(1);
...@@ -206,7 +245,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -206,7 +245,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
} }
} }
} }
await uninstall(bundleName); await uninstall('com.example.third1');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
...@@ -227,6 +266,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -227,6 +266,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
var data = await bundle.getAllShortcutInfo(bundleName); var data = await bundle.getAllShortcutInfo(bundleName);
expect(typeof data).assertEqual('object'); expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(0); expect(data.length).assertEqual(0);
await uninstall('com.example.third2')
done(); done();
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getAllShortcutInfo_0900==================end'); console.info('=====================bms_getAllShortcutInfo_0900==================end');
...@@ -241,10 +281,12 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -241,10 +281,12 @@ describe('ActsBmsAllShortcutInfoTest', function () {
it('bms_getAllShortcutInfo_1000', 0, async function (done) { it('bms_getAllShortcutInfo_1000', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_1000=================='); console.info('=====================bms_getAllShortcutInfo_1000==================');
var bundleName = 'com.example.third2'; var bundleName = 'com.example.third2';
var bundlePath = ['/data/test/bmsThirdBundleTest2.hap'];
await install(bundlePath);
bundle.getAllShortcutInfo(bundleName, async (result, data) => { bundle.getAllShortcutInfo(bundleName, async (result, data) => {
expect(result.code).assertEqual(0); expect(result.code).assertEqual(0);
expect(data.length).assertEqual(0); expect(data.length).assertEqual(0);
await uninstall(bundleName); await uninstall('com.example.third2');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
...@@ -342,7 +384,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -342,7 +384,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
expect(typeof data).assertEqual('object'); expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(1); expect(data.length).assertEqual(1);
checkShortcutIsExist(data, 'id.third1', 'third1'); checkShortcutIsExist(data, 'id.third1', 'third1');
await uninstall(bundleName); await uninstall('com.example.third1');
var info = await bundle.getAllShortcutInfo(bundleName); var info = await bundle.getAllShortcutInfo(bundleName);
expect(info.length).assertEqual(0); expect(info.length).assertEqual(0);
done(); done();
...@@ -357,9 +399,16 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -357,9 +399,16 @@ describe('ActsBmsAllShortcutInfoTest', function () {
* @tc.desc: get the shortcut information of this hap after uninstalling the hap * @tc.desc: get the shortcut information of this hap after uninstalling the hap
*/ */
it('bms_getAllShortcutInfo_1600', 0, async function (done) { it('bms_getAllShortcutInfo_1600', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_1600==================');; console.info('=====================bms_getAllShortcutInfo_1600==================');
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'];
await install(bundlePath);
var bundleName = 'com.example.third1'; var bundleName = 'com.example.third1';
bundle.getAllShortcutInfo(bundleName, (result, data) => { var data = await bundle.getAllShortcutInfo(bundleName);
expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(1);
checkShortcutIsExist(data, 'id.third1', 'third1');
await uninstall('com.example.third1');
bundle.getAllShortcutInfo(bundleName, async(result, data) => {
expect(result.code).assertEqual(-1); expect(result.code).assertEqual(-1);
expect(data.length).assertEqual(0); expect(data.length).assertEqual(0);
done(); done();
...@@ -384,6 +433,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -384,6 +433,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
expect(data.length).assertEqual(2); expect(data.length).assertEqual(2);
checkShortcutIsExist(data, 'id.third4A', 'third4A'); checkShortcutIsExist(data, 'id.third4A', 'third4A');
checkShortcutIsExist(data, 'id.third4B', 'third4B'); checkShortcutIsExist(data, 'id.third4B', 'third4B');
await uninstall('com.example.third4')
done(); done();
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getAllShortcutInfo_1700==================end'); console.info('=====================bms_getAllShortcutInfo_1700==================end');
...@@ -398,12 +448,14 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -398,12 +448,14 @@ describe('ActsBmsAllShortcutInfoTest', function () {
it('bms_getAllShortcutInfo_1800', 0, async function (done) { it('bms_getAllShortcutInfo_1800', 0, async function (done) {
console.info('=====================bms_getAllShortcutInfo_1800=================='); console.info('=====================bms_getAllShortcutInfo_1800==================');
var bundleName = 'com.example.third4'; var bundleName = 'com.example.third4';
var bundlePath = ['/data/test/bmsThirdBundleTest4.hap'];
await install(bundlePath);
bundle.getAllShortcutInfo(bundleName, async (result, data) => { bundle.getAllShortcutInfo(bundleName, async (result, data) => {
expect(result.code).assertEqual(0); expect(result.code).assertEqual(0);
expect(data.length).assertEqual(2); expect(data.length).assertEqual(2);
checkShortcutIsExist(data, 'id.third4A', 'third4A'); checkShortcutIsExist(data, 'id.third4A', 'third4A');
checkShortcutIsExist(data, 'id.third4B', 'third4B'); checkShortcutIsExist(data, 'id.third4B', 'third4B');
await uninstall(bundleName); await uninstall('com.example.third4');
done(); done();
}); });
setTimeout(function () { setTimeout(function () {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"bmsThirdBundleTest1",
"ActsBmsCheckPermissionTest.hap" "ActsBmsCheckPermissionTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
......
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
} }
} }
], ],
"defPermissions": [ "defPermissions": [
{ {
"name": "com.permission.CAMERA", "name": "com.permission.CAMERA",
...@@ -90,6 +89,16 @@ ...@@ -90,6 +89,16 @@
], ],
"when": "always" "when": "always"
} }
},
{
"name": "com.permission.PERMISSION_B",
"reason": "Need PERMISSION_B",
"usedScene": {
"ability": [
"com.example.actsbmscheckpermissiontest.MainAbility"
],
"when": "always"
}
} }
] ]
} }
......
...@@ -17,8 +17,8 @@ import bundle from '@ohos.bundle' ...@@ -17,8 +17,8 @@ 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_NAME = 'com.example.actsbmscheckpermissiontest'; const BUNDLE_NAME = 'com.example.actsbmscheckpermissiontest';
const PERMISSION_ONE = 'com.permission.CAMERA'; const PERMISSION_ONE = 'com.permission.PERMISSION_A';
const PERMISSION_TWO = 'com.permission.PERMISSION_A'; const PERMISSION_TWO = 'com.permission.PERMISSION_B';
const TIMEOUT = 1000; const TIMEOUT = 1000;
const NAMECOUNT = 10000; const NAMECOUNT = 10000;
...@@ -31,7 +31,7 @@ describe('ActsBmsCheckPermissionTest', function () { ...@@ -31,7 +31,7 @@ describe('ActsBmsCheckPermissionTest', function () {
*/ */
it('bms_checkPermission_0100', 0, async function (done) { it('bms_checkPermission_0100', 0, async function (done) {
console.info('=====================bms_checkPermission_0100=================='); console.info('=====================bms_checkPermission_0100==================');
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO) var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_ONE)
expect(data).assertEqual(0); expect(data).assertEqual(0);
done(); done();
setTimeout(function () { setTimeout(function () {
...@@ -46,7 +46,7 @@ describe('ActsBmsCheckPermissionTest', function () { ...@@ -46,7 +46,7 @@ describe('ActsBmsCheckPermissionTest', function () {
*/ */
it('bms_checkPermission_0200', 0, async function (done) { it('bms_checkPermission_0200', 0, async function (done) {
console.info('=====================bms_checkPermission_0200=================='); console.info('=====================bms_checkPermission_0200==================');
await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO, (err, data) => { await bundle.checkPermission(BUNDLE_NAME, PERMISSION_ONE, (err, data) => {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(data).assertEqual(0); expect(data).assertEqual(0);
done(); done();
...@@ -275,4 +275,38 @@ describe('ActsBmsCheckPermissionTest', function () { ...@@ -275,4 +275,38 @@ describe('ActsBmsCheckPermissionTest', function () {
console.info('=====================bms_checkPermission_1400==================end'); console.info('=====================bms_checkPermission_1400==================end');
}, TIMEOUT) }, TIMEOUT)
}) })
/*
* @tc.number: bms_checkPermission_1500
* @tc.name: check whether the permission is granted
* @tc.desc: Verify that permissions which availableScope is system_grant requested
* from other apps are granted. (by promise)
*/
it('bms_checkPermission_1500', 0, async function (done) {
console.info('=====================bms_checkPermission_1500==================');
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO)
expect(data).assertEqual(0);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_1500==================end');
}, TIMEOUT)
})
/*
* @tc.number: bms_checkPermission_1600
* @tc.name: check whether the permission is granted
* @tc.desc: Verify that permissions which availableScope is system_grant requested
* from other apps are granted. (by callback)
*/
it('bms_checkPermission_1600', 0, async function (done) {
console.info('=====================bms_checkPermission_1600==================');
await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO, (err, data) => {
expect(err.code).assertEqual(0);
expect(data).assertEqual(0);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_1600==================end');
}, TIMEOUT)
})
}) })
\ No newline at end of file
...@@ -26,7 +26,10 @@ ...@@ -26,7 +26,10 @@
"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",
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.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"
] ]
}, },
{ {
......
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 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 TIMEOUT = 1000; const TIMEOUT = 2000;
describe('ActsBmsHapModuleTest', function () { describe('ActsBmsHapModuleTest', function () {
...@@ -31,15 +31,43 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -31,15 +31,43 @@ describe('ActsBmsHapModuleTest', function () {
let bundleName = 'com.example.bmsmainabilityfirstscene'; let bundleName = 'com.example.bmsmainabilityfirstscene';
let ret = false let ret = false
bundle.getBundleInfo(bundleName, 1, callback); bundle.getBundleInfo(bundleName, 1, callback);
function callback(err, data) { async function callback(err, data) {
console.debug('=======get bundle========' + JSON.stringify(data)); console.debug('=======get bundle========' + JSON.stringify(data));
let hapModuleInfo = data.hapModuleInfo[0]; expect(data.hapModuleInfo.length).assertEqual(1);
console.debug('=======get hapModule========' + JSON.stringify(hapModuleInfo)) if (data.hapModuleInfo.length > 0) {
console.debug('=======get hapModule mainAbilityName========' + hapModuleInfo.mainAbilityName) let hapModuleInfo = data.hapModuleInfo[0];
expect(hapModuleInfo.moduleName).assertEqual('entry'); console.debug('=======get hapModule========' + JSON.stringify(hapModuleInfo))
expect(hapModuleInfo.mainAbilityName).assertEqual('com.example.bmsmainabilityfirstscene.MainAbility'); console.debug('=======get hapModule mainAbilityName========' + hapModuleInfo.mainAbilityName)
checkHapModuleInfo(hapModuleInfo); expect(hapModuleInfo.moduleName).assertEqual('entry');
ret = true; expect(hapModuleInfo.mainAbilityName).assertEqual('com.example.bmsmainabilityfirstscene.MainAbility');
expect(hapModuleInfo.name).assertEqual('com.example.bmsmainabilityfirstscene');
expect(hapModuleInfo.description).assertEqual('');
expect(hapModuleInfo.descriptionId).assertEqual(0);
expect(hapModuleInfo.icon).assertEqual('');
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.labelId).assertEqual(0);
expect(hapModuleInfo.iconId).assertEqual(0);
expect(hapModuleInfo.backgroundImg).assertEqual('');
expect(hapModuleInfo.supportedModes).assertEqual(0);
console.info('===============hapModuleInfo.reqCapabilities==========' + JSON.stringify(hapModuleInfo.reqCapabilities))
expect(typeof hapModuleInfo.reqCapabilities).assertEqual('object');
expect(hapModuleInfo.deviceTypes).assertEqual('phone');
console.info('===============hapModuleInfo.abilityInfo==========' + JSON.stringify(hapModuleInfo.abilityInfo))
expect(typeof hapModuleInfo.abilityInfo).assertEqual('object');
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.mainAbilityName).assertEqual('com.example.bmsmainabilityfirstscene.MainAbility');
expect(hapModuleInfo.installationFree).assertEqual(false);
for (let i = 0, len = hapModuleInfo.reqCapabilities.length; i < len; i++) {
console.debug('=======get reqCapabilities========' + JSON.stringify(hapModuleInfo.reqCapabilities[i]));
expect(hapModuleInfo.reqCapabilities[i]).assertEqual('');
}
for (let j = 0, len = hapModuleInfo.abilityInfo.length; j < len; j++) {
console.debug('=======get abilityInfo========' + JSON.stringify(hapModuleInfo.abilityInfo[j]))
expect(hapModuleInfo.abilityInfo[j].name).assertEqual('com.example.bmsmainabilityfirstscene.MainAbility');
}
ret = true;
}
await uninstall(bundleName);
done(); done();
} }
setTimeout(function () { setTimeout(function () {
...@@ -54,12 +82,12 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -54,12 +82,12 @@ describe('ActsBmsHapModuleTest', function () {
*/ */
it('bms_getHapModuleInfo_0200', 0, async function (done) { it('bms_getHapModuleInfo_0200', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0200===========') console.debug('===========begin bms_getHapModuleInfo_0200===========')
await install(['/data/test/bmsMainAbilityFirstScene.hap']);
await install(['/data/test/bmsMainAbilitySecondScene.hap']); await install(['/data/test/bmsMainAbilitySecondScene.hap']);
let ret = false let ret = false
let bundleName = 'com.example.bmsmainabilityfirstscene'; let bundleName = 'com.example.bmsmainabilityfirstscene';
let firstMainAbility = 'com.example.bmsmainabilityfirstscene.MainAbility'; let firstMainAbility = 'com.example.bmsmainabilityfirstscene.MainAbility';
let secondMainAbility = 'com.example.bmsmainabilitysecondscene.MainAbility'; let secondMainAbility = 'com.example.bmsmainabilitysecondscene.MainAbility';
let result = new Map();
bundle.getBundleInfo(bundleName, 1, async (err, data) => { bundle.getBundleInfo(bundleName, 1, async (err, data) => {
console.debug('=======hapModule length========' + data.hapModuleInfo.length); console.debug('=======hapModule length========' + data.hapModuleInfo.length);
expect(data.hapModuleInfo.length).assertEqual(2); expect(data.hapModuleInfo.length).assertEqual(2);
...@@ -67,12 +95,13 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -67,12 +95,13 @@ describe('ActsBmsHapModuleTest', function () {
console.debug('=======get hapModule========' + JSON.stringify(data.hapModuleInfo[i])) console.debug('=======get hapModule========' + JSON.stringify(data.hapModuleInfo[i]))
console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[i].mainAbilityName); console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[i].mainAbilityName);
checkHapModuleInfo(data.hapModuleInfo[i]); checkHapModuleInfo(data.hapModuleInfo[i]);
result.set(data.hapModuleInfo[i].mainAbilityName, data.hapModuleInfo[i]);
} }
expect(result.has(firstMainAbility)).assertTrue(); if (data.hapModuleInfo.length == 2) {
expect(result.has(secondMainAbility)).assertTrue(); expect(data.hapModuleInfo[0].mainAbilityName).assertEqual(firstMainAbility);
expect(result.get(firstMainAbility).moduleName).assertEqual('entry'); expect(data.hapModuleInfo[0].moduleName).assertEqual('entry');
expect(result.get(secondMainAbility).moduleName).assertEqual('bmsmainabilitysecondscene'); expect(data.hapModuleInfo[1].mainAbilityName).assertEqual(secondMainAbility);
expect(data.hapModuleInfo[1].moduleName).assertEqual('bmsmainabilitysecondscene');
}
await uninstall(bundleName); await uninstall(bundleName);
ret = true; ret = true;
done(); done();
...@@ -92,15 +121,40 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -92,15 +121,40 @@ describe('ActsBmsHapModuleTest', function () {
await install(['/data/test/bmsThirdBundleTest2.hap']); await install(['/data/test/bmsThirdBundleTest2.hap']);
let bundleName = 'com.example.third2'; let bundleName = 'com.example.third2';
let ret = false; let ret = false;
bundle.getBundleInfo(bundleName, 1).then(async (data) => { bundle.getBundleInfo(bundleName, 1,).then(async (data) => {
console.debug('=======get hapModule========' + JSON.stringify(data)) console.debug('=======get hapModule========' + JSON.stringify(data))
expect(data.hapModuleInfo.length).assertEqual(1); expect(data.hapModuleInfo.length).assertEqual(1);
console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[0].mainAbilityName) if (data.hapModuleInfo.length > 0) {
expect(data.hapModuleInfo[0].mainAbilityName).assertEqual(''); console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[0].mainAbilityName)
expect(data.hapModuleInfo[0].moduleName).assertEqual('entry'); expect(data.hapModuleInfo[0].mainAbilityName).assertEqual('');
checkHapModuleInfo(data.hapModuleInfo[0]); expect(data.hapModuleInfo[0].moduleName).assertEqual('entry');
checkHapModuleInfo(data.hapModuleInfo[0]);
ret = true;
}
await uninstall(bundleName);
done();
})
setTimeout(function () {
expect(ret).assertTrue();
}, TIMEOUT);
})
it('bms_getHapModuleInfo_0400', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0400===========')
await install(['/data/test/bmsThirdBundleTest5.hap']);
let bundleName = 'com.example.third5';
let ret = true;
bundle.getBundleInfo(bundleName, 1, async (err, data) => {
console.debug('=======get hapModule========' + JSON.stringify(data))
expect(data.hapModuleInfo.length).assertEqual(1);
if (data.hapModuleInfo.length == 1) {
console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[0].mainAbilityName)
expect(data.hapModuleInfo[0].mainAbilityName).assertEqual('com.example.third5.AMainAbility');
expect(data.hapModuleInfo[0].moduleName).assertEqual('entry');
checkHapModuleInfo(data.hapModuleInfo[0]);
ret = true;
}
await uninstall(bundleName); await uninstall(bundleName);
ret = true;
done(); done();
}) })
setTimeout(function () { setTimeout(function () {
...@@ -108,6 +162,58 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -108,6 +162,58 @@ describe('ActsBmsHapModuleTest', function () {
}, TIMEOUT); }, TIMEOUT);
}) })
it('bms_getHapModuleInfo_0500', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0500===========')
await install(['/data/test/bmsThirdBundleTest1.hap']);
await install(['/data/test/bmsThirdBundleTestA1.hap']);
let bundleName = 'com.example.third1';
let ret = false
bundle.getBundleInfo(bundleName, 1, callback);
async function callback(err, data) {
console.debug('=======get bundle========' + JSON.stringify(data));
expect(data.hapModuleInfo.length).assertEqual(1);
if (data.hapModuleInfo.length == 1) {
let hapModuleInfo = data.hapModuleInfo[0];
console.debug('=======get hapModule========' + JSON.stringify(hapModuleInfo))
console.debug('=======get hapModule mainAbilityName========' + hapModuleInfo.mainAbilityName)
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.mainAbilityName).assertEqual('com.example.third1.AMainAbility');
checkHapModuleInfo(hapModuleInfo);
}
await uninstall(bundleName);
ret = true;
done();
}
setTimeout(function () {
expect(ret).assertTrue();
}, TIMEOUT);
});
it('bms_getHapModuleInfo_0600', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0600===========')
let bundleName = 'com.example.system1';
let ret = false
bundle.getBundleInfo(bundleName, 1, callback);
function callback(err, data) {
console.debug('=======get bundle========' + JSON.stringify(data));
console.debug('=======data.hapModuleInfo.length========' + data.hapModuleInfo.length);
expect(data.hapModuleInfo.length).assertEqual(1);
if (data.hapModuleInfo.length == 1) {
let hapModuleInfo = data.hapModuleInfo[0];
console.debug('=======get hapModule========' + JSON.stringify(hapModuleInfo))
console.debug('=======get hapModule mainAbilityName========' + hapModuleInfo.mainAbilityName)
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.mainAbilityName).assertEqual('com.example.system1.MainAbility');
checkHapModuleInfo(hapModuleInfo);
ret = true;
}
done();
}
setTimeout(function () {
expect(ret).assertTrue();
}, TIMEOUT);
});
function checkHapModuleInfo(dataInfo) { function checkHapModuleInfo(dataInfo) {
console.debug('========begin check hapModuleInfo========') console.debug('========begin check hapModuleInfo========')
expect(typeof dataInfo.name).assertEqual('string'); expect(typeof dataInfo.name).assertEqual('string');
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
"push": [ "push": [
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap", "bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap", "bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleJs.hap->/data/test/bmsThirdBundleJs.hap" "bmsThirdBundleJs.hap->/data/test/bmsThirdBundleJs.hap",
"bmsThirdBundleC.hap->/data/test/bmsThirdBundleC.hap"
] ]
}, },
{ {
......
...@@ -32,7 +32,12 @@ describe('ActsBmsJsTest', function () { ...@@ -32,7 +32,12 @@ describe('ActsBmsJsTest', function () {
await install(['/data/test/bmsThirdBundleTest2.hap']); await install(['/data/test/bmsThirdBundleTest2.hap']);
let data = await bundle.getBundleInfo(bundleName, 1); let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1); expect(data.abilityInfo.length).assertEqual(1);
checkIsExist(abilityName, data); if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('');
}
await uninstall(bundleName); await uninstall(bundleName);
done(); done();
setTimeout(function () { setTimeout(function () {
...@@ -54,9 +59,16 @@ describe('ActsBmsJsTest', function () { ...@@ -54,9 +59,16 @@ describe('ActsBmsJsTest', function () {
await install(['/data/test/bmsThirdBundleTest5.hap']); await install(['/data/test/bmsThirdBundleTest5.hap']);
let data = await bundle.getBundleInfo(bundleName, 1) let data = await bundle.getBundleInfo(bundleName, 1)
console.debug('==========bundleInfo==========' + JSON.stringify(data)) console.debug('==========bundleInfo==========' + JSON.stringify(data))
expect(data.abilityInfo.length).assertLarger(1); expect(data.abilityInfo.length).assertEqual(2);
checkIsExist(abilityName1, data); if(data.abilityInfo.length == 2){
checkIsExist(abilityName2, data); console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName1);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('');
expect(data.abilityInfo[1].name).assertEqual(abilityName2);
expect(data.abilityInfo[1].srcLanguage).assertEqual('js');
expect(data.abilityInfo[1].srcPath).assertEqual('');
}
await uninstall(bundleName); await uninstall(bundleName);
done(); done();
setTimeout(function () { setTimeout(function () {
...@@ -77,13 +89,45 @@ describe('ActsBmsJsTest', function () { ...@@ -77,13 +89,45 @@ describe('ActsBmsJsTest', function () {
await install(['/data/test/bmsThirdBundleJs.hap']); await install(['/data/test/bmsThirdBundleJs.hap']);
let data = await bundle.getBundleInfo(bundleName, 1); let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1); expect(data.abilityInfo.length).assertEqual(1);
checkIsExist(abilityName, data); if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('default');
}
await uninstall(bundleName);
done();
setTimeout(function () {
console.info('=====================bms_getJsAbility_0300==================end');
}, TIMEOUT)
})
/*
* @tc.number: bms_getJsAbility_0400
* @tc.name: test the multi js ability
* @tc.desc: 1.install a c++ hap which has an ability with short domain name
* 2.check the ability name by the interface of getBundleInfo
*/
it('bms_getJsAbility_0400', 0, async function (done) {
console.info('=====================bms_getJsAbility_0400==================');
let bundleName = 'com.example.c';
let abilityName = '.MainAbility';
await install(['/data/test/bmsThirdBundleC.hap']);
let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1);
if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('c++');
expect(data.abilityInfo[0].srcPath).assertEqual('default/c++/');
}
await uninstall(bundleName); await uninstall(bundleName);
done(); done();
setTimeout(function () { setTimeout(function () {
console.info('=====================bms_getJsAbility_0300==================end'); console.info('=====================bms_getJsAbility_0300==================end');
}, TIMEOUT) }, TIMEOUT)
}) })
async function install(bundlePath) { async function install(bundlePath) {
var installer = await bundle.getBundleInstaller(); var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, { installer.install(bundlePath, {
...@@ -123,15 +167,4 @@ describe('ActsBmsJsTest', function () { ...@@ -123,15 +167,4 @@ describe('ActsBmsJsTest', function () {
expect(data.statusMessage).assertEqual('SUCCESS'); expect(data.statusMessage).assertEqual('SUCCESS');
} }
} }
function checkIsExist(abilityName, data)
{
console.debug('==========bundleInfo==========' + JSON.stringify(data))
console.debug('==========AbilityInfo===========' + JSON.stringify(data.abilityInfo))
let abilityNames = new Map();
for (var i = 0; i < data.abilityInfo.length; i++) {
console.debug('==========abilityName==========' + data.abilityInfo[i].name);
abilityNames.set(data.abilityInfo[i].name, data.abilityInfo[i]);
}
expect(abilityNames.has(abilityName)).assertEqual(true);
}
}) })
\ No newline at end of file
...@@ -9,18 +9,18 @@ ...@@ -9,18 +9,18 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAnsIconTest") { ohos_js_hap_suite("ActsBmsKitTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./entry/src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
] ]
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsIconTest" hap_name = "ActsBmsKitTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" source_dir = "./entry/src/main/js/default"
......
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "120000", "test-timeout": "120000",
"package": "com.example.actsansicontest", "package": "com.example.actsbmskittest",
"shell-timeout": "120000" "shell-timeout": "60000"
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsAnsIconTest.hap" "ActsBmsKitTest.hap",
], "bmsThirdBundleTest1.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{ {
"app": { "app": {
"bundleName": "com.example.actsanspublishonetest", "bundleName": "com.example.actsbmskittest",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 5, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Beta1" "releaseType": "Beta1"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.actsanspublishonetest", "package": "com.example.actsbmskittest",
"name": ".MyApplication", "name": ".MyApplication",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home",
], "flag.home.intent.from.system"
"actions": [ ],
"action.system.home" "actions": [
] "action.system.home"
} ]
], }
"name": "com.example.actsanspublishonetest.MainAbility", ],
"icon": "$media:icon", "name": "com.example.actsbmskittest.MainAbility",
"description": "$string:mainability_description", "icon": "$media:icon",
"label": "$string:app_name", "description": "$string:mainability_description",
"type": "page", "label": "$string:app_name",
"isVisible": "true", "type": "page",
"launchType": "standard", "launchType": "standard",
"visible": true "visible": true
} }
], ],
"js": [ "js": [
{ {
"pages": [ "pages": [
"pages/index/index" "pages/index/index"
], ],
"name": "default", "name": "default",
"window": { "window": {
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": false "autoDesignWidth": false
} }
} }
] ],
} "defPermissions": [
} {
"name": "com.permission.CAMERA",
"grantMode": "user_grant",
"availableScope": ["signature"]
},
{
"name": "com.permission.PERMISSION_A",
"grantMode": "system_grant",
"availableScope": ["signature"]
}
],
"reqPermissions": [
{
"name": "com.permission.CAMERA",
"reason": "Need open camera",
"usedScene": {
"ability": [
"com.example.actsbmscheckpermissiontest.MainAbility"
],
"when": "always"
}
},
{
"name": "com.permission.PERMISSION_A",
"reason": "Need PERMISSION_A",
"usedScene": {
"ability": [
"com.example.actsbmscheckpermissiontest.MainAbility"
],
"when": "always"
}
}
]
}
}
\ No newline at end of file
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
* 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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index' import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global const injectRef = Object.getPrototypeOf(global) || global
...@@ -21,20 +19,19 @@ injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') ...@@ -21,20 +19,19 @@ injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default { export default {
data: { data: {
title: "" title: 'Bms Stress Test'
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.data.title;
}, },
onShow() { onShow() {
console.info('onShow finish') console.info('onReady finish')
const core = Core.getInstance() const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
'id': 'extend' 'id': 'extend'
}) })
core.addService('expect', expectExtend) core.addService('expect', expectExtend)
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
configService.setConfig(this) configService.setConfig(this)
...@@ -42,6 +39,7 @@ export default { ...@@ -42,6 +39,7 @@ export default {
core.execute() core.execute()
}, },
onReady() { onReady() {
console.info('onReady');
}, },
} onBackPress(){
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "publish1" "value": "actsbmskittest"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import featureAbility from '@ohos.ability.featureability'
import commonEvent from '@ohos.commonevent'
const TIMEOUT = 2000;
const STRESSLEVEL = 20;
const BUNDLE_NAME = 'com.example.actsbmskittest';
const PERMISSION_NAME = 'com.permission.PERMISSION_A';
const START_ABILITY_TIMEOUT = 3000;
const EVENTTIMEOUT = 5000;
var subscriberInfo_0100 = {
events: ['ACTS_Third1_Publish_CommonEvent'],
};
describe('ActsBmsKitTest', function () {
beforeAll(async (done) => {
var subscriber;
let id;
function subscribeCallBack(err, data) {
clearTimeout(id);
console.debug('=====subscribeCallBack=====' + data.event);
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
console.debug('=====subscribeCallBack end=====');
done();
}
commonEvent.createSubscriber(subscriberInfo_0100).then((data) => {
console.debug('====>Create Subscriber====>');
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback(err, data) {
console.debug('====>UnSubscribe CallBack====>');
done();
}
function timeout() {
console.debug('=====timeout======');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug('=======start ability========')
await featureAbility.startAbility(
{
want:
{
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility'
}
}
)
setTimeout(function () {
console.info('==================beforeAll==================end');
}, TIMEOUT)
})
/*
* @tc.number: ActsBmsKit_getAllShortcutInfo_0100
* @tc.name: Pressure test interface getAllShortcutInfo by promise
* @tc.desc: get the shortcut information of the hap
*/
it('ActsBmsKit_getAllShortcutInfo_0100', 0, async function (done) {
console.info('=====================ActsBmsKit_getAllShortcutInfo_0100==================');
var bundleName = 'com.example.third1';
let count;
for (count = 0; count < STRESSLEVEL; count++) {
let data = await bundle.getAllShortcutInfo(bundleName);
expect(typeof data).assertEqual('object');
expect(data.length).assertEqual(1);
if (!checkShortcutIsExist(data, 'id.third1', 'third1'))
break;
}
done();
setTimeout(function () {
console.info('==================ActsBmsKit_getAllShortcutInfo_0100==================end');
}, TIMEOUT)
});
/*
* @tc.number: ActsBmsKit_getAllShortcutInfo_0200
* @tc.name: Pressure test interface getAllShortcutInfo by callback
* @tc.desc: get the shortcut information of the hap
*/
it('ActsBmsKit_getAllShortcutInfo_0200', 0, async function (done) {
console.info('=====================ActsBmsKit_getAllShortcutInfo_0200==================');
var bundleName = 'com.example.third1';
for (let count = 0; count < STRESSLEVEL; count++) {
bundle.getAllShortcutInfo(bundleName, async (err, data) => {
expect(data.length).assertEqual(1);
expect(err.code).assertEqual(0);
checkShortcutIsExist(data, 'id.third1', 'third1');
if (count == STRESSLEVEL - 1) {
done();
} else if (err.code != 0) {
console.log('call function level is: ' + count);
expect().assertFail();
done();
}
})
}
setTimeout(function () {
console.info('=====================ActsBmsKit_getAllShortcutInfo_0200==================end');
}, TIMEOUT)
})
/*
* @tc.number: ActsBmsKit_checkPermission_0100
* @tc.name: Pressure test interface checkPermission by promise;
* @tc.desc:
*/
it('ActsBmsKit_checkPermission_0100', 0, async function (done) {
console.info('=====================ActsBmsKit_checkPermission_0100==================');
for (let count = 0; count < STRESSLEVEL; count++) {
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_NAME);
console.log('checkPermission is granted: ' + data);
expect(data).assertEqual(0);
if (data != 0) {
break;
}
}
done();
setTimeout(function () {
console.info('=====================ActsBmsKit_checkPermission_0100==================end');
}, TIMEOUT)
})
/*
* @tc.number: ActsBmsKit_checkPermission_0200
* @tc.name: Pressure test interface checkPermission by callback;
* @tc.desc:
*/
it('ActsBmsKit_checkPermission_0200', 0, async function (done) {
console.info('=====================ActsBmsKit_checkPermission_0200==================');
for (let count = 0; count < STRESSLEVEL; count++) {
await bundle.checkPermission(BUNDLE_NAME, PERMISSION_NAME, (err, data) => {
expect(err.code).assertEqual(0);
expect(data).assertEqual(0);
console.log('checkPermission is granted: ' + data);
if (count == STRESSLEVEL - 1) {
done();
} else if (err.code != 0 || data != 0) {
console.log('call function level is: ' + count);
expect().assertFail();
done();
}
})
}
setTimeout(function () {
console.info('=====================ActsBmsKit_checkPermission_0200==================end');
}, TIMEOUT)
})
/*
* @tc.number: ActsBmsKit_getModuleUsageRecordTest_0100
* @tc.name: Pressure test interface getModuleUsageRecord(int maxNum) by promise;
* @tc.desc: When the number of starts of ability is less than maxNum, call interface getModuleUsageRecord
*/
it('ActsBmsKit_getModuleUsageRecordTest_0100', 0, async function (done) {
console.debug('=====================ActsBmsKit_getModuleUsageRecordTest_0100==================');
var bundleName = 'com.example.third1';
for (let count = 0; count < STRESSLEVEL; count++) {
console.debug("===========STRESSLEVEL===============" + count)
let records = await bundle.getModuleUsageRecords(50);
checkModuleUsageRecord(records, 'ActsBmsKit_getModuleUsageRecordTest_0100');
var result = checkIsExist(records, bundleName);
expect(result).assertEqual(true);
if (!result) {
break;
}
}
done();
setTimeout(function () {
console.debug('===========ActsBmsKit_getModuleUsageRecordTest_0100===========end');
}, EVENTTIMEOUT)
})
/*
* @tc.number: ActsBmsKit_getModuleUsageRecordTest_0200
* @tc.name: Pressure test interface getModuleUsageRecord(int maxNum) by callback;
* @tc.desc: When the number of starts of ability is less than maxNum, call interface getModuleUsageRecord
*/
it('ActsBmsKit_getModuleUsageRecordTest_0200', 0, async function (done) {
console.debug('=====================ActsBmsKit_getModuleUsageRecordTest_0200==================');
var bundleName = 'com.example.third1';
let count = 0;
for (let i = 0; i < STRESSLEVEL; i++) {
bundle.getModuleUsageRecords(50, (err, data) => {
expect(err.code).assertEqual(0);
checkModuleUsageRecord(data, 'ActsBmsKit_getModuleUsageRecordTest_0200');
var result = checkIsExist(data, bundleName);
expect(result).assertEqual(true);
if (count == STRESSLEVEL - 1) {
done();
} else if (err.code != 0) {
console.log('call function level is: ' + count);
expect().assertFail();
done();
}
count++;
});
}
setTimeout(function () {
console.debug('==========ActsBmsKit_getModuleUsageRecordTest_0200==================end');
}, TIMEOUT)
})
function checkModuleUsageRecord(data, caseName) {
console.debug('======================check ModuleUsageRecord begin==========================');
console.debug(caseName + ' ==========record length is ========== ' + data.length);
expect(data.length).assertLarger(0);
for (let i = 0, length = data.length; i < length; i++) {
console.debug('=======All Info========' + JSON.stringify(data[i]));
console.debug('=============bundleName is=========' + JSON.stringify(data[i].bundleName));
expect(data[i].bundleName.length).assertLarger(0);
console.debug('=============appLabelId==============' + JSON.stringify(data[i].appLabelId));
expect(data[i].appLabelId).assertLarger(0);
console.debug('=============name==============' + JSON.stringify(data[i].name));
expect(data[i].name.length).assertLarger(0);
console.debug('=============labelId==============' + JSON.stringify(data[i].labelId));
expect(data[i].labelId >=0 ).assertTrue();
console.debug('=============descriptionId==============' + JSON.stringify(data[i].descriptionId));
expect(data[i].descriptionId).assertEqual(0);
console.debug('=============abilityName==============' + JSON.stringify(data[i].abilityName));
expect(data[i].abilityName.length).assertLarger(0);
console.debug('=============abilityLabelId==============' + JSON.stringify(data[i].abilityLabelId));
expect(data[i].abilityLabelId).assertLarger(0);
console.debug('===========abilityDescriptionId===========' + JSON.stringify(data[i].abilityDescriptionId));
expect(data[i].abilityDescriptionId).assertLarger(0);
console.debug('=============abilityIconId==============' + JSON.stringify(data[i].abilityIconId));
expect(data[i].abilityIconId).assertLarger(0);
console.debug('=============launchedCount==============' + JSON.stringify(data[i].launchedCount));
expect(data[i].launchedCount).assertLarger(0);
console.debug('=============lastLaunchTime==============' + JSON.stringify(data[i].lastLaunchTime));
expect(data[i].lastLaunchTime).assertLarger(0);
console.debug('=============isRemoved==============' + JSON.stringify(data[i].isRemoved));
expect(data[i].isRemoved).assertEqual(false);
expect(data[i].installationFreeSupported).assertEqual(false);
}
}
function checkIsExist(data, bundleName) {
let bundles = new Map();
for (let i = 0, length = data.length; i < length; i++) {
console.debug('=============bundleName is=========' + JSON.stringify(data[i].bundleName));
bundles.set(data[i].bundleName, data[i]);
}
if (bundles.has(bundleName)) {
console.debug(bundleName + ' is exist');
return true;
}
else {
console.debug(bundleName + ' is not exist');
return false;
}
}
function checkShortcutInfo(dataInfo, name) {
console.info('=======Shortcut Info========' + JSON.stringify(dataInfo))
console.info('=============Shortcutid=========' + dataInfo.id);
expect(typeof dataInfo.id).assertEqual('string');
expect(dataInfo.id).assertEqual('id.' + name);
console.info('=============icon==============' + JSON.stringify(dataInfo.icon));
expect(typeof dataInfo.disableMessage).assertEqual('string');
expect(typeof dataInfo.isStatic).assertEqual('boolean');
expect(typeof dataInfo.isHomeShortcut).assertEqual('boolean');
expect(typeof dataInfo.isEnabled).assertEqual('boolean');
expect(typeof dataInfo.hostAbility).assertEqual('string');
console.info('=============label==============' + JSON.stringify(dataInfo.label));
expect(typeof dataInfo.wants).assertEqual('object');
if (typeof dataInfo.wants != 'undefined' && Object.keys(dataInfo.wants).length != 0) {
expect(dataInfo.wants.length).assertLarger(0);
for (var j = 0; j < dataInfo.wants.length; j++) {
console.info('========targetClass=========' + JSON.stringify(dataInfo.wants[j].targetClass));
expect(dataInfo.wants[j].targetClass).assertEqual('com.example.' + name + '.MainAbility');
console.info('========targetBundle=========' + JSON.stringify(dataInfo.wants[j].targetBundle));
expect(dataInfo.wants[j].targetBundle).assertEqual('com.example.' + name);
}
}
}
function checkShortcutIsExist(dataInfo, shortcutId, testName) {
let info = new Map();
for (var i = 0, len = dataInfo.length; i < len; i++) {
expect(typeof dataInfo[i]).assertEqual('object');
info.set(dataInfo[i].id, dataInfo[i]);
}
expect(info.has(shortcutId)).assertTrue();
if (!info.has(shortcutId)) {
return false;
} else {
checkShortcutInfo(info.get(shortcutId), testName);
return true;
}
}
})
\ No newline at end of file
...@@ -12,4 +12,5 @@ ...@@ -12,4 +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('./Subscriber.js')
\ No newline at end of file require('./ActsBmsKitTest.test.js')
\ No newline at end of file
...@@ -73,6 +73,7 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -73,6 +73,7 @@ describe('ActsBmsMetaDataTest', function () {
checkMetaData(dataMap2.get(abilityName1), 'Data1'); checkMetaData(dataMap2.get(abilityName1), 'Data1');
checkMetaData(dataMap2.get(abilityName2), 'Data3'); checkMetaData(dataMap2.get(abilityName2), 'Data3');
} }
await uninstall('com.example.third1');
done(); done();
setTimeout(function () { setTimeout(function () {
console.debug('============bms_getMetaData_0100===========') console.debug('============bms_getMetaData_0100===========')
...@@ -86,6 +87,8 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -86,6 +87,8 @@ describe('ActsBmsMetaDataTest', function () {
*/ */
it('bms_getMetaData_0200', 0, async function (done) { it('bms_getMetaData_0200', 0, async function (done) {
console.info('=====================bms_getMetaData_0200=================='); console.info('=====================bms_getMetaData_0200==================');
await install(['/data/test/bmsThirdBundleTest1.hap'])
await install(['/data/test/bmsThirdBundleTest3.hap'])
await install(['/data/test/bmsThirdBundleTestA1.hap']) await install(['/data/test/bmsThirdBundleTestA1.hap'])
let dataMap = new Map(); let dataMap = new Map();
let abilityName1 = 'com.example.third1.AMainAbility'; let abilityName1 = 'com.example.third1.AMainAbility';
...@@ -110,6 +113,7 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -110,6 +113,7 @@ describe('ActsBmsMetaDataTest', function () {
checkMetaData(dataMap.get(abilityName1), 'DataA1'); checkMetaData(dataMap.get(abilityName1), 'DataA1');
checkMetaData(dataMap.get(abilityName2), 'Data3'); checkMetaData(dataMap.get(abilityName2), 'Data3');
} }
await uninstall('com.example.third1');
done(); done();
setTimeout(function () { setTimeout(function () {
console.debug('============bms_getMetaData_0200===========') console.debug('============bms_getMetaData_0200===========')
...@@ -123,6 +127,7 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -123,6 +127,7 @@ describe('ActsBmsMetaDataTest', function () {
*/ */
it('bms_getMetaData_0300', 0, async function (done) { it('bms_getMetaData_0300', 0, async function (done) {
console.info('=====================bms_getMetaData_0300=================='); console.info('=====================bms_getMetaData_0300==================');
await install(['/data/test/bmsThirdBundleTest1.hap'])
await uninstall('com.example.third1'); await uninstall('com.example.third1');
var dataInfos = await bundle.queryAbilityByWant({ var dataInfos = await bundle.queryAbilityByWant({
want: { want: {
...@@ -267,7 +272,29 @@ describe('ActsBmsMetaDataTest', function () { ...@@ -267,7 +272,29 @@ describe('ActsBmsMetaDataTest', function () {
} }
expect(dataMap.has(abilityName1)).assertTrue(); expect(dataMap.has(abilityName1)).assertTrue();
if (dataMap.has(abilityName1)) { if (dataMap.has(abilityName1)) {
checkMetaData(dataMap.get(abilityName1), 'Data1V'); 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(); done();
setTimeout(function () { setTimeout(function () {
......
...@@ -2402,8 +2402,8 @@ describe('ActsBundleManagerTest', function () { ...@@ -2402,8 +2402,8 @@ describe('ActsBundleManagerTest', function () {
* @tc.desc Test install interfaces. * @tc.desc Test install interfaces.
*/ */
it('install_0600', 0, async function (done) { it('install_0600', 0, async function (done) {
let data = await demo.getBundleInstaller() let installer = await demo.getBundleInstaller()
await data.install([PATH + BMSJSTEST1], { await installer.install([PATH + BMSJSTEST1], {
param: { param: {
userId: 0, userId: 0,
installFlag: 1, installFlag: 1,
...@@ -2417,18 +2417,18 @@ describe('ActsBundleManagerTest', function () { ...@@ -2417,18 +2417,18 @@ describe('ActsBundleManagerTest', function () {
var datainfo1 = await demo.getBundleInfo(NAME1, 1); var datainfo1 = await demo.getBundleInfo(NAME1, 1);
expect(datainfo1.name).assertEqual(NAME1); expect(datainfo1.name).assertEqual(NAME1);
expect(datainfo1.uid).assertLarger(UIDMINVALUE); expect(datainfo1.uid).assertLarger(UIDMINVALUE);
await installer.uninstall(NAME1, {
param: {
userId: 0,
installFlag: 1,
isKeepData: true
}
}, async (err, data) => {
expect(typeof data).assertEqual(OBJECT);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
});
} }
await data.uninstall(NAME1, {
param: {
userId: 0,
installFlag: 1,
isKeepData: true
}
}, async (err, data) => {
expect(typeof data).assertEqual(OBJECT);
expect(data.statusMessage).assertEqual("SUCCESS");
done();
});
setTimeout(function () { setTimeout(function () {
console.info('====> install_0600 =====>') console.info('====> install_0600 =====>')
}, TIMEOUT) }, TIMEOUT)
...@@ -2451,8 +2451,8 @@ describe('ActsBundleManagerTest', function () { ...@@ -2451,8 +2451,8 @@ describe('ActsBundleManagerTest', function () {
function OnReceiveinstallEvent(err, data) { function OnReceiveinstallEvent(err, data) {
expect(typeof data).assertEqual(OBJECT); expect(typeof data).assertEqual(OBJECT);
expect(data.statusMessage).assertEqual("STATUS_INSTALL_FAILURE_INVALID"); expect(data.statusMessage).assertEqual("STATUS_INSTALL_FAILURE_INVALID");
} done();
done(); }
}); });
setTimeout(function () { setTimeout(function () {
console.info('====> install_0700 =====>') console.info('====> install_0700 =====>')
......
...@@ -13,19 +13,19 @@ ...@@ -13,19 +13,19 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAnsGetActiveTest") { ohos_js_hap_suite("BmsCheckPermissionTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./entry/src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
] ]
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsGetActiveTest" hap_name = "BmsCheckPermissionTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" source_dir = "./entry/src/main/js/default"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./entry/src/main/config.json"
} }
{
"description": "Configuration for hjunit demo Tests",
}
{ {
"app": { "app": {
"bundleName": "com.example.actsansactivesubscribertest", "bundleName": "com.example.bmscheckpermissiontest",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 5, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Beta1" "releaseType": "Beta1"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.actsansactivesubscribertest", "package": "com.example.bmscheckpermissiontest",
"name": ".MyApplication", "name": ".MyApplication",
"deviceType": [ "deviceType": [
"phone" "phone"
...@@ -32,16 +32,16 @@ ...@@ -32,16 +32,16 @@
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home",
"flag.home.intent.from.system"
] ]
} }
], ],
"name": "com.example.actsansactivesubscribertest.MainAbility", "name": "com.example.bmscheckpermissiontest.MainAbility",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:mainability_description",
"label": "$string:app_name", "label": "$string:app_name",
"type": "page", "type": "page",
"isVisible": "true",
"launchType": "standard", "launchType": "standard",
"visible": true "visible": true
} }
...@@ -57,6 +57,54 @@ ...@@ -57,6 +57,54 @@
"autoDesignWidth": false "autoDesignWidth": false
} }
} }
],
"defPermissions": [
{
"name": "com.permission.LOCATION_IN_BACKGROUND",
"grantMode": "user_grant",
"availableScope": [
"signature"
]
},
{
"name": "com.permission.MICROPHONE",
"grantMode": "user_grant",
"availableScope": [
"signature"
]
}
],
"reqPermissions": [
{
"name": "com.permission.LOCATION_IN_BACKGROUND",
"reason": "Need LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"com.example.bmscheckpermissiontest.MainAbility"
],
"when": "always"
}
},
{
"name": "com.permission.MICROPHONE",
"reason": "Need MICROPHONE",
"usedScene": {
"ability": [
"com.example.bmscheckpermissiontest.MainAbility"
],
"when": "always"
}
},
{
"name": "com.permission.PERMISSION_THIRD1",
"reason": "Need PERMISSION_THIRD1",
"usedScene": {
"ability": [
"com.example.bmscheckpermissiontest.MainAbility"
],
"when": "always"
}
}
] ]
} }
} }
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
.container {
display: flex;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
flex-direction: column;
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 500px;
}
.btn {
margin-top:20px;
width: 300px;
height: 100px;
border-width:5px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ title }}
</text>
<div class="log">
<textarea class="log">
{{logmessage}}
</textarea>
</div>
<button class="btn" value="requestPermissons" onclick="requestPermissons"></button>
<button class="btn" value="bms_checkPermission_1700" onclick="bms_checkPermission_1700"></button>
<button class="btn" value="bms_checkPermission_1800" onclick="bms_checkPermission_1800"></button>
<button class="btn" value="bms_checkPermission_1900" onclick="bms_checkPermission_1900"></button>
<button class="btn" value="bms_checkPermission_2000" onclick="bms_checkPermission_2000"></button>
<button class="btn" value="Clear" onclick="clearLog"></button>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureability'
import bundle from '@ohos.bundle'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
data: {
title: "checkPermission Test",
logmessage: "check permission test: \n"
},
onInit() {
this.title = this.data.title;
this.logmessage = this.data.logmessage;
},
onReady() {
},
async requestPermissons() {
this.data.logmessage += 'requestPermissons\n'
console.debug("==========begin request permissions==========")
var context = await featureAbility.getContext();
await context.requestPermissionsFromUser(["com.permission.PERMISSION_THIRD1",
"com.permission.LOCATION_IN_BACKGROUND", "com.permission.MICROPHONE"], 1,
(err, data) => {
console.log("RequestPermissionForUser:requestCode=" + data.requestCode);
for (var j = 0; j < data.permissions.length; j++) {
console.log("RequestPermissionForUser permissions : " + data.permissions[j]);
}
for (var j = 0; j < data.grantResults.length; j++) {
console.log("RequestPermissionForUser grantResults : " + data.grantResults[j]);
}
});
},
/*
* @tc.number: bms_checkPermission_1700
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whose availableScope is user_grant whether is granted. (by promise)
*/
async bms_checkPermission_1700() {
console.info('=====================bms_checkPermission_1700==================');
var data = await bundle.checkPermission("com.example.bmscheckpermissiontest",
'com.permission.LOCATION_IN_BACKGROUND')
if (data == 0) {
this.data.logmessage += 'bms_checkPermission_1700 result: PERMISSION_GRANTED\n'
} else {
this.data.logmessage += 'bms_checkPermission_1700 result: PERMISSION_NOT_GRANTED\n'
}
},
/*
* @tc.number: bms_checkPermission_1800
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whose availableScope is user_grant whether is granted. (by callback)
*/
bms_checkPermission_1800() {
console.info('=====================bms_checkPermission_1800==================');
bundle.checkPermission("com.example.bmscheckpermissiontest", 'com.permission.MICROPHONE', (err, data) => {
console.debug("======err code======:" + err.code);
console.debug("======result======:" + data);
if (data == 0 && err.code == 0) {
this.data.logmessage += 'bms_checkPermission_1800 result: PERMISSION_GRANTED\n'
} else {
this.data.logmessage += 'bms_checkPermission_1800 result: PERMISSION_NOT_GRANTED\n'
}
})
},
/*
* @tc.number: bms_checkPermission_1900
* @tc.name: check whether the permission is granted
* @tc.desc: Verify that permissions which availableScope is user_grant requested
* from other apps are granted. (by promise)
*/
async bms_checkPermission_1900() {
console.info('=====================bms_checkPermission_1900==================');
var data = await bundle.checkPermission("com.example.bmscheckpermissiontest",
'com.permission.PERMISSION_THIRD1')
if (data == 0) {
this.data.logmessage += 'bms_checkPermission_1900 result: PERMISSION_GRANTED\n'
} else {
this.data.logmessage += 'bms_checkPermission_1900 result: PERMISSION_NOT_GRANTED\n'
}
},
/*
* @tc.number: bms_checkPermission_2000
* @tc.name: check whether the permission is granted
* @tc.desc: Verify that permissions which availableScope is user_grant requested
* from other apps are granted. (by callback)
*/
bms_checkPermission_2000() {
console.info('=====================bms_checkPermission_2000==================');
bundle.checkPermission("com.example.bmscheckpermissiontest", 'com.permission.PERMISSION_THIRD1',
(err, data) => {
console.debug("======err code======:" + err.code);
console.debug("======result======:" + data);
if (data == 0 && err.code == 0) {
this.data.logmessage += 'bms_checkPermission_2000 result: PERMISSION_GRANTED\n'
} else {
this.data.logmessage += 'bms_checkPermission_2000 result: PERMISSION_NOT_GRANTED\n'
}
})
},
clearLog() {
this.data.logmessage = "";
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "bmscheckpermissiontest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"module": { "module": {
"package": "com.example.third5", "package": "com.example.third5",
"name": ".BmsThirdBundle5", "name": ".BmsThirdBundle5",
"mainAbility": "com.example.third5.AMainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
......
...@@ -130,6 +130,18 @@ ...@@ -130,6 +130,18 @@
"autoDesignWidth": false "autoDesignWidth": false
} }
} }
],
"defPermissions": [
{
"name": "com.permission.PERMISSION_THIRD1",
"grantMode": "user_grant",
"availableScope": ["signature"]
},
{
"name": "com.permission.PERMISSION_B",
"grantMode": "system_grant",
"availableScope": ["signature"]
}
] ]
} }
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"module": { "module": {
"package": "com.example.third1.entry", "package": "com.example.third1.entry",
"name": "com.example.third1.BmsThirdBundle1", "name": "com.example.third1.BmsThirdBundle1",
"mainAbility": "com.example.third1.AMainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsAnsPublishOneTest") { ohos_hap("bmsThirdBundleC") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
hap_name = "ActsAnsPublishOneTest" hap_name = "bmsThirdBundleC"
subsystem_name = XTS_SUITENAME subsystem_name = XTS_SUITENAME
final_hap_path = final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
...@@ -26,9 +26,9 @@ ohos_hap("ActsAnsPublishOneTest") { ...@@ -26,9 +26,9 @@ ohos_hap("ActsAnsPublishOneTest") {
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
} }
ohos_js_assets("hjs_demo_js_assets") { 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") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{
"description": "Configuration for hjunit demo Tests",
}
{ {
"app": { "app": {
"bundleName": "com.example.actsansicontest", "bundleName": "com.example.c",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 5, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Beta1" "releaseType": "Beta1"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.actsansicontest", "package": "com.example.c",
"name": ".actsansicontest", "name": ".MyApplication",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home"
] ]
} }
], ],
"name": "com.example.actsansicontest.MainAbility", "name": ".MainAbility",
"icon": "$media:icon", "srcLanguage": "c++",
"description": "$string:mainability_description", "srcPath": "default/c++/",
"label": "$string:app_name", "visible": true,
"type": "page", "icon": "$media:icon",
"isVisible": "true", "description": "$string:mainability_description",
"launchType": "standard" "label": "$string:app_name",
} "type": "page",
], "launchType": "standard"
"js": [ }
{ ],
"pages": [ "js": [
"pages/index/index" {
], "pages": [
"name": "default", "pages/index/index"
"window": { ],
"designWidth": 720, "name": "default",
"autoDesignWidth": false "window": {
} "designWidth": 720,
} "autoDesignWidth": false
] }
} }
]
}
} }
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
订阅程序1启动 {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/*
* 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.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "Sub1" "value": "ThirdJsTest"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
], ],
"name": ".MainAbility", "name": ".MainAbility",
"srcLanguage": "js", "srcLanguage": "js",
"srcPath": "default",
"visible": true, "visible": true,
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:mainability_description",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"module": { "module": {
"package": "com.example.system1", "package": "com.example.system1",
"name": ".BmsSystemBundle1", "name": ".BmsSystemBundle1",
"mainAbility": "com.example.system1.MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
......
...@@ -90,19 +90,21 @@ ...@@ -90,19 +90,21 @@
"launchType": "standard", "launchType": "standard",
"metaData": { "metaData": {
"parameters": [{ "parameters": [{
"name": "Data1V", "name": "Data1V0",
"type": "float", "type": "float",
"description": "$string:mainability_description" "description": "$string:mainability_description"
}], },
{
"name": "Data1V1",
"type": "float",
"description": "$string:mainability_description"
}],
"results": [{ "results": [{
"name": "Data1V", "name": "Data1V",
"type": "float", "type": "float",
"description": "$string:mainability_description" "description": "$string:mainability_description"
}], }],
"customizeData": [{ "customizeData": [{
"name": "Data1V",
"value": "float",
"extra": "$string:mainability_description"
}] }]
} }
} }
......
...@@ -20,7 +20,6 @@ group("ans_standard") { ...@@ -20,7 +20,6 @@ group("ans_standard") {
#"actsansnotificationremove:ActsAnsNotificationRemove", #"actsansnotificationremove:ActsAnsNotificationRemove",
"actsansslottest:ActsAnsSlotTest", "actsansslottest:ActsAnsSlotTest",
"publish_test:publish_test", "publish_test:publish_test",
"publishicontest:ActsAnsIconTest",
] ]
} }
} }
...@@ -251,12 +251,12 @@ describe('ActsAnsNotificationCancel', function () { ...@@ -251,12 +251,12 @@ describe('ActsAnsNotificationCancel', function () {
function onConsumeCancelAllNoNotify(err, data) { function onConsumeCancelAllNoNotify(err, data) {
console.info("================onConsume_cancelAll_noNotify_0300=======================>"); console.info("================onConsume_cancelAll_noNotify_0300=======================>");
console.info("================onConsume_0300 data: =======================>" + JSON.stringify(data)); console.info("================onConsume_0300 data: =======================>" + JSON.stringify(data));
expect(1).assertequal(0); expect().assertFail();
console.info("================onConsume_cancelAll_noNotify_0300 end=======================>"); console.info("================onConsume_cancelAll_noNotify_0300 end=======================>");
} }
function onCancelCancelAllNoNotify(err, data) { function onCancelCancelAllNoNotify(err, data) {
console.info("=================onCancel_cancelAll_0300=======================>"); console.info("=================onCancel_cancelAll_0300=======================>");
expect(1).assertequal(0); expect().assertFail();
console.info("================onCancel_0300 data : =======================>" + JSON.stringify(data)); console.info("================onCancel_0300 data : =======================>" + JSON.stringify(data));
console.info("================onCancel_0300 err : =======================>" + JSON.stringify(err)); console.info("================onCancel_0300 err : =======================>" + JSON.stringify(err));
console.info("================onCancel_0300 end=======================>"); console.info("================onCancel_0300 end=======================>");
...@@ -297,14 +297,14 @@ describe('ActsAnsNotificationCancel', function () { ...@@ -297,14 +297,14 @@ describe('ActsAnsNotificationCancel', function () {
function onConsumeCancelAllNoNotifyPromise(err, data) { function onConsumeCancelAllNoNotifyPromise(err, data) {
console.info("================onConsume_cancelAll_noNotify_promise_0400=======================>"); console.info("================onConsume_cancelAll_noNotify_promise_0400=======================>");
console.info("================onConsume_promise_0400 data: =======================>" + JSON.stringify(data)); console.info("================onConsume_promise_0400 data: =======================>" + JSON.stringify(data));
expect(1).assertequal(0); expect().assertFail();
console.info("================onConsume_promise_0400 end=======================>"); console.info("================onConsume_promise_0400 end=======================>");
} }
function onCancelCancelAllNoNotifyPromise(err, data) { function onCancelCancelAllNoNotifyPromise(err, data) {
console.info("===============onCancel_cancelAll_noNotify_promise_0400=======================>"); console.info("===============onCancel_cancelAll_noNotify_promise_0400=======================>");
console.info("===============onCancel_promise_0400 data=================>" + JSON.stringify(data)); console.info("===============onCancel_promise_0400 data=================>" + JSON.stringify(data));
console.info("===============onCancel_promise_0400 err=====================>" + JSON.stringify(err)); console.info("===============onCancel_promise_0400 err=====================>" + JSON.stringify(err));
expect(1).assertequal(0); expect().assertFail();
console.info("===============onCancel_cancelAll_noNotify_promise_0400 end=======================>"); console.info("===============onCancel_cancelAll_noNotify_promise_0400 end=======================>");
} }
......
...@@ -72,8 +72,12 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -72,8 +72,12 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.sound).assertEqual(""); expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0100 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0100 finish====>");
done(); notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{
console.debug("====>removeSlot SOCIAL_COMMUNICATION enter====>");
expect(err.code).assertEqual(0);
done();
})
}); });
setTimeout(function(){ setTimeout(function(){
console.debug("====>time out ActsAnsGetSlotTestCallback_0100====>"); console.debug("====>time out ActsAnsGetSlotTestCallback_0100====>");
...@@ -103,7 +107,11 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -103,7 +107,11 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0200 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestCallback_0200 finish====>");
done(); notification.removeSlot(notification.SlotType.SERVICE_INFORMATION, (err)=>{
console.debug("====>removeSlot SERVICE_INFORMATION enter====>");
expect(err.code).assertEqual(0);
done();
})
} }
console.debug("====>addSlot SlotType.SERVICE_INFORMATION: ====>"); console.debug("====>addSlot SlotType.SERVICE_INFORMATION: ====>");
await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, addSlotActsAnsGetSlotTestCallbackSecond); await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, addSlotActsAnsGetSlotTestCallbackSecond);
...@@ -137,7 +145,11 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -137,7 +145,11 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0300 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestCallback_0300 finish====>");
done(); notification.removeSlot(notification.SlotType.CONTENT_INFORMATION, (err)=>{
console.debug("====>removeSlot CONTENT_INFORMATION enter====>");
expect(err.code).assertEqual(0);
done();
})
} }
console.debug("====>addSlot SlotType.CONTENT_INFORMATION: ====>"); console.debug("====>addSlot SlotType.CONTENT_INFORMATION: ====>");
await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, addSlotActsAnsGetSlotTestCallbackThird); await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, addSlotActsAnsGetSlotTestCallbackThird);
...@@ -171,7 +183,11 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -171,7 +183,11 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 finish====>");
done(); notification.removeSlot(notification.SlotType.OTHER_TYPES, (err)=>{
console.debug("====>removeSlot OTHER_TYPES enter====>");
expect(err.code).assertEqual(0);
done();
})
} }
console.debug("====>addSlot SlotType.OTHER_TYPES: ====>"); console.debug("====>addSlot SlotType.OTHER_TYPES: ====>");
await notification.addSlot(notification.SlotType.OTHER_TYPES, addSlotActsAnsGetSlotTestCallbackFourth); await notification.addSlot(notification.SlotType.OTHER_TYPES, addSlotActsAnsGetSlotTestCallbackFourth);
...@@ -205,7 +221,11 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -205,7 +221,11 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0500 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestCallback_0500 finish====>");
done(); notification.removeSlot(notification.SlotType.OTHER_TYPES, (err)=>{
console.debug("====>removeSlot OTHER_TYPES enter====>");
expect(err.code).assertEqual(0);
done();
})
} }
console.debug("====>addSlot SlotType.UNKNOWN_TYPE: ====>"); console.debug("====>addSlot SlotType.UNKNOWN_TYPE: ====>");
await notification.addSlot(notification.SlotType.UNKNOWN_TYPE, addSlotActsAnsGetSlotTestCallbackFifth); await notification.addSlot(notification.SlotType.UNKNOWN_TYPE, addSlotActsAnsGetSlotTestCallbackFifth);
...@@ -215,4 +235,4 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -215,4 +235,4 @@ describe('ActsAnsGetSlotTestCallback', function () {
console.debug("====>time out ActsAnsGetSlotTestCallback_0500====>"); console.debug("====>time out ActsAnsGetSlotTestCallback_0500====>");
}, 1000); }, 1000);
}) })
}) })
\ No newline at end of file \ No newline at end of file
...@@ -42,7 +42,11 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -42,7 +42,11 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 finish====>");
done(); notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{
console.debug("====>removeSlot SOCIAL_COMMUNICATION enter====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsGetSlotTestPromise_0100 end====>"); console.debug("====>ActsAnsGetSlotTestPromise_0100 end====>");
setTimeout(function(){ setTimeout(function(){
...@@ -75,7 +79,11 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -75,7 +79,11 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsGetSlotTestPromise_0200 finish====>"); console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsGetSlotTestPromise_0200 finish====>");
done(); notification.removeSlot(notification.SlotType.SERVICE_INFORMATION, (err)=>{
console.debug("====>removeSlot SERVICE_INFORMATION enter====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsGetSlotTestPromise_0200 end====>"); console.debug("====>ActsAnsGetSlotTestPromise_0200 end====>");
setTimeout(function(){ setTimeout(function(){
...@@ -109,7 +117,11 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -109,7 +117,11 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotPromise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 finish====>"); console.debug("====>getSlotPromise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 finish====>");
done(); notification.removeSlot(notification.SlotType.CONTENT_INFORMATION, (err)=>{
console.debug("====>removeSlot CONTENT_INFORMATION enter====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.info("====>ActsAnsGetSlotTestPromise_0300 end====>"); console.info("====>ActsAnsGetSlotTestPromise_0300 end====>");
setTimeout(function(){ setTimeout(function(){
...@@ -143,7 +155,11 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -143,7 +155,11 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotPromise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 finish====>"); console.debug("====>getSlotPromise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 finish====>");
done(); notification.removeSlot(notification.SlotType.OTHER_TYPES, (err)=>{
console.debug("====>removeSlot OTHER_TYPES enter====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsGetSlotTestPromise_0400 end====>"); console.debug("====>ActsAnsGetSlotTestPromise_0400 end====>");
setTimeout(function(){ setTimeout(function(){
...@@ -177,7 +193,11 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -177,7 +193,11 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 finish====>"); console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 finish====>");
done(); notification.removeSlot(notification.SlotType.OTHER_TYPES, (err)=>{
console.debug("====>removeSlot OTHER_TYPES enter====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsGetSlotTestPromise_0500 end====>"); console.debug("====>ActsAnsGetSlotTestPromise_0500 end====>");
setTimeout(function(){ setTimeout(function(){
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "180000", "test-timeout": "60000",
"package": "com.example.actsansslotsystemcallback", "package": "com.example.actsansslotsystemcallback",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -19,8 +19,8 @@ describe('ActsAnsSlotSystemCallback', function () { ...@@ -19,8 +19,8 @@ describe('ActsAnsSlotSystemCallback', function () {
/* /*
* @tc.number : ActsAnsSlotSystemCallback_0100 * @tc.number : ActsAnsSlotSystemCallback_0100
* @tc.name : Verify getSlots after adding slots and removeSlot * @tc.name : Verify getSlots after adding slots and removeAllSlots
* @tc.desc : getSlots after adding all type slots and removing slot * @tc.desc : getSlots after adding all type slots and remove all slots
*/ */
it('ActsAnsSlotSystemCallback_0100', 0, async function (done) { it('ActsAnsSlotSystemCallback_0100', 0, async function (done) {
console.debug("====>ActsAnsSlotSystemCallback_0100 start====>"); console.debug("====>ActsAnsSlotSystemCallback_0100 start====>");
...@@ -159,9 +159,9 @@ describe('ActsAnsSlotSystemCallback', function () { ...@@ -159,9 +159,9 @@ describe('ActsAnsSlotSystemCallback', function () {
expect(data[3].lightEnabled).assertEqual(true); expect(data[3].lightEnabled).assertEqual(true);
expect(data[3].lightColor).assertEqual(4); expect(data[3].lightColor).assertEqual(4);
console.debug("====>getSlots end====>"); console.debug("====>getSlots end====>");
console.debug("====>ActsAnsSlotSystemCallback_0100 end====>"); notification.removeAllSlots((err)=>{
notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{ console.debug("====>removeAllSlots ActsAnsSlotSystemCallback_0100 err====>" + JSON.stringify(err));
console.debug("====>removeSlot ActsAnsSlotSystemCallback_0100 err====>" + JSON.stringify(err)); console.debug("====>ActsAnsSlotSystemCallback_0100 end====>");
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
done(); done();
}) })
...@@ -170,7 +170,7 @@ describe('ActsAnsSlotSystemCallback', function () { ...@@ -170,7 +170,7 @@ describe('ActsAnsSlotSystemCallback', function () {
expect().assertFail(); expect().assertFail();
} }
}) })
setTimeout(timeOut, 10000); setTimeout(timeOut, 2000);
}) })
/* /*
...@@ -230,9 +230,13 @@ describe('ActsAnsSlotSystemCallback', function () { ...@@ -230,9 +230,13 @@ describe('ActsAnsSlotSystemCallback', function () {
expect(data.lightEnabled).assertEqual(true); expect(data.lightEnabled).assertEqual(true);
expect(data.lightColor).assertEqual(1); expect(data.lightColor).assertEqual(1);
console.debug("====>getSlotActsAnsSlotSystemCallback_0200 finish====>"); console.debug("====>getSlotActsAnsSlotSystemCallback_0200 finish====>");
console.debug("====>ActsAnsSlotSystemCallback_0200 end====>"); notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{
done(); console.debug("====>removeSlot SOCIAL_COMMUNICATION err====>" + JSON.stringify(err));
console.debug("====>ActsAnsSlotSystemCallback_0200 end====>");
expect(err.code).assertEqual(0);
done();
})
}) })
setTimeout(timeOutTwo, 10000); setTimeout(timeOutTwo, 2000);
}) })
}) })
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "180000", "test-timeout": "60000",
"package": "com.example.actsansslotsystempromise", "package": "com.example.actsansslotsystempromise",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -191,12 +191,16 @@ describe('ActsAnsSlotSystemPromise', function () { ...@@ -191,12 +191,16 @@ describe('ActsAnsSlotSystemPromise', function () {
expect(data.lightEnabled).assertEqual(true); expect(data.lightEnabled).assertEqual(true);
expect(data.lightColor).assertEqual(2); expect(data.lightColor).assertEqual(2);
console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsSlotSystemPromise_0100 finish====>"); console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsSlotSystemPromise_0100 finish====>");
done(); notification.removeSlot(notification.SlotType.SERVICE_INFORMATION, (err)=>{
console.debug("====>removeSlot SERVICE_INFORMATION err====>" + JSON.stringify(err));
console.debug("====>ActsAnsSlotSystemPromise_0100 end====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsSlotTestSystem_0100 end====>");
setTimeout(function (){ setTimeout(function (){
console.debug("====>time out ActsAnsSlotTestSystem_0100====>"); console.debug("====>time out ActsAnsSlotTestSystem_0100====>");
}, 10000); }, 2000);
}) })
...@@ -240,8 +244,8 @@ describe('ActsAnsSlotSystemPromise', function () { ...@@ -240,8 +244,8 @@ describe('ActsAnsSlotSystemPromise', function () {
}) })
console.debug("====>getSlot SlotType.SOCIAL_COMMUNICATION: ====>"); console.debug("====>getSlot SlotType.SOCIAL_COMMUNICATION: ====>");
notification.getSlot(notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { notification.getSlot(notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.debug("====>getSlotActsAnsSlotSystemPromise_0200 enter====>"); console.debug("====>getSlot ActsAnsSlotSystemPromise_0200 enter====>");
console.debug("====>getSlotActsAnsSlotSystemPromise_0200 data====>" + JSON.stringify(data)); console.debug("====>getSlot ActsAnsSlotSystemPromise_0200 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION);
expect(data.level).assertEqual(notification.SlotLevel.LEVEL_NONE); expect(data.level).assertEqual(notification.SlotLevel.LEVEL_NONE);
expect(data.desc).assertEqual("slot_SOCIAL_COMMUNICATION_Desc_First"); expect(data.desc).assertEqual("slot_SOCIAL_COMMUNICATION_Desc_First");
...@@ -251,12 +255,16 @@ describe('ActsAnsSlotSystemPromise', function () { ...@@ -251,12 +255,16 @@ describe('ActsAnsSlotSystemPromise', function () {
expect(data.sound).assertEqual("slot_SOCIAL_COMMUNICATION_Sound_First"); expect(data.sound).assertEqual("slot_SOCIAL_COMMUNICATION_Sound_First");
expect(data.lightEnabled).assertEqual(true); expect(data.lightEnabled).assertEqual(true);
expect(data.lightColor).assertEqual(1); expect(data.lightColor).assertEqual(1);
console.debug("====>getSlotActsAnsSlotSystemPromise_0200 finish====>"); console.debug("====>getSlot ActsAnsSlotSystemPromise_0200 finish====>");
done(); notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{
console.debug("====>removeSlot SOCIAL_COMMUNICATION err====>" + JSON.stringify(err));
console.debug("====>ActsAnsSlotSystemPromise_0200 end====>");
expect(err.code).assertEqual(0);
done();
})
}) })
console.debug("====>ActsAnsSlotSystemPromise_0200 end====>");
setTimeout(function (){ setTimeout(function (){
console.debug("====>time out ActsAnsSlotSystemPromise_0200====>"); console.debug("====>time out ActsAnsSlotSystemPromise_0200====>");
}, 10000); }, 2000);
}) })
}) })
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "150000", "test-timeout": "60000",
"package": "com.example.actsansslotaddremoveall", "package": "com.example.actsansslotaddremoveall",
"shell-timeout": "150000" "shell-timeout": "60000"
}, },
"kits": [ "kits": [
{ {
......
...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplayFiveTest', function () { ...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplayFiveTest', function () {
* @tc.desc: verify the function of displayBadge * @tc.desc: verify the function of displayBadge
*/ */
it('ActsBadgeDisplay_test_1000', 0, async function (done) { it('ActsBadgeDisplay_test_1000', 0, async function (done) {
await notify.displayBadge( var promise = await notify.displayBadge(
{ {
bundle:"com.example.actsanslocalcandisplaytest" bundle:"com.example.actsanslocalcandisplaytest"
},"").then(console.log("====>ActsBadgeDisplay_test_1000 success====>")) },"")
expect(promise).assertEqual(undefined)
done(); done();
setTimeout(function(){ setTimeout(function(){
console.debug("====>time out ActsBadgeDisplay_test_1000====>"); console.debug("====>time out ActsBadgeDisplay_test_1000====>");
......
...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplayFourTest', function () { ...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplayFourTest', function () {
* @tc.desc: verify the function of displayBadge * @tc.desc: verify the function of displayBadge
*/ */
it('ActsBadgeDisplay_test_0800', 0, async function (done) { it('ActsBadgeDisplay_test_0800', 0, async function (done) {
await notify.displayBadge( var promise = await notify.displayBadge(
{ {
bundle:"com.example.actsanslocalcandisplaytest" bundle:"com.example.actsanslocalcandisplaytest"
},100).then(console.log("====>ActsBadgeDisplay_test_0800 success====>")) },100)
expect(promise).assertEqual(undefined)
done(); done();
setTimeout(function(){ setTimeout(function(){
console.debug("====>time out ActsBadgeDisplay_test_0800====>"); console.debug("====>time out ActsBadgeDisplay_test_0800====>");
......
...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplaySetFiveTest', function () { ...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplaySetFiveTest', function () {
* @tc.desc: verify the function of displayBadge * @tc.desc: verify the function of displayBadge
*/ */
it('ActsBadgeDisplaySet_test_1000', 0, async function (done) { it('ActsBadgeDisplaySet_test_1000', 0, async function (done) {
await notify.displayBadge( var promise = await notify.displayBadge(
{ {
bundle:"com.example.actsanslocalcandisplaytest" bundle:"com.example.actsanslocalcandisplaytest"
},"").then(console.log("====>ActsBadgeDisplaySet_test_1000 success====>")) },"")
expect(promise).assertEqual(undefined)
done(); done();
setTimeout(function(){ setTimeout(function(){
console.debug("====>time out ActsBadgeDisplaySet_test_1000====>"); console.debug("====>time out ActsBadgeDisplaySet_test_1000====>");
......
...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplaySetFourTest', function () { ...@@ -42,10 +42,11 @@ describe('ActsAnsBadgeDisplaySetFourTest', function () {
* @tc.desc: verify the function of displayBadge * @tc.desc: verify the function of displayBadge
*/ */
it('ActsBadgeDisplaySet_test_0800', 0, async function (done) { it('ActsBadgeDisplaySet_test_0800', 0, async function (done) {
await notify.displayBadge( var promise = await notify.displayBadge(
{ {
bundle:"com.example.actsanslocalcandisplaytest" bundle:"com.example.actsanslocalcandisplaytest"
},100).then(console.log("====>ActsBadgeDisplaySet_test_0800 success====>")) },100)
expect(promise).assertEqual(undefined)
done(); done();
setTimeout(function(){ setTimeout(function(){
console.debug("====>time out ActsBadgeDisplaySet_test_0800====>"); console.debug("====>time out ActsBadgeDisplaySet_test_0800====>");
......
...@@ -17,7 +17,7 @@ group("getactive") { ...@@ -17,7 +17,7 @@ group("getactive") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
#"getactivenormal:getactivenormal", #"getactivenormal:ActsAnsActiveTest",
#"getcancelactivenum:ActsAnsGetCancelActiveNumTest", #"getcancelactivenum:ActsAnsGetCancelActiveNumTest",
] ]
} }
......
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="D:\HUAWEI\DevEco Studio 2.1.0.301\tools\gradle" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/entry" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://developer.huawei.com/repo/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://repo.huaweicloud.com/repository/maven/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
...@@ -13,14 +13,19 @@ ...@@ -13,14 +13,19 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
group("getactivenormal") { ohos_js_hap_suite("ActsAnsActiveTest") {
testonly = true hap_profile = "./entry/src/main/config.json"
if (is_standard_system) { deps = [
deps = [ ":hjs_demo_js_assets",
"active:ActsAnsGetActiveTest", ":hjs_demo_resources",
]
#"sub:ActsAnsActiveSubscriberTest", certificate_profile = "./signature/openharmony_sx.p7b"
"publish:ActsAnsActivePublishTest", hap_name = "ActsAnsActiveTest"
] }
} ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
} }
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "60000", "test-timeout": "60000",
"package": "com.example.actsanspublishtwotest", "package": "com.example.actsansactivetest",
"shell-timeout": "60000" "shell-timeout": "21600000"
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsAnsPublishTwoTest.hap" "ActsAnsActiveTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
/*
* 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 notify from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var time = 1000
describe('ActsAnsGetActiveTest', function () {
console.info("===ActsSubscriberTest start===>");
/*
* @tc.number: ActsActive_test_0100
* @tc.name: getAllActiveNotifications()
* @tc.desc: verify the function of getAllActiveNotifications
*/
it('ActsActive_test_0100', 0, async function (done) {
await notify.getAllActiveNotifications((error, data) => {
console.log("===>getAllActiveNotifications1===>" + data)
expect(typeof(data)).assertEqual('object')
for (let i = 0; i < data.length; i++) {
console.log("===>getAllActiveNotificationshashCode1===>" + data[i].hashCode)
console.log("===>getAllActiveNotificationsid1===>" + data[i].id)
console.log("===>getAllActiveNotificationslotType1===>" + data[i].slotType)
console.log("===>getAllActiveNotificationclassification1===>" + data[i].classification)
console.log("===>getAllActiveNotificationsortingKey1===>" + data[i].sortingKey)
console.log("===>getAllActiveNotificationscontentType1===>" + data[i].content.contentType)
console.log("===>getAllActiveNotificationstitle1===>" + data[i].content.normal.title)
console.log("===>getAllActiveNotificationstext1===>" + data[i].content.normal.text)
console.log("===>getAllActiveNotificationsadditionalText1===>" + data[i].content.normal.additionalText)
}
})
var promise = await notify.getAllActiveNotifications()
expect(typeof(promise)).assertEqual('object')
for (let i = 0; i < promise.length; i++) {
console.log("===>getAllActiveNotificationsPromisehashCode1===>" + promise[i].hashCode)
console.log("===>getAllActiveNotificationsPromiseid1===>" + promise[i].id)
console.log("===>getAllActiveNotificationsPromiseslotType1===>" + promise[i].slotType)
console.log("===>getAllActiveNotificationsPromiseclassification1===>" + promise[i].classification)
console.log("===>getAllActiveNotificationsPromisesortingKey1===>" + promise[i].sortingKey)
console.log("===>getAllActiveNotificationsPromisecontentType1===>" + promise[i].content.contentType)
console.log("===>getAllActiveNotificationsPromisetitle1===>" + promise[i].content.normal.title)
console.log("===>getAllActiveNotificationsPromisetext1===>" + promise[i].content.normal.text)
console.log("===>getAllActiveNotificationsPromiseadditionalText1===>" + promise[i].content.normal.additionalText)
}
done();
setTimeout(function(){
console.debug("====>time out ActsActive_test_0100====>");
}, time);
})
})
/*
* 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.
*/
require('./GetActiveInfo.test.js')
\ No newline at end of file
{ {
"app": { "app": {
"bundleName": "com.example.actsanspublishtwotest", "bundleName": "com.example.actsansactivetest",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.actsanspublishtwotest", "package": "com.example.actsansactivetest",
"name": ".MyApplication", "name": ".MyApplication",
"deviceType": [ "deviceType": [
"phone" "phone"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
] ]
} }
], ],
"name": "com.example.actsanspublishtwotest.MainAbility", "name": "com.example.actsansactivetest.MainAbility",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:mainability_description",
"label": "$string:app_name", "label": "$string:app_name",
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
} }
] ]
} }
} }
\ No newline at end of file
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
* 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('./Icon.js') require('./active.js')
\ No newline at end of file \ No newline at end of file
/*
* 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 notify from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var time = 1000
describe('ActsAnsActiveTest', function () {
console.info("===========ActsAnsActiveTest start====================>");
//consume
async function consumeCallback(err, data) {
console.debug("==========================>consumeCallback data : =======================>" + JSON.stringify(data));
await notify.getAllActiveNotifications((error, data) => {
console.log("==========================>getAllActiveNotifications1=======================>" + data)
expect(typeof(data)).assertEqual('object')
for (let i = 0; i < data.length; i++) {
console.log("==========================>getAllActiveNotificationshashCode1=======================>" + data[i].hashCode)
console.log("==========================>getAllActiveNotificationsid1=======================>" + data[i].id)
console.log("==========================>getAllActiveNotificationslotType1=======================>" + data[i].slotType)
console.log("==========================>getAllActiveNotificationclassification1=======================>" + data[i].classification)
console.log("==========================>getAllActiveNotificationsortingKey1=======================>" + data[i].sortingKey)
console.log("==========================>getAllActiveNotificationscontentType1=======================>" + data[i].content.contentType)
console.log("==========================>getAllActiveNotificationstitle1=======================>" + data[i].content.normal.title)
console.log("==========================>getAllActiveNotificationstext1=======================>" + data[i].content.normal.text)
console.log("==========================>getAllActiveNotificationsadditionalText1=======================>" + data[i].content.normal.additionalText)
}
})
var notificationInfo = await notify.getAllActiveNotifications()
expect(typeof(notificationInfo)).assertEqual('object')
for (let i = 0; i < notificationInfo.length; i++) {
console.log("==========================>getAllActiveNotificationsPromisehashCode1=======================>" + notificationInfo[i].hashCode)
console.log("==========================>getAllActiveNotificationsPromiseid1=======================>" + notificationInfo[i].id)
console.log("==========================>getAllActiveNotificationsPromiseslotType1=======================>" + notificationInfo[i].slotType)
console.log("==========================>getAllActiveNotificationsPromiseclassification1=======================>" + notificationInfo[i].classification)
console.log("==========================>getAllActiveNotificationsPromisesortingKey1=======================>" + notificationInfo[i].sortingKey)
console.log("==========================>getAllActiveNotificationsPromisecontentType1=======================>" + notificationInfo[i].content.contentType)
console.log("==========================>getAllActiveNotificationsPromisetitle1=======================>" + notificationInfo[i].content.normal.title)
console.log("==========================>getAllActiveNotificationsPromisetext1=======================>" + notificationInfo[i].content.normal.text)
console.log("==========================>getAllActiveNotificationsPromiseadditionalText1=======================>" + notificationInfo[i].content.normal.additionalText)
}
}
//subscribeOn
function subscribeOnCallback(err) {
console.debug("==========================>subscribeOnCallback=======================>");
}
//subscribe
function subscribeCallback(err) {
console.debug("==========================>subscribeCallback=======================>");
}
function publishCallback001(){
console.log('ActsNotificationTest ACTS_Publish_0100 asyncCallback')
}
/*
* @tc.number: ActsWantAgent_test_0100
* @tc.name: createSubscriber(),subscribe()
* @tc.desc: verify the function of createSubscriber,subscribe
*/
it('ActsActiveSubscriber_test_0100', 0, async function (done) {
console.debug("===============ActsWantAgent_test_0100======begin====================>");
var subInfo ={
onConsume:consumeCallback,
onConnect:subscribeOnCallback,
}
try{
await notify.subscribe(subInfo,subscribeCallback);
}catch(err) {
console.error('=ActsActiveSubscriber_test_0100 订阅 subscribeCallback err:'+err);
}
console.debug("===============ActsActiveSubscriber_test_0100=======end===================>");
done();
setTimeout(function(){
console.debug("====>time out ActsActiveSubscriber_test_0100====>");
}, time);
})
/*
* @tc.number: ACTS_GetActiveNumTest_0100
* @tc.name: getActiveNotifications(),getActiveNotificationNums()
* @tc.desc: verify the function of getActiveNotifications,getActiveNotificationNums
*/
it('ACTS_GetActiveNumTest_0100', 0,async function (done) {
await notify.publish({
id: 1,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test1_title",
text: "test1_text",
additionalText: "test1_additionalText"
},
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION,
classification:"classification1",
sortingKey:"sortingKey1",
},publishCallback001);
await notify.publish({
id: 2,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test2_title",
text: "test2_text",
additionalText: "test2_additionalText"
},
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION,
classification:"classification2",
sortingKey:"sortingKey2",
},publishCallback001);
await notify.getActiveNotifications(
(error,data) => {
console.log("============PublishgetActiveNotificationsTest1============"+data)
expect(typeof(data)).assertEqual('object')
for (let i = 0; i < data.length; i++) {
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].hashCode)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].id)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].classification)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].sortingKey)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].slotType)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.contentType)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.normal.title)
console.log("==========================>PublishgegetAllActiveNotifications1tActiveNotificationsTest1=======================>" + data[i].content.normal.text)
console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.normal.additionalText)
}
})
var promise = await notify.getActiveNotifications();
expect(typeof(promise)).assertEqual('object')
for (let i = 0; i < promise.length; i++) {
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].hashCode)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].id)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].slotType)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].classification)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].sortingKey)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.contentType)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.title)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.text)
console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.additionalText)
}
await notify.getActiveNotificationCount((error,data) => {
console.log("============getActiveNotificationNumsTest1============"+JSON.stringify(data))
expect(typeof(data)).assertEqual('number')
})
var num = await notify.getActiveNotificationCount()
console.log("============getActiveNotificationNumsTest1Promise============"+JSON.stringify(num))
console.log("============ACTS_PublishTest1_0100 finished============")
expect(typeof(num)).assertEqual('number')
done();
setTimeout(function(){
console.debug("====>time out ACTS_GetActiveNumTest_0100====>");
}, time);
})
})
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAnsActivePublishTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsActivePublishTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.actsansactivepublishtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsActivePublishTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansactivepublishtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansactivepublishtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansactivepublishtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"isVisible": "true",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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 notification from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var time = 1000
describe('ActsAnsActivePublishTest', function () {
function publishCallback001(){
console.log('ActsNotificationTest ACTS_Publish_0100 asyncCallback')
}
/*
* @tc.number: ACTS_GetActiveNumTest_0100
* @tc.name: getActiveNotifications(),getActiveNotificationNums()
* @tc.desc: verify the function of getActiveNotifications,getActiveNotificationNums
*/
it('ACTS_GetActiveNumTest_0100', 0,async function (done) {
await notification.publish({
id: 1,
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test1_title",
text: "test1_text",
additionalText: "test1_additionalText"
},
},
slotType:notification.SlotType.SOCIAL_COMMUNICATION,
classification:"classification1",
sortingKey:"sortingKey1",
},publishCallback001);
await notification.publish({
id: 2,
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test2_title",
text: "test2_text",
additionalText: "test2_additionalText"
},
},
slotType:notification.SlotType.SOCIAL_COMMUNICATION,
classification:"classification2",
sortingKey:"sortingKey2",
},publishCallback001);
await notification.getActiveNotifications(
(error,data) => {
console.log("==PublishgetActiveNotificationsTest1=="+data)
expect(typeof(data)).assertEqual('object')
for (let i = 0; i < data.length; i++) {
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].hashCode)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].id)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].classification)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].sortingKey)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].slotType)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].content.contentType)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].content.normal.title)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].content.normal.text)
console.log("===>PublishgetActiveNotificationsTest1===>" + data[i].content.normal.additionalText)
}
})
var promise = await notification.getActiveNotifications();
expect(typeof(promise)).assertEqual('object')
for (let i = 0; i < promise.length; i++) {
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].hashCode)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].id)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].slotType)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].classification)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].sortingKey)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].content.contentType)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].content.normal.title)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].content.normal.text)
console.log("==>publishgetAllActiveNotificationsPromisehashCode==>" + promise[i].content.normal.additionalText)
}
await notification.getActiveNotificationCount((error,data) => {
console.log("==getActiveNotificationNumsTest1=="+JSON.stringify(data))
expect(typeof(data)).assertEqual('number')
})
var promise = await notification.getActiveNotificationCount();
console.log("==getActiveNotificationNumsTest1Promise=="+JSON.stringify(promise))
console.log("==ACTS_PublishTest1_0100 finished==")
expect(typeof(promise)).assertEqual('number')
done();
setTimeout(function(){
console.debug("====>time out ACTS_GetActiveNumTest_0100====>");
}, time);
})
})
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAnsActiveSubscriberTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsActiveSubscriberTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "com.example.actsansactivesubscribertest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsAnsActiveSubscriberTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册