From 1d1238606b4c94e169e74603f7cb8ea3e9da23c8 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Thu, 8 Sep 2022 16:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9B=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../src/main/ets/MainAbility/MainAbility.ts | 13 ++++++++- .../entry/src/main/ets/pages/index/index.ets | 9 ------- .../entry/src/main/ets/test/Ability.test.ets | 19 +++++++++++++ .../main/ets/test/OnAndOffScreenTest.test.ets | 26 +++++++++++++++++- .../entry/src/main/module.json | 1 + .../ets/test/FaSetDisplayOrientation.test.ets | 10 +++++++ .../src/main/ets/test/FaShowOnLock.test.ets | 25 +++++++++++++++++ .../entry/src/main/module.json | 1 + .../entry/src/main/ets/test/Ability.test.ets | 26 ++++++++++++++++++ .../main/js/test/FeatureAbilityJsunit.test.js | 18 ++++++++++++- .../main/js/test/StartAbilityJsunit.test.js | 18 +++++++++++++ .../src/main/ets/test/FmsAcquireForm.test.ets | 12 +++++++++ .../main/ets/test/FmsAcquireForm2.test.ets | 12 +++++++++ .../src/main/ets/test/FmsDeleteForm.test.ets | 27 ++++++++++++++++++- .../ets/test/FmsDynamicRefreshForm.test.ets | 12 +++++++++ .../src/main/ets/test/FmsReleaseForm.test.ets | 12 +++++++++ .../ets/test/FmsFormStateDisable.test.ets | 25 +++++++++++++++-- .../main/ets/test/FmsFormStateEnable.test.ets | 25 +++++++++++++++-- .../test/FmsFormStateNotifyInvisible.test.ets | 12 +++++++++ .../FmsFormStateNotifyInvisible2.test.ets | 12 +++++++++ .../test/FmsFormStateNotifyVisible.test.ets | 12 +++++++++ .../src/main/ets/MainAbility/MainAbility.ts | 13 ++++++++- .../ets/MainAbility/pages/index/index.ets | 10 ------- .../entry/src/main/ets/test/Ability.test.ets | 16 +++++++++++ .../entry/src/main/module.json | 1 + .../src/main/ets/MainAbility/MainAbility.ts | 14 +++++++++- .../ets/MainAbility/pages/index/index.ets | 10 ------- .../entry/src/main/ets/test/Ability.test.ets | 15 ++++++++++- .../entry/src/main/module.json | 1 + 29 files changed, 367 insertions(+), 40 deletions(-) diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts index 6d4dc7c06..a7588ad77 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,12 +13,23 @@ * limitations under the License. */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { onCreate(want,launchParam){ // Ability is creating, initialize resources for this ability console.log("AbilityMultiInstanceTest onCreate") globalThis.abilityWant = want; + + globalThis.abilityContext = this.context + let abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } onDestroy() { @@ -29,7 +40,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability console.log("AbilityMultiInstanceTest onWindowStageCreate") - globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) console.log("AbilityMultiInstanceTest onWindowStageCreate finish") } diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets index 8104a9e40..88f0dd53f 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets @@ -13,20 +13,11 @@ * limitations under the License. */ -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../../test/List.test' @Entry @Component struct Index { aboutToAppear(){ - let abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - let abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets index 8b530aded..c13edd358 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -91,6 +91,25 @@ async function startAbilityProcess(abilityContext, parameters) { export default function abilityTest(abilityContext) { describe('ActsAbilityTest', function () { + let TAG1 = "ACTS_AbilityMultiInstance_Single == "; + afterEach(async (done) => { + console.log(TAG1 + "afterEach called"); + let wantInfo = { + bundleName: "com.example.abilitymultiinstance", + abilityName: "com.example.abilitymultiinstance.MainAbility" + } + await abilityContext.startAbility(wantInfo).then((data) => { + console.log(TAG1 + "startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log(TAG1 + "startAbility err : " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log(TAG1 + "afterEach end"); + done(); + }, 500); + }) + /* * @tc.number: ACTS_AbilityMultiInstance_Multi_0100 * @tc.name: Connects a service ability, which is used to start a cloned page ability. diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets index 44f8b8275..8b1994eba 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets @@ -17,15 +17,39 @@ import { BY,UiDriver,UiComponent } from '@ohos.uitest'; import commonEvent from '@ohos.commonEvent'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import power from '@ohos.power'; +import backgroundTaskManager from '@ohos.backgroundTaskManager'; export default function OnAndOffScreenTest() { describe('OnAndOffScreenTest', function () { let TAG = ""; - let TAG1 = "SUB_AA_OpenHarmony == "; + let TAG1 = "SUB_AA_OpenHarmony == OnAndOffScreenTest : "; let sleepTimeOne = 1000; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let id = undefined; + beforeAll(async (done) => { + console.log(TAG1 + "beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log(TAG1 + "Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log(TAG1 + "requestId is : " + id); + setTimeout(function () { + console.log(TAG1 + "beforeAll end"); + done(); + }, sleepTimeOne); + }) + + afterAll(async (done) => { + console.log(TAG1 + "afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log(TAG1 + "afterAll end"); + done(); + }, sleepTimeOne); + }) async function slideScreen(TAG) { console.log(TAG + "slideScreen start"); diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json index f81b1543a..8bbef22e5 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json @@ -22,6 +22,7 @@ "startWindowIcon": "$media:icon", "startWindowBackground": "$color:white", "visible": true, + "launchType": "singleton", "skills": [ { "entities": [ diff --git a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaSetDisplayOrientation.test.ets b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaSetDisplayOrientation.test.ets index c3ce871f4..c4ca0cb70 100644 --- a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaSetDisplayOrientation.test.ets +++ b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaSetDisplayOrientation.test.ets @@ -29,6 +29,16 @@ export default function FaSetDisplayOrientationTest() { afterEach(async (done) => { console.log(TAG1 + "afterEach called"); + let wantInfo = { + bundleName: "com.example.supportfunctionhaptest", + abilityName: "MainAbility" + } + await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => { + console.log(TAG1 + "startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log(TAG1 + "startAbility err : " + JSON.stringify(err)); + }) + let cmd1 = "aa force-stop ohos.acts.aafwk.test.fasupportfunction"; let cmd2 = "aa force-stop ohos.acts.aafwk.test.fasupportfunctionthree"; diff --git a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaShowOnLock.test.ets b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaShowOnLock.test.ets index 84203ede6..ca61879ab 100644 --- a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaShowOnLock.test.ets +++ b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/ets/test/FaShowOnLock.test.ets @@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import commonEvent from '@ohos.commonEvent'; import power from '@ohos.power'; +import backgroundTaskManager from '@ohos.backgroundTaskManager'; export default function FaShowOnLockTest() { @@ -26,6 +27,30 @@ export default function FaShowOnLockTest() { let sleepTimeOne = 1000; let sleepTimeTwo = 2000; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let id = undefined; + beforeAll(async (done) => { + console.log(TAG1 + "beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log(TAG1 + "Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log(TAG1 + "requestId is : " + id); + setTimeout(function () { + console.log(TAG1 + "beforeAll end"); + done(); + }, sleepTimeOne); + }) + + afterAll(async (done) => { + console.log(TAG1 + "afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log(TAG1 + "afterAll end"); + done(); + }, sleepTimeOne); + }) + beforeEach(async (done) => { console.log(TAG1 + "beforeEach called"); let status = undefined; diff --git a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json index f81b1543a..8bbef22e5 100644 --- a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json @@ -22,6 +22,7 @@ "startWindowIcon": "$media:icon", "startWindowBackground": "$color:white", "visible": true, + "launchType": "singleton", "skills": [ { "entities": [ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets index 2f92b8b00..acc8ff7f6 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets @@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " import commonEvent from '@ohos.commonEvent' import appManager from '@ohos.application.appManager' import osaccount from '@ohos.account.osAccount' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; var subscriberInfo_MainAbility = { events: ["ACTS_InterfaceMultiUsers_0100_Start_CommonEvent","ACTS_TerminateSelf_CommonEvent"] @@ -39,6 +40,31 @@ export default function abilityTest() { // }) // }) // }) + + let id = undefined; + beforeAll(async (done) => { + console.log("ACTS_InterfaceMultiUsers beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log("ACTS_InterfaceMultiUsers Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log("ACTS_InterfaceMultiUsers requestId is : " + id); + setTimeout(function () { + console.log("ACTS_InterfaceMultiUsers beforeAll end"); + done(); + }, 1000); + }) + + afterAll(async (done) => { + console.log("ACTS_InterfaceMultiUsers afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log("ACTS_InterfaceMultiUsers afterAll end"); + done(); + }, 1000); + }) + console.debug("====>in ACTS_InterfaceMultiUsers====>"); /* * @tc.number : ACTS_startAbility_0100 diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js index adb2b8c92..67affdfdb 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js @@ -84,7 +84,7 @@ describe('ActsFeatureAbilityTest', function () { console.info('beforeEach called') }) - afterEach(function() { + afterEach(async function(done) { /* * @tc.teardown: teardown invoked after each testcases @@ -94,6 +94,22 @@ describe('ActsFeatureAbilityTest', function () { setTimeout(() => {}, 500); backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()); setTimeout(() => {}, 500); + + let wantInfo = { + want: { + bundleName: "com.example.actsfeatureabilitytest", + abilityName: "com.example.actsfeatureabilitytest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("ACTS_wantConstant startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ACTS_wantConstant startAbility err : " + JSON.stringify(err)); + }) + setTimeout(function () { + console.log("ACTS_wantConstant afterEach end"); + done(); + }, 500); }) /** diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js index 216bba81a..e420df97c 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js @@ -23,6 +23,24 @@ const errCode1 = 202; export default function startAbilityTest() { describe('StartAbilityTest', function () { + afterEach(async function(done) { + let wantInfo = { + want: { + bundleName: "com.example.actsfeatureabilitytest", + abilityName: "com.example.actsfeatureabilitytest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("SUB_AA_JsApi_StartAbility startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("SUB_AA_JsApi_StartAbility startAbility err : " + JSON.stringify(err)); + }) + setTimeout(function () { + console.log("SUB_AA_JsApi_StartAbility afterEach end"); + done(); + }, 500); + }) + /* * @tc.number: SUB_AA_JsApi_StartAbility_0100 * @tc.name: testAbility0100. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets index cb718c637..aef4000c8 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/test/FmsAcquireForm.test.ets @@ -57,6 +57,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formacquiretest", + abilityName: "com.ohos.st.formacquiretest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_acquireForm startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_acquireForm startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets index 0eb17e84a..04066271e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/test/FmsAcquireForm2.test.ets @@ -60,6 +60,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formacquiretest2", + abilityName: "com.ohos.st.formacquiretest2.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_acquireForm2 startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_acquireForm2 startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets index 151d24e4d..3cedbffb3 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/test/FmsDeleteForm.test.ets @@ -16,7 +16,8 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; import systemTime from '@ohos.systemTime'; -import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; const onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -45,6 +46,30 @@ let subscriberSupply; export default function test() { describe(`FmsDeleteFormTest`, () => { + let id = undefined; + beforeAll(async (done) => { + console.log("FMS_deleteForm beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log("FMS_deleteForm Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log("FMS_deleteForm requestId is : " + id); + setTimeout(function () { + console.log("FMS_deleteForm beforeAll end"); + done(); + }, 1000); + }) + + afterAll(async (done) => { + console.log("FMS_deleteForm afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log("FMS_deleteForm afterAll end"); + done(); + }, 1000); + }) + beforeEach(async () => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event); subscriberOnReleased = await commonEvent.createSubscriber(onReleasedFormEvent); diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets index 09ee65d6b..14374575c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/test/FmsDynamicRefreshForm.test.ets @@ -60,6 +60,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); commonEvent.unsubscribe(subscriberOnRefresh, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRefresh")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formdynamicrefreshtest", + abilityName: "com.ohos.st.formdynamicrefreshtest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_timedRefresh startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_timedRefresh startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets index bef74bca0..98f917915 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/test/FmsReleaseForm.test.ets @@ -56,6 +56,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); commonEvent.unsubscribe(subscriberOnReleased, () => unsubscribeCallback("afterEach unsubscribe subscriberOnReleased")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formreleasetest", + abilityName: "com.ohos.st.formreleasetest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_releaseForm startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_releaseForm startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets index 793cff053..33e7f385c 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/test/FmsFormStateDisable.test.ets @@ -15,7 +15,8 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -47,8 +48,28 @@ var subscriberSupply; export default function test() { describe(`FmsStateFormTest`, () => { + let id = undefined; beforeAll(async (done) => { - done(); + console.log("FMS_disableFormsUpdate beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log("FMS_disableFormsUpdate Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log("FMS_disableFormsUpdate requestId is : " + id); + setTimeout(function () { + console.log("FMS_disableFormsUpdate beforeAll end"); + done(); + }, 1000); + }) + + afterAll(async (done) => { + console.log("FMS_disableFormsUpdate afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log("FMS_disableFormsUpdate afterAll end"); + done(); + }, 1000); }) beforeEach(async () => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets index e412b4112..205120afe 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/test/FmsFormStateEnable.test.ets @@ -15,7 +15,8 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -47,8 +48,28 @@ var subscriberSupply; export default function test() { describe(`FmsStateFormTest`, () => { + let id = undefined; beforeAll(async (done) => { - done(); + console.log("FMS_enableFormsUpdate beforeAll called"); + let myReason = 'test FaShowOnLockTest'; + let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.log("FMS_enableFormsUpdate Request suspension delay will time out."); + }) + id = delayInfo.requestId; + console.log("FMS_enableFormsUpdate requestId is : " + id); + setTimeout(function () { + console.log("FMS_enableFormsUpdate beforeAll end"); + done(); + }, 1000); + }) + + afterAll(async (done) => { + console.log("FMS_enableFormsUpdate afterAll called"); + backgroundTaskManager.cancelSuspendDelay(id); + setTimeout(function () { + console.log("FMS_enableFormsUpdate afterAll end"); + done(); + }, 1000); }) beforeEach(async () => { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets index 3fc87b2f5..d1e1fdea5 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/test/FmsFormStateNotifyInvisible.test.ets @@ -60,6 +60,18 @@ export default function test() { commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formstatenotifyinvisibletest", + abilityName: "com.ohos.st.formstatenotifyinvisibletest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_notifyInvisibleForms startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_notifyInvisibleForms startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) /** diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets index 84d1c2846..6dd14fbb1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/test/FmsFormStateNotifyInvisible2.test.ets @@ -54,6 +54,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formstatenotifyinvisibletest2", + abilityName: "com.ohos.st.formstatenotifyinvisibletest2.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_notifyInvisibleForms2 startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_notifyInvisibleForms2 startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) /** diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets index 9458578b8..ffd33691e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/test/FmsFormStateNotifyVisible.test.ets @@ -57,6 +57,18 @@ export default function test() { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + + let wantInfo = { + want: { + bundleName: "com.ohos.st.formstatenotifyvisibletest", + abilityName: "com.ohos.st.formstatenotifyvisibletest.TestAbility" + } + } + await featureAbility.startAbility(wantInfo).then((data) => { + console.log("FMS_notifyVisibleForms startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("FMS_notifyVisibleForms startAbility err : " + JSON.stringify(err)); + }) await sleep(1000); }) /** diff --git a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts index 553641481..717657a0c 100644 --- a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,6 +13,9 @@ * limitations under the License. */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { @@ -20,6 +23,14 @@ export default class MainAbility extends Ability { // Ability is creating, initialize resources for this ability console.log("MainAbility onCreate") globalThis.abilityWant = want; + globalThis.abilityContext = this.context + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } onDestroy() { @@ -30,7 +41,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability console.log("MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } diff --git a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/pages/index/index.ets index 18591878e..d10df7d7f 100644 --- a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/pages/index/index.ets +++ b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -13,20 +13,10 @@ * limitations under the License. */ import router from '@ohos.router'; -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../../../test/List.test' @Entry @Component struct Index { aboutToAppear() { - console.info("start run testcase!!!!") - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { diff --git a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets index fdfab03ef..daf5122ee 100644 --- a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets @@ -42,6 +42,22 @@ export default function killProcessWithAccountTest() { }) }) + afterEach(async (done) => { + console.log("ACTS_KillProcessWithAccount afterEach called"); + let wantInfo = { + bundleName: "com.acts.killprocesswithaccount", + abilityName: "com.acts.killprocesswithaccount.MainAbility" + } + await globalThis.abilityContext.startAbility(wantInfo).then((data) => { + console.log("ACTS_KillProcessWithAccount startAbility data : " + JSON.stringify(data)); + }).catch((err) => { + console.log("ACTS_KillProcessWithAccount startAbility err : " + JSON.stringify(err)); + }) + setTimeout(function () { + console.log("ACTS_KillProcessWithAccount afterEach end"); + done(); + }, 500); + }) beforeEach(async (done) => { console.log('======>beforeEach killProcessWithAccountTest<=======' + flag); diff --git a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json index cf635c27f..fd1246168 100644 --- a/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json +++ b/ability/ability_runtime/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json @@ -21,6 +21,7 @@ "label": "$string:entry_label", "visible": true, "orientation": "portrait", + "launchType": "singleton", "skills": [ { "actions": [ diff --git a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts index 5d9cb94eb..03bed122d 100644 --- a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,12 +13,24 @@ * limitations under the License. */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { onCreate(want,launchParam){ // Ability is creating, initialize resources for this ability console.log("MainAbility onCreate") globalThis.abilityWant = want; + + globalThis.abilityContext = this.context + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } onDestroy() { @@ -29,7 +41,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability console.log("MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } diff --git a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/pages/index/index.ets index bebda07c2..acd879f64 100644 --- a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/pages/index/index.ets +++ b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -13,9 +13,6 @@ * limitations under the License. */ import router from '@ohos.router'; -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../../../test/List.test' @Entry @@ -23,13 +20,6 @@ import testsuite from '../../../test/List.test' struct Index { aboutToAppear(){ - console.info("start run testcase!!!!") - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets index 860b27fab..05ba5e1ac 100644 --- a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -43,7 +43,20 @@ export default function abilityTest() { await appManager.killProcessesByBundleName("com.example.multiinstancehapa"); await appManager.killProcessesByBundleName("com.example.multiinstancehapb"); - done(); + let wantInfo = { + bundleName: "com.example.processmultiinstance", + abilityName: "com.example.processmultiinstance.MainAbility" + } + await globalThis.abilityContext.startAbility(wantInfo).then((data) => { + console.log("ACTS_Process_MultiInstance startAbility data: " + JSON.stringify(data)); + }).catch((err) => { + console.log("ACTS_Process_MultiInstance startAbility err: " + JSON.stringify(err)); + }) + + setTimeout(function () { + console.log("ACTS_Process_MultiInstance afterEach end"); + done(); + }, 500); }) /** diff --git a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json index 0152946dc..694171f95 100644 --- a/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json +++ b/ability/ability_runtime/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json @@ -21,6 +21,7 @@ "label": "$string:entry_label", "visible": true, "orientation": "portrait", + "launchType": "singleton", "skills": [ { "actions": [ -- GitLab