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 c30c08de8f1fec7eec9ddaa3231eec72192d6ac6..ba110ccd8ac98fb92688237eddf9565d5d43df6d 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 @@ -32,9 +32,16 @@ var array = new Array(); function sleep(time) { return new Promise((resolve)=>setTimeout(resolve,time)); } + export default function ApiCoverTest() { describe('ApiCoverTestTest', function () { + afterEach(async (done) => { + setTimeout(function () { + done(); + }, 2000); + }) + /* * @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 6b6c51e6f56ae9876b0d3231e8fec3afe6b445b6..6a1ba6268d3389c2e3f8f9f56c799da7677ca5fc 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));