提交 44c1a198 编写于 作者: Z zhaoyuan17

add xts bms test

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 f23e8fc5
......@@ -17,7 +17,24 @@ group("bundlemanager") {
testonly = true
if (is_standard_system) {
deps = [
"actsbmsallshortcutinfotest:ActsBmsAllShortcutInfoTest",
"actsbmscheckpermissiontest:ActsBmsCheckPermissionTest",
"actsbmshapmoduletest:ActsBmsHapModuleTest",
"actsbmsjstest:ActsBmsJsTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"sceneProject/bmsgetinfosfifthscene:bmsThirdBundleTest5",
"sceneProject/bmsgetinfosfirstscene:bmsThirdBundleTest1",
"sceneProject/bmsgetinfosfirstsceneupdate:bmsThirdBundleTestA1",
"sceneProject/bmsgetinfosfourthscene:bmsThirdBundleTest4",
"sceneProject/bmsgetinfosjsscene:bmsThirdBundleJs",
"sceneProject/bmsgetinfosscenesystem:bmsSystemBundleTest1",
"sceneProject/bmsgetinfosscenevendor:bmsVendorBundleTest1",
"sceneProject/bmsgetinfossecondscene:bmsThirdBundleTest2",
"sceneProject/bmsgetinfosthirdscene:bmsThirdBundleTest3",
"sceneProject/bmsmainabilityfirstscene:bmsMainAbilityFirstScene",
"sceneProject/bmsmainabilitysecondscene:bmsMainAbilitySecondScene",
"sceneProject/bmssceneeight:bmsJstest8",
"sceneProject/bmsscenefive:bmsJstest5",
"sceneProject/bmsscenefour:bmsJstest4",
......
# 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("ActsBmsAllShortcutInfoTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsAllShortcutInfoTest"
}
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.actsbmsallshortcutinfotest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsAllShortcutInfoTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap",
"bmsThirdBundleTest3.hap->/data/test/bmsThirdBundleTest3.hap",
"bmsThirdBundleTest4.hap->/data/test/bmsThirdBundleTest4.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsallshortcutinfotest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsallshortcutinfotest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsbmsallshortcutinfotest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: 'Test Shortcut'
},
onInit() {
this.title = this.data.title;
},
onShow() {
console.info('onReady finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
onBackPress(){
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "actsbmsallshortcutinfotest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
*/
require('./ActsBmsAllShortcutInfoTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBmsCheckPermissionTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsCheckPermissionTest"
}
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.actsbmscheckpermissiontest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsCheckPermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsbmscheckpermissiontest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmscheckpermissiontest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsbmscheckpermissiontest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"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.permissionchange.MainAbility"
],
"when": "always"
}
},
{
"name": "com.permission.PERMISSION_A",
"reason": "Need PERMISSION_A",
"usedScene": {
"ability": [
"com.example.permissionchange.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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: 'Test CheckPermission'
},
onInit() {
this.title = this.data.title;
},
onShow() {
console.info('onReady finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
}
}
{
"string": [
{
"name": "app_name",
"value": "actsbmscheckpermissiontest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const BUNDLE_NAME = 'com.example.actsbmscheckpermissiontest';
const PERMISSION_ONE = 'com.permission.CAMERA';
const PERMISSION_TWO = 'com.permission.PERMISSION_A';
describe('ActsBmsCheckPermissionTest', function () {
/*
* @tc.number: bms_checkPermission_0100
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whose availableScope is system_grant whether is granted. (by promise)
*/
it('bms_checkPermission_0100', 0, async function (done) {
console.info('=====================bms_checkPermission_0100==================');
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO)
expect(data).assertEqual(0);
done();
})
/*
* @tc.number: bms_checkPermission_0200
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whose availableScope is system_grant whether is granted. (by callback)
*/
it('bms_checkPermission_0200', 0, async function (done) {
console.info('=====================bms_checkPermission_0200==================');
await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO, (err, data) => {
expect(err.code).assertEqual(0);
expect(data).assertEqual(0);
done();
})
})
/*
* @tc.number: bms_checkPermission_0300
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by promise)
*/
it('bms_checkPermission_0300', 0, async function (done) {
console.info('=====================bms_checkPermission_0300==================');
var data = await bundle.checkPermission('', PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_0400
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by callback)
*/
it('bms_checkPermission_0400', 0, async function (done) {
console.info('=====================bms_checkPermission_0400==================');
await bundle.checkPermission('', PERMISSION_ONE, (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
/*
* @tc.number: bms_checkPermission_0500
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by promise)
*/
it('bms_checkPermission_0500', 0, async function (done) {
console.info('=====================bms_checkPermission_0500==================');
var data = await bundle.checkPermission(BUNDLE_NAME, '')
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_0600
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by callback)
*/
it('bms_checkPermission_0600', 0, async function (done) {
console.info('=====================bms_checkPermission_0600==================');
await bundle.checkPermission(BUNDLE_NAME, '', (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
/*
* @tc.number: bms_checkPermission_0700
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by promise)
*/
it('bms_checkPermission_0700', 0, async function (done) {
console.info('=====================bms_checkPermission_0700==================');
var data = await bundle.checkPermission(BUNDLE_NAME, '@\n,. 。测试@abc1^%12345')
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_0800
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by callback)
*/
it('bms_checkPermission_0800', 0, async function (done) {
console.info('=====================bms_checkPermission_0800==================');
await bundle.checkPermission(BUNDLE_NAME, '@\n,. 。测试@abc1^%12345', (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
/*
* @tc.number: bms_checkPermission_0900
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by callback)
*/
it('bms_checkPermission_0900', 0, async function (done) {
console.info('=====================bms_checkPermission_0900==================');
var data = await bundle.checkPermission('@\n,. 。测试@abc1^%12345', PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_1000
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by callback)
*/
it('bms_checkPermission_1000', 0, async function (done) {
console.info('=====================bms_checkPermission_1000==================');
await bundle.checkPermission('@\n,. 。测试@abc1^%12345', PERMISSION_ONE, (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
/*
* @tc.number: bms_checkPermission_1100
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by promise)
*/
it('bms_checkPermission_1100', 0, async function (done) {
console.info('=====================bms_checkPermission_1100==================');
var permissionName = 'test';
for (var i = 0; i < 10000; i++) {
permissionName += 'test';
}
var data = await bundle.checkPermission(BUNDLE_NAME, permissionName)
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_1200
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the permissionName is invalid. (by callback)
*/
it('bms_checkPermission_1200', 0, async function (done) {
console.info('=====================bms_checkPermission_1200==================');
var permissionName = 'test';
for (var i = 0; i < 10000; i++) {
permissionName += 'test';
}
await bundle.checkPermission(BUNDLE_NAME, permissionName, (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
/*
* @tc.number: bms_checkPermission_1300
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by promise)
*/
it('bms_checkPermission_1300', 0, async function (done) {
console.info('=====================bms_checkPermission_1300==================');
var bundleName = 'test';
for (var i = 0; i < 10000; i++) {
bundleName += 'test';
}
var data = await bundle.checkPermission(bundleName, PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
})
/*
* @tc.number: bms_checkPermission_1400
* @tc.name: check whether the permission is granted
* @tc.desc: verify the requested permission whether is granted, which by calling the checkpermission
* function and the bundleName is invalid. (by callback)
*/
it('bms_checkPermission_1400', 0, async function (done) {
console.info('=====================bms_checkPermission_1400==================');
var bundleName = 'test';
for (var i = 0; i < 10000; i++) {
bundleName += 'test';
}
await bundle.checkPermission(bundleName, PERMISSION_ONE, (err, data) => {
expect(err.code).assertEqual(-1);
expect(data).assertEqual(-1);
done();
})
})
})
\ 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.
*/
require('./ActsBmsCheckPermissionTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBmsHapModuleTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsHapModuleTest"
}
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.actsbmshapmoduletest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsHapModuleTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"bmsMainAbilityFirstScene.hap.hap->/data/test/bmsMainAbilityFirstScene.hap",
"bmsMainAbilitySecondScene.hap->/data/test/bmsMainAbilitySecondScene.hap",
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsbmshapmoduletest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmshapmoduletest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsbmshapmoduletest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: 'Test HapModuleInfo'
},
onInit() {
this.title = this.data.title;
},
onShow() {
console.info('onReady finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "actsbmshapmoduletest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsBmsHapModuleTest', function () {
/*
* @tc.number: bms_getHapModuleInfo_0100
* @tc.name: get hapModuleInfo from one app by getBundleInfo
* @tc.desc: get the module information of the hap with type of entry
*/
it('bms_getHapModuleInfo_0100', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0100===========')
await install(['/data/test/bmsMainAbilityFirstScene.hap']);
let bundleName = 'com.example.bmsmainabilityfirstscene';
bundle.getBundleInfo(bundleName, 1, callback);
function callback(err, data) {
console.debug('=======get bundle========' + JSON.stringify(data));
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.bmsmainabilityfirstscene.MainAbility');
checkHapModuleInfo(hapModuleInfo);
done();
}
});
/*
* @tc.number: bms_getHapModuleInfo_0200
* @tc.name: get hapModuleInfo from two modules by getBundleInfo
* @tc.desc: get the module information of the hap with type of feature
*/
it('bms_getHapModuleInfo_0200', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0200===========')
await install(['/data/test/bmsMainAbilitySecondScene.hap']);
let bundleName = 'com.example.bmsmainabilityfirstscene';
let firstMainAbility = 'com.example.bmsmainabilityfirstscene.MainAbility';
let secondMainAbility = 'com.example.bmsmainabilitysecondscene.MainAbility';
let result = new Map();
bundle.getBundleInfo(bundleName, 1, async (err, data) => {
console.debug('=======hapModule length========' + data.hapModuleInfo.length);
expect(data.hapModuleInfo.length).assertEqual(2);
for (let i = 0, len = data.hapModuleInfo.length;i < len; i++) {
console.debug('=======get hapModule========' + JSON.stringify(data.hapModuleInfo[i]))
console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[i].mainAbilityName);
checkHapModuleInfo(data.hapModuleInfo[i]);
result.set(data.hapModuleInfo[i].mainAbilityName, data.hapModuleInfo[i]);
}
expect(result.has(firstMainAbility)).assertTrue();
expect(result.has(secondMainAbility)).assertTrue();
expect(result.get(firstMainAbility).moduleName).assertEqual('entry');
expect(result.get(secondMainAbility).moduleName).assertEqual('bmsmainabilitysecondscene');
await uninstall(bundleName);
done();
})
})
/*
* @tc.number: bms_getHapModuleInfo_0300
* @tc.name: get hapModuleInfo one app without mainAbility by getBundleInfo
* @tc.desc: get the module information of the hap without mainAbility
*/
it('bms_getHapModuleInfo_0300', 0, async function (done) {
console.debug('===========begin bms_getHapModuleInfo_0300===========')
await install(['/data/test/bmsThirdBundleTest2.hap']);
let bundleName = 'com.example.third2';
bundle.getBundleInfo(bundleName, 1).then(async (data) => {
console.debug('=======get hapModule========' + JSON.stringify(data))
expect(data.hapModuleInfo.length).assertEqual(1);
console.debug('=======get hapModule mainAbilityName========' + data.hapModuleInfo[0].mainAbilityName)
expect(data.hapModuleInfo[0].mainAbilityName).assertEqual('');
expect(data.hapModuleInfo[0].moduleName).assertEqual('entry');
checkHapModuleInfo(data.hapModuleInfo[0]);
await uninstall(bundleName);
done();
})
})
function checkHapModuleInfo(dataInfo) {
console.debug('========begin check hapModuleInfo========')
expect(typeof dataInfo.name).assertEqual('string');
expect(typeof dataInfo.description).assertEqual('string');
expect(typeof dataInfo.descriptionId).assertEqual('number');
expect(typeof dataInfo.icon).assertEqual('string');
expect(typeof dataInfo.label).assertEqual('string');
expect(typeof dataInfo.labelId).assertEqual('number');
expect(typeof dataInfo.iconId).assertEqual('number');
expect(typeof dataInfo.backgroundImg).assertEqual('string');
expect(typeof dataInfo.supportedModes).assertEqual('number');
expect(typeof dataInfo.reqCapabilities).assertEqual('object');
expect(typeof dataInfo.deviceTypes).assertEqual('object');
expect(typeof dataInfo.abilityInfo).assertEqual('object');
expect(typeof dataInfo.moduleName).assertEqual('string');
expect(typeof dataInfo.mainAbilityName).assertEqual('string');
expect(typeof dataInfo.installationFree).assertEqual('boolean');
}
async function install(bundlePath)
{
var installer = await bundle.getBundleInstaller();
await installer.install(bundlePath, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveInstallEvent);
function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
async function uninstall(bundleName)
{
var installer = await bundle.getBundleInstaller();
await installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveUninstallEvent);
function onReceiveUninstallEvent(err, data) {
console.info('========uninstall Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
})
\ 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.
*/
require('./ActsBmsHapModuleTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBmsJsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsJsTest"
}
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.actsbmsjstest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"bmsThirdBundleTest2.hap->/data/test/bmsThirdBundleTest2.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleJs.hap->/data/test/bmsThirdBundleJs.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsjstest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsjstest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": ".MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true,
"srcPath": "default"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 50px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "Test Multi Js Ability"
},
onInit() {
this.title = this.data.title;
},
onShow() {
},
onReady() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "actsbmsjstest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsBmsJsTest', function () {
/*
* @tc.number: bms_getJsAbility_0100
* @tc.name: test the multi js ability
* @tc.desc: 1.install a js hap which has an ability with full domain name
* 2.check the ability name by the interface of getBundleInfo
*/
it('bms_getJsAbility_0100', 0, async function (done) {
console.info('=====================bms_getJsAbility_0100==================');
let bundleName = 'com.example.third2';
let abilityName = 'com.example.third2.MainAbility';
await install(['/data/test/bmsThirdBundleTest2.hap']);
bundle.getBundleInfo(bundleName,1).then((data)=>{
expect(data.abilityInfo.length).assertEqual(1);
checkIsExist(abilityName, data);
uninstall(bundleName);
done();
});
})
/*
* @tc.number: bms_getJsAbility_0200
* @tc.name: test the multi js ability
* @tc.desc: 1.install a js hap with two ability
* 2.check the ability name by the interface of getBundleInfo
*/
it('bms_getJsAbility_0200', 0, async function (done) {
console.info('=====================bms_getJsAbility_0200==================');
var bundleName = 'com.example.third5';
let abilityName1 = 'com.example.third5.AMainAbility';
let abilityName2 = 'com.example.third5.BMainAbility';
await install(['/data/test/bmsThirdBundleTest5.hap']);
bundle.getBundleInfo(bundleName,1).then((data)=>{
console.debug('==========bundleInfo==========' + JSON.stringify(data))
expect(data.abilityInfo.length).assertLarger(1);
checkIsExist(abilityName1, data);
checkIsExist(abilityName2, data);
uninstall(bundleName);
done();
});
})
/*
* @tc.number: bms_getJsAbility_0300
* @tc.name: test the multi js ability
* @tc.desc: 1.install a js hap which has an ability with short domain name
* 2.check the ability name by the interface of getBundleInfo
*/
it('bms_getJsAbility_0300', 0, async function (done) {
console.info('=====================bms_getJsAbility_0300==================');
let bundleName = 'com.example.js';
let abilityName = 'com.example.js.MainAbility';
await install(['/data/test/bmsThirdBundleJs.hap']);
bundle.getBundleInfo(bundleName,1).then((data)=>{
expect(data.abilityInfo.length).assertEqual(1);
checkIsExist(abilityName, data);
uninstall(bundleName);
done();
});
})
async function install(bundlePath)
{
var installer = await bundle.getBundleInstaller();
await installer.install(bundlePath, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveInstallEvent);
function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
async function uninstall(bundleName)
{
var installer = await bundle.getBundleInstaller();
await installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveUninstallEvent);
function onReceiveUninstallEvent(err, data) {
console.info('========uninstall Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
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
/*
* 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('./ActsBmsJsTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBmsMetaDataTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsMetaDataTest"
}
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.actsbmsmetadatatest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsMetaDataTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTest3.hap->/data/test/bmsThirdBundleTest3.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsmetadatatest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsmetadatatest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsbmsmetadatatest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: 'Test MetaData'
},
onInit() {
this.title = this.data.title;
},
onShow() {
console.info('onReady finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
onBackPress(){
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "actsbmsmetadatatest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('ActsBmsMetaDataTest', function () {
/*
* @tc.number: bms_getMetaData_0100
* @tc.name: test to get meta data for an application.
* @tc.desc: get an application's meta data which contains two HAP packages.
*/
it('bms_getMetaData_0100', 0, async function (done) {
console.info('=====================bms_getMetaData_0100==================');
await install(['/data/test/bmsThirdBundleTest1.hap'])
await install(['/data/test/bmsThirdBundleTest3.hap'])
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility',
},
}
}, 0, 0)
checkMetaData(datainfo.metaData);
datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third1',
abilityName: 'com.example.third3.MainAbility',
},
}
}, 0, 0)
checkMetaData(datainfo.metaData);
done();
})
/*
* @tc.number: bms_getMetaData_0200
* @tc.name: test to get meta data for an update application.
* @tc.desc: get an application's meta data that is updated.
*/
it('bms_getMetaData_0200', 0, async function (done) {
console.info('=====================bms_getMetaData_0200==================');
await install(['/data/test/bmsThirdBundleTestA1.hap'])
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.AMainAbility',
},
}
}, 0, 0)
checkMetaData(datainfo.metaData);
done();
})
/*
* @tc.number: bms_getMetaData_0300
* @tc.name: test to get meta data for an uninstalled application.
* @tc.desc: get an application's meta data that is uninstalled.
*/
it('bms_getMetaData_0300', 0, async function (done) {
console.info('=====================bms_getMetaData_0300==================');
await uninstall('com.example.third1');
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility',
},
}
}, 0, 0)
console.info('==========abilityInfo is ==========' + datainfo);
console.info('==========abilityInfo is ==========' + JSON.stringify(datainfo));
checkMetaDataNoExit(datainfo.metaData);
done();
})
/*
* @tc.number: bms_getMetaData_0400
* @tc.name: test to get meta data for an application.
* @tc.desc: get an application's meta data which has two abilities.
*/
it('bms_getMetaData_0400', 0, async function (done) {
console.info('=====================bms_getMetaData_0400==================');
await install(['/data/test/bmsThirdBundleTest5.hap']);
var datainfo1 = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third5',
abilityName: 'com.example.third5.AMainAbility',
},
}
}, 0, 0)
console.info('==========abilityInfo is ==========' + JSON.stringify(datainfo1));
checkMetaData(datainfo1.metaData);
var datainfo2 = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.third5',
abilityName: 'com.example.third5.BMainAbility',
},
}
}, 0, 0)
console.info('==========abilityInfo is ==========' + JSON.stringify(datainfo2));
checkMetaData(datainfo2.metaData);
uninstall('com.example.third5');
done();
})
/*
* @tc.number: bms_getMetaData_0500
* @tc.name: test to get meta data for an application that does not exist.
* @tc.desc: get an application's meta data which does not exist.
*/
it('bms_getMetaData_0500', 0, async function (done) {
console.info('=====================bms_getMetaData_0500==================');
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.noexist',
abilityName: 'com.example.noexist.MainAbility',
},
}
}, 0, 0)
console.info('==========abilityInfo is ==========' + datainfo);
console.info('==========abilityInfo is ==========' + JSON.stringify(datainfo));
checkMetaDataNoExit(datainfo.metaData);
done();
})
/*
* @tc.number: bms_getMetaData_0600
* @tc.name: test to get meta data for a system application.
* @tc.desc: get a system application's meta data.
*/
it('bms_getMetaData_0600', 0, async function (done) {
console.info('=====================bms_getMetaData_0600==================');
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.system1',
abilityName: 'com.example.system1.MainAbility',
},
}
}, 0, 0)
checkMetaData(datainfo.metaData);
done();
})
/*
* @tc.number: bms_getMetaData_0700
* @tc.name: test to get meta data for a vendor application.
* @tc.desc: get a vendor application's meta data.
*/
it('bms_getMetaData_0700', 0, async function (done) {
console.info('=====================bms_getMetaData_0700==================');
var datainfo = await bundle.queryAbilityByWant({
want: {
action: 'action.system.home',
entities: ['entity.system.home'],
elementName: {
deviceId: '0',
bundleName: 'com.example.vendor1',
abilityName: 'com.example.vendor1.MainAbility',
},
}
}, 0, 0)
checkMetaData(datainfo.metaData);
done();
})
function checkMetaData(data) {
console.info('==========MetaData is==========' + JSON.stringify(data));
var parameters = data.parameters;
var results = data.results;
var customizeDatas = data.customizeDatas;
expect(typeof parameters).assertEqual('object');
expect(typeof results).assertEqual('object');
expect(typeof customizeDatas).assertEqual('object');
console.info('==========parameters.length is==========' + parameters.length);
console.info('==========results.length is==========' + results.length);
console.info('==========customizeDatas.length is==========' + customizeDatas.length);
expect(parameters.length).assertLarger(0);
expect(results.length).assertLarger(0);
expect(customizeDatas.length).assertLarger(0);
for (let i = 0; i < parameters.length; i++) {
console.info('==========Parameter description is==========' + parameters[i].description);
expect(typeof parameters[i].description).assertEqual('string');
console.info('==========Parameter name is==========' + parameters[i].name);
expect(typeof parameters[i].name).assertEqual('string');
console.info('==========Parameter type is==========' + parameters[i].type);
expect(typeof parameters[i].type).assertEqual('string');
}
for (let i = 0; i < results.length; i++) {
console.info('==========Results description is==========' + results[i].description);
expect(typeof results[i].description).assertEqual('string');
console.info('==========Results name is==========' + results[i].name);
expect(typeof results[i].name).assertEqual('string');
console.info('==========Results type is==========' + results[i].type);
expect(typeof results[i].type).assertEqual('string');
}
for (let i = 0; i < customizeDatas.length; i++) {
console.info('==========CustomizeData name is==========' + customizeDatas[i].name);
expect(typeof customizeDatas[i].name).assertEqual('string');
console.info('==========CustomizeData value is==========' + customizeDatas[i].value);
expect(typeof customizeDatas[i].value).assertEqual('string');
console.info('==========CustomizeData extra is==========' + customizeDatas[i].extra);
expect(typeof customizeDatas[i].extra).assertEqual('string');
}
}
function checkMetaDataNoExit(data) {
console.info('==========MetaData is==========' + JSON.stringify(data));
var parameters = data.parameters;
var results = data.results;
var customizeDatas = data.customizeDatas;
expect(typeof parameters).assertEqual('object');
expect(typeof results).assertEqual('object');
expect(typeof customizeDatas).assertEqual('object');
expect(parameters.length).assertEqual(0);
expect(results.length).assertEqual(0);
expect(customizeDatas.length).assertEqual(0);
}
async function install(bundlePath) {
var installer = await bundle.getBundleInstaller();
await installer.install(bundlePath, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveinstallEvent);
function onReceiveinstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
async function uninstall(bundleName) {
var installer = await bundle.getBundleInstaller();
await installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveinstallEvent);
function onReceiveinstallEvent(err, data) {
console.info('========uninstall Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
})
\ 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.
*/
require('./ActsBmsMetaDataTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBmsModuleUsageRecordTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsModuleUsageRecordTest"
}
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.actsbmsmoduleusagerecordtest",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ActsBmsModuleUsageRecordTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsmoduleusagerecordtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsmoduleusagerecordtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsbmsmoduleusagerecordtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"visible": true,
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 50px;
}
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "Test ModuleUsageRecord"
},
onInit() {
this.title = this.data.title;
},
onShow() {
console.info('onReady finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test.js')
core.execute()
},
onReady() {
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "actsbmsmoduleusagerecordtest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 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 START_ABILITY_TIMEOUT = 5000;
const MIN_NUM = 2;
const MAX_NUM = 10;
const INVALID_NUM = -1;
var SubscriberInfo_bms_getModuleUsageRecordTest_0100 = {
events: ['ACTS_Third1_Publish_CommonEvent'],
};
describe('ActsBmsModuleUsageRecordTest', function () {
beforeAll(async (done) => {
console.debug('=======before all install========');
bundle.getBundleInstaller().then((data) => {
data.install(['/data/test/bmsThirdBundleTest1.hap'], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveinstallEvent);
})
function onReceiveinstallEvent(err, data) {
console.info('========install finish========' + JSON.stringify(err));
console.info('========install finish========' + JSON.stringify(data));
console.info('========install finish========' + data.status);
console.info('========install finish========' + data.statusMessage);
done()
}
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0100
* @tc.name: getModuleUsageRecord(maxNum)
* @tc.desc: Use the getModuleUsageRecord interface to query the activation times and last
* activation time of ability
*/
it('bms_getModuleUsageRecordTest_0100', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0100==================');
var bundleName = 'com.example.third1';
var Subscriber;
let id;
async function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual('ACTS_Third1_Publish_CommonEvent');
console.debug('====>Subscribe CallBack data:====>' + JSON.stringify(data));
let records = await bundle.getModuleUsageRecords(MIN_NUM);
checkModuleUsageRecord(records, 'bms_getModuleUsageRecordTest_0100');
var result = checkIsExist(records, bundleName);
expect(result).assertEqual(true);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
done();
}
await commonEvent.createSubscriber(SubscriberInfo_bms_getModuleUsageRecordTest_0100).then(async (data) => {
console.debug('====>Create Subscriber====>');
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug('====>UnSubscribe CallBack====>');
done();
}
function timeout() {
expect().assertFail();
console.debug('bms_getModuleUsageRecordTest_0100=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug('=======start ability========')
let result = await featureAbility.startAbility(
{
want:
{
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility'
}
}
)
expect(result).assertEqual(0);
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0200
* @tc.name: getModuleUsageRecord(maxNum)
* @tc.desc: When the number of starts of ability is less than maxNum, call interface getModuleUsageRecord
*/
it('bms_getModuleUsageRecordTest_0200', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0200==================');
var bundleName = 'com.example.third1';
bundle.getModuleUsageRecords(MIN_NUM, (err, data) => {
expect(err.code).assertEqual(0);
checkModuleUsageRecord(data, 'bms_getModuleUsageRecordTest_0200');
var result = checkIsExist(data, bundleName);
expect(result).assertEqual(true);
done();
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0300
* @tc.name: getModuleUsageRecord(maxNum)
* @tc.desc: When the number of starts of ability is less than maxNum, call interface getModuleUsageRecord
*/
it('bms_getModuleUsageRecordTest_0300', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0300==================');
var bundleName = 'com.example.third1';
bundle.getModuleUsageRecords(MAX_NUM, (err, data) => {
expect(err.code).assertEqual(0);
checkModuleUsageRecord(data, 'bms_getModuleUsageRecordTest_0300');
var result = checkIsExist(data, bundleName);
expect(result).assertEqual(true);
done();
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0400
* @tc.name: getModuleUsageRecord(maxNum)
* @tc.desc: When the number of starts of ability is less than maxNum, call interface getModuleUsageRecord
*/
it('bms_getModuleUsageRecordTest_0400', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0400==================');
var bundleName = 'com.example.third1';
var records = await bundle.getModuleUsageRecords(MAX_NUM);
checkModuleUsageRecord(records, 'bms_getModuleUsageRecordTest_0400');
var result = checkIsExist(records, bundleName);
expect(result).assertEqual(true);
done();
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0500
* @tc.name: getModuleUsageRecord(maxNum) by promise
* @tc.desc: Uninstall a third-party application, and then use the getModuleUsageRecord interface
* to query the activation times and last activation time of ability
*/
it('bms_getModuleUsageRecordTest_0500', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0500==================');
var bundleName = 'com.example.third1'
await uninstall(bundleName);
console.debug('===================uninstall third1====================');
var records = await bundle.getModuleUsageRecords(MAX_NUM)
checkModuleUsageRecord(records, 'bms_getModuleUsageRecordTest_0500');
var result = checkIsExist(records, bundleName);
expect(result).assertEqual(false);
done();
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0600
* @tc.name: getModuleUsageRecord(maxNum,callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: Uninstall a third-party application, and then use the getModuleUsageRecord interface
* to query the activation times and last activation time of ability
*/
it('bms_getModuleUsageRecordTest_0600', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0600==================');
var bundleName = 'com.example.third1'
await bundle.getModuleUsageRecords(MAX_NUM, (err, data) => {
expect(err.code).assertEqual(0);
checkModuleUsageRecord(data, 'bms_getModuleUsageRecordTest_0600');
var result = checkIsExist(data, bundleName);
expect(result).assertEqual(false);
done();
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0700
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: test getModuleUsageRecord with the invalid parameter
*/
it('bms_getModuleUsageRecordTest_0700', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0700==================');
await bundle.getModuleUsageRecords(INVALID_NUM, (err, data) => {
console.debug('============err.code==========' + err.code);
expect(err.code).assertEqual(0);
expect(data.length).assertEqual(0);
done();
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0800
* @tc.name: getModuleUsageRecord(maxNum) by promise
* @tc.desc: test getModuleUsageRecord with the invalid parameter
*/
it('bms_getModuleUsageRecordTest_0800', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0800==================');
var data = await bundle.getModuleUsageRecords(INVALID_NUM);
expect(data.length).assertEqual(0);
done();
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0900
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: test getModuleUsageRecord with the critical value
*/
it('bms_getModuleUsageRecordTest_0900', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_0900==================');
await bundle.getModuleUsageRecords(0, (err, data) => {
console.debug('============err.code==========' + err.code);
expect(err.code).assertEqual(0);
expect(data.length).assertEqual(0);
done();
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1000
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: test getModuleUsageRecord with the critical value
*/
it('bms_getModuleUsageRecordTest_1000', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_1000==================');
var data = await bundle.getModuleUsageRecords(0);
expect(data.length).assertEqual(0);
done();
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1100
* @tc.name: getModuleUsageRecord(maxNum) by promise
* @tc.desc: Install a third-party which is uninstalled, and then use the getModuleUsageRecord interface
* to query the activation times and last activation time of ability
*/
it('bms_getModuleUsageRecordTest_1100', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_1100==================');
var bundleName = 'com.example.third1'
var bundlePath = ['/data/test/bmsThirdBundleTest1.hap']
await install(bundlePath);
console.debug('===================install third1====================');
var records = await bundle.getModuleUsageRecords(MAX_NUM)
checkModuleUsageRecord(records, 'bms_getModuleUsageRecordTest_1100');
var result = checkIsExist(records, bundleName);
expect(result).assertEqual(true);
done();
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1200
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: Install a third-party which is uninstalled, and then use the getModuleUsageRecord interface
* to query the activation times and last activation time of ability
*/
it('bms_getModuleUsageRecordTest_1200', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_1200==================');
var bundleName = 'com.example.third1'
await bundle.getModuleUsageRecords(MAX_NUM, (err, data) => {
expect(err.code).assertEqual(0);
checkModuleUsageRecord(data, 'bms_getModuleUsageRecordTest_1200');
var result = checkIsExist(data, bundleName);
expect(result).assertEqual(true);
done();
})
})
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;
}
}
async function install(bundlePath) {
var installer = await bundle.getBundleInstaller();
await installer.install(bundlePath, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveinstallEvent);
function onReceiveinstallEvent(err, data) {
console.debug('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
async function uninstall(bundleName) {
var installer = await bundle.getBundleInstaller();
await installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveinstallEvent);
function onReceiveinstallEvent(err, data) {
console.debug('========uninstall Finish========');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
console.debug('========data.statusMessage========' + data.statusMessage);
}
}
afterAll(async (done) => {
console.debug('=======after all install========');
let bundleName = 'com.example.third1'
uninstall(bundleName);
done();
})
})
\ 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.
*/
require('./ActsBmsModuleUsageRecordTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap("bmsThirdBundleTest5") {
hap_profile = "./src/main/config.json"
hap_name = "bmsThirdBundleTest5"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/js/resources" ]
hap_profile = "./src/main/config.json"
}
{
"app": {
"bundleName": "com.example.third5",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.third5",
"name": ".BmsThirdBundle5",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.third5.AMainAbility",
"srcLanguage": "js",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"form": {
"formEntity": [
"homeScreen",
"searchbox"
],
"defaultHeight": 100,
"defaultWidth": 200,
"minHeight": 50,
"minWidth": 100
},
"forms": [
{
"colorMode": "light",
"description": " JS5A Form",
"supportDimensions": [
"1*2",
"2*2",
"2*4"
],
"type": "JS",
"jsComponentName": "JS_name5A",
"metaData": {
"customizeData": [
{
"name": "originWidgetName5A",
"value": "com.huawei.weather.testWidget5A"
}
]
},
"isDefault": true,
"deepLink": "ability://com.example.myapplication.fa/.MainAbility",
"defaultDimension": "1*2",
"name": "Form_JS5A",
"scheduledUpateTime": "21:55",
"updateEnabled": true,
"updateDuration": 1
}
],
"launchType": "standard",
"metaData": {
"parameters": [
{
"name": "Data5A",
"type": "float",
"description": "$string:mainability_description"
}
],
"results": [
{
"name": "Data5A",
"type": "float",
"description": "$string:mainability_description"
}
],
"customizeData": [
{
"name": "Data5A",
"value": "float",
"extra": "$string:mainability_description"
}
]
}
},
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": ".BMainAbility",
"srcLanguage": "js",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"forms": [
{
"colorMode": "light",
"description": " JS5B Form",
"supportDimensions": [
"1*2",
"4*4"
],
"type": "JS",
"jsComponentName": "JS_name5B",
"metaData": {
"customizeData": [
{
"name": "originWidgetName5B",
"value": "com.huawei.weather.testWidget5B"
}
]
},
"isDefault": true,
"deepLink": "ability://com.example.myapplication.fa/.MainAbility",
"defaultDimension": "1*2",
"name": "Form_JS5B",
"scheduledUpateTime": "21:55",
"updateEnabled": true,
"updateDuration": 1
}
],
"launchType": "standard",
"metaData": {
"parameters": [
{
"name": "Data5B",
"type": "float",
"description": "$string:mainability_description"
}
],
"results": [
{
"name": "Data5B",
"type": "float",
"description": "$string:mainability_description"
}
],
"customizeData": [
{
"name": "Data5B",
"value": "float",
"extra": "$string:mainability_description"
}
]
}
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pagesB/index/index"
],
"name": "default2",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册