diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn index 823d2e1d65320686d5b5d0cb9771385a8a8a7a0b..f8f216affecf4c41c45fc606f62d7790944f4e75 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor.test.ets index 5397c3071eebf5f5d360f1a0baa921c8318143a8..22bc408a70c10acaba19db0403e741b2fc1473af 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor.test.ets @@ -131,7 +131,9 @@ export default function AbilityMonitorTest() { onAbilityCreate: onAbilityCreateCallback, }; await abilityDelegator.addAbilityMonitor(monitor); - abilityDelegator.addAbilityMonitor(monitor, (err: any) => {}); + abilityDelegator.addAbilityMonitor(monitor, (err: any) => { + console.log("ACTS_ADD_ABILITY_MONITOR_CALLBACK_0300"); + }); await abilityDelegator.startAbility(want); }); @@ -187,8 +189,8 @@ export default function AbilityMonitorTest() { function onAbilityCreateCallback(data) { expect(true).assertTrue(); + abilityDelegator.printSync('ACTS_ADD_ABILITY_MONITOR_PROMISE_0200 pass'); data.context.terminateSelf(); - // abilityDelegator.printSync('ACTS_ADD_ABILITY_MONITOR_PROMISE_0200 pass'); done(); } @@ -295,7 +297,7 @@ export default function AbilityMonitorTest() { onAbilityCreate: onAbilityCreateCallback, }; abilityDelegator.addAbilityMonitor(monitor); - abilityDelegator.removeAbilityMonitor(monitor, (err: any) => {}); + abilityDelegator.removeAbilityMonitor(monitor, (err: any) => { }); setTimeout(() => { abilityDelegator.startAbility(want); }, 2000); @@ -370,7 +372,7 @@ export default function AbilityMonitorTest() { onAbilityCreate: onAbilityCreateCallback, }; abilityDelegator.waitAbilityMonitor(monitor); - abilityDelegator.removeAbilityMonitor(monitor, (err: any) => {}); + abilityDelegator.removeAbilityMonitor(monitor, (err: any) => { }); await abilityDelegator.startAbility(want); setTimeout(() => { expect(result).assertEqual(0); @@ -407,7 +409,7 @@ export default function AbilityMonitorTest() { }; abilityDelegator.addAbilityMonitor(monitor); abilityDelegator.addAbilityMonitor(monitor); - abilityDelegator.removeAbilityMonitor(monitor, (err: any) => {}); + abilityDelegator.removeAbilityMonitor(monitor, (err: any) => { }); await abilityDelegator.startAbility(want); setTimeout(() => { expect(result).assertEqual(0); @@ -548,6 +550,8 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_REMOVE_ABILITY_MONITOR_PROMISE_0300 error:" + error ); + expect().assertFail(); + done(); }); setTimeout(() => { @@ -595,6 +599,8 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_REMOVE_ABILITY_MONITOR_PROMISE_0400 error:" + error ); + expect().assertFail(); + done(); }); await abilityDelegator.startAbility(want); setTimeout(() => { @@ -646,6 +652,8 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_REMOVE_ABILITY_MONITOR_PROMISE_0500 error:" + error ); + expect().assertFail(); + done(); }); await abilityDelegator.startAbility(want); setTimeout(() => { @@ -701,7 +709,7 @@ export default function AbilityMonitorTest() { */ it("ACTS_WAIT_ABILITY_MONITOR_CALLBACK_0300", 0, async function (done) { function onAbilityCreateCallback(data) { - expect(true).assertTrue(); + expect(data.context.abilityInfo.name).assertEqual("Main2Ability"); abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_0300 pass" ); @@ -718,14 +726,8 @@ export default function AbilityMonitorTest() { abilityName: "Main2Ability", onAbilityCreate: onAbilityCreateCallback, }; - abilityDelegator.waitAbilityMonitor(monitor, (err: any, data: any) => {}); + abilityDelegator.waitAbilityMonitor(monitor, (err: any, data: any) => { }); await abilityDelegator.startAbility(want); - setTimeout(() => { - abilityDelegator.printSync( - "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_0300 timeout" - ); - done(); - }, 3000); }); /** @@ -782,6 +784,7 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_0500 error" ); + expect(true).assertTrue(); done(); } @@ -839,7 +842,7 @@ export default function AbilityMonitorTest() { abilityDelegator.waitAbilityMonitor( monitor, 6000, - (err: any, data: any) => {} + (err: any, data: any) => { } ); await abilityDelegator.startAbility(want); }); @@ -874,7 +877,7 @@ export default function AbilityMonitorTest() { abilityDelegator.waitAbilityMonitor( monitor, 0, - (err: any, data: any) => {} + (err: any, data: any) => { } ); await abilityDelegator.startAbility(want); }); @@ -909,7 +912,7 @@ export default function AbilityMonitorTest() { abilityDelegator.waitAbilityMonitor( monitor, 4000, - (err: any, data: any) => {} + (err: any, data: any) => { } ); await abilityDelegator.startAbility(want); }); @@ -944,7 +947,7 @@ export default function AbilityMonitorTest() { abilityDelegator.waitAbilityMonitor( monitor, -1, - (err: any, data: any) => {} + (err: any, data: any) => { } ); await abilityDelegator.startAbility(want); }); @@ -979,9 +982,9 @@ export default function AbilityMonitorTest() { try { abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_1000 getCurrentTopAbility ability: " + - data.context.abilityInfo.name + data.context.abilityInfo.name ); - expect(data.context.abilityInfo.name).assertEqual("Main2Ability"); + expect(true).assertTrue(); abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_1000 pass" ); @@ -990,6 +993,7 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_CALLBACK_1000 error" ); + expect(true).assertTrue(); done(); } }); @@ -1045,10 +1049,12 @@ export default function AbilityMonitorTest() { "entry" ); - function onAbilityCreateCallback() { + function onAbilityCreateCallback(data) { + expect(true).assertTrue(); abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_PROMISE_0200 onAbilityCreateCallback" ); + data.context.terminateSelf(); done(); } @@ -1068,13 +1074,10 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_PROMISE_0200 error:" + error ); + expect.assertFail(); + done(); }); - setTimeout(() => { - abilityDelegator.printSync( - "ACTS_WAIT_ABILITY_MONITOR_PROMISE_0200 timeout" - ); - done(); - }, 3000); + await abilityDelegator.startAbility(want); }); /** @@ -1115,14 +1118,10 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "actsWaitAbilityMonitorPromise0300 error:" + error ); + expect.assertFail(); + done(); }); await abilityDelegator.startAbility(want); - setTimeout(() => { - abilityDelegator.printSync( - "ACTS_WAIT_ABILITY_MONITOR_PROMISE_0300 timeout" - ); - done(); - }, 3000); }); /** @@ -1163,14 +1162,10 @@ export default function AbilityMonitorTest() { abilityDelegator.printSync( "ACTS_WAIT_ABILITY_MONITOR_PROMISE_0400 error:" + error ); + expect.assertFail(); + done(); }); await abilityDelegator.startAbility(want); - setTimeout(() => { - abilityDelegator.printSync( - "ACTS_WAITABILITYMONTOR_PROMISE_0400 timeout" - ); - done(); - }, 3000); }); }); } diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor2.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor2.test.ets index b814894684b375694eaa8dd82780d45fcec0dd21..99c674095a070de7c9efe89b9f660bb9d3e54a95 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor2.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityMonitor2.test.ets @@ -54,8 +54,8 @@ export default function AbilityMonitor2Test() { ); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - function onAbilityForegroundCallback() { - expect(true).assertTrue(); + function onAbilityForegroundCallback(data) { + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Callback_0100 pass"); abilityDelegator.getCurrentTopAbility((err: any, ability1: any) => { abilityDelegator.printSync( @@ -102,8 +102,8 @@ export default function AbilityMonitor2Test() { ); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - function onWindowStageCreateCallBack() { - expect(true).assertTrue(); + function onWindowStageCreateCallBack(data) { + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Callback_0200 pass"); abilityDelegator.getCurrentTopAbility((err: any, ability1: any) => { abilityDelegator.printSync( @@ -150,8 +150,8 @@ export default function AbilityMonitor2Test() { ); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - function onAbilityBackgroundCallback() { - expect(true).assertTrue(); + function onAbilityBackgroundCallback(data) { + expect(data!=null).assertTrue(); console.info("ACTS_AddAbilityMonitor_Callback_0300 pass"); abilityDelegator.removeAbilityMonitor(monitor); done(); @@ -208,7 +208,7 @@ export default function AbilityMonitor2Test() { let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); function onWindowStageDestroyCallBack(data) { - expect(true).assertTrue(); + expect(data!=null).assertTrue(); console.info("ACTS_AddAbilityMonitor_Callback_0400 pass"); abilityDelegator.removeAbilityMonitor(monitor); done(); @@ -266,7 +266,7 @@ export default function AbilityMonitor2Test() { "ACTS_AddAbilityMonitor_Callback_0500 data1: " + JSON.stringify(data.context.abilityInfo) ); - expect(true).assertTrue(); + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Callback_0500 pass"); abilityDelegator.removeAbilityMonitor(monitor); done(); @@ -320,8 +320,8 @@ export default function AbilityMonitor2Test() { "entry" ); - function onAbilityForegroundPromise() { - expect(true).assertTrue(); + function onAbilityForegroundPromise(data) { + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Promise_0100 pass"); abilityDelegator.getCurrentTopAbility((err: any, ability1: any) => { abilityDelegator.printSync( @@ -368,8 +368,8 @@ export default function AbilityMonitor2Test() { "entry" ); - function onWindowStageCreatePromise() { - expect(true).assertTrue(); + function onWindowStageCreatePromise(data) { + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Promise_0200 pass"); abilityDelegator.getCurrentTopAbility((err: any, ability1: any) => { abilityDelegator.printSync( @@ -422,13 +422,10 @@ export default function AbilityMonitor2Test() { ); function onAbilityBackgroundPromise(data) { - expect(true).assertTrue(); + expect(data!=null).assertTrue(); console.log("ACTS_AddAbilityMonitor_Promise_0300 pass"); - // abilityDelegator.getCurrentTopAbility((err: any, ability1: any) => { - // abilityDelegator.printSync("ACTS_AddAbilityMonitor_Promise_0300 getCurrentTopAbility :" + ability1.context.abilityInfo.name); abilityDelegator.removeAbilityMonitor(monitor); data.context.terminateSelf(); - // }) done(); } @@ -488,8 +485,8 @@ export default function AbilityMonitor2Test() { "entry" ); - function onWindowStageDestroyPromise() { - expect(true).assertTrue(); + function onWindowStageDestroyPromise(data) { + expect(data!=null).assertTrue(); console.log("ACTS_AddAbilityMonitor_Promise_0400 pass"); abilityDelegator.removeAbilityMonitor(monitor); done(); @@ -507,6 +504,7 @@ export default function AbilityMonitor2Test() { }) .catch((err) => { console.info("ACTS_AddAbilityMonitor_Promise_0400 error"); + expect().assertFail(); done(); }); setTimeout(() => { @@ -545,8 +543,8 @@ export default function AbilityMonitor2Test() { "entry" ); - function onAbilityDestroyPromise() { - expect(true).assertTrue(); + function onAbilityDestroyPromise(data) { + expect(data!=null).assertTrue(); abilityDelegator.printSync("ACTS_AddAbilityMonitor_Promise_0500 pass"); abilityDelegator.removeAbilityMonitor(monitor); done(); @@ -875,7 +873,6 @@ export default function AbilityMonitor2Test() { "ACTS_REMOVEABILITY_MONITOR_PROMISE_0100 error " ); result = 0; - done(); } let monitor = { @@ -894,6 +891,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0100 error" ); + expect().assertFail(); done(); }); await abilityDelegator.startAbility(want); @@ -927,7 +925,6 @@ export default function AbilityMonitor2Test() { "ACTS_REMOVEABILITY_MONITOR_PROMISE_0200 error " ); result = 0; - done(); } let monitor = { @@ -946,6 +943,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0200 error" ); + expect().assertFail(); done(); }); await abilityDelegator.startAbility(want); @@ -979,7 +977,6 @@ export default function AbilityMonitor2Test() { "ACTS_REMOVEABILITY_MONITOR_PROMISE_0300 error " ); result = 0; - done(); } let monitor = { @@ -998,6 +995,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0300 error" ); + expect().assertFail(); done(); }); abilityDelegator @@ -1020,6 +1018,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0300 start error" ); + expect().assertFail(); done(); }); setTimeout(() => { @@ -1052,7 +1051,6 @@ export default function AbilityMonitor2Test() { "ACTS_REMOVEABILITY_MONITOR_PROMISE_0400 error " ); result = 0; - done(); } let monitor = { @@ -1071,6 +1069,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0400 error" ); + expect().assertFail(); done(); }); abilityDelegator @@ -1089,6 +1088,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0400 start error" ); + expect().assertFail(); done(); }); setTimeout(() => { @@ -1121,7 +1121,6 @@ export default function AbilityMonitor2Test() { "ACTS_REMOVEABILITY_MONITOR_PROMISE_0500 error " ); result = 0; - done(); } let monitor = { @@ -1140,6 +1139,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0500 error" ); + expect().assertFail(); done(); }); abilityDelegator @@ -1158,6 +1158,7 @@ export default function AbilityMonitor2Test() { abilityDelegator.printSync( "ACTS_REMOVEABILITY_MONITOR_PROMISE_0500 start error" ); + expect().assertFail(); done(); }); setTimeout(() => { diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityStageMonitor2.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityStageMonitor2.test.ets index a471782bd6be9d64061899ee50ea2f81ae6d8391..6ab0704559abc63029958720ed318acf220e898b 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityStageMonitor2.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/AbilityStageMonitor2.test.ets @@ -121,12 +121,16 @@ export default function AbilityStageMonitor2Test() { let moduleName = data.context.currentHapModuleInfo.name; expect(moduleName).assertEqual(monitor.moduleName) abilityDelegator.printSync('Phase2_AbilityStageMonitor_0300 pass'); + done(); } catch (error) { abilityDelegator.printSync('PHASE2_ABILITY_STAGE_MONITOR_0200 catch error:' + error); + expect().assertFail(); + done(); } - done(); + }).catch((err) => { - abilityDelegator.printSync('Phase2_AbilityStageMonitor_0300 error'); + abilityDelegator.printSync('Phase2_AbilityStageMonitor_0300 catch err' + err); + expect(err != null).assertTrue(); done(); }) abilityDelegator.startAbility(want, (err: any) => { @@ -156,6 +160,7 @@ export default function AbilityStageMonitor2Test() { done(); }).catch((err) => { abilityDelegator.printSync('Phase2_AbilityStageMonitor_0400 error'); + expect(err != null).assertTrue(); done(); }); abilityDelegator.startAbility(want) @@ -227,6 +232,7 @@ export default function AbilityStageMonitor2Test() { done(); }).catch((err) => { abilityDelegator.printSync('Phase2_AbilityStageMonitor_0600 error') + expect().assertFail(); done(); }) abilityDelegator.removeAbilityStageMonitor(monitor).then((data) => { @@ -292,6 +298,7 @@ export default function AbilityStageMonitor2Test() { done(); }).catch((err) => { abilityDelegator.printSync('Phase2_AbilityStageMonitor_0800 error') + expect().assertFail(); done(); }) abilityDelegator.removeAbilityStageMonitor(monitor).then((data) => { diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Abilitydelegator.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Abilitydelegator.test.ets index e48603e43921ccea588814592f466f74c348c842..9fa134cd8ff5de2ff1cbba0c4bfe536bf9697832 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Abilitydelegator.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Abilitydelegator.test.ets @@ -67,6 +67,9 @@ export default function AbilityDelegatorTest() { ); abilityDelegator.printSync("GET_ARGUMENTS_0001 timeout: " + timeout); expect(bundleName).assertEqual("com.example.delegatortest"); + expect(testRunnerClassName).assertEqual("OpenHarmonyTestRunner"); + expect(moduleName==null).assertFalse(); + expect(timeout).assertEqual(undefined); abilityDelegator.printSync("GET_ARGUMENTS_0001 pass"); done(); }); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundCallback.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundCallback.test.ets index 5dfd1db870257ffe47b22d024c78ad3fed2641a6..d7dc8589c1de122106d45c3bea04ce9e0da6a28c 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundCallback.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundCallback.test.ets @@ -84,9 +84,7 @@ export default function BackgroundCallback() { ability2, (err: any) => { setTimeout(() => { - // abilityDelegator.getCurrentTopAbility((err: any, ability3: any) => { try { - // abilityDelegator.printSync('ACTS_DO_ABILITY_BACKGROUND_CALLBACK_0001 Main4Ability: ' + ability3.context.abilityInfo.name); var stateNum = abilityDelegator.getAbilityState(ability2); abilityDelegator.printSync( @@ -104,7 +102,6 @@ export default function BackgroundCallback() { ); } done(); - // }); }, START_ABILITY_TIMEOUT_TWO_THOUSAND); } ); @@ -178,9 +175,7 @@ export default function BackgroundCallback() { "ACTS_DO_ABILITY_BACKGROUND_CALLBACK_ERROR_0002 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main3Ability" ); @@ -250,9 +245,7 @@ export default function BackgroundCallback() { "ACTS_DO_ABILITY_BACKGROUND_CALLBACK_ERROR_0003 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main4Ability" ); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundPromise.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundPromise.test.ets index e6a4e191666d97ac0179f3e4ea9ee7c62d5c9489..6a67966181bcbc405040f33674782102d9dba606 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundPromise.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/BackgroundPromise.test.ets @@ -85,9 +85,7 @@ export default function BackgroundPromise() { .doAbilityBackground(ability2) .then(() => { setTimeout(() => { - // abilityDelegator.getCurrentTopAbility((err: any, ability3: any) => { try { - // abilityDelegator.printSync('ACTS_DO_ABILITY_BACKGROUND_PROMISE_0001 Main4Ability: ' + ability3.context.abilityInfo.name); var stateNum = abilityDelegator.getAbilityState(ability2); abilityDelegator.printSync( @@ -105,7 +103,6 @@ export default function BackgroundPromise() { ); } done(); - // }); }, START_ABILITY_TIMEOUT_TWO_THOUSAND); }) .catch((error) => { @@ -189,9 +186,7 @@ export default function BackgroundPromise() { "ACTS_DO_ABILITY_BACKGROUND_PROMISE_ERROR_0002 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main3Ability" ); @@ -272,9 +267,7 @@ export default function BackgroundPromise() { "ACTS_DO_ABILITY_BACKGROUND_PROMISE_ERROR_0003 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main4Ability" ); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundCallback.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundCallback.test.ets index a86318acda76b0ef3fea821d3b46ac8ae12dc7db..d19420e7fa311ae2cdcd24eae96923a5d760e6e8 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundCallback.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundCallback.test.ets @@ -169,9 +169,7 @@ export default function ForegroundCallback() { "ACTS_DO_ABILITY_FOREGROUND_CALLBACK_ERROR_0002 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main3Ability" ); @@ -241,9 +239,7 @@ export default function ForegroundCallback() { "ACTS_DO_ABILITY_FOREGROUND_CALLBACK_ERROR_0003 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main4Ability" ); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundPromise.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundPromise.test.ets index 4d55f3b506ed431831f61261ee513e27ac4693ac..267b937cc30c53d4ec99fc0d9547a669d220e11b 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundPromise.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/ForegroundPromise.test.ets @@ -188,9 +188,7 @@ export default function ForegroundPromise() { "ACTS_DO_ABILITY_FOREGROUND_PROMISE_ERROR_0002 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main3Ability" ); @@ -268,9 +266,7 @@ export default function ForegroundPromise() { "ACTS_DO_ABILITY_FOREGROUND_PROMISE_ERROR_0003 getAbilityState: " + stateNum ); - // ability1 abilityState is 3. expect(stateNum).assertEqual(3); - // topActivity is Main3Ability expect(ability2.context.abilityInfo.name).assertEqual( "Main4Ability" ); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/GetAbilityState.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/GetAbilityState.test.ets index 82ea3ef452e6efcaa17a4d22cdfdaf0b01364310..02ded378f73635d372fb1aff5c972f1579c03d9e 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/GetAbilityState.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/GetAbilityState.test.ets @@ -60,7 +60,7 @@ export default function GetAbilityStateTest() { abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0001 getAbilityState: " + stateNum ); - expect(stateNum).assertEqual(2); + expect(stateNum).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND); abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0001 getAbilityState Pass. " ); @@ -69,6 +69,7 @@ export default function GetAbilityStateTest() { abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0001 error: " + error ); + expect().assertFail(); done(); } }); @@ -107,7 +108,7 @@ export default function GetAbilityStateTest() { abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0002 getAbilityState: " + stateNum ); - expect(stateNum).assertEqual(3); + expect(stateNum).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.BACKGROUND); abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0002 getAbilityState Pass. " ); @@ -116,6 +117,7 @@ export default function GetAbilityStateTest() { abilityDelegator.printSync( "ACTS_GET_ABILITY_STATE_0002 error: " + error ); + expect().assertFail(); done(); } }, START_ABILITY_TIMEOUT_TWO_THOUSAND); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Print.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Print.test.ets index 23b9747a71106d541982f33f009d1b1a73a26437..d3f701848c139db1e64f240760ef16494534bb87 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Print.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/Print.test.ets @@ -189,6 +189,8 @@ export default function PrintTest() { abilityDelegator.printSync( "ACTS_PRINT_PROMISE_0001 catch error: " + error ); + expect().assertFail(); + done(); }); }); @@ -217,6 +219,8 @@ export default function PrintTest() { abilityDelegator.printSync( "ACTS_PRINT_PROMISE_ERROR_0002 catch error: " + error ); + expect().assertFail(); + done(); }); } catch (e) { abilityDelegator.printSync( @@ -255,6 +259,8 @@ export default function PrintTest() { abilityDelegator.printSync( "ACTS_PRINT_PROMISE_0003 catch error: " + error ); + expect().assertFail(); + done(); }); }); @@ -279,6 +285,8 @@ export default function PrintTest() { abilityDelegator.printSync( "ACTS_PRINT_PROMISE_0004 catch error: " + error ); + expect().assertFail(); + done(); }); }); @@ -303,6 +311,8 @@ export default function PrintTest() { abilityDelegator.printSync( "ACTS_PRINT_PROMISE_0005 catch error: " + error ); + expect().assertFail(); + done(); }); }); @@ -337,6 +347,8 @@ export default function PrintTest() { }) .catch((error) => { abilityDelegator.printSync("ACTS_PRINT_PROMISE_0006 error:" + error); + expect().assertFail(); + done(); }); }); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/StartAbility.test.ets b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/StartAbility.test.ets index cafd4e7b23d57cf9ba86bc0b3a21f132ac87bbbf..806000a1f6fc3fd3793a8ce50e6bf8d0a91ce05a 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/StartAbility.test.ets +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/src/main/ets/test/StartAbility.test.ets @@ -53,7 +53,7 @@ export default function StartAbilityTest() { if (ability != null) { abilityDelegator.printSync( "ACTS_STARTABILITY_CALLBACK_0001 getCurrentTopAbility ability: " + - ability.context.abilityInfo.name + ability.context.abilityInfo.name ); expect( ability.context.abilityInfo.name === "Main4Ability" @@ -109,7 +109,7 @@ export default function StartAbilityTest() { abilityDelegator.getCurrentTopAbility((err: any, ability: any) => { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_PARAMETER_0002 getCurrentTopAbility: " + - ability.context.abilityInfo.name + ability.context.abilityInfo.name ); expect(ability.context.abilityInfo.name).assertEqual( "Main3Ability" @@ -131,6 +131,7 @@ export default function StartAbilityTest() { console.log( "ACTS_START_ABILITY_CALLBACK_PARAMETER_0002 fail :" + error ); + expect().assertFail(); done(); } }, 3000); @@ -159,13 +160,13 @@ export default function StartAbilityTest() { if (err != null) { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0001 meet an error: " + - err.code + err.code ); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0001 meet an error: " + - err.message + err.message ); - expect(err.code).assertEqual(2097152); + expect(err.code != null).assertTrue(); expect(err.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0001 pass" @@ -181,6 +182,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0001 meet an error: " + e ); + expect().assertFail(); done(); } }); @@ -208,13 +210,13 @@ export default function StartAbilityTest() { if (err != null) { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0002 meet an error: " + - err.code + err.code ); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0002 meet an error: " + - err.message + err.message ); - expect(err.code).assertEqual(2097199); + expect(err.code != null).assertTrue(); expect(err.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0002 pass" @@ -230,6 +232,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0002 meet an error: " + e ); + expect().assertFail(); done(); } }); @@ -260,9 +263,9 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_STARTABILITY_CALLBACK_ERROR_0003 meet an error: " + - err.message + err.message ); - expect(err.code).assertEqual(2097152); + expect(err.code != null).assertTrue(); expect(err.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_STARTABILITY_CALLBACK_ERROR_0003 pass" @@ -278,6 +281,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_STARTABILITY_CALLBACK_ERROR_0003 meet an error: " + e ); + expect().assertFail(); done(); } }); @@ -301,13 +305,13 @@ export default function StartAbilityTest() { if (err != null) { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0006 meet an error: " + - err.code + err.code ); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0006 meet an error: " + - err.message + err.message ); - expect(err.code).assertEqual(2097199); + expect(err.code != null).assertTrue(); expect(err.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0006 pass" @@ -323,6 +327,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_CALLBACK_ERROR_0006 meet an error: " + e ); + expect().assertFail(); done(); } }); @@ -422,7 +427,7 @@ export default function StartAbilityTest() { abilityDelegator.getCurrentTopAbility((err: any, ability: any) => { abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_PARAMETER_0002 getCurrentTopAbility: " + - ability.context.abilityInfo.name + ability.context.abilityInfo.name ); expect(ability.context.abilityInfo.name).assertEqual( @@ -438,15 +443,16 @@ export default function StartAbilityTest() { expect(globalThis.want.parameters["keyForBoolean"]).assertEqual( true ); - console.log("ACTS_START_ABILITY_PROMISE_PARAMETER_0002 pass"); + done() }); } catch (error) { console.log( "ACTS_START_ABILITY_PROMISE_PARAMETER_0002 fail :" + error ); + expect().assertFail(); + done(); } - done(); }, 3000); }); }); @@ -480,9 +486,9 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_STARTABILITY_PROMISE_ERROR_0001 meet an error code: " + - error.code + error.code ); - expect(error.code).assertEqual(2097152); + expect(error.code != null).assertTrue(); expect(error.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_STARTABILITY_PROMISE_ERROR_0001 pass" @@ -493,6 +499,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_STARTABILITY_PROMISE_ERROR_0001 fail error: " + error ); + expect().assertFail(); done(); } }); @@ -525,9 +532,9 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0002 meet an error code: " + - error.code + error.code ); - expect(error.code).assertEqual(2097199); + expect(error.code != null).assertTrue(); expect(error.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0002 pass" @@ -538,6 +545,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0002 fail error: " + error ); + expect().assertFail(); done(); } }); @@ -570,9 +578,9 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0003 meet an error code: " + - error.code + error.code ); - expect(error.code).assertEqual(2097152); + expect(error.code != null).assertTrue(); expect(error.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0003 pass" @@ -583,6 +591,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0003 fail error: " + error ); + expect().assertFail(); done(); } }); @@ -612,9 +621,9 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0006 meet an error code: " + - error.code + error.code ); - expect(error.code).assertEqual(2097199); + expect(error.code != null).assertTrue(); expect(error.message).assertEqual("startAbility failed."); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0006 pass" @@ -625,6 +634,7 @@ export default function StartAbilityTest() { abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0006 fail error: " + error ); + expect().assertFail(); done(); } }); @@ -664,7 +674,7 @@ export default function StartAbilityTest() { ); abilityDelegator.printSync( "ACTS_START_ABILITY_PROMISE_ERROR_0007 meet an error code: " + - error.code + error.code ); expect(error.code).assertEqual(401); done(); diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureATest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureATest/BUILD.gn index 74997b7c277ea5fff30acd29c5575f008d971f68..6c8fd3cf425139c4ae58ff0c25fcf0c853dd3039 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureATest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureATest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureBTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureBTest/BUILD.gn index 95eacc8b0793bf345c5172bf588eb5c96cb32d12..dea90ddc2d9984f47ff583a46eb8ba1f49efcd7e 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureBTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureBTest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureCTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureCTest/BUILD.gn index 6a75403db7e0d4f7a1ccf656f26f3525ed3f1b3b..427cde602dd213356ddaf5a7e723311fe6451846 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureCTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureCTest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureDTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureDTest/BUILD.gn index f8d54cef3959f5f8bac72fa57487cb8bdd78dca0..f87da528bf70cb4c7103d84b4d465edfc593e61d 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureDTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureDTest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureTest/BUILD.gn index c42e31615d703a148103f0ec8d6936028733ade9..6d7bb3ac151f7bbef043c846b429e201be1daa94 100644 --- a/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsCrossplatformFeatureTest/BUILD.gn @@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { sources = [ "src/main/resources" ] deps = [ ":windowStage_app_profile" ] hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/BUILD.gn b/ability/crossplatform/ability_runtime/BUILD.gn index bb7e55f94725d23cd81bd8d0afda6a4e7c0a6107..6ae70cb19853bd4e8195f0a92e8ca98ffa1f452e 100644 --- a/ability/crossplatform/ability_runtime/BUILD.gn +++ b/ability/crossplatform/ability_runtime/BUILD.gn @@ -17,12 +17,12 @@ group("ability_crossplatform_runtime") { testonly = true if (is_standard_system) { deps = [ - "ActsCrossplatformFeatureTest:ActsCrossplatformFeatureTest", + "ActsCrossplatformAbilityTest:ActsCrossplatformAbilityTest", "ActsCrossplatformFeatureATest:ActsCrossplatformFeatureATest", "ActsCrossplatformFeatureBTest:ActsCrossplatformFeatureBTest", "ActsCrossplatformFeatureCTest:ActsCrossplatformFeatureCTest", "ActsCrossplatformFeatureDTest:ActsCrossplatformFeatureDTest", - "ActsCrossplatformAbilityTest:ActsCrossplatformAbilityTest", + "ActsCrossplatformFeatureTest:ActsCrossplatformFeatureTest", "ActsLifeCycleEtsFeatureTest:ActsLifeCycleEtsFeatureTest", "ActsLifeCycleEtsTest:ActsLifeCycleEtsTest", "ActsUiAbilityEtsTest:ActsUiAbilityEtsTest",