diff --git a/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js b/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js index 4b13f8ccfd86edf623d24b98c1c03104acc03d37..e204b13300fb79e037cc50542e8647d4ceea252c 100644 --- a/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js +++ b/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js @@ -5247,7 +5247,8 @@ describe('ActsDataAbilityHelperTest', function () { function onAsyncCallback0401(err) { expect(err.code).assertEqual(0); flagCallback01++; - waitDone("onAsyncCallback0401"); + expect(false).assertTrue(); + done() } function onAsyncCallback0402(err) { flagCallback02++; @@ -5261,28 +5262,14 @@ describe('ActsDataAbilityHelperTest', function () { function onAsyncCallback0403(err) { expect(err.code).assertEqual(0); flagCallback03++; - waitDone("onAsyncCallback0403"); + expect(false).assertTrue(); + done() } function waitDone(caller) { console.debug("=ACTS_OnOff_0400 caller ====>" + caller); - if (flagCallback01 == 1 && flagCallback02 == 0 && flagCallback03 == 1) { - clearTimeout(currentAlertTimeout); - function mySetTimeout() { - DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0401); - DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0403); - console.log('ACTS_OnOff_0400==== { - console.debug('ACTS_OnOff_0400====" - + flagCallback01 + flagCallback02 + flagCallback03); + if (flagCallback01 == 0 && flagCallback02 == 0 && flagCallback03 == 0) { + expect("notifyChange").assertEqual(caller); + done() } } try { 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 fce9888d7ad8ef22729e92f873b43dac478adb40..36d5ac0c2fe2e4bb49c2204894493a5e9f752288 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 @@ -19,6 +19,7 @@ let resultCode = 123; let bundleName = 'ohso.act.aafwk'; let mainAbilityName = 'ohos.acts.aafwk.jsap'; const errCode = 1; +const errCode1 = 202; describe('ConnectAbilityTest', function () { @@ -64,12 +65,10 @@ describe('ConnectAbilityTest', function () { * @tc.desc: StartAbility fail with error parameter.(by promise) */ it("SUB_AA_JsApi_StartAbility_0300", 0, async function (done) { - let parameter = { - 'StartAbilityParameter': { - 'want': {} - } + let startAbilityParameter = { + 'want': {} } - await featureAbility.startAbility(parameter).then((data) => { + await featureAbility.startAbility(startAbilityParameter).then((data) => { console.log('testAbility0300 data: ' + JSON.stringify(data)) expect().assertFail() }).catch((error) => { @@ -85,12 +84,10 @@ describe('ConnectAbilityTest', function () { * @tc.desc: StartAbility fail with error parameter.(by callback) */ it("SUB_AA_JsApi_StartAbility_0400", 0, async function (done) { - let parameter = { - 'StartAbilityParameter': { - 'want': {} - } + let startAbilityParameter = { + 'want': {} } - featureAbility.startAbility((parameter), (error, data) => { + featureAbility.startAbility((startAbilityParameter), (error, data) => { console.log('testAbility0400 data: ' + JSON.stringify(data)) console.log('testAbility0400 error: ' + JSON.stringify(error)) expect(errCode).assertEqual(error.code) @@ -192,16 +189,13 @@ describe('ConnectAbilityTest', function () { * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by promise) */ it("SUB_AA_JsApi_Ability_0900", 0, async function (done) { - let parameter = { - 'startAbilityParameter': { - 'want': { - 'bundleName': bundleName, - 'abilityName': mainAbilityName - } - + let startAbilityParameter = { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName } } - await featureAbility.startAbility(parameter).then((data) => { + await featureAbility.startAbility(startAbilityParameter).then((data) => { console.log('testAblity0900 data: ' + JSON.stringify(data)) expect().assertFail() }).catch((error) => { @@ -217,16 +211,13 @@ describe('ConnectAbilityTest', function () { * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by callback) */ it("SUB_AA_JsApi_Ability_1000", 0, async function (done) { - let parameter = { - 'startAbilityParameter': { - 'want': { - 'bundleName': bundleName, - 'abilityName': mainAbilityName - } - + let startAbilityParameter = { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName } } - featureAbility.startAbility((parameter), (error, data) => { + featureAbility.startAbility((startAbilityParameter), (error, data) => { console.log('testAblity1000 data: ' + JSON.stringify(data)) console.log('testAblity1000 error: ' + JSON.stringify(error)) expect(errCode).assertEqual(error.code) @@ -246,7 +237,7 @@ describe('ConnectAbilityTest', function () { expect().assertFail() }).catch((error) => { console.log('testAblity1100 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) }) done() }) @@ -261,7 +252,7 @@ describe('ConnectAbilityTest', function () { featureAbility.startAbility(parameter, (error, data) => { console.log('testAblity1200 data: ' + JSON.stringify(data)) console.log('testAblity1200 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) done(); }) }) @@ -277,7 +268,7 @@ describe('ConnectAbilityTest', function () { expect().assertFail() }).catch((error) => { console.log('testAblity1300 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) }) done() }) @@ -291,7 +282,7 @@ describe('ConnectAbilityTest', function () { featureAbility.startAbility(undefined, (error, data) => { console.log('testAblity1400 data: ' + JSON.stringify(data)) console.log('testAblity1400 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) done(); }) }) @@ -308,7 +299,7 @@ describe('ConnectAbilityTest', function () { expect.assertFail() }).catch((error) => { console.log('testAblity1500' + JSON.stringify(error)); - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) }) done() }) @@ -323,7 +314,7 @@ describe('ConnectAbilityTest', function () { featureAbility.startAbilityForResult(parameter, (error, data) => { console.log('testAblity1600 data: ' + JSON.stringify(data)) console.log('testAblity1600 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) console.log('testAblity1600-1 error: ' + JSON.stringify(error)) done(); }) @@ -340,7 +331,7 @@ describe('ConnectAbilityTest', function () { expect.assertFail() }).catch((error) => { console.log('testAblity1700' + JSON.stringify(error)); - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) }) done() }) @@ -353,7 +344,7 @@ describe('ConnectAbilityTest', function () { it("SUB_AA_JsApi_Ability_1800", 0, async function (done) { featureAbility.startAbilityForResult(undefined, (error) => { console.log('testAblity1800' + JSON.stringify(error)); - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) done() }) }) @@ -364,19 +355,17 @@ describe('ConnectAbilityTest', function () { * @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by promise) */ it("SUB_AA_JsApi_Ability_1900", 0, async function (done) { - let parameter = { - 'StartAbilityParameter': { - 'want': { - 'bundleName': bundleName, - 'abilityName': mainAbilityName, - 'parameters': { - 'key': resultCode, - 'terminate': true - } + let startAbilityParameter = { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName, + 'parameters': { + 'key': resultCode, + 'terminate': true } } } - await featureAbility.startAbilityForResult(parameter).then((data) => { + await featureAbility.startAbilityForResult(startAbilityParameter).then((data) => { console.log('testAblity1900 data: ' + JSON.stringify(data)) expect.assertFail() }).catch((error) => { @@ -392,19 +381,17 @@ describe('ConnectAbilityTest', function () { * @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by callback) */ it("SUB_AA_JsApi_Ability_2000", 0, async function (done) { - let parameter = { - 'StartAbilityParameter': { - 'want': { - 'bundleName': bundleName, - 'abilityName': mainAbilityName, - 'parameters': { - 'key': resultCode, - 'terminate': true - } + let startAbilityParameter = { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName, + 'parameters': { + 'key': resultCode, + 'terminate': true } } } - featureAbility.startAbilityForResult(parameter, (error, data) => { + featureAbility.startAbilityForResult(startAbilityParameter, (error, data) => { console.log('testAblity2000' + JSON.stringify(error)); expect(errCode).assertEqual(error.code) done() diff --git a/ability/ability_runtime/formmanager/fa/formhostst_ets/formsystemhoste/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/formmanager/fa/formhostst_ets/formsystemhoste/entry/src/main/ets/MainAbility/pages/index.ets index 98e1ed889caa21abd651ba0aa80ef309090258f8..8eaf42ac8b3e569d536a781b0e92e7b15ac346b5 100644 --- a/ability/ability_runtime/formmanager/fa/formhostst_ets/formsystemhoste/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ability/ability_runtime/formmanager/fa/formhostst_ets/formsystemhoste/entry/src/main/ets/MainAbility/pages/index.ets @@ -191,7 +191,7 @@ struct Index { commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack); }) .catch((error) => { - console.info('formsystemhost refreshForm error:' + error); + console.info('formsystemhost refreshForm error:' + JSON.stringify(error)); let commonEventPublishData = { data: error.code.toString(), parameters: { diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets index 5b86592fd8dc3a81a56bb820a53d60befd86c601..cce3bb1e31fc6e131fd5609d727a01618f639ab1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/ets/MainAbility/test/FmsAcquireForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onErrorForm_Event = { events: ["FMS_FormOnError_commonEvent"], @@ -30,6 +30,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnError; @@ -48,6 +52,14 @@ export default function test() { await sleep(1000); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnError, () => unsubscribeCallback("afterEach unsubscribe subscriberOnError")); + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) + /** * @tc.number: FMS_acquireForm_0200 * @tc.name: The form host does not have permission to use the form diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets index d1e4165606d329b53b7fe75925c0660fdea0b7cf..f0ea932ef4b4f45da952de58effc6439ded7d8f7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/ets/MainAbility/test/FmsAcquireForm2.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onErrorForm_Event = { events: ["FMS_FormOnError_commonEvent"], @@ -30,6 +30,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnError; @@ -37,6 +41,10 @@ var subscriberOnAcquired; var subscriberCast; var subscriberSupply; +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); + } + export default function test() { describe(`FmsAcquiredFormTest2`, () => { @@ -47,6 +55,14 @@ export default function test() { subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnError, () => unsubscribeCallback("afterEach unsubscribe subscriberOnError")); + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) + /** * @tc.number: FMS_acquireForm_3800 * @tc.name: Failed to add form when parameter ability is wrong. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json index f004fd4342be2787b9233d86904451a61773a781..b412802a8235344f13bdc6084cb49585a7437794 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/Test.json @@ -18,6 +18,13 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602" + ] } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets index a441a41cab763d925c649dd0ad5e749472bac451..f47eb716d1d86a365f2681e5d6ea1233cea71b1a 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/ets/MainAbility/test/FmsDeleteForm.test.ets @@ -16,7 +16,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; import systemTime from '@ohos.systemTime'; -import { beforeEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; const onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -31,6 +31,10 @@ const onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + const deleteForm_Event = "FMS_FormDelete_commonEvent"; let subscriberOnAcquired; @@ -49,6 +53,14 @@ export default function test() { await sleep(1000); }); + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnReleased, () => unsubscribeCallback("afterEach unsubscribe subscriberOnReleased")); + commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) + /** * @tc.number: FMS_deleteForm_0200 * @tc.name: host does not have permission diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets index efaa811b298e51718e335f170be315f9dcba72db..cfcc92ec5e9fddcfd215e6e021dcba41c66e132f 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/ets/MainAbility/test/FmsDynamicRefreshForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; const onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -33,6 +33,10 @@ const onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + const deleteForm_Event = "FMS_FormDelete_commonEvent"; let subscriberOnAcquired; @@ -51,6 +55,14 @@ export default function test() { await sleep(1000); }); + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); + commonEvent.unsubscribe(subscriberOnRefresh, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRefresh")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) + /** * @tc.number: FMS_timedRefresh_0100 * @tc.name: formID id is error(formID < 0) diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets index 11b10395cf7c038d8fbf6f8592df22e4d21fb1b2..7cc7f1fdd4075540df93fd8e03e09bdb2b1db27e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets @@ -62,12 +62,12 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { tempDataC = dataC[0]; expect(error.code).assertEqual(ERR_OK_CODE); expect(error.message).assertEqual(ERR_OK); - console.log(`==========${callbackName} ${describeName} end==========`); }); await sleep(2000) checkDataB(tempDataB) checkDataC(tempDataC) done(); + console.log(`==========${callbackName} ${describeName} end==========`); } catch (error) { console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName} should not reach here`); @@ -104,7 +104,8 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(dataC.length).assertEqual(1); tempDataB = dataB[0]; tempDataC = dataC[0]; - + checkDataB(tempDataB) + checkDataC(tempDataC) done(); console.log(`==========${promiseName} ${describeName} end==========`); } catch (error) { @@ -126,15 +127,14 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityb").assertEqual(formInfo.formConfigAbility) expect(3).assertEqual(formInfo.updateDuration) expect(2).assertEqual(formInfo.defaultDimension) expect('10:30').assertEqual(formInfo.scheduledUpdateTime) expect(1).assertEqual(formInfo.supportDimensions[0]) expect(2).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameB').assertEqual(formInfo.customizeData[0].name) - expect('valueB').assertEqual(formInfo.customizeData[0].value) + expect('valueB').assertEqual(formInfo.customizeData.originWidgetNameB) } function checkDataC(formInfo){ expect("com.ohos.st.formsystemproviderc").assertEqual(formInfo.bundleName) @@ -148,15 +148,14 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityc").assertEqual(formInfo.formConfigAbility) expect(4).assertEqual(formInfo.updateDuration) expect('15:30').assertEqual(formInfo.scheduledUpdateTime) expect(3).assertEqual(formInfo.defaultDimension) expect(3).assertEqual(formInfo.supportDimensions[0]) expect(4).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameC').assertEqual(formInfo.customizeData[0].name) - expect('valueC').assertEqual(formInfo.customizeData[0].value) + expect('valueC').assertEqual(formInfo.customizeData.originWidgetNameC) } }); }; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets index 31f4d1f1c3b27ac24a08d898b5c6e207853637cd..d5bd25b2ecf5b7d57761d356a6af31a4d105a380 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandonetest/entry/src/main/ets/MainAbility/test/GetFormsInfo.test.ets @@ -236,15 +236,14 @@ export const getFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityb").assertEqual(formInfo.formConfigAbility) expect(3).assertEqual(formInfo.updateDuration) expect(2).assertEqual(formInfo.defaultDimension) expect('10:30').assertEqual(formInfo.scheduledUpdateTime) expect(1).assertEqual(formInfo.supportDimensions[0]) expect(2).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameB').assertEqual(formInfo.customizeData[0].name) - expect('valueB').assertEqual(formInfo.customizeData[0].value) + expect('valueB').assertEqual(formInfo.customizeData.originWidgetNameB) } /** @@ -517,14 +516,13 @@ export const getFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityc").assertEqual(formInfo.formConfigAbility) expect(4).assertEqual(formInfo.updateDuration) expect(3).assertEqual(formInfo.defaultDimension) expect(3).assertEqual(formInfo.supportDimensions[0]) expect(4).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameC').assertEqual(formInfo.customizeData[0].name) - expect('valueC').assertEqual(formInfo.customizeData[0].value) + expect('valueC').assertEqual(formInfo.customizeData.originWidgetNameC) } }); }; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets index 8058bc266157816b71c0119f5014986bb28193ee..670da2dc8e1a1ee9c94c6b13795653c744fb00b7 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandtwotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets @@ -132,15 +132,14 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityb").assertEqual(formInfo.formConfigAbility) expect(3).assertEqual(formInfo.updateDuration) expect(2).assertEqual(formInfo.defaultDimension) expect('10:30').assertEqual(formInfo.scheduledUpdateTime) expect(1).assertEqual(formInfo.supportDimensions[0]) expect(2).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameB').assertEqual(formInfo.customizeData[0].name) - expect('valueB').assertEqual(formInfo.customizeData[0].value) + expect('valueB').assertEqual(formInfo.customizeData.originWidgetNameB) } function checkDataA1(formInfo){ @@ -155,15 +154,14 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilitya01").assertEqual(formInfo.formConfigAbility) expect(1).assertEqual(formInfo.updateDuration) expect(1).assertEqual(formInfo.defaultDimension) expect('5:30').assertEqual(formInfo.scheduledUpdateTime) expect(1).assertEqual(formInfo.supportDimensions[0]) expect(3).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameA01').assertEqual(formInfo.customizeData[0].name) - expect('valueA01').assertEqual(formInfo.customizeData[0].value) + expect('valueA01').assertEqual(formInfo.customizeData.originWidgetNameA01) } function checkDataA2(formInfo){ @@ -178,7 +176,7 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertFalse() expect(formInfo.updateEnabled).assertFalse() expect(formInfo.formVisibleNotify).assertFalse() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilitya02").assertEqual(formInfo.formConfigAbility) expect(2).assertEqual(formInfo.updateDuration) expect(4).assertEqual(formInfo.defaultDimension) @@ -187,8 +185,7 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(2).assertEqual(formInfo.supportDimensions[1]) expect(3).assertEqual(formInfo.supportDimensions[2]) expect(4).assertEqual(formInfo.supportDimensions[3]) - expect('originWidgetNameA02').assertEqual(formInfo.customizeData[0].name) - expect('valueA02').assertEqual(formInfo.customizeData[0].value) + expect('valueA02').assertEqual(formInfo.customizeData.originWidgetNameA02) } }); }; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets index b049106819b7c52879e3fa09f629b378248cfb05..e3b8503e66822eeaece2fe0d17e078195e49d1cd 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formgetformsinfotest/formsoneandzerotest/entry/src/main/ets/MainAbility/test/GetAllFormsInfo.test.ets @@ -122,15 +122,14 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => { expect(formInfo.isDefault).assertTrue() expect(formInfo.updateEnabled).assertTrue() expect(formInfo.formVisibleNotify).assertTrue() - expect(undefined).assertEqual(formInfo.relatedBundleName) + expect('').assertEqual(formInfo.relatedBundleName) expect("abilityb").assertEqual(formInfo.formConfigAbility) expect(3).assertEqual(formInfo.updateDuration) expect(2).assertEqual(formInfo.defaultDimension) expect('10:30').assertEqual(formInfo.scheduledUpdateTime) expect(1).assertEqual(formInfo.supportDimensions[0]) expect(2).assertEqual(formInfo.supportDimensions[1]) - expect('originWidgetNameB').assertEqual(formInfo.customizeData[0].name) - expect('valueB').assertEqual(formInfo.customizeData[0].value) + expect('valueB').assertEqual(formInfo.customizeData.originWidgetNameB) } }); }; diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets index ea0cdf380490476ed848dddbe157e52ab82b6804..f174204c7e6e8025bfbe0d99a54d2b6de38931a9 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formhostdeathrecipienttest/entry/src/main/ets/MainAbility/test/FmsHostDeathRecipient.test.ets @@ -15,7 +15,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; const onAcquiredEvent = { events: [`FMS_FormOnAcquired_commonEvent`], @@ -28,6 +28,11 @@ const onRequestEvent = { }; const formOnTerminateEvent = `FMS_FormTerminate_commonEvent`; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + + let tcNumber; let hostCounter; let providerCounter; @@ -47,6 +52,13 @@ export default function test() { onRequestEventSubscriber = await commonEvent.createSubscriber(onRequestEvent); }); + afterEach(async() => { + commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onAcquiredEventSubscriber")); + commonEvent.unsubscribe(onSupplyEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onSupplyEventSubscriber")); + commonEvent.unsubscribe(onRequestEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onRequestEventSubscriber")); + await sleep(1000); + }) + /** * @tc.number: FMS_hostDeathRecipient_0200 * @tc.name: Reset host ability and requestForm. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json index 5e0ae08e4331e977092d65e48243011363e4e07d..ac9ae4d70dca5b4c984a7c9ecb889ca79e7d6655 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/Test.json @@ -15,6 +15,13 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602" + ] } ] } \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets index 1c740db61a8bfb6763f72b992fbc7a35bc4eb385..c201dbc2691d1ada18ffe859c2d2ab5f0b182f84 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formperformancetest/entry/src/main/ets/MainAbility/test/FmsPerformanceTest.test.ets @@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import formHost from '@ohos.application.formHost'; import commonEvent from '@ohos.commonEvent'; import systemTime from '@ohos.systemTime'; -import { beforeEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; const onAcquiredEvent = { events: [`FMS_FormOnAcquired_commonEvent`], @@ -38,9 +38,17 @@ const publishOnDeleteCallback = (tcNumber, done) => { done(); } +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + let onAcquiredEventSubscriber; let onSupplyEventSubscriber; +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); + } + export default function test() { describe(`FmsPerformanceTest`, () => { @@ -49,6 +57,12 @@ export default function test() { onSupplyEventSubscriber = await commonEvent.createSubscriber(onSupplyEvent); }); + afterEach(async() => { + commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onAcquiredEventSubscriber")); + commonEvent.unsubscribe(onSupplyEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onSupplyEventSubscriber")); + await sleep(1000); + }) + /** * @tc.number: FMS_performanceTest_0100 * @tc.name: Performance test. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets index 3437587e817b12ce0c0e62ac824233437df4f14f..2a4b59f8a2776dea27a433bf5e42faf4e42be5be 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/ets/MainAbility/test/FmsReleaseForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -28,6 +28,10 @@ var onReleasedFormEvent = { }; var deleteForm_Event = "FMS_FormDelete_commonEvent"; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var subscriberOnAcquired; var subscriberOnDeleted; var subscriberOnReleased; @@ -45,6 +49,14 @@ export default function test() { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event); subscriberOnDeleted = await commonEvent.createSubscriber(onDeletedFormEvent); subscriberOnReleased = await commonEvent.createSubscriber(onReleasedFormEvent); + await sleep(1000); + }) + + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); + commonEvent.unsubscribe(subscriberOnReleased, () => unsubscribeCallback("afterEach unsubscribe subscriberOnReleased")); + await sleep(1000); }) /** diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets index b0521cab47a78567b35960b74f7059998f69288a..ce857acd33bfbc6ede705215eb65c1dca0d959fa 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -33,6 +33,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnAcquired; @@ -55,6 +59,14 @@ export default function test() { await sleep(1000); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel")); + commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) + /** * @tc.number: FMS_disableFormsUpdate_0200 * @tc.name: The form user does not have permission. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json index 6de3637f2fd1edb97c32d70be810f0d81879bb55..d0068688e3849ed62e3927354377d88da1d255c6 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/Test.json @@ -20,6 +20,13 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602" + ] } ] } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets index 886ff89ca9911b7cde1fdd096cacd5dd7afe0d8c..96c355bb6390721e0ec067fe5c3c5fa06cfaf0db 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -33,6 +33,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnAcquired; @@ -55,6 +59,13 @@ export default function test() { await sleep(1000); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel")); + commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) /** * @tc.number: FMS_enableFormsUpdate_0200 * @tc.name: The form user does not have permission. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets index 2b88bb784585dd67c33b13963dc9ef5757a05378..1f851a364c76e882460b982d9c83d20bc8caf43e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { describe, beforeEach, expect, it } from "deccjsunit/index"; +import { describe, afterEach, beforeEach, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -33,6 +33,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnAcquired; @@ -51,6 +55,13 @@ export default function test() { await sleep(1000); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel")); + commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) /** * @tc.number: FMS_notifyInvisibleForms_0200 * @tc.name: The form user does not have permission. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets index e972f88887c2201dd5982887e26b52f7ba13eac5..c886fd3df6150137fa79787ddaba4b9af7745841 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -29,6 +29,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnAcquired; @@ -46,6 +50,12 @@ export default function test() { await sleep(1000); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) /** * @tc.number: FMS_notifyInvisibleForms_0900 * @tc.name: There are correct and wrong formId in the form ID parameter list diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets index 5c71d84f71b72105d2d4fe6a5e77be3d13068974..804612722d2d5f58d8f8946a83449317370112fc 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -29,6 +29,10 @@ var onSupplyEvent = { events: ["FMS_FormSupply_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; var subscriberOnAcquired; @@ -49,7 +53,12 @@ export default function test() { await sleep(1000); }) - + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); + commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); + await sleep(1000); + }) /** * @tc.number: FMS_notifyVisibleForms_0200 * @tc.name: The form user does not have permission. diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets index 803ce1074ce04577db4f05d0648bec2c0913fd52..f47cbacfb9d74b42914ebd6facffdf1c99e5d2ac 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/MainAbility/test/FmsStress.test.ets @@ -16,7 +16,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import formHost from '@ohos.application.formHost'; import commonEvent from '@ohos.commonEvent'; -import { beforeEach, describe, expect, it } from 'deccjsunit/index'; +import { beforeEach, afterEach, describe, expect, it } from 'deccjsunit/index'; const onDeletedEvent = { events: [`FMS_FormOnDeleted_commonEvent`] @@ -29,6 +29,10 @@ const onSupplyEvent = { }; const formOnDeleteEvent = `FMS_FormDelete_commonEvent`; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + const unsubscribeOnDeletedCallback = (tcNumber, done) => { console.info(`${tcNumber} unsubscribeOnDeleted Callback`); done(); @@ -47,6 +51,10 @@ let onDeletedEventSubscriber; let onAcquiredEventSubscriber; let onSupplyEventSubscriber; +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); + } + export default function test() { describe(`FmsStressTest`, () => { @@ -56,6 +64,13 @@ export default function test() { onSupplyEventSubscriber = await commonEvent.createSubscriber(onSupplyEvent); }); + afterEach(async() => { + commonEvent.unsubscribe(onDeletedEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onDeletedEventSubscriber")); + commonEvent.unsubscribe(onAcquiredEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onAcquiredEventSubscriber")); + commonEvent.unsubscribe(onSupplyEventSubscriber, () => unsubscribeCallback("afterEach unsubscribe onSupplyEventSubscriber")); + await sleep(1000); + }) + const subscribeDeletedEvent = (tcNumber, expectedDeletedFormAmount, done) => { commonEvent.subscribe(onDeletedEventSubscriber, async (err, data) => { const formIds = data.parameters.formIds; @@ -594,7 +609,7 @@ export default function test() { const systemstatus = await formHost.isSystemReady(); console.info(`${tcNumber} systemstatus: ${JSON.stringify(systemstatus)}`); - expect(systemstatus).assertEqual(0); + expect(systemstatus).assertEqual(undefined); done(); }); }); diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets index 213a31c19a3582eb306e87ccdfd483f129344972..958ac7cef44f0d72e8c26693fc733c99e3e56359 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/ets/MainAbility/test/FmsUpdateRefreshForm.test.ets @@ -15,7 +15,7 @@ import featureAbility from "@ohos.ability.featureAbility"; import commonEvent from '@ohos.commonEvent'; -import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index"; +import { beforeAll, beforeEach, afterEach, describe, expect, it } from "deccjsunit/index"; var onAcquiredForm_Event = { events: ["FMS_FormOnAcquired_commonEvent"], @@ -30,6 +30,10 @@ var onRequestFormEvent = { events: ["FMS_FormOnRequest_commonEvent"], }; +const unsubscribeCallback = (tcNumber) => { + console.info(`====>${tcNumber} unsubscribeCallback====>`); +} + var deleteForm_Event = "FMS_FormDelete_commonEvent"; @@ -38,6 +42,10 @@ var subscriberOnDeleted; var subscriberOnRefresh; var subscriberOnRequest; +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); + } + export default function test() { describe(`FmsUpdateRefreshFormTest`, () => { @@ -52,6 +60,13 @@ export default function test() { subscriberOnRequest = await commonEvent.createSubscriber(onRequestFormEvent); }) + afterEach(async() => { + commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); + commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); + commonEvent.unsubscribe(subscriberOnRefresh, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRefresh")); + commonEvent.unsubscribe(subscriberOnRequest, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRequest")); + await sleep(1000); + }) /** * @tc.number: FMS_updateForm_0100 * @tc.name: formID id is error(formID < 0)