提交 d0241e07 编写于 作者: C chengxingzhen

xts-startAbilityByCall接口覆盖

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 ff258d04
......@@ -26,6 +26,7 @@ group("ability_runtime") {
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"actsabilityusertest:ActsAbilityuserTest",
"actscalldataabilitytest:ActsCallDataAbilityTest",
"actscalltest:actscalltest",
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
......
......@@ -138,37 +138,5 @@ export default function ActsAmsCallBackFifthScene() {
}
);
})
/*
* @tc.number : Acts_Ams_test_6700
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_6700', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_6700 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_6700 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
}
);
})
})
}
\ No newline at end of file
......@@ -82,36 +82,5 @@ export default function ActsAmsCallBackFirstScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_0300
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_0300', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_0300 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -133,36 +133,5 @@ export default function ActsAmsCallBackFourthScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_5100
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_5100', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_5100 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_5100 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -99,36 +99,5 @@ export default function ActsAmsCallBackSecondScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_1900
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_1900', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_1900 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1900 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -93,36 +93,5 @@ export default function ActsAmsCallBackThirdScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_3500
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_3500', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_3500 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_3500 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -149,32 +149,5 @@ export default function ActsAmsTestFifthScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_0200
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_0200', 0, async function (done) {
let info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -83,32 +83,5 @@ export default function ActsAmsTestFirstScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_0200
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_0200', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -152,35 +152,5 @@ export default function ActsAmsTestFourthScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_1800
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_1800', 0, async function (done) {
console.info("sleep begin");
sleep(2000);
console.info("sleep end");
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1800 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -105,32 +105,5 @@ export default function ActsAmsTestSecondScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_1800
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_1800', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1800 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -107,34 +107,5 @@ export default function ActsAmsTestThirdScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_3400
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_3400', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
console.info('Acts_Ams_test_3400 getProcessRunningInformation JSON String: \
' + JSON.stringify(info));
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_3400 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ 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("//test/xts/tools/build/suite.gni")
group("actscalltest") {
testonly = true
if (is_standard_system) {
deps = [
"systemappcalleea:ActsSystemAppCalleeARelyHap",
"systemappcallera:ActsSystemAppCallerARelyHap",
"systemappcallerb:ActsSystemAppCallerBRelyHap",
"systemappcallerc:ActsSystemAppCallerCRelyHap",
"systemcallentrytest:ActsCallTestEntryTest",
"systemcallfeature:ActsCallTestFeatureRelyHap",
"thirdappa:ActsThirdAppARelyHap",
"thirdcalltest:ActsThirdCallTest",
]
}
}
{
"app":{
"bundleName":"com.example.systemappcalleea",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsSystemAppCalleeARelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcalleea_js_assets",
":systemappcalleea_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCalleeARelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcalleea_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcalleea_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcalleea_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcalleea_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
var event_case2000 = "call_case2000_test";
var subscribeInfo = {
events: [event_case2000, ],
};
var subscriber;
function test2200ReleaseCallback(data) {
console.log('SystemAppCalleeA MainAbility test2200ReleaseCallback:' + data);
test2200ReleaseFlag = data.toString();
}
var test2200ReleaseFlag = '';
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class MainAbility extends Ability {
test2200(data) {
console.log("SystemAppCalleeA MainAbility test2200");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let want = {
bundleName: "com.example.systemappcalleea",
abilityName: "com.example.systemappcalleea.SecondAbility",
};
console.log("SystemAppCalleeA MainAbility test2200 before startAbilityByCall");
let resultData = new MySequenceable(0, '', '');
globalThis.abilityContext.startAbilityByCall(want).then((caller) => {
let param = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", '');
caller.onRelease(test2200ReleaseCallback);
caller.callWithResult('test2200', param).then((data2) => {
data2.readSequenceable(resultData);
caller.release();
for (let start=Date.now(); Date.now() - start <= 200;);
resultData.result = test2200ReleaseFlag;
let commonEventData = {
parameters: {
num: resultData.num,
str: resultData.str,
result: resultData.result,
}
};
commonEvent.publish('call_case2200_test_result', commonEventData, (err) => {
console.log('SystemAppCalleeA publish call_case2200_test_result event')
})
});
});
return resultData;
}
subscribeCallBack(err, data) {
console.log('SystemAppCalleeA MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_case2000:
globalThis.abilityContext.terminateSelf();
break;
default:
console.log('SystemAppCalleeA MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('test2200', this.test2200);
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCalleeA MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
});
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA MainAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class SecondAbility extends Ability {
test2200(data) {
console.log("SystemAppCalleeA SecondAbility test2200");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let result = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", '');
return result;
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext2 = this.context;
this.callee.on('test2200', this.test2200);
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA SecondAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA SecondAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA ThirdAbility onCreate")
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
globalThis.abilityWant = want;
globalThis.abilityContext3 = this.context;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA ThirdAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA ThirdAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA ThirdAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA ThirdAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA ThirdAbility onBackground")
}
};
/*
* 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';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcalleea.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemappcalleea.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.systemappcalleea.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallera",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsSystemAppCallerARelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallera_js_assets",
":systemappcallera_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerARelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallera_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallera_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallera_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallera_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
console.log("SystemAppCallerA MainAbility getCaller");
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerA MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerA MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerA MainAbility caller error in stressCall');
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerA", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerA MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerA MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerA MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function startNext(context) {
console.log("SystemAppCallerA MainAbility startNext");
let want = {
bundleName: "com.example.systemappcallerb",
abilityName: "com.example.systemappcallerb.MainAbility",
parameters: {case_num: "case5600"},
}
context.startAbility(want,
(err) => {console.log("SystemAppCallerA MainAbility startAbility callback");});
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerA MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerA MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerA MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
startNext(this.context);
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA MainAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class SecondAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA SecondAbility onForeground");
if ((globalThis.abilityWant.parameters.case_num == "case0700") ||
(globalThis.abilityWant.parameters.case_num == "case0800")) {
console.log("SystemAppCallerA SecondAbility special process in");
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA SecondAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA SecondAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA ThirdAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA ThirdAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA ThirdAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA ThirdAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA ThirdAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA ThirdAbility onForeground");
if ((globalThis.abilityWant.parameters.case_num == "case0700") ||
(globalThis.abilityWant.parameters.case_num == "case0800")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA ThirdAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA ThirdAbility onBackground")
}
};
/*
* 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';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallera.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemappcallera.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.systemappcallera.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallerb",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsSystemAppCallerBRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallerb_js_assets",
":systemappcallerb_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerBRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallerb_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallerb_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallerb_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallerb_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerB MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerB MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerB MainAbility caller error in stressCall');
return;
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerB", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerB MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerB MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerB MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function startNext(context) {
let want = {
bundleName: "com.example.systemappcallerc",
abilityName: "com.example.systemappcallerc.MainAbility",
parameters: {case_num: "case5600"},
}
context.startAbility(want,
(err) => {console.log("SystemAppCallerB MainAbility startAbility callback");});
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerB MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerB MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerB MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerB MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerB MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerB MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerB MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerB MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
startNext(this.context);
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerB MainAbility onBackground")
}
};
/*
* 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';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallerb.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallerc",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsSystemAppCallerCRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallerc_js_assets",
":systemappcallerc_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerCRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallerc_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallerc_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallerc_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallerc_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerC MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerC MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerC MainAbility caller error in stressCall');
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerC", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerC MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerC MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerC MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function triggerStressEvent() {
let commonEventData = {}
commonEvent.publish(event_call, commonEventData, (err) => {
console.log('SystemAppCallerC publish event')
})
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerC MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerC MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerC MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerC MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerC MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerC MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerC MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerC MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
for (let start=Date.now(); Date.now() - start <= 100;);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
triggerStressEvent();
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerC MainAbility onBackground")
}
};
/*
* 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';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallerc.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemcalltest",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCallTestEntryTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemcallentrytest_js_assets",
":systemcallentrytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallTestEntryTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemcallentrytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemcallentrytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemcallentrytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemcallentrytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.systemcalltest",
"module-name": "com.example.systemcalltest",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsCallTestEntryTest.hap",
"ActsCallTestFeatureRelyHap.hap",
"ActsSystemAppCallerARelyHap.hap",
"ActsSystemAppCallerBRelyHap.hap",
"ActsSystemAppCallerCRelyHap.hap",
"ActsSystemAppCalleeARelyHap.hap",
"ActsThirdAppARelyHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
}
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
export default class MainAbility extends Ability {
test2100(data) {
console.log("SystemCallTest MainAbility test2100 begin");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
return new MySequenceable(recvData.num + 1, recvData.str + "Main", recvData.result);
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.callee = this.callee;
this.callee.on('test2100', this.test2100);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest MainAbility onBackground")
}
};
/*
* 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 '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.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.
*/
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SystemCallTest SecondAbility)')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
var callerA = "SystemAppCallerA"
var callSeqA= new Array();
var callerB = "SystemAppCallerB"
var callSeqB= new Array();
var callerC = "SystemAppCallerC"
var callSeqC= new Array();
var seq = 0;
function isArrayEqual(a1, a2) {
return a1.length==a2.length && a1.every(function(value,index) { return value === a2[index]});
}
function isArrayEqualWithoutOrder(a1, a2) {
if (a1.length != a2.length) {
return false;
}
for (let ind in a1) {
if (a2.indexOf(a1[ind]) == -1) {
return false;
};
}
return true;
}
var expectStressResult=[0,1,2,3,4,5,6,7,8,9];
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCall2(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed2';
var commonEventData = {
code: 0,
data: 'calleeCheckCall2Param',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
function test2100ReleaseCallback(data) {
console.log('SystemCallTest SecondAbility test2100ReleaseCallback:' + data);
test2100ReleaseFlag = data.toString();
}
var test2100ReleaseFlag = '';
export default class SecondAbility extends Ability {
test2100(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let want = {
bundleName: "com.example.systemcalltest",
abilityName: "com.example.systemcalltest.MainAbility",
};
console.log("SystemCallTest SecondAbility test2100 before startAbilityByCall");
let resultData = new MySequenceable(0, '', '');
globalThis.abilityContext2.startAbilityByCall(want).then((caller) => {
let param = new MySequenceable(recvData.num + 1, recvData.str + "Second", recvData.result);
caller.onRelease(test2100ReleaseCallback);
for (let start=Date.now(); Date.now() - start <= 200;);
caller.callWithResult('test2100', param).then((data2) => {
data2.readSequenceable(resultData);
caller.release();
for (let start=Date.now(); Date.now() - start <= 200;);
resultData.result = test2100ReleaseFlag;
let commonEventData = {
parameters: {
num: resultData.num,
str: resultData.str,
result: resultData.result,
}
};
commonEvent.publish('call_case2100_test_result', commonEventData, (err) => {
console.log('SystemCallTest SecondAbility publish call_case2200_test_result event');
})
});
});
return resultData;
}
testOff(data) {
let recvSequence = new MySequenceable(0, '', '');
data.readSequenceable(recvSequence);
return recvSequence;
}
stressMethod(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
console.log('SystemCallTest SecondAbility stressMethod caller ' + recvData.str);
if (recvData.str == callerA) {
callSeqA.push(recvData.num);
} else if (recvData.str == callerB) {
callSeqB.push(recvData.num);
} else if (recvData.str == callerC) {
callSeqC.push(recvData.num);
}
seq++;
if (seq >= 30) {
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerA ' + callSeqA);
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerB ' + callSeqB);
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerC ' + callSeqC);
let stressResult=isArrayEqualWithoutOrder(callSeqA, expectStressResult);
stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqB, expectStressResult);
stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqC, expectStressResult);
console.log('SystemCallTest SecondAbility stressMethod stressResult ' + stressResult);
let commonEventData = {
data: stressResult.toString(),
};
commonEvent.publish('com.example.systemcalltest.Test5600', commonEventData, (err) => {
console.log('SystemCallTest SecondAbility stress test result event');
});
seq=0;
callSeqA = [];
callSeqB = [];
callSeqC = [];
}
return recvData;
}
loopMethod(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
return new MySequenceable(recvData.num + 1, recvData.str, '');
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.secondCallee = this.callee;
globalThis.abilityContext2 = this.context;
this.callee.on('test2100', this.test2100);
this.callee.on('testOff', this.testOff);
this.callee.on('stressMethod', this.stressMethod);
this.callee.on('loopMethod', this.loopMethod);
this.callee.on('testCall', testCall);
this.callee.on('testCall2', testCall2);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest SecondAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest SecondAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ 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 '@ohos.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 it',
'-s level', '-s testType', '-s size', '-s timeout'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${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 ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.systemcalltest.MainAbility' + ' -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 end')
}
};
\ 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 { describe, afterEach, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
import missionManager from '@ohos.application.missionManager'
var sysABundleName = "com.example.systemcalltest";
var sysASecondAbilityName = "com.example.systemcalltest.SecondAbility";
var systemAppCalleeABundleName = "com.example.systemappcalleea";
var systemAppCalleeAMainAbilityName = "com.example.systemappcalleea.MainAbility";
var systemAppCalleeASecondAbilityName = "com.example.systemappcalleea.SecondAbility";
var systemAppCalleeAThirdAbilityName = "com.example.systemappcalleea.ThirdAbility";
var thirdAppABundleName = "com.example.thirdappa";
var thirdAppAMainAbilityName = "com.example.thirdappa.MainAbility";
var subscriberInfo = {
events: ["CallTest"],
};
var caseDepBundles = [];
var subscriber = null;
const ERROR_CODE_INVALID_PARAM = 401;
const ERROR_CODE_FUNC_REGISTERED = 16200004;
const ERROR_CODE_FUNC_NOT_EXIST = 16200005;
const ERROR_CODE_INNER_ERROR = 16000050;
const ERROR_CODE_TYPE_ERROR = 16000002;
class MySequenceable {
num: number = 0;
str: String = "default";
result: String = "default";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
export default function abilityTest() {
describe('ActsAbilityTest', function () {
afterEach(async (done) => {
if (subscriber != null) {
commonEvent.unsubscribe(subscriber, () => {
console.log('======>afterEach unsubscribe<=======');
});
subscriber = null;
}
setTimeout(() => {
done();
}, 200)
})
/**
* @tc.number: ACTS_CommonComponent_Call_0100
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0100 begin');
let want = {
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
}
globalThis.abilityContext.startAbilityByCall(want)
.then(data => {
console.info(`ACTS_CommonComponent_Call_0100 startAbilityByCall SUCCESS`);
expect().assertFail();
done();
})
.catch(error => {
console.info(`ACTS_CommonComponent_Call_0100 startAbilityByCall Catch error: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERROR_CODE_INNER_ERROR)
done();
});
})
/**
* @tc.number: ACTS_CommonComponent_Call_0300
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0300 begin');
caseDepBundles = [systemAppCalleeABundleName];
function unSubscribeCallBack() {
console.log('ACTS_CommonComponent_Call_0300 unSubscribeCallBack')
subscriber = null;
done();
}
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0300 releaseCallBack' + data);
commonEvent.unsubscribe(subscriber, unSubscribeCallBack);
}
function subscribeCallBack(err, data) {
console.log('ACTS_CommonComponent_Call_0300 subscribeCallBack data:' + JSON.stringify(data))
expect(data.data).assertEqual('calleeCheckCallParam');
expect(data.parameters.num).assertEqual(300);
expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0300');
expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0300processed');
console.log('ACTS_CommonComponent_Call_0300 do release');
caller.release();
}
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
caller.onRelease(releaseCallback);
let param = new MySequenceable(300, "ACTS_CommonComponent_Call_0300", 'default');
caller.call('testCall', param).then(() => {
console.log('ACTS_CommonComponent_Call_0300 call success');
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0300 call exception' + err);
expect().assertFail();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0400
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0400', 0, async function (done) {
caseDepBundles = [systemAppCalleeABundleName];
console.log('ACTS_CommonComponent_Call_0400 begin');
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0400 releaseCallBack' + data);
done();
}
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
caller.onRelease(releaseCallback);
let param = new MySequenceable(400, "ACTS_CommonComponent_Call_0400", 'default');
caller.callWithResult('testCallWithResult', param).then((data) => {
console.log('ACTS_CommonComponent_Call_0400 call success');
var result = new MySequenceable(0, '', '');
data.readSequenceable(result);
expect(result.num).assertEqual(400);
expect(result.str).assertEqual('ACTS_CommonComponent_Call_0400');
expect(result.result).assertEqual('ACTS_CommonComponent_Call_0400processed');
caller.release();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0400 call exception' + err);
expect().assertFail();
caller.release();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0500
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0500 begin');
var caller1;
var caller2;
caseDepBundles = [systemAppCalleeABundleName];
function unSubscribeCallBack() {
console.log('ACTS_CommonComponent_Call_0500 unSubscribeCallBack')
subscriber = null;
caller1.release();
done();
}
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0500 releaseCallBack' + data);
commonEvent.unsubscribe(subscriber, unSubscribeCallBack);
}
function subscribeCallBack(err, data) {
console.log('ACTS_CommonComponent_Call_0500 subscribeCallBack data:' + JSON.stringify(data))
expect(data.data).assertEqual('calleeCheckCallParam');
expect(data.parameters.num).assertEqual(500);
expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0500');
expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0500processed');
console.log('ACTS_CommonComponent_Call_0500 do release');
caller2.release();
}
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
caller1 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
caller2 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
});
caller2.onRelease(releaseCallback);
let param = new MySequenceable(500, "ACTS_CommonComponent_Call_0500", 'default');
caller2.call('testCall', param).then(() => {
console.log('ACTS_CommonComponent_Call_0500 call success');
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0500 call exception' + err);
expect().assertFail();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0600
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0600', 0, async function (done) {
caseDepBundles = [systemAppCalleeABundleName];
console.log('ACTS_CommonComponent_Call_0600 begin');
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0600 releaseCallBack' + data);
caller1.release();
done();
}
let caller1 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
let caller2 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
});
caller2.onRelease(releaseCallback);
let param = new MySequenceable(600, "ACTS_CommonComponent_Call_0600", 'default');
caller2.callWithResult('testCallWithResult', param).then((data) => {
console.log('ACTS_CommonComponent_Call_0600 call success');
var result = new MySequenceable(0, '', '');
data.readSequenceable(result);
expect(result.num).assertEqual(600);
expect(result.str).assertEqual('ACTS_CommonComponent_Call_0600');
expect(result.result).assertEqual('ACTS_CommonComponent_Call_0600processed');
caller2.release();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0600 call exception' + err);
expect().assertFail();
caller2.release();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0700
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0700', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0700 begin');
var caller;
caseDepBundles = [systemAppCalleeABundleName];
function unSubscribeCallBack() {
console.log('ACTS_CommonComponent_Call_0700 unSubscribeCallBack')
subscriber = null;
done();
}
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0700 releaseCallBack' + data);
commonEvent.unsubscribe(subscriber, unSubscribeCallBack);
}
function releaseCallback1(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0700 releaseCallBack1' + data);
setTimeout(() => {
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
caller = data;
console.log('ACTS_CommonComponent_Call_0700 caller get')
caller.onRelease(releaseCallback);
let param = new MySequenceable(700, "ACTS_CommonComponent_Call_0700", 'default');
caller.call('testCall', param).then(() => {
console.log('ACTS_CommonComponent_Call_0700 call success');
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0700 call exception' + err);
expect().assertFail();
})
})
}, 100);
}
function subscribeCallBack(err, data) {
console.log('ACTS_CommonComponent_Call_0700 subscribeCallBack data:' + JSON.stringify(data))
expect(data.data).assertEqual('calleeCheckCallParam');
expect(data.parameters.num).assertEqual(700);
expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0700');
expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0700processed');
console.log('ACTS_CommonComponent_Call_0700 do release');
caller.release();
}
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
caller = data;
console.log('ACTS_CommonComponent_Call_0700 caller get')
caller.onRelease(releaseCallback1);
caller.release();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0800
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0800', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0800 begin');
var caller;
caseDepBundles = [systemAppCalleeABundleName];
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0800 releaseCallBack' + data);
done();
}
function releaseCallback1(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0800 releaseCallBack' + data);
setTimeout(() => {
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
caller = data;
caller.onRelease(releaseCallback);
let param = new MySequenceable(800, "ACTS_CommonComponent_Call_0800", 'default');
caller.callWithResult('testCallWithResult', param).then((data) => {
console.log('ACTS_CommonComponent_Call_0800 call success');
var result = new MySequenceable(0, '', '');
data.readSequenceable(result);
expect(result.num).assertEqual(800);
expect(result.str).assertEqual('ACTS_CommonComponent_Call_0800');
expect(result.result).assertEqual('ACTS_CommonComponent_Call_0800processed');
caller.release();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0800 call exception' + err);
expect().assertFail();
caller.release();
})
});
}, 100);
}
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
caller = data;
console.log('ACTS_CommonComponent_Call_0800 caller get')
caller.onRelease(releaseCallback1);
caller.release();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_0900
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_0900', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_0900 begin');
caseDepBundles = [thirdAppABundleName];
var caller;
function unSubscribeCallBack() {
console.log('ACTS_CommonComponent_Call_0900 unSubscribeCallBack')
subscriber = null;
done();
}
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0900 releaseCallBack' + data);
commonEvent.unsubscribe(subscriber, unSubscribeCallBack);
}
function subscribeCallBack(err, data) {
console.log('ACTS_CommonComponent_Call_0900 subscribeCallBack data:' + JSON.stringify(data))
expect(data.data).assertEqual('calleeCheckCallParam');
expect(data.parameters.num).assertEqual(900);
expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0900');
expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0900processed');
console.log('AMS_CallTest_0100 do release');
caller.release();
}
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: thirdAppABundleName,
abilityName: thirdAppAMainAbilityName,
});
caller.onRelease(releaseCallback);
let param = new MySequenceable(900, "ACTS_CommonComponent_Call_0900", 'default');
caller.call('testCall', param).then(() => {
console.log('ACTS_CommonComponent_Call_0900 call success');
}).catch(err => {
console.log('ACTS_CommonComponent_Call_0900 call exception' + err);
expect().assertFail();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_1000
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_1000', 0, async function (done) {
caseDepBundles = [thirdAppABundleName];
console.log('ACTS_CommonComponent_Call_1000 begin');
var caller;
function releaseCallback(data) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_1000 releaseCallBack' + data);
done();
}
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: thirdAppABundleName,
abilityName: thirdAppAMainAbilityName,
});
caller.onRelease(releaseCallback);
let param = new MySequenceable(1000, "ACTS_CommonComponent_Call_1000", 'default');
caller.callWithResult('testCallWithResult', param).then((data) => {
console.log('ACTS_CommonComponent_Call_1000 call success');
var result = new MySequenceable(0, '', '');
data.readSequenceable(result);
expect(result.num).assertEqual(1000);
expect(result.str).assertEqual('ACTS_CommonComponent_Call_1000');
expect(result.result).assertEqual('ACTS_CommonComponent_Call_1000processed');
caller.release();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_1000 call exception' + err);
expect().assertFail();
caller.release();
})
})
/**
* @tc.number: ACTS_CommonComponent_Call_1700
* @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string.
*/
it('ACTS_CommonComponent_Call_1700', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1700 begin');
var exceptionFlag = false;
await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAThirdAbilityName,
}).then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_1700 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_TYPE_ERROR);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3100
* @tc.name: The parameter method of the Callee.on function is an empty string.
* @tc.desc: Verify that the parameter method of the Callee.on function is an empty string.
*/
it('ACTS_CommonComponent_Call_3100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3100 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3100 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on('', onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3200
* @tc.name: The parameter method of the Callee.on function is null.
* @tc.desc: Verify that the parameter method of the Callee.on function is null.
*/
it('ACTS_CommonComponent_Call_3200', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3200 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3200 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on(null, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3200 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3300
* @tc.name: The parameter method of the Caller.callWithResult function is undefined.
* @tc.desc: Verify that the parameter method of the Caller.callWithResult function is undefined.
*/
it('ACTS_CommonComponent_Call_3300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3300 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3300 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on(undefined, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3400
* @tc.name: The parameter "method" of the Callee.off function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Callee.off function is an empty string.
*/
it('ACTS_CommonComponent_Call_3400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3400 begin');
let finishFlag = 0;
try {
globalThis.callee.off('');
} catch (err) {
console.log('ACTS_CommonComponent_Call_3400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3500
* @tc.name: The parameter "method" of the Callee.off function is null.
* @tc.desc: Verify that the parameter "method" of the Callee.off function is null.
*/
it('ACTS_CommonComponent_Call_3500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3500 begin');
let finishFlag = 0;
try {
globalThis.callee.off(null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3600
* @tc.name: The parameter “method” of the Callee.off function is undefined.
* @tc.desc: Verify that the parameter “method” of the Callee.off function is undefined.
*/
it('ACTS_CommonComponent_Call_3600', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3600 begin');
let finishFlag = 0;
try {
globalThis.callee.off(undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3600 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4300
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4300 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', "");
} catch (err) {
console.log('ACTS_CommonComponent_Call_4300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4400
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4400 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4500
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4500 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5000
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5000', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5000 begin');
let finishFlag = 0;
function testCallback_5100() {
console.log('ACTS_CommonComponent_Call_5000 testCallback');
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err' + err);
expect().assertFail();
globalThis.callee.off('ACTS_CommonComponent_Call_5000');
done();
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_REGISTERED);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
globalThis.callee.off('ACTS_CommonComponent_Call_5000');
console.log('ACTS_CommonComponent_Call_5000 finished');
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5100
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5100 begin');
let finishFlag = 0;
function testCallback_5100() {
console.log('ACTS_CommonComponent_Call_5100 testCallback');
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5100', testCallback_5100);
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) {
console.log('ACTS_CommonComponent_Call_5100 first step err' + err);
expect().assertFail();
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
done();
}
try {
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) {
console.log('ACTS_CommonComponent_Call_5100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_NOT_EXIST);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
console.log('ACTS_CommonComponent_Call_5100 finished');
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5200
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5200', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5200 begin');
let exceptionFlag = false;
await globalThis.globalThis.abilityContext.startAbilityByCall(null)
.then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5200 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5300
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5300 begin');
let exceptionFlag = false;
await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: "",
abilityName: "",
}).then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INNER_ERROR);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5400
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5400 begin');
let exceptionFlag = false;
await globalThis.globalThis.abilityContext.startAbilityByCall(undefined)
.then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_5600
* @tc.name: The callee exits abnormally after the caller requests the call to be called successfully.
* @tc.desc: Verify that the caller can unregister the server's death listener.
*/
it('ACTS_CommonComponent_Call_5600', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5600 begin');
function releaseCallback(data) {
console.log('ACTS_CommonComponent_Call_5600 releaseCallBack:' + data);
expect(data).assertEqual("died");
done();
}
let bundleNameCallee = "com.example.systemappcalleea";
let abilityNameCallee = "com.example.systemappcalleea.MainAbility";
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5600 startAbilityByCall fail');
expect().assertFail();
}
try {
caller.off('release', releaseCallback);
} catch (e) {
console.log('ACTS_CommonComponent_Call_5600 Caller onRelease fail ' + e);
expect().assertFail();
done();
}
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_5700
* @tc.name: The callee exits abnormally after the caller requests the call to be called successfully.
* @tc.desc: Verify that the caller can unregister the server's death listener.
*/
it('ACTS_CommonComponent_Call_5700', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5700 begin');
function releaseCallback(data) {
console.log('ACTS_CommonComponent_Call_5700 releaseCallBack:' + data);
expect(data).assertEqual("died");
done();
}
let bundleNameCallee = "com.example.systemappcalleea";
let abilityNameCallee = "com.example.systemappcalleea.MainAbility";
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5700 startAbilityByCall fail');
expect().assertFail();
done();
}
let flag = false;
try {
caller.off('release');
} catch (e) {
console.log('ACTS_CommonComponent_Call_5700 Caller onRelease fail ' + e);
flag = true;
done();
}
})
/**
* @tc.number: ACTS_CommonComponent_Call_5800
* @tc.name: The callee exits abnormally after the caller requests the call to be called successfully.
* @tc.desc: Verify that the caller can unregister the server's death listener.
*/
it('ACTS_CommonComponent_Call_5800', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5800 begin');
function releaseCallback(data) {
console.log('ACTS_CommonComponent_Call_5800 releaseCallBack:' + data);
expect(data).assertEqual("died");
done();
}
let bundleNameCallee = "com.example.systemappcalleea";
let abilityNameCallee = "com.example.systemappcalleea.MainAbility";
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5800 startAbilityByCall fail');
expect().assertFail();
done();
}
let flag = false;
try {
caller.off('Not release', releaseCallback);
} catch (e) {
console.log('ACTS_CommonComponent_Call_5800 Caller onRelease fail ' + e);
done();
}
})
/**
* @tc.number: ACTS_CommonComponent_Call_5900
* @tc.name: The callee exits abnormally after the caller requests the call to be called successfully.
* @tc.desc: Verify that the caller can unregister the server's death listener.
*/
it('ACTS_CommonComponent_Call_5900', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5900 begin');
let bundleNameCallee = "com.example.systemappcalleea";
let abilityNameCallee = "com.example.systemappcalleea.MainAbility";
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5900 startAbilityByCall fail');
expect().assertFail();
done();
}
let flag = false;
try {
caller.off('Not release');
} catch (e) {
console.log('ACTS_CommonComponent_Call_5900 Caller onRelease fail ' + e);
done();
}
})
})
}
\ 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 abilityTest from './Ability.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "com.example.systemcalltest",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemcalltest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemcalltest.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "singleton",
"orientation": "portrait"
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.ABILITY_BACKGROUND_COMMUNICATION",
"reason":"need use ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemcalltest",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsCallTestFeatureRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemcallfeature_js_assets",
":systemcallfeature_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallTestFeatureRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemcallfeature_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemcallfeature_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemcallfeature_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemcallfeature_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest Second Hap MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
let callSeq = "";
export default class MainAbility extends Ability {
test2300(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let sendData = new MySequenceable(0, '', '');
if (recvData.num == 2300 && recvData.str == 'case2300') {
sendData.num = 0;
} else {
sendData.num = 1;
}
sendData.str = callSeq;
return sendData;
}
test4600(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let sendData = new MySequenceable(0, '', '');
if (recvData.num == 4600 && recvData.str == 'case4600') {
sendData.num = 0;
} else {
sendData.num = 1;
}
sendData.str = callSeq;
return sendData;
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest Second Hap MainAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('test2300', this.test2300);
this.callee.on('test4600', this.test4600);
callSeq = callSeq + "onCreate";
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest Second Hap MainAbility onDestroy")
callSeq = callSeq + "onDestroy";
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest Second Hap MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
callSeq = callSeq + "onWindowStageCreate";
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest Second Hap MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest Second Hap MainAbility onForeground")
callSeq = callSeq + "onForeground";
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest Second Hap MainAbility onBackground")
callSeq = callSeq + "onBackground";
}
};
/*
* 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 Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('second module')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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.
*/
@Entry
@Component
struct Second {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SystemCallTest SecondAbility)')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "com.example.second",
"process": "com.example.secondprocess",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.second.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.thirdappa",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsThirdAppARelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":thirdappa_js_assets",
":thirdappa_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsThirdAppARelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("thirdappa_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("thirdappa_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("thirdappa_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":thirdappa_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>ThirdAppA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>ThirdAppA MainAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>ThirdAppA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("ThirdAppA MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ThirdAppA MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ThirdAppA MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ThirdAppA MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ThirdAppA MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("ThirdAppA MainAbility onBackground")
}
};
/*
* 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';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.thirdappa.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.thirdcalltest",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsThirdCallTest") {
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":thirdcalltest_js_assets",
":thirdcalltest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsThirdCallTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("thirdcalltest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("thirdcalltest_js_assets") {
source_dir = "./entry/src/main/ets"
}
ohos_resources("thirdcalltest_resources") {
sources = [ "./entry/src/main/resources" ]
deps = [ ":thirdcalltest_app_profile" ]
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "100000",
"bundle-name": "com.example.thirdcalltest",
"module-name": "phone",
"shell-timeout": "60000",
"testcase-timeout": 100000
},
"kits": [
{
"test-file-name": [
"ActsThirdCallTest.hap",
"ActsSystemAppCalleeARelyHap.hap",
"ActsThirdAppARelyHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
}
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest FifthAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA FifthAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest FifthAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class FifthAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest FifthAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest FifthAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest FifthAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest FifthAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest FifthAbility onForeground")
if ((globalThis.abilityWant.parameters.case_num == "case1300") ||
(globalThis.abilityWant.parameters.case_num == "case1400")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA FifthAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest FifthAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest ForthAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA ForthAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest ForthAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ForthAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest ForthAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest ForthAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest ForthAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest ForthAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest ForthAbility onForeground")
if ((globalThis.abilityWant.parameters.case_num == "case1300") ||
(globalThis.abilityWant.parameters.case_num == "case1400")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA ForthAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest ForthAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("ThirdCallTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.callee = this.callee;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ThirdCallTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ThirdCallTest MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ThirdCallTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ThirdCallTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("ThirdCallTest MainAbility onBackground")
}
};
/*
* 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 '@ohos/hypium'
import testsuite from '../../../test/List.test'
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class SecondAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest SecondAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest SecondAbility onForeground")
if ((globalThis.abilityWant.parameters.case_num == "case1300") ||
(globalThis.abilityWant.parameters.case_num == "case1400")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA SecondAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest SecondAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.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) 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 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 it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${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 ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.thirdcalltest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
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 end')
}
};
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA ThirdAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest ThirdAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest ThirdAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest ThirdAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest ThirdAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest ThirdAbility onForeground")
if ((globalThis.abilityWant.parameters.case_num == "case1300") ||
(globalThis.abilityWant.parameters.case_num == "case1400")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA ThirdAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest ThirdAbility onBackground")
}
};
/*
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
const MAX_MISSION_NUM = 1024;
var systemAppCalleeABundleName = "com.example.systemappcalleea";
var systemAppCalleeAMainAbilityName = "com.example.systemappcalleea.MainAbility";
var thirdAppABundleName = "com.example.thirdappa";
var thirdAppAMainAbilityName = "com.example.thirdappa.MainAbility";
var thirdCallTestBundleName = "com.example.thirdcalltest";
var thirdCallTestMainAbilityName = "com.example.thirdcalltest.MainAbility";
var thirdCallTestSecondAbilityName = "com.example.thirdcalltest.SecondAbility";
var thirdCallTestThirdAbilityName = "com.example.thirdcalltest.ThirdAbility";
var thirdCallTestForthAbilityName = "com.example.thirdcalltest.ForthAbility";
var thirdCallTestFifthAbilityName = "com.example.thirdcalltest.FifthAbility";
var subscriberInfo = {
events: ["CallTest"],
};
class MySequenceable {
num: number = 0;
str: string = "default";
result: string = "default";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function delay(time) {
let delta;
if (typeof time != 'number' || time <= 0) {
delta = 100;
} else {
delta = Math.round(time);
}
for (let start = Date.now(); Date.now() - start <= delta; );
}
export default function abilityTest() {
describe('ActsAbilityTest', function () {
beforeEach(async (done) => {
done();
})
afterEach(async (done) => {
setTimeout(() => {
done();
}, 500)
})
/**
* @tc.number: ACTS_CommonComponent_Call_1100
* @tc.name: The thirdApp is not allowed to startAbilityByCall.
* @tc.desc: Verify that the thirdApp is not allowed to startAbilityByCall.
*/
it('ACTS_CommonComponent_Call_1100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1100 begin');
let want = {
bundleName: thirdCallTestBundleName,
abilityName: thirdCallTestForthAbilityName,
}
globalThis.abilityContext.startAbilityByCall(want)
.then(data => {
console.info(`ACTS_CommonComponent_Call_1100 startAbilityByCall SUCCESS`);
expect().assertFail();
done();
})
.catch(error => {
console.info(`ACTS_CommonComponent_Call_1100 startAbilityByCall Catch`);
done();
});
})
/**
* @tc.number: ACTS_CommonComponent_Call_1500
* @tc.name: The thirdApp is not allowed to startAbilityByCall.
* @tc.desc: Verify that the thirdApp is not allowed to startAbilityByCall.
*/
it('ACTS_CommonComponent_Call_1500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1500 begin');
let want = {
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
}
globalThis.abilityContext.startAbilityByCall(want)
.then(data => {
console.info(`ACTS_CommonComponent_Call_1500 startAbilityByCall SUCCESS`);
expect().assertFail();
done();
})
.catch(error => {
console.info(`ACTS_CommonComponent_Call_1500 startAbilityByCall Catch`);
done();
});
})
/**
* @tc.number: ACTS_CommonComponent_Call_1600
* @tc.name: The thirdApp is not allowed to startAbilityByCall.
* @tc.desc: Verify that the thirdApp is not allowed to startAbilityByCall.
*/
it('ACTS_CommonComponent_Call_1600', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1600 begin');
let want = {
bundleName: thirdAppABundleName,
abilityName: thirdAppAMainAbilityName,
}
globalThis.abilityContext.startAbilityByCall(want)
.then(data => {
console.info(`ACTS_CommonComponent_Call_1600 startAbilityByCall SUCCESS`);
expect().assertFail();
done();
})
.catch(error => {
console.info(`ACTS_CommonComponent_Call_1600 startAbilityByCall Catch`);
done();
});
})
})
}
\ 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 abilityTest from './Ability.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.thirdcalltest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.thirdcalltest.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.thirdcalltest.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard"
},
{
"name": "com.example.thirdcalltest.ForthAbility",
"srcEntrance": "./ets/ForthAbility/ForthAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.thirdcalltest.FifthAbility",
"srcEntrance": "./ets/FifthAbility/FifthAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -104,6 +104,13 @@ export default class MainAbility extends Ability {
console.log("actsspecifytesthap onForeground")
callBackSeq += "onForeground";
onShowProcess();
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info("actsspecifytesthap MainAbility terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info("actsspecifytesthap MainAbility terminateSelf err = " + JSON.stringify(err));
});
}, 2000)
}
onBackground() {
......
......@@ -13,25 +13,14 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { describe, afterEach, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
import missionManager from '@ohos.application.missionManager'
import appManager from '@ohos.application.appManager'
var subscriberInfoMultiInstance = {
events: ["MultiInstanceStartNext", "MultiInstanceStartFinish", "TestAppOnForeground"]
};
const START_ABILITY_TIMEOUT = 5000;
const MAX_MISSION_NUM = 1024;
function sleep(time) {
return new Promise((resove, reject) => {
setTimeout(() => {
resove("time arrived");
}, time)
})
}
async function startAbilityProcess(abilityContext, options, parameters) {
let bundleName;
......@@ -60,35 +49,12 @@ async function startAbilityProcess(abilityContext, options, parameters) {
}
}
function getMissionId() {
return new Promise(async (resolve, reject) => {
var missionId = -1;
var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM);
for (let i = 0; i < missionInfos.length; i++) {
console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i]))
if ((missionInfos[i].want.abilityName == "com.example.actsgetdisplayidtest.MainAbility") &&
(missionInfos[i].runningState == 0)) {
missionId = missionInfos[i].missionId;
break;
}
}
console.log('======>getMissionId resolve missionId<=======' + missionId);
resolve(missionId);
})
}
export default function abilityTest(abilityContext) {
describe('ActsGetDisplayIdStartAbilityTest', function () {
afterEach(async (done) => {
var testMissionId;
testMissionId = await getMissionId();
console.log('======>afterEach test missionId<=======' + testMissionId);
await missionManager.moveMissionToFront(testMissionId);
await sleep(1000)
await appManager.killProcessesByBundleName("com.example.actsspecifytesthap");
setTimeout(() => { done(); }, 1000)
setTimeout(() => { done(); }, 2000)
})
......
......@@ -58,35 +58,5 @@ describe('ActsAbilityRunningInfosTest', function () {
done();
})
})
/*
* @tc.number: ACTS_getProcessRunningInformation_0300
* @tc.name: Application running ability information query
* @tc.desc: Verify applications are started to query getProcessRunningInformation ability information
* (by promise)
*/
it('ACTS_getProcessRunningInformation_0300', 0, async function (done) {
console.log('ACTS_getProcessRunningInformation_0300====<begin');
var data = await appManager.getProcessRunningInformation()
console.info('====> ACTS_getProcessRunningInformation_0300 ====>' + JSON.stringify(data))
expect(checkRunningProcess('com.example.abilityrunninginfostest', data)).assertTrue();
done();
})
/*
* @tc.number: ACTS_getProcessRunningInformation_0400
* @tc.name: Application running ability information query
* @tc.desc: Verify applications are started to query getProcessRunningInformation ability information
* (by callback)
*/
it('ACTS_getProcessRunningInformation_0400', 0, async function (done) {
console.log('ACTS_getProcessRunningInformation_0400====<begin');
appManager.getProcessRunningInformation((err, data) => {
console.info('====> ACTS_getProcessRunningInformation_0400 ====>' + JSON.stringify(data))
expect(checkRunningProcess('com.example.abilityrunninginfostest', data)).assertTrue();
done();
})
})
})
}
......@@ -520,62 +520,6 @@ export default function ApiCoverTest() {
done()
});
/*
* @tc.number SUB_AA_Test_ProcessRunningInformation_0100
* @tc.name Test getProcessRunningInformation in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessRunningInformation_0100', 0, async function (done) {
let processRunningInformation:appManagerNew.ProcessRunningInformation;
let process;
appManagerNew.getProcessRunningInformation().then((processRunningInformations)=>{
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations));
for(let i = 0; i < processRunningInformations.length; i++){
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations[i]));
expect(processRunningInformations[i].pid).assertLarger(0)
expect(processRunningInformations[i].uid).assertLarger(0)
if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){
process = processRunningInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
}).catch((error)=>{
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(error));
expect().assertFail()
done()
})
});
/*
* @tc.number SUB_AA_Test_ProcessRunningInformation_0200
* @tc.name Test getProcessRunningInformation by callback in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessRunningInformation_0200', 0, async function (done) {
let process;
appManagerNew.getProcessRunningInformation((error, processRunningInformations)=>{
if (error) {
console.info("SUB_AA_Test_ProcessRunningInformation_0200:" + JSON.stringify(error));
expect().assertFail()
done()
}
console.info("SUB_AA_Test_ProcessRunningInformation_0200:" + JSON.stringify(processRunningInformations));
for(let i = 0; i < processRunningInformations.length; i++){
console.info("SUB_AA_Test_ProcessRunningInformation_0200:" + JSON.stringify(processRunningInformations[i]));
expect(processRunningInformations[i].pid).assertLarger(0)
expect(processRunningInformations[i].uid).assertLarger(0)
if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){
process = processRunningInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
})
});
/*
* @tc.number SUB_AA_FMS_AbilityStage_0100
* @tc.name Start AbilityStage and get config.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册