diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index a447767a22ad613f535ab34f909ca063ef75793b..a812c464a14b89e593b93efdb87c92d865856290 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -55,16 +43,20 @@ describe('ActsAmsCallBackFifthScene', function () { console.info('----ActsAmsCallBackFifthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFifthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfifthscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfifthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfifthscene') { + console.log("ActsAmsCallBackFifthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFifthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -76,8 +68,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -89,8 +85,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -102,9 +102,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene SimulateFeatureAbilitySed start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); - setTimeout(done(), 5000); + setTimeout(done, 5000); }); function timeout(done) { @@ -114,346 +117,147 @@ describe('ActsAmsCallBackFifthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_6600 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_6600', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_6600 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_6600 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_6600 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7000 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_7000', 0, async function (done) { var maxnum = 10; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, data) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + data.length + ']'); - console.info('Acts_Ams_test_7000 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_6800 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_6800', 0, async function (done) { - var maxnum = 10; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, data) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_7000 getMissionInfos error.code : \ ' + error.code + ',data length [' + data.length + ']'); - console.info('Acts_Ams_test_6800 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); + expect(data.length).assertEqual(4); for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9000 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_9000', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_9000 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10000 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10000', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10000 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11000 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_11000', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_11000 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + console.info('Acts_Ams_test_7000 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); + expect(typeof (data[i].missionId)).assertEqual("number"); + expect(data[i].missionId).assertLarger(0); + + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7200 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_7200', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_7200 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_7200 removeMission error.code \ + console.info('Acts_Ams_test_7200 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7600 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_7600', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_7600 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_7600 moveMissionToTop error.code \ + console.info('Acts_Ams_test_7600 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_12000 - * @tc.name : deleteMissions : Remove Missions + * @tc.name : clearMission : Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_12000', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_12000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_12000 deleteMissions error.code \ + console.info('Acts_Ams_test_12000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) @@ -463,14 +267,15 @@ describe('ActsAmsCallBackFifthScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_8000', 0, async function (done) { - abilityManager.killProcessesByBundleName('com.ix.verify.io', + appManager.killProcessesByBundleName('com.ix.verify.io', (error, info) => { console.info('Acts_Ams_test_8000 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js index d280f5629e3781e92b248dde4bfbecca5fd5140d..3ba401843b653bc303d30b6ab8d556c67d0b1525 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js @@ -40,6 +40,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index ef6213c489f1c1e757fe5b22e640429160f76a48..a28022c48c68a6b55235c4059e4a17d9fd6691f2 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,16 +40,20 @@ describe('ActsAmsCallBackFirstScene', function () { console.info('----ActsAmsCallBackFirstScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFirstScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfirstscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfirstscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfirstscene') { + console.log("ActsAmsCallBackFirstScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFirstScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -73,7 +65,10 @@ describe('ActsAmsCallBackFirstScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFirstScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -85,53 +80,41 @@ describe('ActsAmsCallBackFirstScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_0200 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_0200', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_0200 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_0200 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0200 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -140,231 +123,33 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_0400 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_0400', 0, async function (done) { var maxnum = 10; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_0400 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_0400 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_0600 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_0600', 0, async function (done) { - var maxnum = 10; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_0600 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8600 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8600', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8600 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9600 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9600', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9600 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10600 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10600', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10600 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(2); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0400 getMissionInfos data[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -373,18 +158,21 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_1400 - * @tc.name : removeMissions : Remove Missions + * @tc.name : clearMissions : Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_1400', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var missionID = result[0].id + 100; - abilityManager.removeMissions([missionID], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var missionID = result[0].missionId + 100; + missionManager.clearMission(missionID, (error, info) => { - console.info('Acts_Ams_test_1400 removeMissions error.code \ + console.info('Acts_Ams_test_1400 clearMissions error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertLarger(0); + expect(error.code).assertLarger(-1); done(); }); setTimeout(timeout, 5000); @@ -392,17 +180,20 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_0800 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_0800', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_0800 removeMission error.code \ + console.info('Acts_Ams_test_0800 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -414,35 +205,35 @@ describe('ActsAmsCallBackFirstScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_1600', 0, async function (done) { - abilityManager.killProcessesByBundleName('com.ix.simulate.feature', + appManager.killProcessesByBundleName('com.ix.simulate.feature', (error, info) => { console.info('Acts_Ams_test_1600 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); - }) /* * @tc.number : Acts_Ams_test_1200 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_1200', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1200 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_1200 moveMissionToTop error.code \ + console.info('Acts_Ams_test_1200 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js index 317505e8dc895d1578a0454cc2d096005a81302c..8b48ca37486b43a1a860e41c0efc46e09cfb7858 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 70a17b595ad757499f0c70776184158ee27a332a..7aee5154f30196191c3d1c070ae5b7e61a073b74 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,30 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", "com.example.VerifyActThirdAbility", "com.example.VerifyIoThirdAbility", - "com.example.SimulateEntryAbilityFir", + "com.example.SimulateEntryAbility", "com.example.actsamscallbackfourthscene.MainAbility" ] @@ -58,16 +46,20 @@ describe('ActsAmsCallBackFourthScene', function () { console.info('----ActsAmsCallBackFourthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFourthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfourthscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfourthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfourthscene') { + console.log("ActsAmsCallBackFourthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFourthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -79,8 +71,12 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -92,8 +88,12 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -105,19 +105,26 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene VerifyActThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: { deviceId: "", bundleName: "com.ix.simulate.entry", - abilityName: "com.example.SimulateEntryAbility", + abilityName: "com.example.SimulateEntryAbilityFir", action: "action1", parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene SimulateEntryAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); setTimeout(done(), 5000); @@ -130,53 +137,41 @@ describe('ActsAmsCallBackFourthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_5000 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_5000', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_5000 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_5000 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_5000 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -186,251 +181,33 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_5400 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_5400', 0, async function (done) { var maxnum = 100; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, data) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + data.length + ']'); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5400 queryRecentAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_5200 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_5200', 0, async function (done) { - var maxnum = 30; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, data) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_5400 getMissionInfos error.code : \ ' + error.code + ',data length [' + data.length + ']'); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); + expect(data.length).assertEqual(5); for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5200 queryRunningAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8900 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8900', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8900 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9900 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9900', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9900 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(4); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10900 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10900', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10900 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(4); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + console.info('Acts_Ams_test_5400 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); + expect(typeof (data[i].missionId)).assertEqual("number"); + expect(data[i].missionId).assertLarger(0); + + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); }); @@ -439,18 +216,20 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_5600 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_5600', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5600 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_5600 removeMission error.code \ + console.info('Acts_Ams_test_5600 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -458,18 +237,20 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_6000 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_6000', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_6000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_6000 moveMissionToTop error.code \ + console.info('Acts_Ams_test_6000 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -481,7 +262,7 @@ describe('ActsAmsCallBackFourthScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_6400', 0, async function (done) { - abilityManager.killProcessesByBundleName('xxxxxxxxx', + missionManager.killProcessesByBundleName('xxxxxxxxx', (error, info) => { console.info('Acts_Ams_test_6400 killProcessesByBundleName error.code \ ' + error.code + ',data [' + info + ']'); @@ -494,20 +275,22 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_11900 - * @tc.name : deleteMissions : delete Missions + * @tc.name : clearMissions : delete Missions * @tc.desc : delete Missions(by CallBack) */ it('Acts_Ams_test_11900', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[1].id, result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearAllMissions( (error, info) => { - console.info('Acts_Ams_test_11900 deleteMissions error.code: \ + console.info('Acts_Ams_test_11900 clearAllMissions error.code: \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 66b2c6ccbf0cd1496ad9070ce8d7e7dcbb63dbb1..15cf58f95e742bce3da7d4414e28546209f3203c 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsCallBackSecondScene', function () { console.info('----ActsAmsCallBackSecondScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackSecondScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbacksecondscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbacksecondscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbacksecondscene') { + console.log("ActsAmsCallBackSecondScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackSecondScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -75,8 +67,12 @@ describe('ActsAmsCallBackSecondScene', function () { parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackSecondScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); + await featureAbility.startAbility( { want: @@ -88,6 +84,9 @@ describe('ActsAmsCallBackSecondScene', function () { parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackSecondScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); setTimeout(done(), 5000); @@ -100,53 +99,41 @@ describe('ActsAmsCallBackSecondScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_1800 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_1800', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_1800 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_1800 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1800 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -155,231 +142,33 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2000 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_2000', 0, async function (done) { var maxnum = 20; - abilityManager.queryRunningAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_2000 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_2200 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_2200', 0, async function (done) { - var maxnum = 20; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_2000 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_2200 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8700 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8700', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8700 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9700 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9700', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9700 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(3); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_2000 getMissionInfos data[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10700 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10700', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10700 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -388,17 +177,20 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2400 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_2400', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_2400 removeMission error.code \ + console.info('Acts_Ams_test_2400 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -406,17 +198,20 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2800 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_2800', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_2800 moveMissionToTop error.code \ + console.info('Acts_Ams_test_2800 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -428,7 +223,7 @@ describe('ActsAmsCallBackSecondScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_3200', 0, async function (done) { - abilityManager.killProcessesByBundleName('XXXXXXXXXXXX', + appManager.killProcessesByBundleName('XXXXXXXXXXXX', (error, info) => { console.info('Acts_Ams_test_3200 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); @@ -440,22 +235,22 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_3000 - * @tc.name : removeMissions: Remove Missions + * @tc.name : clearMissions: Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_3000', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_3000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_3000 removeMissions error.code \ + console.info('Acts_Ams_test_3000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) - -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 6ff3630b1da5727f5f1864f5580a94e85ee66099..0dcdf5c2cb5915b8daacc3f80a31149727dd63fa 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,22 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,16 +41,20 @@ describe('ActsAmsCallBackThirdScene', function () { console.info('----ActsAmsCallBackThirdScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackThirdScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackthirdscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackthirdscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackthirdscene') { + console.log("ActsAmsCallBackThirdScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackThirdScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -73,8 +66,12 @@ describe('ActsAmsCallBackThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackThirdScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -86,7 +83,10 @@ describe('ActsAmsCallBackThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackThirdScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -98,53 +98,41 @@ describe('ActsAmsCallBackThirdScene', function () { } function sleep(delay) { - var startTime = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_3400 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_3400', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_3400 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_3400 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3400 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -153,231 +141,33 @@ describe('ActsAmsCallBackThirdScene', function () { /* * @tc.number : Acts_Ams_test_3600 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_3600', 0, async function (done) { var maxnum = 20; - abilityManager.queryRunningAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_3600 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_3800 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_3800', 0, async function (done) { - var maxnum = 20; - var flag = 2; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_3800 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8800 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8800', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8800 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9800 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9800', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_3600 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9800 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(3); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3600 getMissionInfos info[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10800 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10800', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10800 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -386,55 +176,68 @@ describe('ActsAmsCallBackThirdScene', function () { /* * @tc.number : Acts_Ams_test_4000 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_4000', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_4000 removeMission error.code \ + console.info('Acts_Ams_test_4000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4400 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_4400', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_4400 moveMissionToTop error.code \ + console.info('Acts_Ams_test_4400 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_11800 - * @tc.name : deleteMissions : delete Missions + * @tc.name : clearMissions : delete Missions * @tc.desc : delete Missions(by CallBack) */ it('Acts_Ams_test_11800', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_11800 deleteMissions error.code \ + console.info('Acts_Ams_test_11800 clearMissions error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); + done(); setTimeout(timeout, 5000); }) @@ -444,15 +247,15 @@ describe('ActsAmsCallBackThirdScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_4800', 0, async function (done) { - abilityManager.killProcessesByBundleName('xxxxxxxxxxx', + appManager.killProcessesByBundleName('xxxxxxxxxxx', (error, info) => { console.info('Acts_Ams_test_4800 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(2097215); + expect(error.code).assertEqual(2097215); done(); - }); + } + ); + done(); setTimeout(timeout, 5000); }) -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json index 703124fbf940b305c81db024e9f357b3aa9f2b73..f02cf70ee9fc043a341f2934a01bae7b426aecdc 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfifthscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js index 317505e8dc895d1578a0454cc2d096005a81302c..8b48ca37486b43a1a860e41c0efc46e09cfb7858 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index ed497243e7bdabc786dafcb295a7e0e17ff689f8..e39fd291d68276c83938d5f383100522b5b31851 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,30 +12,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", - "com.example.VerifyIoThirdAbility", - "com.example.actsamstestfifthscene.MainAbility", - "com.example.SimulateFeatureAbilitySed" + "com.example.actsamstestfifthscene.MainAbility" ] var bundleNameList = [ @@ -47,24 +33,25 @@ var bundleNameList = [ "com.ohos.telephonydataability", "com.ohos.contactsdataability", "com.ix.simulate.feature", - "com.example.actsamstestfifthscene", - "com.ix.verify.io" + "com.example.actsamstestfifthscene" ] describe('ActsAmsTestFifthScene', function () { console.info('----ActsAmsTestFifthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFifthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfifthscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfifthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); - } + console.log("ActsAmsTestFifthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFifthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } + await featureAbility.startAbility( { want: @@ -81,8 +68,12 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -99,8 +90,12 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -117,7 +112,10 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene SimulateFeatureAbilitySed start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -129,314 +127,127 @@ describe('ActsAmsTestFifthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* - * @tc.number : Acts_Ams_test_6500 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info - * @tc.desc : Get All Running Processes Info(by Promise) - */ - it('Acts_Ams_test_6500', 0, async function (done) { + * @tc.number : Acts_Ams_test_0100 + * @tc.name : getProcessRunningInfos : Get All Running Processes Info + * @tc.desc : Get All Running Processes Info(by Promise) + */ + it('Acts_Ams_test_0100', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('getAllRunningProcesses data length [' + info.length + ']'); - console.info('Acts_Ams_test_6500 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0100 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_7500 - * @tc.name : moveMissionToTop : Move Mission To Top - * @tc.desc : Move Mission To Top(by Promise) - */ - it('Acts_Ams_test_7500', 0, async function (done) { + * @tc.number : Acts_Ams_test_1100 + * @tc.name : moveMissionToFront : Move Mission To Top + * @tc.desc : Move Mission To Top(by Promise) + */ + it('Acts_Ams_test_1100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[1].id); - console.info('Acts_Ams_test_7500 moveMissionToTop data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var result = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_1100 getMissionInfos failed: ' + err); + }); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_1100 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); - sleep(1000); - var ret = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - expect(result[1].baseAbility.bundleName).assertEqual(ret[0].baseAbility.bundleName); - expect(result[1].topAbility.bundleName).assertEqual(ret[0].topAbility.bundleName); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_6900 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_6900', 0, async function (done) { + * @tc.number : Acts_Ams_test_0300 + * @tc.name : getMissionInfos : Query Running Ability Mission Infos + * @tc.desc : Query Running Ability Mission Infos(by Promise) + */ + it('Acts_Ams_test_0300', 0, async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_6900 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_0300 getMissionInfos failed: ' + err); + }); + console.info('Acts_Ams_test_0300 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8500 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8500', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8500 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9500 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9500', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9500 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); + expect(data.length).assertEqual(4); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_0300 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_10500 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10500', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10500 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + * @tc.number : Acts_Ams_test_0700 + * @tc.name : clearMission : Remove Mission + * @tc.desc : Remove Mission(by Promise) + */ + it('Acts_Ams_test_0700', 0, async function (done) { + var maxnum = 10; + var result = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_0700 getMissionInfos failed: ' + err); + }); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_6700 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_6700', 0, async function (done) { - var maxnum = 10; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_6700 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11500 - * @tc.name : deleteMissions: delete Missions - * @tc.desc : delete Missions(by Promise) - */ - it('Acts_Ams_test_11500', 0, async function (done) { - var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.deleteMissions([result[1].id]); - console.info('Acts_Ams_test_11500 deleteMissions data [' + info + ']'); + var info = await missionManager.clearMission(result[1].missionId); + console.info('Acts_Ams_test_0700 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_7900 - * @tc.name : killProcessesByBundleName : Kill Processes By BundleName - * @tc.desc : Kill Processes By BundleName(by Promise) - */ - it('Acts_Ams_test_7900', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('com.ix.verify.io'); - console.info('Acts_Ams_test_7900 killProcessesByBundleName data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + * @tc.number : Acts_Ams_test_1500 + * @tc.name : killProcessesByBundleName : Kill Processes By BundleName + * @tc.desc : Kill Processes By BundleName(by Promise) + */ + it('Acts_Ams_test_1500', 0, async function (done) { + var info = await appManager.killProcessesByBundleName('com.ix.simulate.feature'); + console.info('Acts_Ams_test_1500 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) - }) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json index aa9e125d72712b52d9db4813c3667929d14d597a..4bd37e87f41bbd17e4e4d12f92e5298214501d4d 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfirstscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index a6a77dd6dba0f6c0cb4907a774ee6e90918d0021..6bc56ed06cec8111b1496cf1cad9b12550a21ba3 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,14 +40,17 @@ describe('ActsAmsTestFirstScene', function () { console.info('----ActsAmsTestFirstScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFirstScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfirstscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfirstscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestfirstscene') { + console.log("ActsAmsTestFirstScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFirstScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } await featureAbility.startAbility( @@ -78,7 +69,10 @@ describe('ActsAmsTestFirstScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFirstScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -90,65 +84,57 @@ describe('ActsAmsTestFirstScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_0100 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_0100', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_0100 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0100 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); }) + /* * @tc.number : Acts_Ams_test_1100 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_1100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_1100 moveMissionToTop data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_1100 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -156,209 +142,30 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_0300 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by Promise) */ it('Acts_Ams_test_0300', 0, async function (done) { var maxnum = 10; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('Acts_Ams_test_0300 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_0500 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_0500', 0, async function (done) { - var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info('Acts_Ams_test_0500 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8100 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8100', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8100 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9100 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9100', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9100 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(2); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_0300 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10100 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10100', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10100 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -366,14 +173,17 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_0700 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_0700', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_0700 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_0700 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -381,16 +191,19 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_11100 - * @tc.name : deleteMissions: delete Missions + * @tc.name : clearMissions: delete Missions * @tc.desc : delete Missions(by Promise) */ it('Acts_Ams_test_11100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } expect(result.length).assertEqual(1); - var missionID = result[0].id + 1; - var info = await abilityManager.deleteMissions([missionID]); - console.info('Acts_Ams_test_11100 deleteMissions data [' + info + ']'); + var missionID = result[0].missionId + 1; + var info = await missionManager.clearMission(missionID); + console.info('Acts_Ams_test_11100 clearMissions data [' + info + ']'); expect(info).assertLarger(0); done(); setTimeout(timeout, 5000); @@ -402,10 +215,10 @@ describe('ActsAmsTestFirstScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_1500', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('com.ix.simulate.feature'); + var info = await appManager.killProcessesByBundleName('com.ix.simulate.feature'); console.info('Acts_Ams_test_1500 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json index 8429b0324c1d1e9b1640aab2577257140ab8ab84..cf3b5c6e2b9a34eb75eea53b4e0b376a865f1e20 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfourthscene", "shell-timeout": "60000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 7ca0d328296698e38b3eec0089c07242acc1ffeb..0fc802257d857bc5d0fa0620e68d66966c84df23 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,31 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", - "com.example.VerifyActThirdAbility", - "com.example.VerifyIoThirdAbility", "com.example.actsamstestfourthscene.MainAbility", - "com.example.SimulateEntryAbilityFir" + "com.example.VerifyIoThirdAbility" ] var bundleNameList = [ @@ -48,25 +34,28 @@ var bundleNameList = [ "com.ohos.telephonydataability", "com.ohos.contactsdataability", "com.ix.simulate.feature", - "com.ix.verify.io", - "com.ix.simulate.entry", "com.example.actsamstestfourthscene", - "com.ix.verify.act" + "com.ix.verify.io" ] + describe('ActsAmsTestFourthScene', function () { console.info('----ActsAmsTestFourthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFourthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfourthscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfourthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestfourthscene') { + console.log("ActsAmsTestFourthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFourthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -83,8 +72,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -101,8 +94,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -119,8 +116,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene VerifyActThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -137,7 +138,10 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene SimulateEntryAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -149,67 +153,28 @@ describe('ActsAmsTestFourthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* - * @tc.number : Acts_Ams_test_4900 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.number : Acts_Ams_test_1700 + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ - it('Acts_Ams_test_4900', 0, async function (done) { + it('Acts_Ams_test_1700', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('getAllRunningProcesses data length [' + info.length + ']'); - console.info('Acts_Ams_test_4900 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8400 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8400', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8400 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1700 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); @@ -226,205 +191,33 @@ describe('ActsAmsTestFourthScene', function () { }) /* - * @tc.number : Acts_Ams_test_5300 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.number : Acts_Ams_test_2100 + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by Promise) */ - it('Acts_Ams_test_5300', 0, async function (done) { - var maxnum = 100; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); + it('Acts_Ams_test_2100', 0, async function (done) { + var maxnum = 20; + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_2100 getMissionInfos error.code : \ + ' + error.code + ',data length [' + data.length + ']'); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5300 queryRecentAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_5100 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_5100', 0, async function (done) { - var maxnum = 30; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5100 queryRunningAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9400 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9400', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9400 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); + expect(data.length).assertEqual(5); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_2100 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10400 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10400', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10400 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -437,9 +230,11 @@ describe('ActsAmsTestFourthScene', function () { */ it('Acts_Ams_test_5500', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_5500 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5500 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await abilityManager.clearMission(result[0].id); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(0); done(); @@ -448,31 +243,35 @@ describe('ActsAmsTestFourthScene', function () { /* * @tc.number : Acts_Ams_test_5900 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_5900', 0, async function (done) { - var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_5900 moveMissionToTop data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var maxnum = 20; + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_5900 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_6100 - * @tc.name : removeMissions: Remove Missions - * @tc.desc : Remove Missions(by Promise) + * @tc.number : Acts_Ams_test_2100 + * @tc.name : clearMission : Remove Mission + * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_6100', 0, async function (done) { - var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMissions([result[0].id, result[1].id]); - console.info('Acts_Ams_test_6100 removeMissions data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var maxnum = 20; + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_6100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearAllMissions(); + console.info('Acts_Ams_test_6100 clearAllMissions data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -484,7 +283,7 @@ describe('ActsAmsTestFourthScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_6300', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('xxxxxxxxxxxx'); + var info = await appManager.killProcessesByBundleName('xxxxxxxxxxxx'); console.info('Acts_Ams_test_6300 killProcessesByBundleName data [' + info + ']'); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(2097215); diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json index f889d08f761ccaabe63f8a0ed329490f9fa519d7..2a9a90561bebb0b996de85ebf4eab2367d244f0f 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestsecondscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 5a52dbb6cbcb8c66416042b3722ac4c177ff5604..37c078535d6766b063a9b4f980a8d8546b11dbd1 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsTestSecondScene', function () { console.info('----ActsAmsTestSecondScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestSecondScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestsecondscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestsecondscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestsecondscene') { + console.log("ActsAmsTestSecondScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestSecondScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -80,8 +72,12 @@ describe('ActsAmsTestSecondScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestSecondScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -98,7 +94,10 @@ describe('ActsAmsTestSecondScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestSecondScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -110,50 +109,39 @@ describe('ActsAmsTestSecondScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_1700 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_1700', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_1700 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); + console.info('Acts_Ams_test_1700 getProcessRunningInfos JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1700 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); @@ -161,14 +149,17 @@ describe('ActsAmsTestSecondScene', function () { /* * @tc.number : Acts_Ams_test_2700 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_2700', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_2700 moveMissionToTop data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_2700 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -176,240 +167,49 @@ describe('ActsAmsTestSecondScene', function () { /* * @tc.number : Acts_Ams_test_1900 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by Promise) */ it('Acts_Ams_test_1900', 0, async function (done) { var maxnum = 20; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_1900 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_2100 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_2100', 0, async function (done) { - var maxnum = 20; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_2100 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8200 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8200', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8200 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9200 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9200', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9200 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_1900 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(3); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_1900 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); }) - /* - * @tc.number : Acts_Ams_test_10200 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10200', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10200 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11200 - * @tc.name : deleteMissions: delete Missions - * @tc.desc : delete Missions(by Promise) - */ - it('Acts_Ams_test_11200', 0, async function (done) { - var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.deleteMissions([result[0].id]); - console.info('Acts_Ams_test_11200 deleteMissions data [' + info + ']'); - expect(info).assertEqual(0); - done(); - setTimeout(timeout, 5000); - }) - /* * @tc.number : Acts_Ams_test_2100 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_2300', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_2300 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2300 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_2300 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -421,11 +221,10 @@ describe('ActsAmsTestSecondScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_3100', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('XXXXXXXXXXXX'); + var info = await appManager.killProcessesByBundleName('XXXXXXXXXXXX'); console.info('Acts_Ams_test_3100 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(2097215); done(); setTimeout(timeout, 5000); }) -}) - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json index cd2c04356e443c5de382ab0c7c3e7954ed72ba6a..629d269911692abfa2847d5990a4785a1dd4ab53 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestthirdscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 6dd0bdb08376a0e48c72be6b145c1e2be876ce18..17677f5903c57a561066f19a60121f6688299c5e 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsTestThirdScene', function () { beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestThirdScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestthirdscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestthirdscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestthirdscene') { + console.log("ActsAmsTestThirdScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestThirdScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -80,8 +72,12 @@ describe('ActsAmsTestThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestThirdScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -98,7 +94,10 @@ describe('ActsAmsTestThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestThirdScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -110,92 +109,39 @@ describe('ActsAmsTestThirdScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_3300 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_3300', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_3300 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); + console.info('Acts_Ams_test_3300 getProcessRunningInfos JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3300 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_3500 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_3500', 0, async function (done) { - var maxnum = 20; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('Acts_Ams_test_3500 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -203,166 +149,31 @@ describe('ActsAmsTestThirdScene', function () { /* * @tc.number : Acts_Ams_test_3700 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by Promise) */ it('Acts_Ams_test_3700', 0, async function (done) { var maxnum = 20; - var flag = 2; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info('Acts_Ams_test_3700 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8300 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8300', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8300 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9300 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9300', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9300 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_3700 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(3); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_3700 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10300 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10300', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10300 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -370,45 +181,54 @@ describe('ActsAmsTestThirdScene', function () { /* * @tc.number : Acts_Ams_test_3900 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_3900', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[1].id); - console.info('Acts_Ams_test_3900 removeMission data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_3900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[1].missionId); + console.info('Acts_Ams_test_3900 clearMission data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4300 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_4300', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_4300 moveMissionToTop data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4300 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_4300 moveMissionToFront data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4500 - * @tc.name : removeMissions: Remove Missions + * @tc.name : clearMissions: Remove Missions * @tc.desc : Remove Missions(by Promise) */ it('Acts_Ams_test_4500', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMissions([result[0].id]); - console.info('Acts_Ams_test_4500 removeMissions data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4500 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_4500 clearMission data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) @@ -419,11 +239,10 @@ describe('ActsAmsTestThirdScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_4700', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('XXXXXXXX'); + var info = await appManager.killProcessesByBundleName('XXXXXXXX'); console.info('Acts_Ams_test_4700 killProcessesByBundleName data [' + info + ']'); - expect(info).assertEqual(2097215); + expect(info.code).assertEqual(2097215); done(); setTimeout(timeout, 5000); }) -}) - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json index 7ac78910a917151702c06e3c5dc79a842b8ab169..a6b680b41c72c41310edb2fb8ba9f6a3e039b819 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json @@ -3,7 +3,7 @@ "driver": { "type": "JSUnitTest", "test-timeout": "120000", - "package": "com.ohos.launcher", + "package": "com.example.myapplication11", "abilityName": "com.ohos.launcherSed11.MainAbility", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json index ca3e263df7b3475d5ee35dc4da26d6231af80f43..3d20621699b918849c37d9dfbc93f24d3a955793 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.ohos.launcher", + "bundleName": "com.example.myapplication11", "vendor": "example", "version": { "code": 1000000, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js index 37ddae73e5795969c05b96599c8f352cce179426..a69c29d1ead901bef68abfc0c1b37ebc6139ae3b 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import missionManager from '@ohos.application.missionManager' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('ActsAmsCallBackSixth Scene', function () { @@ -51,7 +51,7 @@ describe('ActsAmsCallBackSixth Scene', function () { * @tc.desc : Clear Missions(by CallBack) */ it('Acts_Ams_test_12200', 0, async function (done) { - abilityManager.clearMissions( + missionManager.clearAllMissions( (error,info) => { console.info('Acts_Ams_test_12200 clearMissions error.code ' + error.code + ',data [' + info + ']' ); expect(typeof(info)).assertEqual("number"); @@ -59,4 +59,4 @@ describe('ActsAmsCallBackSixth Scene', function () { }); done(); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json index b13ed4b357308cc813fa04ebdefd19c4edfbf4fb..cd28daa3f6802d671f0c40555e53736bfbd3f370 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json @@ -3,7 +3,7 @@ "driver": { "type": "JSUnitTest", "test-timeout": "120000", - "package": "com.ohos.launcher", + "package": "com.example.myapplication111", "abilityName": "com.ohos.launcherSed111.MainAbility", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json index 572b3d75735927d6767690f6c3197270bf3fb660..0eece2ae89479755d13673d82ad12ee703831865 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.ohos.launcher", + "bundleName": "com.example.myapplication111", "vendor": "example", "version": { "code": 1000000, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js index 7e9feae45a3ba88089459a283d5423fc3eb962b3..8609e3a4097d611fe33aa9bf88b5034caf18ba39 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import missionManager from '@ohos.application.missionManager' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('ActsAmsCallBackSixth Scene', function () { @@ -51,10 +51,10 @@ describe('ActsAmsCallBackSixth Scene', function () { * @tc.desc : Clear Missions(by Promise) */ it('Acts_Ams_test_12100', 0, async function (done) { - var info = await abilityManager.clearMissions(); + var info = await missionManager.clearAllMissions(); console.info('Acts_Ams_test_12100 clearMissions data [' + info + ']'); expect(typeof(info)).assertEqual("number"); expect(info).assertEqual(0); done(); }) -}) +}) \ No newline at end of file