From ffc17af7c8c51f79ccfa2991c7b807ba6fd90f79 Mon Sep 17 00:00:00 2001 From: kirl75 Date: Thu, 20 Jul 2023 20:49:43 +0800 Subject: [PATCH] =?UTF-8?q?xts=E8=A1=A5=E5=85=85=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kirl75 --- .../src/main/ets/MainAbility/MainAbility.ts | 13 +++++- .../entry/src/main/ets/pages/index.ets | 20 +++++++++ .../main/ets/test/ApiCoverAbility.test.ets | 42 +++++++++++++++++-- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts index 2ae3700cb..f2f7d8792 100644 --- a/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts @@ -22,8 +22,9 @@ var caller; var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility"; var event_call = "call.com.example.systemcalltest.SecondAbility"; var event_release = "release.com.example.systemcalltest.SecondAbility"; +var event_onRemoteStateChangeCall = "onRemoteStateChangeCall.com.example.systemcalltest.SecondAbility"; var subscribeInfo = { - events: [event_getcaller, event_call, event_release, ], + events: [event_getcaller, event_call, event_release, event_onRemoteStateChangeCall], }; class MySequenceable { @@ -100,6 +101,13 @@ function releaseCallee() { commonEvent.unsubscribe(subscriber, unsubscribeCallback); } +function onRemoteStateChangeCall(){ + function OnRemoteStateChangeCallback (msg){ + console.log('SystemAppCallerB MainAbility onRemoteStateChange ' + msg); + } + caller.onRemoteStateChange(OnRemoteStateChangeCallback) +} + function startNext(context) { let want = { bundleName: "com.example.systemappcallerc", @@ -122,6 +130,9 @@ export default class MainAbility extends Ability { case event_release: releaseCallee(); break; + case event_onRemoteStateChangeCall: + onRemoteStateChangeCall(); + break; default: console.log('SystemAppCallerB MainAbility subscribeCallBack event error:' + data.event); break; diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets index 6320394ec..b74f4b036 100644 --- a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets @@ -62,6 +62,26 @@ struct Index { commonEventManager.unsubscribe(subscriber, async (err, data) => { console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); }); + } else if (data.event == "terminateSelfPromise") { + this.session.terminateSelf().then((data)=>{ + console.log(TAG + "terminateSelfPromise : " + JSON.stringify(data)); + }).catch((err)=>{ + console.log(TAG + "terminateSelfPromise : " + JSON.stringify(err)); + }) + } else if (data.event == "terminateSelfCallback") { + this.session.terminateSelf((err, data)=>{ + console.log(TAG + "terminateSelfCallback : " + JSON.stringify(data)); + }) + } else if (data.event == "setWindowPrivacyModeFalseCallback") { + this.session.setWindowPrivacyMode(false, (err, data)=>{ + console.log(TAG + "setWindowPrivacyModeFalseCallback : " + JSON.stringify(data)); + }) + } else if (data.event == "setWindowPrivacyModeFalsePromise") { + this.session.setWindowPrivacyMode(false).then(()=>{ + console.log(TAG + "setWindowPrivacyModeFalsePromise : " + JSON.stringify(data)); + }).catch((err)=>{ + console.log(TAG + "setWindowPrivacyModeFalsePromise : " + JSON.stringify(err)); + }) } }); }).catch((error) => { 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 73811c186..2742c9d34 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 @@ -374,13 +374,13 @@ export default function ApiCoverTest() { }) }) - /* + /* * @tc.number SUB_AA_AMS_Context_0200 * @tc.name Register the listener of Ability and cancel the listener. * @tc.desc Function test * @tc.level 3 */ - it('SUB_AA_AMS_Context_0200', 0, async function (done) { + it('SUB_AA_AMS_Context_0200', 0, async function (done) { await globalThis.abilityContext.eventHub.on("contextEvent", func1) globalThis.abilityContext.eventHub.emit("contextEvent", "aa", "bb") await sleep(500) @@ -523,6 +523,8 @@ export default function ApiCoverTest() { expect(1).assertEqual(abilityConstant.MemoryLevel.MEMORY_LEVEL_LOW) expect(2).assertEqual(abilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) expect(5).assertEqual(abilityConstant.LaunchReason.SHARE) + expect(0).assertEqual(abilityConstant.ContinueState.ACTIVE) + expect(1).assertEqual(abilityConstant.ContinueState.INACTIVE) expect('ohos.extra.param.key.contentTitle').assertEqual(wantConstant.Params.CONTENT_TITLE_KEY) expect('ohos.extra.param.key.shareAbstract').assertEqual(wantConstant.Params.SHARE_ABSTRACT_KEY) expect('ohos.extra.param.key.shareUrl').assertEqual(wantConstant.Params.SHARE_URL_KEY) @@ -790,7 +792,7 @@ export default function ApiCoverTest() { }) /* * @tc.number SUB_AA_Form_formBindingData_0100 - * @tc.name The form of a callback getRunningProcessInformation + * @tc.name Create FormBindingData * @tc.desc Function test * @tc.level 3 */ @@ -808,5 +810,39 @@ export default function ApiCoverTest() { expect(formBinding != undefined).assertTrue() done() }) + + /* + * @tc.number SUB_AA_UIAbilityContext_setMissionContinueState_0100 + * @tc.name setMissionContinueState with callback for Ability. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_UIAbilityContext_setMissionContinueState_0100', 0, async function (done) { + TAG = 'SUB_AA_UIAbilityContext_setMissionContinueState_0100'; + globalThis.abilityContext.setMissionContinueState(0, (err, data)=>{ + console.log(`${TAG} setMissionContinueState data ${JSON.stringify(err)}`); + expect(data).assertEqual(undefined); + done(); + }) + }) + + /* + * @tc.number SUB_AA_UIAbilityContext_setMissionContinueState_0200 + * @tc.name setMissionContinueState with promise for Ability. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_UIAbilityContext_setMissionContinueState_0200', 0, async function (done) { + TAG = 'SUB_AA_UIAbilityContext_setMissionContinueState_0200'; + globalThis.abilityContext.setMissionContinueState(0).then((data)=>{ + console.log(`${TAG} setMissionContinueState data ${JSON.stringify(data)}`); + expect(data).assertEqual(undefined); + done(); + }).catch((err)=>{ + console.log(`${TAG} setMissionContinueState promise err ${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + }) }) } -- GitLab