提交 cf17b7ea 编写于 作者: J jiyong_sd

FA ETS HAP

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: Ic9721ff429b7e56fa435919c759fe7db33f5284c
上级 c02c1604
......@@ -18,6 +18,7 @@ ohos_js_hap_suite("ActsAbilityManagerEtsTest") {
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
":hjs_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -26,6 +27,9 @@ ohos_js_hap_suite("ActsAbilityManagerEtsTest") {
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("hjs_demo_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
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",
"type": "OHJSUnitTest",
"test-timeout": "600000",
"package": "com.ohos.acecollaboration",
"shell-timeout": "60000"
"bundle-name": "com.ohos.acecollaboration",
"package-name": "com.ohos.acecollaboration",
"shell-timeout": "600000"
},
"kits": [
{
......
......@@ -16,6 +16,7 @@
"module": {
"package": "com.ohos.acecollaboration",
"name": ".MyApplication",
"srcPath": "",
"mainAbility": "com.ohos.acecollaboration.MainAbility",
"deviceType": [
"phone"
......@@ -56,6 +57,19 @@
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"srcPath": "MainAbility2",
......@@ -153,6 +167,20 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
......
......@@ -13,28 +13,10 @@
* limitations under the License.
*/
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!!!!")
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');
configService.setConfig(this)
testsuite2();
core.execute();
}
build() {
......
/**
* 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 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");
},
/**
* 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");
},
/**
* 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");
},
/**
* 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");
},
/**
* 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");
},
/**
* 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');
},
/**
* 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
/*
* Copyright (C) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
......@@ -14,7 +14,7 @@
*/
import featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets";
import {describe, beforeEach, afterEach, it, expect} from 'hypium/index';
import Utils from './Utils';
export default function ContextJsunit() {
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import {describe, it, expect} from 'hypium/index';
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
import ability_particleAbility from '@ohos.ability.particleAbility';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import {describe, it, expect} from 'hypium/index';
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import {describe, it, expect} from 'hypium/index';
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import {describe, it, expect} from 'hypium/index';
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import {describe, it, expect} from 'hypium/index';
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
......
......@@ -43,6 +43,14 @@
{
"name": "description_serviceability7",
"value": "hap sample empty service"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.ohos.acecollaboration",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"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
}
}
]
}
{
"app": {
"bundleName": "com.ohos.acecollaboration",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"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')
},
/**
* 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!!!!")
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');
configService.setConfig(this)
testsuite_app1();
core.execute();
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('myapplication1 page')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 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!!!!")
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');
configService.setConfig(this)
testsuite_app1();
core.execute();
}
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();
/**
* 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.
*/
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;
}
}
{
"string": [
{
"name": "myapplication1_MainAbility",
"value": "myapplication1_MainAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
}
]
{
"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")
......@@ -18,6 +18,7 @@ ohos_js_hap_suite("ActsBmsEtsUnPermissionTest") {
deps = [
":bms_ets_assets",
":bms_ets_resources",
":bms_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -26,6 +27,9 @@ ohos_js_hap_suite("ActsBmsEtsUnPermissionTest") {
ohos_js_assets("bms_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("bms_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("bms_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsbmsetsunpermissiontest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsBmsEtsUnPermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "120000",
"bundle-name": "com.example.actsbmsetsunpermissiontest",
"package-name": "com.example.actsbmsetsunpermissiontest",
"shell-timeout": "120000"
},
"kits": [
{
"test-file-name": [
"ActsBmsEtsUnPermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsetsunpermissiontest",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsetsunpermissiontest",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsetsunpermissiontest",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsetsunpermissiontest",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"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": ".TestAbility",
"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')
},
/*
* 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) 2022 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 from "../test/List.test.ets"
import featureAbility from "@ohos.ability.featureAbility"
@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')
const timeout=10000
configService.setConfig(timeout)
console.info('parameters---->' + JSON.stringify(Want.parameters))
configService.setConfig(Want.parameters)
testsuite()
core.execute()
console.info('Operation successful. Data: ' + JSON.stringify(Want));
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('ccc World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
/*
* Copyright (c) 2022 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.
*/
@Entry
@Component
struct MyComponent {
aboutToAppear() {
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ccc World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
/*
* Copyright (C) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index.ets"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index"
import bundle from '@ohos.bundle'
import pkg from '@system.package'
......
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ ohos_js_hap_suite("ActsBundleManagerEtsTest") {
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
":hjs_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -26,6 +27,9 @@ ohos_js_hap_suite("ActsBundleManagerEtsTest") {
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("hjs_demo_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
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",
"type": "OHJSUnitTest",
"test-timeout": "600000",
"package": "com.open.harmony.packagemag",
"shell-timeout": "60000"
"bundle-name": "com.open.harmony.packagemag",
"package-name": "com.open.harmony.packagemag",
"shell-timeout": "600000"
},
"kits": [
{
......
......@@ -16,6 +16,7 @@
"module": {
"package": "com.open.harmony.packagemag",
"name": ".MyApplication",
"srcPath": "",
"mainAbility": "com.open.harmony.packagemag.MainAbility",
"deviceType": [
"phone"
......@@ -60,6 +61,19 @@
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
......@@ -83,6 +97,20 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -14,10 +14,6 @@
*/
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 = {
......@@ -35,28 +31,6 @@ async function routePage() {
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() {
......
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
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
/*
* Copyright (C) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
......@@ -15,7 +15,7 @@
import bundle from '@ohos.bundle'
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
const BUNDLE_NAME = "com.open.harmony.packagemag";
const ABILITIY_NAME = "com.open.harmony.packagemag.MainAbility";
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import bundleMgr from '@ohos.bundle';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index';
const NAME1 = "com.example.third1";
const NAME2 = "com.example.l3jsdemo";
......
......@@ -14,7 +14,7 @@
*/
import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
const BUNDLE_NAME1 = 'com.ohos.launcher';
const BUNDLE_NAME2 = 'com.open.harmony.packagemag';
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import bundleManager from '@ohos.bundle';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from 'deccjsunit/index.ets';
import { describe, it, expect } from 'hypium/index';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
......
......@@ -15,6 +15,14 @@
{
"name": "description_serviceability",
"value": "hap sample empty service"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ 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")
......@@ -18,6 +18,7 @@ ohos_js_hap_suite("AceEtsComponentTest") {
deps = [
":ace_ets_component_assets",
":ace_ets_component_resources",
":ace_ets_component_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -26,6 +27,9 @@ ohos_js_hap_suite("AceEtsComponentTest") {
ohos_js_assets("ace_ets_component_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("ace_ets_component_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("ace_ets_component_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
......
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1200000",
"package": "com.open.harmony.acetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"AceEtsComponentTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1200000",
"bundle-name": "com.open.harmony.acetest",
"package-name": "com.open.harmony.acetest",
"shell-timeout": "1200000"
},
"kits": [
{
"test-file-name": [
"AceEtsComponentTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.open.harmony.acetest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.acetest",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.acetest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/appear",
"pages/areaChange",
"pages/ellipse",
"pages/enable",
"pages/flex",
"pages/gauge",
"pages/global",
"pages/gridContainer",
"pages/gridSettings",
"pages/imageEffects",
"pages/layoutConstraints",
"pages/list",
"pages/marquee",
"pages/overlay",
"pages/stepper",
"pages/swiper",
"pages/textStyle",
"pages/touchAble",
"pages/touch",
"pages/visibility",
"pages/zIndex"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
{
"app": {
"bundleName": "com.open.harmony.acetest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.acetest",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.acetest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/appear",
"pages/areaChange",
"pages/ellipse",
"pages/enable",
"pages/flex",
"pages/gauge",
"pages/global",
"pages/gridContainer",
"pages/gridSettings",
"pages/imageEffects",
"pages/layoutConstraints",
"pages/list",
"pages/marquee",
"pages/overlay",
"pages/stepper",
"pages/swiper",
"pages/textStyle",
"pages/touchAble",
"pages/touch",
"pages/visibility",
"pages/zIndex"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
// @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 {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
// @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 {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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.
*/
import events_emitter from '@ohos.emitter'
import prompt from '@system.prompt'
@Entry
@Preview
@Component
struct AppearExample {
@State isShow: boolean = true
@State appearFlag: boolean = false
@State disAppearFlag: boolean = false
private changeAppear: string = 'Hide Text'
private myText: string = 'Text for onAppear'
onPageShow() {
console.info('[appear] page show called');
var stateChangeEvent = {
eventId: 58,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[appear] page stateChangCallBack");
if (eventData != null) {
console.info("[appear] page state change called:" + JSON.stringify(eventData));
if (eventData.data.isShow != null) {
this.isShow = eventData.data.isShow;
}
}
}
build() {
Column() {
Button(this.changeAppear)
.key('appear')
.onClick(() => {
this.isShow = !this.isShow
}).margin(3).backgroundColor(0x2788D9)
if (this.isShow) {
Text(this.myText)
.onAppear(() => {
this.appearFlag = true
this.changeAppear = 'Show Text'
console.info('appearFlag current action state is: ' + this.appearFlag);
prompt.showToast({ message: 'The text is shown', duration: 2000 })
try {
var backData = {
data: {
"ACTION": this.appearFlag,
}
}
var backEvent = {
eventId: 59,
priority: events_emitter.EventPriority.LOW
}
console.info("appearFlag start to emit action state")
events_emitter.emit(backEvent, backData)
} catch {
console.info("appearFlag emit action state err: " + JSON.stringify(err.message))
}
})
.onDisAppear(() => {
this.disAppearFlag = true
this.changeAppear = 'Hide Text'
console.info('disAppearFlag current action state is: ' + this.disAppearFlag);
prompt.showToast({ message: 'The text is hidden', duration: 2000 })
try {
var backData = {
data: {
"ACTION": this.disAppearFlag,
}
}
var backEvent = {
eventId: 60,
priority: events_emitter.EventPriority.LOW
}
console.info("disAppearFlag start to emit action state")
events_emitter.emit(backEvent, backData)
} catch {
console.info("disAppearFlag emit action state err: " + JSON.stringify(err.message))
}
})
}
}.padding(30).width('100%')
}
// @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.
*/
import events_emitter from '@ohos.emitter'
import prompt from '@system.prompt'
@Entry
@Preview
@Component
struct AppearExample {
@State isShow: boolean = true
@State appearFlag: boolean = false
@State disAppearFlag: boolean = false
private changeAppear: string = 'Hide Text'
private myText: string = 'Text for onAppear'
onPageShow() {
console.info('[appear] page show called');
var stateChangeEvent = {
eventId: 58,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[appear] page stateChangCallBack");
if (eventData != null) {
console.info("[appear] page state change called:" + JSON.stringify(eventData));
if (eventData.data.isShow != null) {
this.isShow = eventData.data.isShow;
}
}
}
build() {
Column() {
Button(this.changeAppear)
.key('appear')
.onClick(() => {
this.isShow = !this.isShow
}).margin(3).backgroundColor(0x2788D9)
if (this.isShow) {
Text(this.myText)
.onAppear(() => {
this.appearFlag = true
this.changeAppear = 'Show Text'
console.info('appearFlag current action state is: ' + this.appearFlag);
prompt.showToast({ message: 'The text is shown', duration: 2000 })
try {
var backData = {
data: {
"ACTION": this.appearFlag,
}
}
var backEvent = {
eventId: 59,
priority: events_emitter.EventPriority.LOW
}
console.info("appearFlag start to emit action state")
events_emitter.emit(backEvent, backData)
} catch {
console.info("appearFlag emit action state err: " + JSON.stringify(err.message))
}
})
.onDisAppear(() => {
this.disAppearFlag = true
this.changeAppear = 'Hide Text'
console.info('disAppearFlag current action state is: ' + this.disAppearFlag);
prompt.showToast({ message: 'The text is hidden', duration: 2000 })
try {
var backData = {
data: {
"ACTION": this.disAppearFlag,
}
}
var backEvent = {
eventId: 60,
priority: events_emitter.EventPriority.LOW
}
console.info("disAppearFlag start to emit action state")
events_emitter.emit(backEvent, backData)
} catch {
console.info("disAppearFlag emit action state err: " + JSON.stringify(err.message))
}
})
}
}.padding(30).width('100%')
}
}
\ 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.
*/
import events_emitter from '@ohos.emitter';
@Entry
@Component
struct AreaExample {
@State value: string = 'Text';
@State size: string = '';
@State onActionCalled: boolean = false;
build() {
Column() {
Text(this.value)
.key('text1')
.backgroundColor(Color.Green)
.margin(30)
.fontSize(20)
.onClick(() => {
this.value = this.value + 'Text'
try {
var backData = {
data: {
"value": this.value,
}
}
var backEvent = {
eventId: 61,
priority: events_emitter.EventPriority.LOW
}
console.info("onClick start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onClick emit action state err: " + JSON.stringify(err.message))
}
})
.onAreaChange((oldValue: Area, newValue: Area) => {
console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} newvalue is ${JSON.stringify(newValue)}`)
this.size = JSON.stringify(newValue)
this.onActionCalled = true;
console.info('onAreaChange current action state is: ' + this.onActionCalled);
try {
var backData = {
data: {
"ACTION": this.onActionCalled,
}
}
var backEvent = {
eventId: 62,
priority: events_emitter.EventPriority.LOW
}
console.info("onAreaChange start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onAreaChange emit action state err: " + JSON.stringify(err.message))
}
})
Text('new area is: \n' + this.size)
.key('text2')
.margin({ right: 30, left: 30 })
}
.width('100%').height('100%').margin({ top: 30 })
}
// @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.
*/
import events_emitter from '@ohos.emitter';
@Entry
@Component
struct AreaExample {
@State value: string = 'Text';
@State size: string = '';
@State onActionCalled: boolean = false;
build() {
Column() {
Text(this.value)
.key('text1')
.backgroundColor(Color.Green)
.margin(30)
.fontSize(20)
.onClick(() => {
this.value = this.value + 'Text'
try {
var backData = {
data: {
"value": this.value,
}
}
var backEvent = {
eventId: 61,
priority: events_emitter.EventPriority.LOW
}
console.info("onClick start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onClick emit action state err: " + JSON.stringify(err.message))
}
})
.onAreaChange((oldValue: Area, newValue: Area) => {
console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} newvalue is ${JSON.stringify(newValue)}`)
this.size = JSON.stringify(newValue)
this.onActionCalled = true;
console.info('onAreaChange current action state is: ' + this.onActionCalled);
try {
var backData = {
data: {
"ACTION": this.onActionCalled,
}
}
var backEvent = {
eventId: 62,
priority: events_emitter.EventPriority.LOW
}
console.info("onAreaChange start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onAreaChange emit action state err: " + JSON.stringify(err.message))
}
})
Text('new area is: \n' + this.size)
.key('text2')
.margin({ right: 30, left: 30 })
}
.width('100%').height('100%').margin({ top: 30 })
}
}
\ 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')
},
// @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.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册