From 84e3a5aa331332b3a913902cd2a36b576e6dea07 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Mon, 29 Aug 2022 16:03:58 +0800 Subject: [PATCH] =?UTF-8?q?xts=E5=A4=B1=E8=B4=A5=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../main/ets/test/ApiCoverAbility.test.ets | 54 ++++++++++++++++++- .../src/main/ets/test/VerificationTest.ets | 2 + 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets index e1df7a03e..d959be0bf 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets @@ -21,7 +21,7 @@ import formHost from '@ohos.application.formHost'; import errorManager from '@ohos.application.errorManager'; import abilityConstant from '@ohos.application.AbilityConstant' import appManager from '@ohos.application.appManager' -import appContext from '@ohos.application.context' +import applicationContext from '@ohos.application.context' import commonEvent from '@ohos.commonEvent'; import ability from '@ohos.ability.ability' FormDimension @@ -35,6 +35,13 @@ function sleep(time) { export default function ApiCoverTest() { describe('ApiCoverTestTest', function () { + afterEach(async (done) => { + isUpdated = false; + setTimeout(function () { + done(); + }, gSetTimeout); + }) + /* * @tc.number SUB_AA_ABILITY_Extension_API_001 * @tc.name StartServiceExtensionAbility with incorrect abilityName. @@ -530,5 +537,50 @@ export default function ApiCoverTest() { } }) }) + + /* + * @tc.number SUB_AA_FMS_AcquireForm_0100 + * @tc.name Test startAbility in FormExtensionContext. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_FMS_AcquireForm_0100', 0, async function (done) { + let subscriber = null + let formExtensionContext:applicationContext.FormExtensionContext + let pacMap:ability.PacMap + let subscribeInfo = { + events: ["Form_StartAbility"] + } + function UnSubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AcquireForm_0100 ===UnSubscribeInfoCallback===") + } + function SubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AcquireForm_0100 ===SubscribeInfoCallback===" + JSON.stringify(data)) + expect(data.parameters["Life"]).assertEqual("onForeground") + commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) + done() + } + commonEvent.createSubscriber(subscribeInfo, (err, data) => { + console.info("SUB_AA_FMS_AcquireForm_0100 ===CreateSubscriberCallback===") + subscriber = data + commonEvent.subscribe(subscriber, SubscribeInfoCallback) + }) + let formWant ={ + deviceId:"", + bundleName:"com.example.apicoverhaptest", + abilityName:"CreateFormAbility", + parameters:{ + "createForm": true + } + } + globalThis.abilityContext.startAbility(formWant, (err, data)=>{ + if(err.code == 0){ + console.info("SUB_AA_FMS_AcquireForm_0100 ===acquireFormState=== " + JSON.stringify(data)) + }else{ + expect().assertFail() + done() + } + }) + }) }) } diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/VerificationTest.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/VerificationTest.ets index 6b6c51e6f..6a1ba6268 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/VerificationTest.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/VerificationTest.ets @@ -66,6 +66,8 @@ export default function verificationTest(){ console.info(TAG + "startAbility data = " + JSON.stringify(data)); }).catch((err) => { console.info(TAG + "startAbility err = " + JSON.stringify(err)); + expect().assertFail(); + done(); }); } catch (err) { console.info(TAG + "catch err = " + JSON.stringify(err)); -- GitLab