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

!2166 commit applicationFramework api7,8 ets test

Merge pull request !2166 from dy/master
......@@ -9,7 +9,7 @@
# 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.
# limitations under the License.
import("//build/ohos_var.gni")
......@@ -21,6 +21,7 @@ group("aafwk_standard") {
"abilitymanager:actsabilitymanagertest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest",
"amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton",
"amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS",
......
# 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("ActsAbilityManagerEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityManagerEtsTest"
}
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.ohos.acecollaboration",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAbilityManagerEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.acecollaboration",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.acecollaboration",
"name": ".MyApplication",
"mainAbility": "com.ohos.acecollaboration.MainAbility",
"deviceType": [
"phone"
],
"reqPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"srcPath": "MainAbility",
"srcLanguage": "ets",
"name": "com.ohos.acecollaboration.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"srcPath": "MainAbility2",
"name": ".MainAbility2",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability2",
"formsEnabled": false,
"label": "$string:entry_MainAbility2",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"type": "service"
},
{
"srcPath": "ServiceAbility2",
"name": ".ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability2",
"type": "service"
},
{
"srcPath": "ServiceAbility3",
"name": ".ServiceAbility3",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability3",
"type": "service"
},
{
"srcPath": "ServiceAbility4",
"name": ".ServiceAbility4",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability4",
"type": "service"
},
{
"srcPath": "ServiceAbility5",
"name": ".ServiceAbility5",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability5",
"type": "service"
},
{
"srcPath": "ServiceAbility6",
"name": ".ServiceAbility6",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability6",
"type": "service"
},
{
"srcPath": "ServiceAbility7",
"name": ".ServiceAbility7",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability7",
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": "MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility2",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "com.ohos.acecollaboration.DataAbilityShellProvider.PROVIDER"
}
]
}
}
\ 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('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
async function startService2() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility2",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0100 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService3() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility3",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0200 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService4() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility4",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0300 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService5() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility5",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0400 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService6(){
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility6",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0500 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService7(){
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility7",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0600 startAbility succeeded: ' + JSON.stringify(data));
}
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ACE ETS TEST 组件协同')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button('disconnectAbility_promise')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService2();
});
Button('disconnectAbility_callback')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService3();
});
Button('connectotherAbility')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService4();
});
Button('connectnull')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService5();
});
Button('connecterror')
.fontSize(40)
.height(40)
.margin({top:20})
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService6();
});
Button('connectAPI8')
.fontSize(40)
.height(40)
.margin({top:20})
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService7();
});
}
.width('100%')
.height('100%')
}
}
/**
* 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 {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
export default function contextJsunit() {
describe('appInfoTest', function () {
beforeEach(async function (done) {
console.info("context before each called");
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info("context after each called");
});
/*
* @tc.number: context_getCacheDir_test_0100
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getCacheDir_test_0100", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0100: CacheDir is " + data);
})
} catch (error) {
console.log("logMessage context_getCacheDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0100-------------------");
});
/*
* @tc.number: context_getCacheDir_test_0200
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getCacheDir_test_0200", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0200: getCacheDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getCacheDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0200-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0100
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getFilesDir_test_0100", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0100:FilesDir is " + data);
})
} catch (error) {
console.log("logMessage context_getFilesDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0100-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0200
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getFilesDir_test_0200", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0200: getFilesDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getFilesDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0200-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_test_0100
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0100", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0100', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0100: DistributedDir is " + data);
})
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0100: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributedfiles/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0100-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_0200
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0200", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0200', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0200: getOrCreateDistributedDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0200: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributedfiles/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0200-------------------");
});
/*
* @tc.number: context_getAppType_0100
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getAppType_0100", 0, async function (done) {
console.log("------------------start context_getAppType_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0100_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0100: AppType is " + data);
})
} catch (error) {
console.log("logMessage context_getAppType_0100: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0100-------------------");
});
/*
* @tc.number: context_getAppType_0200
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getAppType_0200", 0, async function (done) {
console.log("------------------start context_getAppType_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0200_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0200: getAppType successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getAppType_0200: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0200-------------------");
});
})
}
/**
* 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 addContextAndAbilityJsunit from './addContextAndAbilityJsunit.test.ets';
import getHapModuleInfoJsunit from './getHapModuleInfoJsunit.test.ets';
import getAbilityInfoJsunit from './getAbilityInfoJsunit.test.ets';
import getApplicationContext from './getApplicationContextJsunit.test.ets';
import getAppVersionInfoJsunit from './getAppVersionInfoJsunit.test.ets';
import ContextJsunit from './ContextJsunit.test.ets';
import DataAbilityJsunit from './DataAbility.test.ets';
export default function testsuite() {
ContextJsunit();
DataAbilityJsunit();
addContextAndAbilityJsunit();
getHapModuleInfoJsunit();
getAbilityInfoJsunit();
getApplicationContext();
getAppVersionInfoJsunit();
}
\ 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 class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(reject)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
/**
* 接口调用时间
* @param startTime 接口调用开始时间
* @param endTime 接口调用结束时间
*/
static getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
}
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
import abilityManager from "@ohos.app.abilitymanager"
const TAG_TEST_0100 = ' context_isUpdatingConfigurations_test_0100 ';
const TAG_TEST_0200 = ' context_isUpdatingConfigurations_test_0200 ';
const TAG_TEST_0300 = ' context_printDrawnCompleted_test_0100 ';
const TAG_TEST_0400 = ' context_printDrawnCompleted_test_0200 ';
const TAG_TEST_0500 = ' context_getAppMemorySize_test_0100 ';
const TAG_TEST_0600 = ' context_getAppMemorySize_test_0200 ';
const TAG_TEST_0700 = ' context_isRamConstrainedDevice_test_0100 ';
const TAG_TEST_0800 = ' context_isRamConstrainedDevice_test_0200 ';
const TAG_TEST_0900 = ' context_featureAbility_test_0100 ';
const TAG_TEST_0010 = ' context_featureAbility_test_0200 ';
const TAG_TEST_0011 = ' context_featureAbility_test_0300 ';
const TAG_TEST_0012 = ' context_featureAbility_test_0400 ';
export default function addContextAndAbilityJsunit() {
describe('appInfoTest', function () {
/*
* @tc.number: context_isUpdatingConfigurations_test_0100
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0100, 0, async function (done) {
console.info(TAG_TEST_0100 + 'promise START');
let detailed;
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.isUpdatingConfigurations().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100, startTime, endTime)
console.info(TAG_TEST_0100 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0100 + 'promise errors is: ' + JSON.stringify(error));
})
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false);
done();
console.log('------------------ ' + TAG_TEST_0100 + ' end -------------------');
});
/*
* @tc.number: context_isUpdatingConfigurations_test_0200
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0200, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0200 + 'callBack START');
try {
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.isUpdatingConfigurations((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200, startTime, endTime)
detailed = data;
console.info(TAG_TEST_0200 + ' callBack succeeded. data is:' + JSON.stringify(data));
});
} catch (error) {
console.error(TAG_TEST_0200 + 'Operation failed. Cause: ' + JSON.stringify(error));
}
await Utils.sleep(2000)
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false);
done();
console.log('------------------ ' + TAG_TEST_0200 + ' end -------------------');
});
/*
* @tc.number: context_printDrawnCompleted_test_0100
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page
capability.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0300, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0300 + 'callBack START');
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.printDrawnCompleted().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
console.info(TAG_TEST_0300 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0300 + 'promise error is: ' + JSON.stringify(error));
});
await Utils.sleep(2000)
expect(detailed).assertEqual(null);
done();
console.log('------------------ ' + TAG_TEST_0300 + ' end -------------------');
})
/*
* @tc.number: context_printDrawnCompleted_test_0200
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page
capability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0400, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0400 + 'callBack START');
try {
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.printDrawnCompleted((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
detailed = data;
console.info(TAG_TEST_0400 + ' callBack succeeded. data is:' + JSON.stringify(data));
});
} catch (error) {
console.error(TAG_TEST_0400 + 'Operation failed. Cause: ' + JSON.stringify(error));
}
await Utils.sleep(2000)
expect(detailed).assertEqual(null);
done();
console.log('------------------ ' + TAG_TEST_0400 + ' end -------------------');
})
/*
* @tc.number: context_getAppMemorySize_test_0100
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500, 0, async function (done) {
console.info(TAG_TEST_0500 + 'promise START');
let detailed;
var startTime = await Utils.getNowTime();
await abilityManager.getAppMemorySize()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0500 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0500 + 'promise errors is: ' + JSON.stringify(error));
})
await Utils.sleep(2000)
expect(typeof (detailed)).assertEqual("number");
expect(detailed).assertEqual(512);
done();
console.log('------------------ ' + TAG_TEST_0500 + ' end -------------------');
});
/*
* @tc.number: context_getAppMemorySize_test_0200
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0600, 0, async function (done) {
console.info(TAG_TEST_0600 + 'callBack START');
var startTime = await Utils.getNowTime();
abilityManager.getAppMemorySize((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0600 + ' callBack error is: ' + JSON.stringify(error));
console.info(TAG_TEST_0600 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("number");
expect(data).assertEqual(512);
console.log('------------------ ' + TAG_TEST_0600 + ' end -------------------');
done();
})
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0100
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0700, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0700 + 'promise START');
var startTime = await Utils.getNowTime();
await abilityManager.isRamConstrainedDevice().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0700 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0700 + 'promise errors is: ' + JSON.stringify(error));
})
await Utils.sleep(1000)
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false)
done();
console.log('------------------ ' + TAG_TEST_0700 + ' end -------------------');
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0200
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0800, 0, async function (done) {
console.info(TAG_TEST_0800 + 'callBack START');
var startTime = await Utils.getNowTime();
abilityManager.isRamConstrainedDevice((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0800 + ' callBack error is:' + error);
console.info(TAG_TEST_0800 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("boolean");
expect(data).assertEqual(false);
done();
})
console.log('------------------ ' + TAG_TEST_0800 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0100
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.NO_ERROR
* @tc.level 0
*/
it(TAG_TEST_0900, 0, async function (done) {
console.info(TAG_TEST_0900 + ' NO_ERROR START');
var no_error = ability_featureAbility.ErrorCode.NO_ERROR
console.info(TAG_TEST_0900 + ' featureAbility no_error is: ' + no_error);
expect(typeof (no_error)).assertEqual("number");
expect(no_error).assertEqual(0);
done();
console.log('------------------ ' + TAG_TEST_0900 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0200
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.INVALID_PARAMETER
* @tc.level 0
*/
it(TAG_TEST_0010, 0, async function (done) {
console.info(TAG_TEST_0010 + ' INVALID_PARAMETER START');
var invalid_parameter = ability_featureAbility.ErrorCode.INVALID_PARAMETER
console.info(TAG_TEST_0010 + ' featureAbility invalid_parameter is: ' + invalid_parameter);
expect(typeof (invalid_parameter)).assertEqual("number");
expect(invalid_parameter).assertEqual(-1);
done();
console.log('------------------ ' + TAG_TEST_0010 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0300
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.ABILITY_NOT_FOUND
* @tc.level 0
*/
it(TAG_TEST_0011, 0, async function (done) {
console.info(TAG_TEST_0011 + ' ABILITY_NOT_FOUND START');
var ability_not_found = ability_featureAbility.ErrorCode.ABILITY_NOT_FOUND
console.info(TAG_TEST_0011 + ' featureAbility ability_not_found is: ' + ability_not_found);
expect(typeof (ability_not_found)).assertEqual("number");
expect(ability_not_found).assertEqual(-2);
done();
console.log('------------------ ' + TAG_TEST_0011 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0400
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.PERMISSION_DENY
* @tc.level 0
*/
it(TAG_TEST_0012, 0, async function (done) {
console.info(TAG_TEST_0012 + ' PERMISSION_DENY START');
var permission_deny = ability_featureAbility.ErrorCode.PERMISSION_DENY
console.info(TAG_TEST_0012 + ' featureAbility permission_deny is: ' + permission_deny);
expect(typeof (permission_deny)).assertEqual("number");
expect(permission_deny).assertEqual(-3);
done();
console.log('------------------ ' + TAG_TEST_0012 + ' end -------------------');
});
})
}
\ 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAbilityInfo_test_0100
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0100', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAbilityInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getAbilityInfo();
console.info('--[context_getAbilityInfo_test_0100] check---');
checkAbilityInfo('context_getAbilityInfo_test_0100', promise);
console.info('[context_getAbilityInfo_test_0100] FINISH');
done();
});
async function startAbility2() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.MainAbility2",
},
};
ability_featureAbility.startAbility(str).then((data) => {
console.info('context_getAbilityInfo_test_0300 startMainAbility2 succeeded: ' + JSON.stringify(data));
}).catch((error) => {
console.error('context_getAbilityInfo_test_0300 startMainAbility2 failed. Cause: ' + JSON.stringify(error));
});
}
/**
* @tc.number: context_getAbilityInfo_test_0200
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getAbilityInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAbilityInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
} catch (error) {
console.error('[context_getAbilityInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getAbilityInfo();
console.info('---[context_getAbilityInfo_test_0200] check---');
checkAbilityInfo('context_getAbilityInfo_test_0200', callback);
console.info('[context_getAbilityInfo_test_0200] FINISH');
done();
})
/**
* @tc.number: context_getAbilityInfo_test_0300_1
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getAbilityInfo_test_0300_1', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0300] STARTability');
startAbility2();
done();
});
/**
* @tc.number: context_getAbilityInfo_test_0400
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0400', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0400] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0400', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0400] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAbilityInfo_test_0400] failed:' + JSON.stringify(error));
})
var promise = await context.getAbilityInfo();
console.info('--[context_getAbilityInfo_test_0400] check---');
checkAbilityInfo('context_getAbilityInfo_test_0400', promise);
console.info('[context_getAbilityInfo_test_0400] FINISH');
done();
});
function checkAbilityInfo(msg, data) {
console.log(msg + "checkAbilityInfo start " + JSON.stringify(data));
console.log(msg + "checkAbilityInfo bundleName : " + data.bundleName);
console.log(msg + "checkAbilityInfo name : " + data.name);
console.log(msg + "checkAbilityInfo label : " + data.label);
console.log(msg + "checkAbilityInfo description : " + data.description);
console.log(msg + "checkAbilityInfo icon : " + data.icon);
console.log(msg + "checkAbilityInfo descriptionId : " + data.descriptionId);
console.log(msg + "checkAbilityInfo iconId : " + data.iconId);
console.log(msg + "checkAbilityInfo moduleName : " + data.moduleName);
console.log(msg + "checkAbilityInfo process : " + data.process);
console.log(msg + "checkAbilityInfo targetAbility : " + data.targetAbility);
console.log(msg + "checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log(msg + "checkAbilityInfo isVisible : " + data.isVisible);
console.log(msg + "checkAbilityInfo formEnabled : " + data.formEnabled);
console.log(msg + "checkAbilityInfo type : " + data.type)
console.log(msg + "checkAbilityInfo orientation : " + data.orientation);
console.log(msg + "checkAbilityInfo launchMode : " + data.launchMode);
console.log(msg + "checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log(msg + "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log(msg + "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg + "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg + "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log(msg + "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log(msg + "checkAbilityInfo readPermission : " + data.readPermission);
console.log(msg + "checkAbilityInfo writePermission : " + data.writePermission);
console.log(msg + "checkAbilityInfo formEntity : " + data.formEntity);
console.log(msg + "checkAbilityInfo minFormHeight : " + data.minFormHeight);
console.log(msg + "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight);
console.log(msg + "checkAbilityInfo minFormWidth : " + data.minFormWidth);
console.log(msg + "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log(msg + "checkAbilityInfo uri : " + data.uri);
console.log(msg + "checkAbilityInfo customizeData : " + data.customizeData);
console.log(msg + "checkAbilityInfo labelId : " + data.labelId);
console.log(msg + "checkAbilityInfo subType : " + data.subType);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.targetAbility)).assertEqual("string");
expect(typeof (data.backgroundModes)).assertEqual("number");
expect(typeof (data.isVisible)).assertEqual("boolean");
expect(typeof (data.formEnabled)).assertEqual("boolean");
expect(typeof (data.type)).assertEqual("number");
expect(typeof (data.subType)).assertEqual("number");
expect(typeof (data.orientation)).assertEqual("number");
expect(typeof (data.launchMode)).assertEqual("number");
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (data.readPermission)).assertEqual("string");
expect(typeof (data.writePermission)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (data.formEntity)).assertEqual("number");
expect(typeof (data.minFormHeight)).assertEqual("number");
expect(typeof (data.defaultFormHeight)).assertEqual("number");
expect(typeof (data.minFormWidth)).assertEqual("number");
expect(typeof (data.defaultFormWidth)).assertEqual("number");
expect(typeof (data.uri)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo(msg, data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId > 0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg + "---checkAbilityInfo End--- ");
}
function checkApplicationInfo(msg, info) {
console.log(msg + "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg + "checkApplicationInfo name : " + info.name);
console.log(msg + "checkApplicationInfo description : " + info.description);
console.log(msg + "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg + "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg + "checkApplicationInfo enabled : " + info.enabled);
console.log(msg + "checkApplicationInfo label : " + info.label);
console.log(msg + "checkApplicationInfo labelId : " + info.labelId);
console.log(msg + "checkApplicationInfo icon : " + info.icon);
console.log(msg + "checkApplicationInfo iconId : " + info.iconId);
console.log(msg + "checkApplicationInfo process : " + info.process);
console.log(msg + "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg + "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg + "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg + "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg + "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg + "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : "
+ info.moduleInfos[i].moduleName);
console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : "
+ info.moduleInfos[i].moduleSourceDir);
}
console.log(msg + "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
if (info.moduleSourceDirs.length == 1){
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else if(info.moduleSourceDirs.length == 2) {
if (info.moduleInfos[0].moduleName == "myapplication1") {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else{
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
}else {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[2].moduleName).assertEqual("entry");
expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
console.log(msg + "---checkApplicationInfo End--- ");
}
})
}
\ 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAppVersionInfo_test_0100
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Promise)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0100', 0, async function (done) {
console.info('[context_getAppVersionInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAppVersionInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0100] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0100', promise);
console.info('[context_getAppVersionInfo_test_0100] FINISH');
done();
});
/**
* @tc.number: context_getAppVersionInfo_test_0200
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getAppVersionInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
}
catch (error) {
console.error('[context_getAppVersionInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0200] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0200', callback);
console.info('[context_getAppVersionInfo_test_0200] FINISH');
done();
});
function checkAppVersionInfo(msg, data) {
console.log(msg + "checkAppVersionInfo start : " + JSON.stringify(data));
console.log(msg + "checkAppVersionInfo appName : " + data.appName);
console.log(msg + "checkAppVersionInfo versionCode : " + data.versionCode);
console.log(msg + "checkAppVersionInfo versionName : " + data.versionName);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.appName)).assertEqual("string");
expect(typeof (data.versionCode)).assertEqual("number");
expect(typeof (data.versionName)).assertEqual("string");
expect(data.appName).assertEqual("");
expect(data.versionCode).assertEqual(1000000);
expect(data.versionName).assertEqual("1.0.0");
console.log(msg + "---checkAppVersionInfo End--- ");
}
})
}
\ 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getApplicationContext_test_0100
* @tc.name: getApplicationContext:Gets the application context information.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getApplicationContext_test_0100', 0, async function (done) {
try {
console.info('[context_getApplicationContext_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext().getApplicationContext();
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getApplicationContext_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getApplicationContext_test_0100] data is:' + JSON.stringify(context));
}
catch (error) {
console.error('[context_getApplicationContext_test_0100] failed:' + JSON.stringify(error));
}
expect(typeof (context)).assertEqual("object");
console.info('[context_getApplicationContext_test_0100] FINISH');
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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 featureAbility from "@ohos.ability.featureAbility";
import testsuite2 from "../test/List.test.ets";
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets";
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase2!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters2---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite2();
core.execute();
console.info('Operation successful2. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed2. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
}
.width('100%')
.height('100%')
}
}
\ 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 getAbilityInfoJsunit from './getAbilityInfoJsunit2.test.ets';
export default function testsuite2() {
getAbilityInfoJsunit();
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
/**
* 接口调用时间
* @param startTime 接口调用开始时间
* @param endTime 接口调用结束时间
*/
static getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
}
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getAbilityInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAbilityInfo_test_0300
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0300', 0, async function (done) {
try{
console.info('[context_getAbilityInfo_test_0300] START2');
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo((error, data)=>{
var timeNewStamp= Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0300',timeOldStamp,timeNewStamp);
console.info('[context_getAbilityInfo_test_0300] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
} catch (error){
console.error('[context_getAbilityInfo_test_0300] failed: ' + JSON.stringify(error));
}
var callback = await context.getAbilityInfo();
console.info('---[context_getAbilityInfo_test_0300] check---');
checkAbilityInfo2('context_getAbilityInfo_test_0300',callback);
console.info('[context_getAbilityInfo_test_0300] FINISH');
done();
})
function checkAbilityInfo2(msg,data) {
console.log(msg+ "checkAbilityInfo2 start " + JSON.stringify(data));
console.log(msg+ "checkAbilityInfo2 bundleName : " + data.bundleName);
console.log(msg+ "checkAbilityInfo2 name : " + data.name);
console.log(msg+ "checkAbilityInfo2 label : " + data.label);
console.log(msg+ "checkAbilityInfo2 description : " + data.description);
console.log(msg+ "checkAbilityInfo2 icon : " + data.icon);
console.log(msg+ "checkAbilityInfo2 descriptionId : " + data.descriptionId);
console.log(msg+ "checkAbilityInfo2 iconId : " + data.iconId);
console.log(msg+ "checkAbilityInfo2 moduleName : " + data.moduleName);
console.log(msg+ "checkAbilityInfo2 process : " + data.process);
console.log(msg+ "checkAbilityInfo2 targetAbility : " + data.targetAbility);
console.log(msg+ "checkAbilityInfo2 backgroundModes : " + data.backgroundModes);
console.log(msg+ "checkAbilityInfo2 isVisible : " + data.isVisible);
console.log(msg+ "checkAbilityInfo2 formEnabled : " + data.formEnabled);
console.log(msg+ "checkAbilityInfo2 type : " + data.type)
console.log(msg+ "checkAbilityInfo2 orientation : " + data.orientation);
console.log(msg+ "checkAbilityInfo2 launchMode : " + data.launchMode);
console.log(msg+ "checkAbilityInfo2 permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log(msg+ "getAbilityInfo2 data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log(msg+ "checkAbilityInfo2 deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg+ "getAbilityInfo2 data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg+ "checkAbilityInfo2 deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log(msg+ "getAbilityInfo2 data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log(msg+ "checkAbilityInfo2 readPermission : " + data.readPermission);
console.log(msg+ "checkAbilityInfo2 writePermission : " + data.writePermission);
console.log(msg+ "checkAbilityInfo2 formEntity : " + data.formEntity);
console.log(msg+ "checkAbilityInfo2 minFormHeight : " + data.minFormHeight);
console.log(msg+ "checkAbilityInfo2 defaultFormHeight : " + data.defaultFormHeight);
console.log(msg+ "checkAbilityInfo2 minFormWidth : " + data.minFormWidth);
console.log(msg+ "checkAbilityInfo2 defaultFormWidth : " + data.defaultFormWidth);
console.log(msg+ "checkAbilityInfo2 uri : " + data.uri);
console.log(msg+ "checkAbilityInfo2 customizeData : " + data.customizeData);
console.log(msg+ "checkAbilityInfo2 labelId : " + data.labelId);
console.log(msg+ "checkAbilityInfo2 subType : " + data.subType);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.targetAbility)).assertEqual("string");
expect(typeof (data.backgroundModes)).assertEqual("number");
expect(typeof (data.isVisible)).assertEqual("boolean");
expect(typeof (data.formEnabled)).assertEqual("boolean");
expect(typeof (data.type)).assertEqual("number");
expect(typeof (data.subType)).assertEqual("number");
expect(typeof (data.orientation)).assertEqual("number");
expect(typeof (data.launchMode)).assertEqual("number");
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (data.readPermission)).assertEqual("string");
expect(typeof (data.writePermission)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (data.formEntity)).assertEqual("number");
expect(typeof (data.minFormHeight)).assertEqual("number");
expect(typeof (data.defaultFormHeight)).assertEqual("number");
expect(typeof (data.minFormWidth)).assertEqual("number");
expect(typeof (data.defaultFormWidth)).assertEqual("number");
expect(typeof (data.uri)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility2");
expect(data.label).assertEqual("$string:entry_MainAbility2");
expect(data.description).assertEqual("$string:description_mainability2");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(false);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo2(msg,data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId >0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg+ "---checkAbilityInfo End--- ");
}
function checkApplicationInfo2(msg,info) {
console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg+ "checkApplicationInfo name : " + info.name);
console.log(msg+ "checkApplicationInfo description : " + info.description);
console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg+ "checkApplicationInfo enabled : " + info.enabled);
console.log(msg+ "checkApplicationInfo label : " + info.label);
console.log(msg+ "checkApplicationInfo labelId : " + info.labelId);
console.log(msg+ "checkApplicationInfo icon : " + info.icon);
console.log(msg+ "checkApplicationInfo iconId : " + info.iconId);
console.log(msg+ "checkApplicationInfo process : " + info.process);
console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName);
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir);
}
console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
if (info.moduleSourceDirs.length == 1){
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else if(info.moduleSourceDirs.length == 2) {
if (info.moduleInfos[0].moduleName == "myapplication1") {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else{
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
}else {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[2].moduleName).assertEqual("entry");
expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
console.log(msg+ "---checkApplicationInfo End--- ");
}
})
}
\ 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 rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
},
onConnect(want) {
console.info('ServiceAbility onConnect');
return new StubTest("test");
},
onDisConnect(want) {
console.info('ServiceAbility onDisConnect');
},
};
/**
* 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'
class StubTest2 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility2 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility2 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
async function sleep(time: any) {
var now = new Date();
var exitTime = now.getTime() + time;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
break;
}
console.info(`sleep ${time} over...`);
}
export default {
onStart() {
console.info('ServiceAbility2 onStart');
},
onStop() {
console.info('ServiceAbility2 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility2 onCommand');
let request = {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility",
}
let options = {
onConnect: async function (element: any, proxy: any) {
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect: async function (element1: any) {
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.deviceId : '
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.bundleName : '
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.abilityName: '
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.uri : '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.shortName : '
+ JSON.stringify(element1.shortName));
},
onFailed: async function (code: any) {
console.log('particleAbility_connectAbility_test_0100 ConnectAbility onFailed errCode : ' + code);
},
}
let connection_succeeded: any;
console.info('particleAbility_connectAbility_test_0100 start ');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0100 connectability', timeOldStamp, timeNewStamp);
connection_succeeded = connection;
console.info('particleAbility_connectAbility_test_0100 service request is:' + JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0100 options is:' + JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0100 data is: ' + JSON.stringify(connection));
console.info('particleAbility_connectAbility_test_0100 connection=: ' + connection);
sleep(5000);
console.info('particleAbility_connectAbility_test_0100 disconnectability start ');
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(connection_succeeded).then((data: any) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0100 disconnectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0100 disconnectability succeeded: ' +
JSON.stringify(data));
}).catch((error: any) => {
console.error('particleAbility_connectAbility_test_0100 disconnectability failed. Cause: ' +
JSON.stringify(error));
})
},
onConnect(want) {
console.info('ServiceAbility2 onConnect');
return new StubTest2("test");
},
};
\ 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
class StubTest3 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility3 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility3 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
async function sleep(time: any) {
var now = new Date();
var exitTime = now.getTime() + time;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
break;
}
console.info(`sleep ${time} over...`);
}
export default {
onStart() {
console.info('ServiceAbility3 onStart');
},
onStop() {
console.info('ServiceAbility3 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility3 onCommand');
let request = {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility",
}
let options = {
onConnect: async function (element: any, proxy: any) {
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId))
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName))
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName))
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri))
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName))
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect: async function (element1: any) {
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.deviceId :'
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.bundleName :'
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.abilityName :'
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.uri : '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.shortName : '
+ JSON.stringify(element1.shortName));
},
onFailed: function (code: any) {
console.log('particleAbility_connectAbility_test_0200 ConnectAbility onFailed errCode: ' + code)
},
}
let connection_succeeded: any;
console.info('particleAbility_connectAbility_test_0200 start ');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0200 connectability', timeOldStamp, timeNewStamp);
connection_succeeded = connection;
console.info('particleAbility_connectAbility_test_0200 service request is:' + JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0200 options is:' + JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0200 connection=: ' + connection);
sleep(5000);
console.info('particleAbility_connectAbility_test_0200 disconnectability start ');
try {
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(connection_succeeded, (error, data) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0200 disconnectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0200 disconnectability succeeded: ' + JSON.stringify(data));
})
}
catch(error: any){
console.error('particleAbility_connectAbility_test_0200 disconnectability failed. Cause: ' +
JSON.stringify(error));
}
},
onConnect(want) {
console.info('ServiceAbility3 onConnect');
return new StubTest3("test");
},
};
\ 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'
class StubTest4 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility4 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility4 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
async function sleep(time: any) {
var now = new Date();
var exitTime = now.getTime() + time;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
break;
}
console.info(`sleep ${time} over...`);
}
export default {
onStart() {
console.info('ServiceAbility4 onStart');
},
onStop() {
console.info('ServiceAbility4 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility4 onCommand');
let request = {
"bundleName": "com.open.harmony.packagemag",
"abilityName": "com.open.harmony.packagemag.packServiceAbility",
}
let options = {
onConnect: async function (element: any, proxy: any) {
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId))
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName))
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName))
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri))
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName))
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect: async function (element1: any) {
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.deviceId : '
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.bundleName: '
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.abilityName:'
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.uri: '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.shortName :'
+ JSON.stringify(element1.shortName));
},
onFailed: function (code: any) {
console.log('particleAbility_connectAbility_test_0300 ConnectAbility onFailed errCode : '+ code);
},
}
let connection_succeeded: any;
console.info('particleAbility_connectAbility_test_0300 start ');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0300 connectability', timeOldStamp, timeNewStamp);
connection_succeeded = connection;
console.info('particleAbility_connectAbility_test_0300 service request is:' + JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0300 options is:' + JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0300 data is: ' + JSON.stringify(connection));
console.info('particleAbility_connectAbility_test_0300 connection=: ' + connection);
sleep(5000);
console.info('particleAbility_connectAbility_test_0300 disconnectability start ');
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(connection_succeeded).then((data: any) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0300 disconnectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0300 disconnectability succeeded:'
+ JSON.stringify(data));
}).catch ((error: any) =>{
console.error('particleAbility_connectAbility_test_0300 disconnectability failed. Cause: ' +
JSON.stringify(error));
})
},
onConnect(want) {
console.info('ServiceAbility4 onConnect');
return new StubTest4("test");
},
};
\ 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'
class StubTest5 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility5 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility5 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
async function sleep(time: any) {
var now = new Date();
var exitTime = now.getTime() + time;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
break;
}
console.info(`sleep ${time} over...`);
}
export default {
onStart() {
console.info('ServiceAbility5 onStart');
},
onStop() {
console.info('ServiceAbility5 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility5 onCommand');
let request = {
"bundleName": "",
"abilityName": "",
}
let options = {
onConnect: async function (element: any, proxy: any) {
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId))
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName))
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName))
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri))
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName))
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect: function (element1: any) {
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.deviceId : '
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.bundleName: '
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.abilityName:'
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.uri : '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.shortName : '
+ JSON.stringify(element1.shortName));
},
onFailed: function (code: any) {
console.log('particleAbility_connectAbility_test_0400 ConnectAbility onFailed errCode:' + code);
},
}
let connection_succeeded: any;
console.info('particleAbility_connectAbility_test_0400 start ');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0400 connectability', timeOldStamp, timeNewStamp);
connection_succeeded = connection;
console.info('particleAbility_connectAbility_test_0400 service request is:' + JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0400 options is:' + JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0400 connection=: ' + connection);
sleep(5000);
console.info('particleAbility_connectAbility_test_0400 disconnectability start ');
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(connection_succeeded).then((data: any) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0400 disconnectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0400 disconnectability succeeded: ' +
JSON.stringify(data));
}).catch((error: any) => {
console.error('particleAbility_connectAbility_test_0400 disconnectability failed. Cause: ' +
JSON.stringify(error));
});
sleep(5000);
console.info('particleAbility_connectAbility_test_0400 disconnectability_fail start ');
try {
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(-1).then((data: any) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0400 disconnectability_fail',
timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0400 disconnectability_fail succeeded: ' +
JSON.stringify(data));
})
}
catch (error: any) {
console.error('particleAbility_connectAbility_test_0400 disconnectability_fail failed. Cause: ' +
JSON.stringify(error));
}
},
onConnect(want) {
console.info('ServiceAbility5 onConnect');
return new StubTest5("test");
},
};
\ 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'
class StubTest6 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility6 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility6 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
let request = {
"bundleName":"com.ohos.acecollaboration",
"abilityName":"com.ohos.acecollaboration.xxx",
}
let options = {
onConnect:async function (element:any, proxy:any) {
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId))
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName))
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName))
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri))
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName))
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect:function (element1:any) {
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.deviceId : '
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.bundleName: '
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.abilityName:'
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.uri : '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.shortName : '
+ JSON.stringify(element1.shortName));
},
onFailed:function (code:any) {
console.log('particleAbility_connectAbility_test_0500 ConnectAbility service onFailed errCode:' + code)
},
}
console.info('particleAbility_connectAbility_test_0500 errorabilityName start');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0500 connectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0500 errorabilityName request is:'
+ JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0500 errorabilityName options is:'
+ JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0500 errorabilityName connection=: ' + connection);
},
onConnect(want) {
console.info('ServiceAbility6 onConnect');
return new StubTest6("test");
},
};
\ 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 particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'
class StubTest7 extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility7 onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility7 op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
function getNowTime() {
return new Date().getTime();
}
function getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
async function sleep(time: any) {
var now = new Date();
var exitTime = now.getTime() + time;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
break;
}
console.info(`sleep ${time} over...`);
}
export default {
onStart() {
console.info('ServiceAbility7 onStart');
},
onStop() {
console.info('ServiceAbility7 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility7 onCommand');
let request = {
"bundleName":"com.example.myapplication",
"abilityName":"com.example.myapplication.ServiceAbility_API8",
}
let options = {
onConnect:async function (element:any, proxy:any) {
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.deviceId : '
+ JSON.stringify(element.deviceId))
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.bundleName : '
+ JSON.stringify(element.bundleName))
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.abilityName : '
+ JSON.stringify(element.abilityName))
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.uri : '
+ JSON.stringify(element.uri))
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.shortName : '
+ JSON.stringify(element.shortName))
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect proxy : '
+ JSON.stringify(proxy));
},
onDisconnect:async function (element1:any) {
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.deviceId : '
+ JSON.stringify(element1.deviceId));
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.bundleName: '
+ JSON.stringify(element1.bundleName));
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.abilityName:'
+ JSON.stringify(element1.abilityName));
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.uri : '
+ JSON.stringify(element1.uri));
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.shortName : '
+ JSON.stringify(element1.shortName));
},
onFailed:function (code:any) {
console.log('particleAbility_connectAbility_test_0600 ConnectAbility onFailed errCode:' + code);
},
}
let connection_succeeded:any;
console.info('particleAbility_connectAbility_test_0600 start ');
var timeOldStamp = getNowTime();
var connection = particleAbility.connectAbility(request, options);
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0600 connectability', timeOldStamp, timeNewStamp);
connection_succeeded = connection;
console.info('particleAbility_connectAbility_test_0600 service request is:' + JSON.stringify(request));
console.info('particleAbility_connectAbility_test_0600 options is:' + JSON.stringify(options));
console.info('particleAbility_connectAbility_test_0600 data is: ' + JSON.stringify(connection));
console.info('particleAbility_connectAbility_test_0600 connection=: ' + connection);
sleep(5000);
console.info('particleAbility_connectAbility_test_0600 disconnectability start ');
var timeOldStamp = getNowTime();
particleAbility.disconnectAbility(connection_succeeded).then((data: any) => {
var timeNewStamp = getNowTime();
getDurationTime('particleAbility_connectAbility_test_0600 disconnectability', timeOldStamp, timeNewStamp);
console.info('particleAbility_connectAbility_test_0600 disconnectability succeeded: ' +
JSON.stringify(data));
}).catch((error: any) =>{
console.error('particleAbility_connectAbility_test_0600 disconnectability failed. Cause: ' +
JSON.stringify(error));
});
},
onConnect(want) {
console.info('ServiceAbility7 onConnect');
return new StubTest7("test");
},
onDisConnect(want) {
console.info('ServiceAbility7 onDisConnect');
},
};
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "eTS_Empty Ability"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
},
{
"name": "description_serviceability2",
"value": "hap sample empty service"
},
{
"name": "description_serviceability3",
"value": "hap sample empty service"
},
{
"name": "description_serviceability4",
"value": "hap sample empty service"
},
{
"name": "description_serviceability5",
"value": "hap sample empty service"
},
{
"name": "description_mainability2",
"value": "eTS_Empty Ability2"
},
{
"name": "entry_MainAbility2",
"value": "MainAbility2"
},
{
"name": "description_serviceability6",
"value": "hap sample empty service"
},
{
"name": "description_serviceability7",
"value": "hap sample empty service"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.ohos.acecollaboration",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication1",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "myapplication1",
"moduleType": "feature",
"installationFree": false
},
"abilities": [
{
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:myapplication1_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"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('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite_app1 from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite_app1();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('myapplication1 page')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ 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 getHapModuleInfoJsunit_app1 from './getHapModuleInfoJsunit_app1.test.ets';
export default function testsuite_app1() {
getHapModuleInfoJsunit_app1();
}
\ 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 class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(reject)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
static getDurationTime(msg,startTime, endTime) {
console.info(msg+'Get Interface startTime: ' + startTime);
console.info(msg+'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg+'Get Interface Duration: ' + duration);
return duration;
}
}
/**
* 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 {describe, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getHapModuleInfo_test_0300
* @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application.
* @tc.desc: Check the return type of the interface (by Promise)
* @tc.level 0
*/
it('context_getHapModuleInfo_test_0300', 0, async function (done) {
console.info('[context_getHapModuleInfo_test_0300] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getHapModuleInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getHapModuleInfo_test_0300', timeOldStamp, timeNewStamp);
console.info('[context_getHapModuleInfo_test_0300] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
})
.catch((error) => {
console.error('[context_getHapModuleInfo_test_0300] failed:' + JSON.stringify(error));
})
var promise = await context.getHapModuleInfo();
console.info('---[context_getHapModuleInfo_test_0300] check---');
checkHapModuleInfo_app('context_getHapModuleInfo_test_0300', promise);
console.info('[context_getHapModuleInfo_test_0300] FINISH');
done();
});
function checkHapModuleInfo_app(msg, data) {
console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data));
console.log(msg + "checkHapModuleInfo name : " + data.name);
console.log(msg + "checkHapModuleInfo description : " + data.description);
console.log(msg + "checkHapModuleInfo descriptionId : " + data.descriptionId);
console.log(msg + "checkHapModuleInfo icon : " + data.icon);
console.log(msg + "checkHapModuleInfo label : " + data.label);
console.log(msg + "checkHapModuleInfo labelId : " + data.labelId);
console.log(msg + "checkHapModuleInfo iconId : " + data.iconId);
console.log(msg + "checkHapModuleInfo backgroundImg : " + data.backgroundImg);
console.log(msg + "checkHapModuleInfo supportedModes : " + data.supportedModes);
console.log(msg + "checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length);
for (var j = 0; j < data.reqCapabilities.length; j++) {
console.log(msg + "getHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]);
}
console.log(msg + "checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length);
console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName);
console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName);
console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.backgroundImg)).assertEqual("string");
expect(typeof (data.supportedModes)).assertEqual("number");
expect(Array.isArray(data.reqCapabilities)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.abilityInfos)).assertEqual(true);
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.mainAbilityName)).assertEqual("string");
expect(typeof (data.installationFree)).assertEqual("boolean");
expect(data.name).assertEqual("com.example.myapplication1");
expect(data.description).assertEqual("");
expect(data.descriptionId).assertEqual(0);
expect(data.icon).assertEqual("$media:icon");
expect(data.label).assertEqual("$string:myapplication1_MainAbility");
expect(data.labelId).assertEqual(0);
expect(data.iconId).assertEqual(0);
expect(data.backgroundImg).assertEqual("");
expect(data.supportedModes).assertEqual(0);
expect(data.deviceTypes[0]).assertEqual("phone");
checkAbilityInfo(msg,data.abilityInfos[0]);
expect(data.moduleName).assertEqual("myapplication1")
expect(data.mainAbilityName).assertEqual("");
expect(data.installationFree).assertEqual(false);
console.log(msg + "---checkHapModuleInfo End---");
}
function checkAbilityInfo(msg,data) {
console.log(msg+ "checkAbilityInfo start " + JSON.stringify(data));
console.log(msg+ "checkAbilityInfo bundleName : " + data.bundleName);
console.log(msg+ "checkAbilityInfo name : " + data.name);
console.log(msg+ "checkAbilityInfo label : " + data.label);
console.log(msg+ "checkAbilityInfo description : " + data.description);
console.log(msg+ "checkAbilityInfo icon : " + data.icon);
console.log(msg+ "checkAbilityInfo descriptionId : " + data.descriptionId);
console.log(msg+ "checkAbilityInfo iconId : " + data.iconId);
console.log(msg+ "checkAbilityInfo moduleName : " + data.moduleName);
console.log(msg+ "checkAbilityInfo process : " + data.process);
console.log(msg+ "checkAbilityInfo targetAbility : " + data.targetAbility);
console.log(msg+ "checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log(msg+ "checkAbilityInfo isVisible : " + data.isVisible);
console.log(msg+ "checkAbilityInfo formEnabled : " + data.formEnabled);
console.log(msg+ "checkAbilityInfo type : " + data.type)
console.log(msg+ "checkAbilityInfo orientation : " + data.orientation);
console.log(msg+ "checkAbilityInfo launchMode : " + data.launchMode);
console.log(msg+ "checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log(msg+ "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log(msg+ "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg+ "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg+ "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log(msg+ "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log(msg+ "checkAbilityInfo readPermission : " + data.readPermission);
console.log(msg+ "checkAbilityInfo writePermission : " + data.writePermission);
console.log(msg+ "checkAbilityInfo formEntity : " + data.formEntity);
console.log(msg+ "checkAbilityInfo minFormHeight : " + data.minFormHeight);
console.log(msg+ "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight);
console.log(msg+ "checkAbilityInfo minFormWidth : " + data.minFormWidth);
console.log(msg+ "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log(msg+ "checkAbilityInfo uri : " + data.uri);
console.log(msg+ "checkAbilityInfo labelId : " + data.labelId);
console.log(msg+ "checkAbilityInfo subType : " + data.subType);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.targetAbility)).assertEqual("string");
expect(typeof (data.backgroundModes)).assertEqual("number");
expect(typeof (data.isVisible)).assertEqual("boolean");
expect(typeof (data.formEnabled)).assertEqual("boolean");
expect(typeof (data.type)).assertEqual("number");
expect(typeof (data.subType)).assertEqual("number");
expect(typeof (data.orientation)).assertEqual("number");
expect(typeof (data.launchMode)).assertEqual("number");
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (data.readPermission)).assertEqual("string");
expect(typeof (data.writePermission)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (data.formEntity)).assertEqual("number");
expect(typeof (data.minFormHeight)).assertEqual("number");
expect(typeof (data.defaultFormHeight)).assertEqual("number");
expect(typeof (data.minFormWidth)).assertEqual("number");
expect(typeof (data.defaultFormWidth)).assertEqual("number");
expect(typeof (data.uri)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.example.myapplication1.MainAbility");
expect(data.label).assertEqual("$string:myapplication1_MainAbility");
expect(data.description).assertEqual("$string:description_mainability");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("myapplication1");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo(msg,data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId > 0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg+ "---checkAbilityInfo End--- ");
}
function checkApplicationInfo(msg,info) {
console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg+ "checkApplicationInfo name : " + info.name);
console.log(msg+ "checkApplicationInfo description : " + info.description);
console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg+ "checkApplicationInfo enabled : " + info.enabled);
console.log(msg+ "checkApplicationInfo label : " + info.label);
console.log(msg+ "checkApplicationInfo labelId : " + info.labelId);
console.log(msg+ "checkApplicationInfo icon : " + info.icon);
console.log(msg+ "checkApplicationInfo iconId : " + info.iconId);
console.log(msg+ "checkApplicationInfo process : " + info.process);
console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName);
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir);
}
console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
if (info.moduleSourceDirs.length == 1){
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else if(info.moduleSourceDirs.length == 2) {
if (info.moduleInfos[0].moduleName == "myapplication1") {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else{
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
}else {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[2].moduleName).assertEqual("entry");
expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
console.log(msg+ "---checkApplicationInfo End--- ");
}
})
}
\ No newline at end of file
{
"string": [
{
"name": "myapplication1_MainAbility",
"value": "myapplication1_MainAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
}
]
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -25,6 +25,7 @@ group("bundlemanager") {
"actsbmskittest:ActsBmsKitTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstallTest",
"actsbundlemgrmultipleinstalltest:ActsBundleMgrMultipleInstallTest",
......
......@@ -15,7 +15,7 @@
import bundle from '@ohos.bundle'
import innerBundleManager from '@ohos.bundle.innerBundleManager'
import { describe, it, expect } from 'deccjsunit/index'
import {describe, it, expect} from 'deccjsunit/index'
const STATUS_INSTALL_PERMISSION_DENIED = 0X44;
const STATUS_UNINSTALL_PERMISSION_DENIED = 0X45;
......@@ -47,7 +47,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(data.status).assertEqual(STATUS_INSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_INSTALL_PERMISSION_DENIED");
done();
};
}
});
/*
......@@ -69,7 +69,7 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(data.status).assertEqual(STATUS_UNINSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_UNINSTALL_PERMISSION_DENIED");
done();
};
}
});
/*
......@@ -144,8 +144,8 @@ describe('ActsBmsJsUnPermissionTest', function () {
it('queryAbilityByWantTest_100', 0, async function (done) {
console.debug('queryAbilityByWantTest_100 start');
bundle.queryAbilityByWant({
bundleName : LAUNCHER_BUNDLE_NAME,
abilityName : LAUNCHER_MAIN_ABILITY
bundleName: LAUNCHER_BUNDLE_NAME,
abilityName: LAUNCHER_MAIN_ABILITY
}, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => {
expect().assertFail();
done();
......@@ -211,8 +211,8 @@ describe('ActsBmsJsUnPermissionTest', function () {
it('setAbilityEnabledTest_100', 0, async function (done) {
console.debug('setAbilityEnabledTest_100 start');
let abilityInfo = {
bundleName : LAUNCHER_BUNDLE_NAME,
name : LAUNCHER_MAIN_ABILITY
bundleName: LAUNCHER_BUNDLE_NAME,
name: LAUNCHER_MAIN_ABILITY
};
bundle.setAbilityEnabled(abilityInfo, false).then(data => {
expect().assertFail();
......@@ -270,4 +270,40 @@ describe('ActsBmsJsUnPermissionTest', function () {
done();
});
});
/*
* @tc.number: getAbilityLabelTest_100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('getAbilityLabelTest_100', 0, async function (done) {
console.debug('[getAbilityLabelTest_100] promise START');
await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY)
.then((data) => {
expect().assertFail();
done();
})
.catch((error) => {
expect(error).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getAbilityInfo_100
* @tc.name: test getAbilityInfo
* @tc.desc: test getAbilityInfo
*/
it('getAbilityInfo_100', 0, async function (done) {
console.debug('getAbilityInfo_100 start');
bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
})
})
# 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("ActsBundleManagerEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBundleManagerEtsTest"
}
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for actsbundleetsgetinfotest Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.open.harmony.packagemag",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsBundleManagerEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.open.harmony.packagemag",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.packagemag",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.packagemag.MainAbility",
"deviceType": [
"phone"
],
"reqPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
}
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:mainability_description",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"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('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 router from '@system.router';
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('ACE ETS TEST 包管理 2 ')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ 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 getabilityInfo from './GetabilityInfo.test.ets';
import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets';
import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets';
import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets";
import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets";
import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets";
export default function testsuite() {
//RM.007
getApplicationInfoJsunit();
getAllAppInfoJsunit();
//RM.006
getabilityInfo();
//RM.014
getAbilityLabelJsUnit();
//RM.017
isAbilityEnableETSUnit();
isApplicationEnabledETSUnit();
}
\ No newline at end of file
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
},
{
"name": "mainability_description",
"value": "eTS_Empty Ability"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册