From b5e86514ee111c477e5e6ea824f4e0f41295bfbc Mon Sep 17 00:00:00 2001 From: dy Date: Mon, 7 Mar 2022 21:24:23 +0800 Subject: [PATCH] commit aafwk connect ability and context call xts Signed-off-by: dy --- .../entry/src/main/config.json | 8 + .../src/main/ets/MainAbility/pages/index.ets | 19 + .../ets/MainAbility/test/DataAbility.test.ets | 469 +++++++++++++++--- .../test/getHapModuleInfoJsunit.test.ets | 226 ++++++++- .../test/getAbilityInfoJsunit2.test.ets | 2 +- .../src/main/ets/ServiceAbility2/service.ts | 62 ++- .../src/main/ets/ServiceAbility3/service.ts | 57 ++- .../src/main/ets/ServiceAbility4/service.ts | 96 ++-- .../src/main/ets/ServiceAbility5/service.ts | 82 +-- .../src/main/ets/ServiceAbility6/service.ts | 40 +- .../src/main/ets/ServiceAbility7/service.ts | 135 +++++ .../main/resources/base/element/string.json | 4 + .../myapplication1/src/main/config.json | 57 +++ .../src/main/ets/MainAbility/app.ets | 8 + .../src/main/ets/MainAbility/pages/index.ets | 43 ++ .../main/ets/MainAbility/test/List.test.ets | 23 + .../src/main/ets/MainAbility/test/Utils.ets | 43 ++ .../test/getHapModuleInfoJsunit_app1.test.ets | 303 +++++++++++ .../main/resources/base/element/string.json | 12 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes 20 files changed, 1461 insertions(+), 228 deletions(-) create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json create mode 100644 aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json index 7232631b8..0fb6c3d49 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json @@ -110,6 +110,14 @@ "srcLanguage": "ets", "description": "$string:description_serviceability6", "type": "service" + }, + { + "srcPath": "ServiceAbility7", + "name": ".ServiceAbility7", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability7", + "type": "service" } ], "js": [ diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets index 30641fad2..a4ac01114 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets @@ -67,6 +67,16 @@ async function startService6(){ var data = featureAbility.startAbility(str); console.info('particleAbility_connectAbility_test_0500 startAbility succeeded: ' + JSON.stringify(data)); } +async function startService7(){ + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility7", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0600 startAbility succeeded: ' + JSON.stringify(data)); +} @Entry @Component @@ -145,6 +155,15 @@ struct MyComponent { .onClick(() => { startService6(); }); + Button('connectAPI8') + .fontSize(40) + .height(40) + .margin({top:20}) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService7(); + }); + } .width('100%') .height('100%') diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets index e795b53ec..2bd64f83f 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets @@ -19,6 +19,7 @@ import {describe, expect, it} from 'deccjsunit/index.ets' const URI_CONTACTS = 'dataability:///com.ohos.contactsdataability'; const contactUri = 'dataability:///com.ohos.contactsdataability/contacts/groups'; +const contactUri2 = 'dataability:///com.ohos.contactsdataability/contacts/groups2'; import Utils from './Utils'; const INSERT_ONE = 'dataAbility_insert_test '; @@ -52,23 +53,22 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(INSERT_ONE + '001', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(INSERT_ONE + '001 start......'); var timeOldStamp = await Utils.getNowTime(); dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(INSERT_ONE + '001', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(INSERT_ONE + '001 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(INSERT_ONE + '001 succeeded data: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result > 0).assertTrue(); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); done(); console.log(INSERT_ONE + '001 end ......'); }); @@ -80,7 +80,7 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(INSERT_ONE + '002', 0, async function (done) { - let detailed; + let details; let wrong; console.log(INSERT_ONE + '002 start......'); pacMap.group_name = 'test2'; @@ -88,20 +88,107 @@ export default function DataAbilityJsunit() { dataAbilityHelper.call(contactUri, 'insert', '', pacMap).then((data) => { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(INSERT_ONE + '002', timeOldStamp, timeNewStamp); - detailed = data; + details = data; console.info(INSERT_ONE + '002 succeeded data: ' + JSON.stringify(data)); }).catch((error) => { wrong = error; console.error(INSERT_ONE + '002 error: ' + JSON.stringify(error)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result > 0).assertTrue(); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); done(); console.log(INSERT_ONE + '002 end......'); }); + + /* + * @tc.number: dataAbility_insert_test_003 + * @tc.name: call : Inserts a incorrect uri data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '003', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '003 start......'); + dataAbilityHelper.call(contactUri2, 'insert', '', pacMap).then((data) => { + details = data + console.info(INSERT_ONE + '003 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '003 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 1); + } else { + expect(typeof (wrong)).assertEqual('number'); + expect(wrong == -1).assertTrue(); + } + done(); + console.log(INSERT_ONE + '003 end......'); + }); + + /* + * @tc.number: dataAbility_insert_test_004 + * @tc.name: call : Inserts a null uri data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '004', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '004 start......'); + dataAbilityHelper.call('', 'insert', '', pacMap).then((data) => { + details = data; + console.info(INSERT_ONE + '004 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '004 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 1); + } else { + expect(typeof (wrong)).assertEqual('number'); + expect(wrong < 0).assertTrue(); + } + done(); + console.log(INSERT_ONE + '004 end......'); + }); + + /* + * @tc.number: dataAbility_insert_test_005 + * @tc.name: call : Inserts a null methold data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '005', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '005 start......'); + let pacMap = { + 'group_name': 'test4', + 'ringtone_modify_time': 28 + }; + dataAbilityHelper.call(contactUri, "", "", pacMap).then((data) => { + details = data; + console.info(INSERT_ONE + '005 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '005 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 1); + } else { + expect(typeof (wrong)).assertEqual('number'); + expect(wrong == -1).assertTrue(); + } + done(); + console.log(INSERT_ONE + '005 end......'); + }); + /* * @tc.number: dataAbility_query_test_001 * @tc.name: call : Queries data in the database. @@ -109,7 +196,7 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(QUERY_TWO + '001', 0, async function (done) { - let detailed; + let details; let wrong; console.log(QUERY_TWO + '001 start......'); let arg = "{\"equalTo\": \"group_name\"}"; @@ -124,14 +211,12 @@ export default function DataAbilityJsunit() { wrong = err; if (wrong) { console.error(QUERY_TWO + '001 error: ' + JSON.stringify(wrong)); - return; } - detailed = data; + details = data; console.info(QUERY_TWO + '001 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("string"); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 4); done(); console.log(QUERY_TWO + '001 end......'); }); @@ -143,7 +228,7 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(QUERY_TWO + '002', 0, async function (done) { - let detailed; + let details; let wrong; console.log(QUERY_TWO + '002 start......'); let arg = "{\"between\": \"ringtone_modify_time\"}"; @@ -158,14 +243,12 @@ export default function DataAbilityJsunit() { wrong = err; if (wrong) { console.error(QUERY_TWO + '002 error: ' + JSON.stringify(wrong)); - return; } - detailed = data; + details = data; console.info(QUERY_TWO + '002 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("string"); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 4); done(); console.log(QUERY_TWO + '002 end......'); }); @@ -177,7 +260,7 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(QUERY_TWO + '003', 0, async function (done) { - let detailed; + let details; let wrong; console.log(QUERY_TWO + '003 start......'); let arg = { @@ -194,14 +277,12 @@ export default function DataAbilityJsunit() { wrong = err; if (wrong) { console.error(QUERY_TWO + '003 error: ' + JSON.stringify(wrong)); - return; } - detailed = data; + details = data; console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('string'); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 4); done(); console.log(QUERY_TWO + '003 end......'); }); @@ -213,7 +294,7 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(QUERY_TWO + '004', 0, async function (done) { - let detailed; + let details; let wrong; console.log(QUERY_TWO + '004 start......'); let arg = { @@ -228,17 +309,81 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(QUERY_TWO + '004', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(QUERY_TWO + '004 error: ' + JSON.stringify(err)); return; } - detailed = data; - console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data)); + details = data; + console.info(QUERY_TWO + '004 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('string'); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 4); done(); - console.log(QUERY_TWO + '003 end......'); + console.log(QUERY_TWO + '004 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_005 + * @tc.name: call : Queries abnormal data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '005', 0, async function (done) { + let details; + let wrong; + let pacMap = { + 'ringtone_modify_time': 20, + 'columns': 'group_name,ringtone_modify_time' + }; + console.log(INSERT_ONE + '003 start......'); + dataAbilityHelper.call(contactUri2, 'query', '', pacMap).then((data) => { + details = data + console.info(QUERY_TWO + '005 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(QUERY_TWO + '005 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 1); + } else { + expect(typeof (wrong)).assertEqual('number'); + expect(wrong < 0).assertTrue(); + } + done(); + console.log(QUERY_TWO + '005 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_006 + * @tc.name: call : Queries abnormal data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '006', 0, async function (done) { + let details; + let wrong; + let pacMap = { + 'ringtone_modify_time': 20, + 'columns': 'group_name,ringtone_modify_time' + }; + console.log(QUERY_TWO + '004 start......'); + dataAbilityHelper.call('', 'query', '', pacMap).then((data) => { + details = data; + console.info(QUERY_TWO + '006 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(QUERY_TWO + '006 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 1); + } else { + expect(typeof (wrong)).assertEqual('number'); + expect(wrong < 0).assertTrue(); + } + done(); + console.log(QUERY_TWO + '006 end......'); }); /* @@ -248,7 +393,8 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(UPDATE_THREE + '001', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(UPDATE_THREE + '001 start......'); let arg = "{\"equalTo\": \"ringtone_modify_time\"}"; let pacMap = { @@ -260,16 +406,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(UPDATE_THREE + '001', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(UPDATE_THREE + '001 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(UPDATE_THREE + '001 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(UPDATE_THREE + '001 end......'); }); @@ -281,7 +425,8 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(UPDATE_THREE + '002', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(UPDATE_THREE + '002 start......'); let arg = "{\"between\": \"ringtone_modify_time\"}"; let pacMap = { @@ -293,16 +438,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(UPDATE_THREE + '002', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(UPDATE_THREE + '002 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(UPDATE_THREE + '002 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(UPDATE_THREE + '002 end......'); }); @@ -314,7 +457,8 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(UPDATE_THREE + '003', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(UPDATE_THREE + '003 start......'); let arg = { 'contains': 'group_name' @@ -328,16 +472,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(UPDATE_THREE + '003', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(UPDATE_THREE + '003 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(UPDATE_THREE + '003 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('number'); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(UPDATE_THREE + '003 end......'); }); @@ -349,7 +491,8 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(UPDATE_THREE + '004', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(UPDATE_THREE + '004 start......'); let arg = { 'lessThan': 'ringtone_modify_time' @@ -363,20 +506,92 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(UPDATE_THREE + '004', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(UPDATE_THREE + '004 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(UPDATE_THREE + '004 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('number'); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(UPDATE_THREE + '004 end......'); }); + /* + * @tc.number: dataAbility_update_test_005 + * @tc.name: call : Updates abnormal data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '005', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '005 start......'); + + let pacMap = { + 'ringtone_modify_time': 32, + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri2, 'update', '', pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '005', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '005 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '005 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 3); + } else { + expect(wrong == -1).assertTrue(); + } + done(); + console.log(UPDATE_THREE + '005 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_006 + * @tc.name: call : Updates abnormal data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '006', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '006 start......'); + + let pacMap = { + 'ringtone_modify_time': 32, + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call('', 'update', '', pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '006', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '006 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '006 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 3); + } else { + expect(wrong == -1).assertTrue(); + } + done(); + console.log(UPDATE_THREE + '006 end......'); + }); + /* * @tc.number: dataAbility_delete_test_001 * @tc.name: call : Deletes one or more data records from the database. @@ -392,7 +607,8 @@ export default function DataAbilityJsunit() { }); it(DELETE_FOUR + '001', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(DELETE_FOUR + '001 start......'); let arg2 = "{\"equalTo\": \"group_name\"}"; let pacMap2 = { @@ -403,16 +619,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(DELETE_FOUR + '001', timeOldStamp, timeNewStamp); if (err2) { + wrong = err2; console.error(DELETE_FOUR + '001 error: ' + JSON.stringify(err2)); - return; } - detailed = data2; + details = data2; console.info(DELETE_FOUR + '001 succeeded: ' + JSON.stringify(data2)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(DELETE_FOUR + '001 end......'); }); @@ -424,7 +638,8 @@ export default function DataAbilityJsunit() { * @tc.level 0 */ it(DELETE_FOUR + '002', 0, async function (done) { - let detailed; + let details; + let wrong console.log(DELETE_FOUR + '002 start......'); let arg = "{\"lessThan\": \"ringtone_modify_time\"}"; let pacMap = { @@ -435,16 +650,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(DELETE_FOUR + '002', timeOldStamp, timeNewStamp); if (err) { + wrong = err; console.error(DELETE_FOUR + '002 error: ' + JSON.stringify(err)); - return; } - detailed = data; + details = data; console.info(DELETE_FOUR + '002 succeeded: ' + JSON.stringify(data)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual("object"); - expect(typeof (detailed.result)).assertEqual("number"); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(DELETE_FOUR + '002 end......'); }); @@ -464,7 +677,8 @@ export default function DataAbilityJsunit() { }); it(DELETE_FOUR + '003', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(DELETE_FOUR + '003 start......'); let arg2 = { 'like': 'group_name' @@ -477,16 +691,14 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(DELETE_FOUR + '003', timeOldStamp, timeNewStamp); if (err2) { + wrong = err2; console.error(DELETE_FOUR + '003 error: ' + JSON.stringify(err2)); - return; } - detailed = data2; + details = data2; console.info(DELETE_FOUR + '003 delete succeeded: ' + JSON.stringify(data2)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('number'); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(DELETE_FOUR + '003 delete end......'); }); @@ -505,7 +717,8 @@ export default function DataAbilityJsunit() { console.info('Operation succeeded4: ' + JSON.stringify(data)); }); it(DELETE_FOUR + '004', 0, async function (done) { - let detailed; + let details; + let wrong; console.log(DELETE_FOUR + '004 start......'); let arg2 = { 'greaterThanOrEqualTo': 'ringtone_modify_time' @@ -518,19 +731,115 @@ export default function DataAbilityJsunit() { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime(DELETE_FOUR + '004', timeOldStamp, timeNewStamp); if (err2) { + wrong = err2; console.error(DELETE_FOUR + '004 error: ' + JSON.stringify(err2)); - return; } - detailed = data2; + details = data2; console.info(DELETE_FOUR + '004 delete succeeded: ' + JSON.stringify(data2)); }); await Utils.sleep(1000); - expect(typeof (detailed)).assertEqual('object'); - expect(typeof (detailed.result)).assertEqual('number'); - expect(detailed.result).assertEqual(0); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); done(); console.log(DELETE_FOUR + '004 delete end......'); }); + + /* + * @tc.number: dataAbility_delete_test_005 + * @tc.name: call : Deletes abnormal data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { + if (err) { + console.error('Operation failed4. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded5: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '005', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '005 start......'); + let pacMap2 = { + 'ringtone_modify_time': 40 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri2, 'delete', '', pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '005', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '005 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '005 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 3); + } else { + expect(wrong == -1).assertTrue(); + } + done(); + console.log(DELETE_FOUR + '005 delete end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_006 + * @tc.name: call : Deletes abnormal data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { + if (err) { + console.error('Operation failed4. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded4: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '006', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '006 start......'); + let pacMap2 = { + 'ringtone_modify_time': 40 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call('', 'delete', '', pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '006', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '006 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '006 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + if (details != null) { + expectDetails(details, true, 3); + } else { + expect(wrong == -1).assertTrue(); + } + done(); + console.log(DELETE_FOUR + '006 delete end......'); + }); }) + + function expectDetails(data, isTrue, keyStatus) { + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.result)).assertEqual(isTrue ? 'number' : 'string'); + if (keyStatus == 1) { + expect(data.result > 0).assertTrue(); + } else if (keyStatus == 2) { + expect(data.result < 0).assertTrue(); + } else if (keyStatus == 3) { + expect(data.result).assertEqual(0); + } else { + console.log('end.........................'); + } + } } diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets index 00e6f18b6..70ad8f51d 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets @@ -53,27 +53,51 @@ export default function getHapModuleInfoJsunit() { * @tc.level 0 */ it('context_getHapModuleInfo_test_0200', 0, async function (done) { + let callback; try { console.info('[context_getHapModuleInfo_test_0200] START'); - var timeOldStamp = await Utils.getNowTime(); var context = ability_featureAbility.getContext(); context.getHapModuleInfo((error, data) => { var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('context_getHapModuleInfo_test_0200', timeOldStamp, timeNewStamp); console.info('[context_getHapModuleInfo_test_0200] data is:' + JSON.stringify(data)); + callback = data; expect(typeof (data)).assertEqual("object"); }); } catch (error) { console.error('[context_getHapModuleInfo_test_0200] failed: ' + JSON.stringify(error)); } - var callback = await context.getHapModuleInfo(); + await Utils.sleep(1000); console.info('---[context_getHapModuleInfo_test_0200] check---'); checkHapModuleInfo('context_getHapModuleInfo_test_0200', callback); console.info('[context_getHapModuleInfo_test_0200] FINISH'); done(); }); + /** + * @tc.number: context_getHapModuleInfo_test_0300_1 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0300_1', 0, async function (done) { + console.info('[context_getHapModuleInfo_test_0300_1] START'); + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.example.myapplication1.MainAbility", + }, + }; + ability_featureAbility.startAbility(str) + .then((data) => { + console.info('[context_getHapModuleInfo_test_0300_1] start myapplication1 successful: ' + JSON.stringify(data)) + }).catch((error) => { + console.error('[context_getHapModuleInfo_test_0300_1] start myapplication1 Cause: ' + JSON.stringify(error)); + }) + done(); + }); + function checkHapModuleInfo(msg, data) { console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data)); console.log(msg + "checkHapModuleInfo name : " + data.name); @@ -123,10 +147,208 @@ export default function getHapModuleInfoJsunit() { expect(data.backgroundImg).assertEqual(""); expect(data.supportedModes).assertEqual(0); expect(data.deviceTypes[0]).assertEqual("phone"); + for (var i = 0; i < data.abilityInfos.length; i++) { + console.log(msg + "-------AbilityInfo data.abilityInfos[" + i + "] : START ------" ); + checkAbilityInfo(msg,data.abilityInfos[i]); + } expect(data.moduleName).assertEqual("entry") expect(data.mainAbilityName).assertEqual(""); expect(data.installationFree).assertEqual(false); console.log(msg + "---checkHapModuleInfo End---"); } + + function checkAbilityInfo(msg,data) { + console.log(msg+ "checkAbilityInfo start " + JSON.stringify(data)); + console.log(msg+ "checkAbilityInfo bundleName : " + data.bundleName); + console.log(msg+ "checkAbilityInfo name : " + data.name); + console.log(msg+ "checkAbilityInfo label : " + data.label); + console.log(msg+ "checkAbilityInfo description : " + data.description); + console.log(msg+ "checkAbilityInfo icon : " + data.icon); + console.log(msg+ "checkAbilityInfo descriptionId : " + data.descriptionId); + console.log(msg+ "checkAbilityInfo iconId : " + data.iconId); + console.log(msg+ "checkAbilityInfo moduleName : " + data.moduleName); + console.log(msg+ "checkAbilityInfo process : " + data.process); + console.log(msg+ "checkAbilityInfo targetAbility : " + data.targetAbility); + console.log(msg+ "checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log(msg+ "checkAbilityInfo isVisible : " + data.isVisible); + console.log(msg+ "checkAbilityInfo formEnabled : " + data.formEnabled); + console.log(msg+ "checkAbilityInfo type : " + data.type) + console.log(msg+ "checkAbilityInfo orientation : " + data.orientation); + console.log(msg+ "checkAbilityInfo launchMode : " + data.launchMode); + console.log(msg+ "checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg+ "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg+ "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg+ "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg+ "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg+ "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg+ "checkAbilityInfo readPermission : " + data.readPermission); + console.log(msg+ "checkAbilityInfo writePermission : " + data.writePermission); + console.log(msg+ "checkAbilityInfo formEntity : " + data.formEntity); + console.log(msg+ "checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log(msg+ "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log(msg+ "checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log(msg+ "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log(msg+ "checkAbilityInfo uri : " + data.uri); + console.log(msg+ "checkAbilityInfo labelId : " + data.labelId); + console.log(msg+ "checkAbilityInfo subType : " + data.subType); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId).assertEqual(16777220); + expect(data.iconId).assertEqual(16777221); + expect(data.moduleName).assertEqual("entry"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo(msg,data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId).assertEqual(16777218); + expect(data.subType).assertEqual(0); + console.log(msg+ "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo(msg,info) { + console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg+ "checkApplicationInfo name : " + info.name); + console.log(msg+ "checkApplicationInfo description : " + info.description); + console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg+ "checkApplicationInfo enabled : " + info.enabled); + console.log(msg+ "checkApplicationInfo label : " + info.label); + console.log(msg+ "checkApplicationInfo labelId : " + info.labelId); + console.log(msg+ "checkApplicationInfo icon : " + info.icon); + console.log(msg+ "checkApplicationInfo iconId : " + info.iconId); + console.log(msg+ "checkApplicationInfo process : " + info.process); + console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes); + console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + + info.moduleInfos[i].moduleName); + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId).assertEqual(16777220); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.labelId).assertEqual("16777218"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.iconId).assertEqual("16777221"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + console.log(msg+ "---checkApplicationInfo End--- "); + } }) } \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets index b6c72e3e9..96062c51c 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets @@ -16,7 +16,7 @@ import {describe, it, expect} from "deccjsunit/index.ets"; import Utils from './Utils'; import ability_featureAbility from '@ohos.ability.featureAbility'; -export default function getHapModuleInfoJsunit() { +export default function getAbilityInfoJsunit() { describe('appInfoTest', function () { /** diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts index 13a986d28..a3c5e8884 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts @@ -33,6 +33,18 @@ class StubTest2 extends rpc.RemoteObject { } } +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + async function sleep(time: any) { var now = new Date(); var exitTime = now.getTime() + time; @@ -58,7 +70,7 @@ export default { "abilityName": "com.ohos.acecollaboration.ServiceAbility", } let options = { - onConnect: function (element: any, proxy: any) { + onConnect: async function (element: any, proxy: any) { console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.deviceId : ' + JSON.stringify(element.deviceId)); console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.bundleName : ' @@ -72,7 +84,7 @@ export default { console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect proxy : ' + JSON.stringify(proxy)); }, - onDisconnect: function (element1: any) { + onDisconnect: async function (element1: any) { console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.deviceId : ' + JSON.stringify(element1.deviceId)); console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.bundleName : ' @@ -84,36 +96,34 @@ export default { console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.shortName : ' + JSON.stringify(element1.shortName)); }, - onFailed: function (code: any) { + onFailed: async function (code: any) { console.log('particleAbility_connectAbility_test_0100 ConnectAbility onFailed errCode : ' + code); }, } let connection_succeeded: any; - async function connectAbility_service() { - console.info('particleAbility_connectAbility_test_0100 start '); - var connection = particleAbility.connectAbility(request, options); - connection_succeeded = connection; - console.info('particleAbility_connectAbility_test_0100 service request is:' + JSON.stringify(request)); - console.info('particleAbility_connectAbility_test_0100 options is:' + JSON.stringify(options)); - console.info('particleAbility_connectAbility_test_0100 data is: ' + JSON.stringify(connection)); - console.info('particleAbility_connectAbility_test_0100 connection=: ' + connection); - } - async function disconnectAbility_promise() { - console.info('particleAbility_connectAbility_test_0100 disconnectability start '); - await particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { - console.info('particleAbility_connectAbility_test_0100 disconnectability succeeded: ' + - JSON.stringify(data)); - }).catch((error: any) => { - console.error('particleAbility_connectAbility_test_0100 disconnectability failed. Cause: ' + - JSON.stringify(error)); - }) - } - connectAbility_service(); - console.info('particleAbility_connectAbility_test_0100 sleep start'); + console.info('particleAbility_connectAbility_test_0100 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0100 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0100 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0100 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0100 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0100 connection=: ' + connection); sleep(5000); - console.info('particleAbility_connectAbility_test_0100 sleep flish'); - disconnectAbility_promise(); + console.info('particleAbility_connectAbility_test_0100 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0100 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0100 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) => { + console.error('particleAbility_connectAbility_test_0100 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }) }, onConnect(want) { console.info('ServiceAbility2 onConnect'); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts index 339413095..72c61a28d 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts @@ -33,6 +33,18 @@ class StubTest3 extends rpc.RemoteObject { } } +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + async function sleep(time: any) { var now = new Date(); var exitTime = now.getTime() + time; @@ -72,7 +84,7 @@ export default { console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect proxy : ' + JSON.stringify(proxy)); }, - onDisconnect: function (element1: any) { + onDisconnect: async function (element1: any) { console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.deviceId :' + JSON.stringify(element1.deviceId)); console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.bundleName :' @@ -90,30 +102,29 @@ export default { } let connection_succeeded: any; - async function connectAbility_service() { - console.info('particleAbility_connectAbility_test_0200 start '); - var connection = particleAbility.connectAbility(request, options); - connection_succeeded = connection; - console.info('particleAbility_connectAbility_test_0200 service request is:' + JSON.stringify(request)); - console.info('particleAbility_connectAbility_test_0200 options is:' + JSON.stringify(options)); - console.info('particleAbility_connectAbility_test_0200 data is: ' + JSON.stringify(connection)); - console.info('particleAbility_connectAbility_test_0200 connection=: ' + connection); - } - - async function disconnectAbility_callback() { - console.info('particleAbility_connectAbility_test_0200 disconnectability start '); - particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { - console.info('particleAbility_connectAbility_test_0200 disconnectability succeeded: ' + - JSON.stringify(data)); - }).catch((error: any) => { - console.error('particleAbility_connectAbility_test_0200 disconnectability failed. Cause: ' + - JSON.stringify(error)); + console.info('particleAbility_connectAbility_test_0200 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0200 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0200 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0200 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0200 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0200 disconnectability start '); + try { + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded, (error, data) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0200 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0200 disconnectability succeeded: ' + JSON.stringify(data)); }) } - connectAbility_service(); - sleep(5000); - disconnectAbility_callback(); - sleep(5000); + catch(error: any){ + console.error('particleAbility_connectAbility_test_0200 disconnectability failed. Cause: ' + + JSON.stringify(error)); + } }, onConnect(want) { console.info('ServiceAbility3 onConnect'); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts index 722bc8779..d35fb6c9b 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts @@ -33,6 +33,18 @@ class StubTest4 extends rpc.RemoteObject { } } +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + async function sleep(time: any) { var now = new Date(); var exitTime = now.getTime() + time; @@ -59,53 +71,59 @@ export default { } let options = { onConnect: async function (element: any, proxy: any) { - console.log('particleAbility_connectAbility_test_0300 ConnectAbility service onConnect element.deviceId : ' + JSON.stringify(element.deviceId)) - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.bundleName : ' + JSON.stringify(element.bundleName)) - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.abilityName : ' + JSON.stringify(element.abilityName)) - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.uri : ' + JSON.stringify(element.uri)) - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.shortName : ' + JSON.stringify(element.shortName)) - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect proxy : ' + JSON.stringify(proxy)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); }, - onDisconnect: function (element1: any) { - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.deviceId : ' + JSON.stringify(element1.deviceId)); - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.bundleName : ' + JSON.stringify(element1.bundleName)); - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.abilityName : ' + JSON.stringify(element1.abilityName)); - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.uri : ' + JSON.stringify(element1.uri)); - console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.shortName : ' + JSON.stringify(element1.shortName)); + onDisconnect: async function (element1: any) { + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.uri: ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.shortName :' + + JSON.stringify(element1.shortName)); }, onFailed: function (code: any) { - console.log('particleAbility_connectAbility_test_0300 ConnectAbility service onFailed errCode : ' + code) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onFailed errCode : '+ code); }, } let connection_succeeded: any; - async function connectAbility_service() { - console.info('particleAbility_connectAbility_test_0300 start '); - var connection = particleAbility.connectAbility(request, options); - connection_succeeded = connection; - console.info('particleAbility_connectAbility_test_0300 service request is:' + JSON.stringify(request)); - console.info('particleAbility_connectAbility_test_0300 options is:' + JSON.stringify(options)); - console.info('particleAbility_connectAbility_test_0300 data is: ' + JSON.stringify(connection)); - console.info('particleAbility_connectAbility_test_0300 connection=: ' + connection); - } - - async function disconnectAbility_promise() { - try { - console.info('particleAbility_connectAbility_test_0300 disconnectability start '); - await particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { - console.info('particleAbility_connectAbility_test_0300 disconnectability succeeded: ' + - JSON.stringify(data)); - }) - } - catch (error: any) { - console.error('particleAbility_connectAbility_test_0300 disconnectability failed. Cause: ' + - JSON.stringify(error)); - } - } - connectAbility_service(); - sleep(5000); - disconnectAbility_promise(); + console.info('particleAbility_connectAbility_test_0300 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0300 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0300 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0300 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0300 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0300 connection=: ' + connection); sleep(5000); + console.info('particleAbility_connectAbility_test_0300 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0300 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0300 disconnectability succeeded:' + + JSON.stringify(data)); + }).catch ((error: any) =>{ + console.error('particleAbility_connectAbility_test_0300 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }) }, onConnect(want) { console.info('ServiceAbility4 onConnect'); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts index de27439c3..16a737c34 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts @@ -33,6 +33,18 @@ class StubTest5 extends rpc.RemoteObject { } } +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + async function sleep(time: any) { var now = new Date(); var exitTime = now.getTime() + time; @@ -85,50 +97,48 @@ export default { + JSON.stringify(element1.shortName)); }, onFailed: function (code: any) { - console.log('particleAbility_connectAbility_test_0400 ConnectAbility service onFailed errCode:' + code) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onFailed errCode:' + code); }, } let connection_succeeded: any; - async function connectAbility_service() { - console.info('particleAbility_connectAbility_test_0400 start '); - var connection = particleAbility.connectAbility(request, options); - connection_succeeded = connection; - console.info('particleAbility_connectAbility_test_0400 service request is:' + JSON.stringify(request)); - console.info('particleAbility_connectAbility_test_0400 options is:' + JSON.stringify(options)); - console.info('particleAbility_connectAbility_test_0400 data is: ' + JSON.stringify(connection)); - console.info('particleAbility_connectAbility_test_0400 connection=: ' + connection); - } - - async function disconnectAbility_promise() { - console.info('particleAbility_connectAbility_test_0400 disconnectability start '); - await particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { - console.info('particleAbility_connectAbility_test_0400 disconnectability succeeded: ' + + console.info('particleAbility_connectAbility_test_0400 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0400 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0400 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0400 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0400 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0400 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) => { + console.error('particleAbility_connectAbility_test_0400 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }); + sleep(5000); + console.info('particleAbility_connectAbility_test_0400 disconnectability_fail start '); + try { + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(-1).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 disconnectability_fail', + timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0400 disconnectability_fail succeeded: ' + JSON.stringify(data)); - }).catch((error: any) => { - console.error('particleAbility_connectAbility_test_0400 disconnectability failed. Cause: ' + - JSON.stringify(error)); }) } - - async function disconnectAbility_fail() { - console.info('particleAbility_connectAbility_test_0400 disconnectability_fail start '); - try { - await particleAbility.disconnectAbility(-1).then((data: any) => { - console.info('particleAbility_connectAbility_test_0400 disconnectability_fail succeeded: ' + - JSON.stringify(data)); - }) - } - catch (error: any) { - console.error('particleAbility_connectAbility_test_0400 disconnectability_fail failed. Cause: ' + - JSON.stringify(error)); - } + catch (error: any) { + console.error('particleAbility_connectAbility_test_0400 disconnectability_fail failed. Cause: ' + + JSON.stringify(error)); } - connectAbility_service(); - sleep(5000); - disconnectAbility_promise(); - sleep(5000); - disconnectAbility_fail(); }, onConnect(want) { console.info('ServiceAbility5 onConnect'); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts index e0eeca12e..b36d40bab 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts @@ -32,16 +32,16 @@ class StubTest6 extends rpc.RemoteObject { return true; } } +function getNowTime() { + return new Date().getTime(); +} -async function sleep(time: any) { - var now = new Date(); - var exitTime = now.getTime() + time; - while (true) { - now = new Date(); - if (now.getTime() > exitTime) - break; - } - console.info(`sleep ${time} over...`); +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; } export default { @@ -90,18 +90,16 @@ export default { }, } - async function connectAbility_service() { - console.info('particleAbility_connectAbility_test_0500 errorabilityName start'); - var connection = particleAbility.connectAbility(request, options); - console.info('particleAbility_connectAbility_test_0500 errorabilityName request is:' - + JSON.stringify(request)); - console.info('particleAbility_connectAbility_test_0500 errorabilityName options is:' - + JSON.stringify(options)); - console.info('particleAbility_connectAbility_test_0500 errorabilityName connection=: ' + connection); - } - - connectAbility_service(); - sleep(6000); + console.info('particleAbility_connectAbility_test_0500 errorabilityName start'); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0500 connectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0500 errorabilityName request is:' + + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0500 errorabilityName options is:' + + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0500 errorabilityName connection=: ' + connection); }, onConnect(want) { console.info('ServiceAbility6 onConnect'); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts new file mode 100644 index 000000000..32fe65dec --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest7 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility7 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility7 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} +export default { + onStart() { + console.info('ServiceAbility7 onStart'); + }, + onStop() { + console.info('ServiceAbility7 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility7 onCommand'); + + let request = { + "bundleName":"com.example.myapplication", + "abilityName":"com.example.myapplication.ServiceAbility_API8", + } + let options = { + onConnect:async function (element:any, proxy:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect:async function (element1:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed:function (code:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onFailed errCode:' + code); + }, + } + + let connection_succeeded:any; + console.info('particleAbility_connectAbility_test_0600 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0600 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0600 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0600 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0600 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0600 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0600 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0600 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0600 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) =>{ + console.error('particleAbility_connectAbility_test_0600 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }); + }, + onConnect(want) { + console.info('ServiceAbility7 onConnect'); + return new StubTest7("test"); + }, + onDisConnect(want) { + console.info('ServiceAbility7 onDisConnect'); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json index e9e972fac..ffd4ec49b 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json @@ -39,6 +39,10 @@ { "name": "description_serviceability6", "value": "hap sample empty service" + }, + { + "name": "description_serviceability7", + "value": "hap sample empty service" } ] } \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json new file mode 100644 index 000000000..ebcff6d52 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json @@ -0,0 +1,57 @@ +{ + "app": { + "bundleName": "com.ohos.acecollaboration", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication1", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "myapplication1", + "moduleType": "feature", + "installationFree": false + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:myapplication1_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..b7a0995c8 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets @@ -0,0 +1,8 @@ +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..caddb5805 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,43 @@ +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite_app1 from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite_app1(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('myapplication1 page') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 000000000..92ef23959 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import getHapModuleInfoJsunit_app1 from './getHapModuleInfoJsunit_app1.test.ets'; + + +export default function testsuite_app1() { + getHapModuleInfoJsunit_app1(); + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 000000000..ff7f88579 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,43 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(msg,startTime, endTime) { + console.info(msg+'Get Interface startTime: ' + startTime); + console.info(msg+'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg+'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets new file mode 100644 index 000000000..e8e61eab5 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets @@ -0,0 +1,303 @@ +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + + /** + * @tc.number: context_getHapModuleInfo_test_0300 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return type of the interface (by Promise) + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0300', 0, async function (done) { + console.info('[context_getHapModuleInfo_test_0300] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getHapModuleInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getHapModuleInfo_test_0300', timeOldStamp, timeNewStamp); + console.info('[context_getHapModuleInfo_test_0300] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }) + .catch((error) => { + console.error('[context_getHapModuleInfo_test_0300] failed:' + JSON.stringify(error)); + }) + var promise = await context.getHapModuleInfo(); + console.info('---[context_getHapModuleInfo_test_0300] check---'); + checkHapModuleInfo_app('context_getHapModuleInfo_test_0300', promise); + console.info('[context_getHapModuleInfo_test_0300] FINISH'); + done(); + }); + + function checkHapModuleInfo_app(msg, data) { + console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data)); + console.log(msg + "checkHapModuleInfo name : " + data.name); + console.log(msg + "checkHapModuleInfo description : " + data.description); + console.log(msg + "checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log(msg + "checkHapModuleInfo icon : " + data.icon); + console.log(msg + "checkHapModuleInfo label : " + data.label); + console.log(msg + "checkHapModuleInfo labelId : " + data.labelId); + console.log(msg + "checkHapModuleInfo iconId : " + data.iconId); + console.log(msg + "checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log(msg + "checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log(msg + "checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log(msg + "getHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log(msg + "checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length); + console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName); + console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfos)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + expect(typeof (data.installationFree)).assertEqual("boolean"); + expect(data.name).assertEqual("com.example.myapplication1"); + expect(data.description).assertEqual(""); + expect(data.descriptionId).assertEqual(0); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:myapplication1_MainAbility"); + expect(data.labelId).assertEqual(0); + expect(data.iconId).assertEqual(0); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + + expect(data.deviceTypes[0]).assertEqual("phone"); + checkAbilityInfo(msg,data.abilityInfos[0]); + + expect(data.moduleName).assertEqual("myapplication1") + expect(data.mainAbilityName).assertEqual(""); + expect(data.installationFree).assertEqual(false); + + console.log(msg + "---checkHapModuleInfo End---"); + } + + function checkAbilityInfo(msg,data) { + console.log(msg+ "checkAbilityInfo start " + JSON.stringify(data)); + console.log(msg+ "checkAbilityInfo bundleName : " + data.bundleName); + console.log(msg+ "checkAbilityInfo name : " + data.name); + console.log(msg+ "checkAbilityInfo label : " + data.label); + console.log(msg+ "checkAbilityInfo description : " + data.description); + console.log(msg+ "checkAbilityInfo icon : " + data.icon); + console.log(msg+ "checkAbilityInfo descriptionId : " + data.descriptionId); + console.log(msg+ "checkAbilityInfo iconId : " + data.iconId); + console.log(msg+ "checkAbilityInfo moduleName : " + data.moduleName); + console.log(msg+ "checkAbilityInfo process : " + data.process); + console.log(msg+ "checkAbilityInfo targetAbility : " + data.targetAbility); + console.log(msg+ "checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log(msg+ "checkAbilityInfo isVisible : " + data.isVisible); + console.log(msg+ "checkAbilityInfo formEnabled : " + data.formEnabled); + console.log(msg+ "checkAbilityInfo type : " + data.type) + console.log(msg+ "checkAbilityInfo orientation : " + data.orientation); + console.log(msg+ "checkAbilityInfo launchMode : " + data.launchMode); + console.log(msg+ "checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg+ "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg+ "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg+ "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg+ "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg+ "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg+ "checkAbilityInfo readPermission : " + data.readPermission); + console.log(msg+ "checkAbilityInfo writePermission : " + data.writePermission); + console.log(msg+ "checkAbilityInfo formEntity : " + data.formEntity); + console.log(msg+ "checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log(msg+ "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log(msg+ "checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log(msg+ "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log(msg+ "checkAbilityInfo uri : " + data.uri); + console.log(msg+ "checkAbilityInfo labelId : " + data.labelId); + console.log(msg+ "checkAbilityInfo subType : " + data.subType); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.example.myapplication1.MainAbility"); + expect(data.label).assertEqual("$string:myapplication1_MainAbility"); + expect(data.description).assertEqual("$string:description_mainability"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId).assertEqual(16777220); + expect(data.iconId).assertEqual(16777221); + expect(data.moduleName).assertEqual("myapplication1"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo(msg,data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId).assertEqual(16777218); + expect(data.subType).assertEqual(0); + console.log(msg+ "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo(msg,info) { + console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg+ "checkApplicationInfo name : " + info.name); + console.log(msg+ "checkApplicationInfo description : " + info.description); + console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg+ "checkApplicationInfo enabled : " + info.enabled); + console.log(msg+ "checkApplicationInfo label : " + info.label); + console.log(msg+ "checkApplicationInfo labelId : " + info.labelId); + console.log(msg+ "checkApplicationInfo icon : " + info.icon); + console.log(msg+ "checkApplicationInfo iconId : " + info.iconId); + console.log(msg+ "checkApplicationInfo process : " + info.process); + console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes); + console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName); + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId).assertEqual(16777220); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.labelId).assertEqual("16777218"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.iconId).assertEqual("16777221"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + console.log(msg+ "---checkApplicationInfo End--- "); + } + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json new file mode 100644 index 000000000..c69dada1a --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "myapplication1_MainAbility", + "value": "myapplication1_MainAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 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