From f08bab3d35896e99a4d10326857819a287f16d11 Mon Sep 17 00:00:00 2001 From: hu0475 Date: Sat, 15 Jul 2023 16:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9gn=E6=A0=BC=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hu0475 --- .../ActsCrossplatformAbilityTest/BUILD.gn | 2 +- .../src/main/ets/test/AbilityMonitor.test.ets | 71 +++++++++---------- .../main/ets/test/AbilityMonitor2.test.ets | 51 ++++++------- .../ets/test/AbilityStageMonitor2.test.ets | 11 ++- .../main/ets/test/Abilitydelegator.test.ets | 3 + .../main/ets/test/BackgroundCallback.test.ets | 7 -- .../main/ets/test/BackgroundPromise.test.ets | 7 -- .../main/ets/test/ForegroundCallback.test.ets | 4 -- .../main/ets/test/ForegroundPromise.test.ets | 4 -- .../main/ets/test/GetAbilityState.test.ets | 6 +- .../src/main/ets/test/Print.test.ets | 12 ++++ .../src/main/ets/test/StartAbility.test.ets | 60 +++++++++------- .../ActsCrossplatformFeatureATest/BUILD.gn | 2 +- .../ActsCrossplatformFeatureBTest/BUILD.gn | 2 +- .../ActsCrossplatformFeatureCTest/BUILD.gn | 2 +- .../ActsCrossplatformFeatureDTest/BUILD.gn | 2 +- .../ActsCrossplatformFeatureTest/BUILD.gn | 2 +- .../crossplatform/ability_runtime/BUILD.gn | 4 +- 18 files changed, 130 insertions(+), 122 deletions(-) diff --git a/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsCrossplatformAbilityTest/BUILD.gn index 823d2e1d6..f8f216aff 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 5397c3071..22bc408a7 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 b81489468..99c674095 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 a471782bd..6ab070455 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 e48603e43..9fa134cd8 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 5dfd1db87..d7dc8589c 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 e6a4e1916..6a6796618 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 a86318acd..d19420e7f 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 4d55f3b50..267b937cc 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 82ea3ef45..02ded378f 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 23b9747a7..d3f701848 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 cafd4e7b2..806000a1f 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 74997b7c2..6c8fd3cf4 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 95eacc8b0..dea90ddc2 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 6a75403db..427cde602 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 f8d54cef3..f87da528b 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 c42e31615..6d7bb3ac1 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 bb7e55f94..6ae70cb19 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", -- GitLab