From 509c4202f7e3d95081938910c37543aec0b07b09 Mon Sep 17 00:00:00 2001 From: yangzk Date: Mon, 24 Oct 2022 22:20:35 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I5XGT5=20Description:=20SDK?= =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9B=E6=8E=A5=E5=8F=A3=E8=A6=86=E7=9B=96?= =?UTF-8?q?=20Sig:=20SIG=5FApplicationFramework=20Feature=20or=20Bugfix:?= =?UTF-8?q?=20Feature=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangzk Change-Id: I2aa61ac37f6e27cd6fcbc2e07f794f56bcba9092 --- .../main/ets/test/ApiCoverAbility.test.ets | 166 +++- .../src/main/ets/Application/AbilityStage.ts | 13 +- .../src/main/ets/FormAbility/FormAbility.ts | 32 +- .../main/ets/ModuleAbility/ModuleAbility.ts | 25 +- .../main/js/test/FeatureAbilityJsunit.test.js | 43 + .../test/ActsNotificationWantAgentNewTest.js | 923 ++++++++++++++++++ .../src/main/js/test/List.test.js | 2 + 7 files changed, 1190 insertions(+), 14 deletions(-) create mode 100644 notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/ActsNotificationWantAgentNewTest.js 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 8f41c6aa1..811951f2a 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 @@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import formProvider from '@ohos.application.formProvider'; import FormInfo from '@ohos.application.formInfo'; +import formInfoNew from '@ohos.app.form.formInfo'; import formError from '@ohos.application.formError'; import formHost from '@ohos.application.formHost'; import errorManager from '@ohos.application.errorManager'; @@ -23,10 +24,13 @@ import abilityConstant from '@ohos.application.AbilityConstant' import appManager from '@ohos.application.appManager' import applicationContext from '@ohos.application.context' import commonEvent from '@ohos.commonEvent'; -import ability from '@ohos.ability.ability' +import ability from '@ohos.ability.ability'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; var EXTENSION_INFO_ERR = 16000001 +var INNER_ERROR = 16000050 var CROSS_USER_DENY = 201 +var INVALID_PARAM = 401 var trueInfo; var array = new Array(); function sleep(time) { @@ -226,6 +230,120 @@ export default function ApiCoverTest() { }) }) + /* + * @tc.number SUB_AA_ABILITY_Extension_API_009 + * @tc.name connectServiceExtensionAbility with invalid want. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ABILITY_Extension_API_009', 0, async function (done) { + console.log(`SUB_AA_ABILITY_Extension_API_009 start`); + let want = { + bundleName: "com.example.extensionapitest1", + abilityName: "FirstExtension" + }; + let options = { + onConnect: function (elementName, proxy) { + console.log("onConnect"); + }, + onDisconnect: function () { + console.log("onDisconnect"); + }, + onFailed: function () { + console.log("onFailed"); + } + } + try { + let id = globalThis.abilityContext.connectServiceExtensionAbility(want, options); + console.log(`connectServiceExtensionAbility id: ${id}`); + } catch (err) { + console.log(`connectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`); + expect().assertFail(); + } + done(); + }) + + /* + * @tc.number SUB_AA_ABILITY_Extension_API_010 + * @tc.name disconnectServiceExtensionAbility with invalid connectionId. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ABILITY_Extension_API_010', 0, async function (done) { + console.log(`SUB_AA_ABILITY_Extension_API_010 start`); + try { + globalThis.abilityContext.disconnectServiceExtensionAbility(undefined, (err, data) => { + console.log(`disconnectServiceExtensionAbility, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + expect(err.code).assertEqual(INNER_ERROR); + done(); + }) + } catch (err) { + console.log(`disconnectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`); + expect().assertFail(); + done(); + } + }) + + /* + * @tc.number SUB_AA_ABILITY_Extension_API_011 + * @tc.name disconnectServiceExtensionAbility with invalid connectionId. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ABILITY_Extension_API_011', 0, async function (done) { + console.log(`SUB_AA_ABILITY_Extension_API_011 start`); + try { + globalThis.abilityContext.disconnectServiceExtensionAbility(undefined).then((err, data) => { + console.log(`disconnectServiceExtensionAbility, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + expect(err.code).assertEqual(INNER_ERROR); + }); + } catch (err) { + console.log(`disconnectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`); + expect().assertFail(); + } + done(); + }) + + /* + * @tc.number SUB_AA_ABILITY_Extension_API_012 + * @tc.name killProcessesBySelf with invalid param. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ABILITY_Extension_API_012', 0, async function (done) { + try { + globalThis.abilityContext.getApplicationContext().killProcessesBySelf(); + globalThis.abilityContext.getApplicationContext().killProcessesBySelf((err, data) => { + console.log(`killProcessesBySelf, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + }) + let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator; + abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArgs: abilityDelegatorRegistry.AbilityDelegatorArgs; + abilityDelegatorArgs = abilityDelegatorRegistry.getArguments(); + let abilityMonitor: abilityDelegatorRegistry.AbilityMonitor = { + abilityName: "FirstExtension" + } + abilityDelegator.addAbilityMonitor(abilityMonitor, (err, data) => { + console.log(`printMsg, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + }) + abilityDelegator.printMsg(undefined); + abilityDelegator.printMsg(undefined, (err, data) => { + console.log(`printMsg, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + }); + let shellCmdResult: abilityDelegatorRegistry.ShellCmdResult; + shellCmdResult = await abilityDelegator.executeShellCmd(undefined); + abilityDelegator.executeShellCmd(undefined, 0, (err, data) => { + console.log(`executeShellCmd, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + }); + abilityDelegator.executeShellCmd(undefined, (err, data) => { + console.log(`executeShellCmd, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); + }); + } catch (err) { + console.log(`catch code: ${err.code}, message: ${err.message}`); + } + done(); + }) + /* * @tc.number SUB_AA_AMS_Context_0100 * @tc.name Get the resource and path of the context. @@ -345,6 +463,52 @@ export default function ApiCoverTest() { expect(3).assertEqual(FormInfo.FormDimension.Dimension_2_4) expect(4).assertEqual(FormInfo.FormDimension.Dimension_4_4) expect(5).assertEqual(FormInfo.FormDimension.Dimension_2_1) + expect(1).assertEqual(FormInfo.FormType.JS); + expect(2).assertEqual(FormInfo.FormType.eTS); + expect(1).assertEqual(FormInfo.VisibilityType.FORM_VISIBLE); + expect(2).assertEqual(FormInfo.VisibilityType.FORM_INVISIBLE); + done(); + }); + + /* + * @tc.number SUB_AA_Form_provider_TestFormInfo_0200 + * @tc.name Get all FormInfo types + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_Form_provider_TestFormInfo_0200', 0, async function (done) { + console.info("SUB_AA_Form_provider_TestFormInfo_0200"); + expect("ohos.extra.param.key.form_dimension").assertEqual(formInfoNew.FormParam.DIMENSION_KEY) + expect("ohos.extra.param.key.form_height").assertEqual(formInfoNew.FormParam.HEIGHT_KEY) + expect("ohos.extra.param.key.module_name").assertEqual(formInfoNew.FormParam.MODULE_NAME_KEY) + expect("ohos.extra.param.key.form_width").assertEqual(formInfoNew.FormParam.WIDTH_KEY) + expect("ohos.extra.param.key.form_name").assertEqual(formInfoNew.FormParam.NAME_KEY) + expect("ohos.extra.param.key.form_temporary").assertEqual(formInfoNew.FormParam.TEMPORARY_KEY) + expect("ohos.extra.param.key.form_identity").assertEqual(formInfoNew.FormParam.IDENTITY_KEY) + expect("ohos.extra.param.key.bundle_name").assertEqual(formInfoNew.FormParam.BUNDLE_NAME_KEY) + expect("ohos.extra.param.key.ability_name").assertEqual(formInfoNew.FormParam.ABILITY_NAME_KEY) + expect(0).assertEqual(formInfoNew.FormState.DEFAULT) + expect(1).assertEqual(formInfoNew.FormState.READY) + expect(-1).assertEqual(formInfoNew.FormState.UNKNOWN) + expect(0).assertEqual(formInfoNew.ColorMode.MODE_DARK) + expect(1).assertEqual(formInfoNew.ColorMode.MODE_LIGHT) + console.info("SUB_AA_Form_provider_TestFormInfo_0200:" + formInfoNew.FormDimension.Dimension_2_1); + expect(1).assertEqual(formInfoNew.FormDimension.Dimension_1_2) + expect(2).assertEqual(formInfoNew.FormDimension.Dimension_2_2) + expect(3).assertEqual(formInfoNew.FormDimension.Dimension_2_4) + expect(4).assertEqual(formInfoNew.FormDimension.Dimension_4_4) + expect(5).assertEqual(formInfoNew.FormDimension.Dimension_2_1) + expect(1).assertEqual(formInfoNew.FormType.JS); + expect(2).assertEqual(formInfoNew.FormType.eTS); + expect(1).assertEqual(formInfoNew.VisibilityType.FORM_VISIBLE); + expect(2).assertEqual(formInfoNew.VisibilityType.FORM_INVISIBLE); + let formStateInfo: formInfoNew.FormStateInfo = { + formState: formInfoNew.FormState.READY, + want: { + bundleName: "com.example.extensionapitest", + abilityName: "FirstExtension" + } + } done(); }); diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/Application/AbilityStage.ts index 32dfe93cc..7195795eb 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/Application/AbilityStage.ts +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/Application/AbilityStage.ts @@ -1,7 +1,18 @@ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from "@ohos.app.ability.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageContext = this.context; + } + + onAcceptWant(want) { + console.log("[Demo] MyAbilityStage onAcceptWant called want:" + JSON.stringify(want)); + let abilityId = want.parameters.startId.toString(); + return abilityId; + } + + onConfigurationUpdate(configuration) { + console.log('[Demo] MyAbilityStage onConfigurationUpdate:' + JSON.stringify(configuration)); } } \ No newline at end of file diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts index 22f718bae..61892dee2 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts @@ -1,39 +1,49 @@ -import FormExtension from '@ohos.application.FormExtension'; -import formBindingData from '@ohos.application.formBindingData'; -import formInfo from '@ohos.application.formInfo'; +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.app.form.formBindingData'; +import formInfo from '@ohos.app.form.formInfo'; -export default class FormModuleAbility extends FormExtension { - onCreate(want) { +export default class FormModuleAbility extends FormExtensionAbility { + onAddForm(want) { // Called to return a FormBindingData object. - console.info("FormAbility onCreate") + console.info("FormAbility onAddForm") + globalThis.abilityContext = this.context; let formData = { }; return formBindingData.createFormBindingData(formData); } - onCastToNormal(formId) { + onCastToNormalForm(formId) { // Called when the form provider is notified that a temporary form is successfully // converted to a normal form. } - onUpdate(formId) { + onUpdateForm(formId) { // Called to notify the form provider to update a specified form. } - onVisibilityChange(newStatus) { + onChangeFormVisibility(newStatus) { // Called when the form provider receives form events from the system. } - onEvent(formId, message) { + onFormEvent(formId, message) { // Called when a specified message event defined by the form provider is triggered. } - onDestroy(formId) { + onRemoveForm(formId) { // Called to notify the form provider that a specified form has been destroyed. } + onConfigurationUpdate(configuration) { + console.log('FormAbility onConfigurationUpdate:' + JSON.stringify(configuration)); + } + onAcquireFormState(want) { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } + + onShareForm(formId) { + console.log('FormAbility onShareForm:' + JSON.stringify(formId)); + return {}; + } }; \ No newline at end of file diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/ModuleAbility/ModuleAbility.ts b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/ModuleAbility/ModuleAbility.ts index 7accf0a48..169bca1f8 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/ModuleAbility/ModuleAbility.ts +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/ModuleAbility/ModuleAbility.ts @@ -1,9 +1,13 @@ -import Ability from '@ohos.application.Ability' +import Ability from '@ohos.app.ability.Ability' +import AbilityConstant + from "../../../../../../../../../../../../interface/sdk-js/api/@ohos.app.ability.AbilityConstant"; export default class ModuleAbility extends Ability { onCreate(want, launchParam) { console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + globalThis.abilityCallee = this.callee; } onDestroy() { @@ -22,6 +26,10 @@ export default class ModuleAbility extends Ability { console.log("[Demo] MainAbility onWindowStageDestroy") } + onWindowStageRestore(windowStage) { + console.log("[Demo] MainAbility onWindowStageRestore") + } + onForeground() { // Ability has brought to foreground console.log("[Demo] MainAbility onForeground") @@ -31,4 +39,19 @@ export default class ModuleAbility extends Ability { // Ability has back to background console.log("[Demo] MainAbility onBackground") } + + onContinue(wantParam) { + console.log("[Demo] MainAbility onContinue") + return AbilityConstant.OnContinueResult.AGREE; + } + + onConfigurationUpdate(configuration) { + console.log('[Demo] MainAbility onConfigurationUpdate: ' + JSON.stringify(configuration)); + } + + onDump(param) { + console.log("[Demo] MainAbility onDump: " + JSON.stringify(param)) + return ["MainAbility"] + } + }; 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 67affdfdb..c77c7cd76 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 @@ -14,6 +14,7 @@ */ import featureAbility from '@ohos.ability.featureAbility' import wantconstant from '@ohos.ability.wantConstant' +import wantConstantNew from '@ohos.app.ability.wantConstant' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import commonEvent from '@ohos.commonEvent' import particleAbility from '@ohos.ability.particleAbility' @@ -152,6 +153,48 @@ describe('ActsFeatureAbilityTest', function () { done(); }) + + /** + * @tc.number: ACTS_wantConstant_0200 + * @tc.name: wantConstant : Check specific enum + * @tc.desc: Check the return type of the interface (by Promise) + */ + it('ACTS_wantConstant_0200', 0, async function (done) { + expect(wantConstantNew.Action.ACTION_HOME).assertEqual("ohos.want.action.home"); + expect(wantConstantNew.Action.ACTION_DIAL).assertEqual("ohos.want.action.dial"); + expect(wantConstantNew.Action.ACTION_SEARCH).assertEqual("ohos.want.action.search"); + expect(wantConstantNew.Action.ACTION_WIRELESS_SETTINGS).assertEqual("ohos.settings.wireless"); + expect(wantConstantNew.Action.ACTION_MANAGE_APPLICATIONS_SETTINGS) + .assertEqual("ohos.settings.manage.applications"); + expect(wantConstantNew.Action.ACTION_APPLICATION_DETAILS_SETTINGS) + .assertEqual("ohos.settings.application.details"); + expect(wantConstantNew.Action.ACTION_SET_ALARM).assertEqual("ohos.want.action.setAlarm"); + expect(wantConstantNew.Action.ACTION_SHOW_ALARMS).assertEqual("ohos.want.action.showAlarms"); + expect(wantConstantNew.Action.ACTION_SNOOZE_ALARM).assertEqual("ohos.want.action.snoozeAlarm"); + expect(wantConstantNew.Action.ACTION_DISMISS_ALARM).assertEqual("ohos.want.action.dismissAlarm"); + expect(wantConstantNew.Action.ACTION_DISMISS_TIMER).assertEqual("ohos.want.action.dismissTimer"); + expect(wantConstantNew.Action.ACTION_SEND_SMS).assertEqual("ohos.want.action.sendSms"); + expect(wantConstantNew.Action.ACTION_CHOOSE).assertEqual("ohos.want.action.choose"); + expect(wantConstantNew.Action.ACTION_SELECT).assertEqual("ohos.want.action.select"); + expect(wantConstantNew.Action.ACTION_SEND_DATA).assertEqual("ohos.want.action.sendData"); + expect(wantConstantNew.Action.ACTION_SEND_MULTIPLE_DATA).assertEqual("ohos.want.action.sendMultipleData"); + expect(wantConstantNew.Action.ACTION_SCAN_MEDIA_FILE).assertEqual("ohos.want.action.scanMediaFile"); + expect(wantConstantNew.Action.ACTION_VIEW_DATA).assertEqual("ohos.want.action.viewData"); + expect(wantConstantNew.Action.ACTION_EDIT_DATA).assertEqual("ohos.want.action.editData"); + expect(wantConstantNew.Action.INTENT_PARAMS_INTENT).assertEqual("ability.want.params.INTENT"); + expect(wantConstantNew.Action.INTENT_PARAMS_TITLE).assertEqual("ability.want.params.TITLE"); + expect(wantConstantNew.Action.ACTION_FILE_SELECT).assertEqual("ohos.action.fileSelect"); + expect(wantConstantNew.Action.PARAMS_STREAM).assertEqual("ability.params.stream"); + expect(wantConstantNew.Action.ACTION_APP_ACCOUNT_AUTH).assertEqual("account.appAccount.action.auth"); + + expect(wantConstantNew.Entity.ENTITY_HOME).assertEqual("entity.system.home"); + expect(wantConstantNew.Entity.ENTITY_DEFAULT).assertEqual("entity.system.default"); + expect(wantConstantNew.Entity.ENTITY_VOICE).assertEqual("entity.system.voice"); + expect(wantConstantNew.Entity.ENTITY_BROWSABLE).assertEqual("entity.system.browsable"); + expect(wantConstantNew.Entity.ENTITY_VIDEO).assertEqual("entity.system.video"); + done(); + }) + /** * @tc.number: ACTS_GetContext_0100 * @tc.name: GetContext : Obtains the Context object diff --git a/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/ActsNotificationWantAgentNewTest.js b/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/ActsNotificationWantAgentNewTest.js new file mode 100644 index 000000000..bae8a557d --- /dev/null +++ b/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/ActsNotificationWantAgentNewTest.js @@ -0,0 +1,923 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import wantAgent from '@ohos.app.ability.wantAgent' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function ActsNotificationWantAgentNewTest() { + describe('SUB_NOTIFICATION_ANS_WANT_AGENT_NEW_TEST', function () { + let TAG = 'SUB_NOTIFICATION_ANS_WANT_AGENT_NEW_TEST ===>' + console.info(TAG + 'SUB_NOTIFICATION_ANS_WANT_AGENT_NEW_TEST START') + + let WantAgent = {} + let wantAgentData1 = {} + let wantAgentData2 = {} + + let WantAgentInfo = { + wants: [ + { + deviceId: "deviceId", + bundleName: "com.example.actsnotificationwantagent", + abilityName: "com.example.actsnotificationwantagent.MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: + { + myKey0: 2222, + myKey1: [1, 2, 3], + myKey2: "[1, 2, 3]", + myKey3: "notification", + myKey4: [false, true, false], + myKey5: ["ANS", "WANT", "AGENT"], + myKey6: true + } + } + ], + operationType: wantAgent.OperationType, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags], + extraInfo: { + key: 'WantAgentInfo_test' + } + } + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0100 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.ONE_TIME_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0100 START`) + WantAgentInfo.operationType = wantAgent.OperationType.UNKNOWN_TYPE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.ONE_TIME_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0100 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0200 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_ABILITY & WantAgentFlags.NO_BUILD_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0200 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.NO_BUILD_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0200 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0300 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_ABILITIES & WantAgentFlags.CANCEL_PRESENT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0300 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITIES + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.CANCEL_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0300 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0400 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_SERVICE & WantAgentFlags.UPDATE_PRESENT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0400 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_SERVICE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0400 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0500 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.SEND_COMMON_EVENT & WantAgentFlags.CONSTANT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0500 START`) + WantAgentInfo.operationType = wantAgent.OperationType.SEND_COMMON_EVENT + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.CONSTANT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0500 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0600 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.REPLACE_ELEMENT + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0600 START`) + WantAgentInfo.operationType = wantAgent.OperationType.UNKNOWN_TYPE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ELEMENT + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0600 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0700 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_ABILITY & WantAgentFlags.REPLACE_ACTION + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0700 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ACTION + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0700 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0800 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_ABILITIES & WantAgentFlags.REPLACE_URI + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0800 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITIES + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_URI + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0800 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0900 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.START_SERVICE & WantAgentFlags.REPLACE_ENTITIES + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0900 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_SERVICE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ENTITIES + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_0900 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1000 + * @tc.name : function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void + * @tc.desc : OperationType.SEND_COMMON_EVENT & WantAgentFlags.REPLACE_BUNDLE + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1000 START`) + WantAgentInfo.operationType = wantAgent.OperationType.SEND_COMMON_EVENT + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_BUNDLE + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1000 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1100 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.ONE_TIME_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1100 START`) + WantAgentInfo.operationType = wantAgent.OperationType.UNKNOWN_TYPE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.ONE_TIME_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1100 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1200 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_ABILITY & WantAgentFlags.NO_BUILD_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1200 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.NO_BUILD_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1200 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1300 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_ABILITIES & WantAgentFlags.CANCEL_PRESENT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1300 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITIES + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.CANCEL_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1300 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1400 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_SERVICE & WantAgentFlags.UPDATE_PRESENT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1400 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_SERVICE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1400 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1500 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.SEND_COMMON_EVENT & WantAgentFlags.CONSTANT_FLAG + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1500 START`) + WantAgentInfo.operationType = wantAgent.OperationType.SEND_COMMON_EVENT + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.CONSTANT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1500 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1600 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.REPLACE_ELEMENT + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1600 START`) + WantAgentInfo.operationType = wantAgent.OperationType.UNKNOWN_TYPE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ELEMENT + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1600 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1700 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_ABILITY & WantAgentFlags.REPLACE_ACTION + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1700 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ACTION + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1700 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1800 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_ABILITIES & WantAgentFlags.REPLACE_URI + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1800 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITIES + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_URI + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1800 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1900 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.START_SERVICE & WantAgentFlags.REPLACE_ENTITIES + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1900 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_SERVICE + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_ENTITIES + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_1900 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2000 + * @tc.name : function getWantAgent(info: WantAgentInfo): Promise + * @tc.desc : OperationType.SEND_COMMON_EVENT & WantAgentFlags.REPLACE_BUNDLE + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2000 START`) + WantAgentInfo.operationType = wantAgent.OperationType.SEND_COMMON_EVENT + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.REPLACE_BUNDLE + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2000 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2100 + * @tc.name : function cancel(agent: WantAgent, callback: AsyncCallback): void + * @tc.desc : Cancels a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2100 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + wantAgent.cancel(WantAgent, (err) => { + if (err.code) { + console.info(`${TAG} cancel AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} cancel AsyncCallback success`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2100 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2200 + * @tc.name : function cancel(agent: WantAgent): Promise + * @tc.desc : Cancels a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2200 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + wantAgent.cancel(WantAgent).then(() => { + console.info(`${TAG} cancel Promise success`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} cancel Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2200 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2300 + * @tc.name : function getBundleName(agent: WantAgent, callback: AsyncCallback): void + * @tc.desc : Obtains the bundle name of a WantAgent. + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2300 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + wantAgent.getBundleName(WantAgent, (err, data) => { + if (err.code) { + console.info(`${TAG} getBundleName AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} getBundleName AsyncCallback success: ${JSON.stringify(data)}`) + expect(data).assertEqual('com.example.actsnotificationwantagent') + done() + } + }) + + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2300 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2400 + * @tc.name : function getBundleName(agent: WantAgent): Promise + * @tc.desc : Obtains the bundle name of a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2400 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + wantAgent.getBundleName(WantAgent) + .then((data) => { + console.info(`${TAG} getBundleName Promise success: ${JSON.stringify(data)}`) + expect(data).assertEqual('com.example.actsnotificationwantagent') + done() + }) + .catch((err) => { + console.info(`${TAG} getBundleName Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2400 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2500 + * @tc.name : function getUid(agent: WantAgent, callback: AsyncCallback): void + * @tc.desc : Obtains the UID of a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2500 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + await wantAgent.getUid(WantAgent, (err, data) => { + if (err.code) { + console.info(`${TAG} getUid AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} getUid AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2500 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2600 + * @tc.name : function getUid(agent: WantAgent): Promise + * @tc.desc : Obtains the UID of a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2600 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + await wantAgent.getUid(WantAgent).then((data) => { + console.info(`${TAG} getUid Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getUid Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2600 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2700 + * @tc.name : function equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback): void + * @tc.desc : Checks whether two WantAgent objects are equal + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2700 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + wantAgentData1 = data + wantAgentData2 = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + wantAgent.equal(wantAgentData1, wantAgentData2, (err, data) => { + if (err.code) { + console.info(`${TAG} equal AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} equal AsyncCallback success: ${JSON.stringify(data)}`) + expect(data).assertTrue() + done() + } + }) + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2700 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2800 + * @tc.name : function equal(agent: WantAgent, otherAgent: WantAgent): Promise + * @tc.desc : Checks whether two WantAgent objects are equal + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2800 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + wantAgentData1 = data + wantAgentData2 = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + wantAgent.equal(wantAgentData1, wantAgentData2).then((data) => { + console.info(`${TAG} equal Promise success: ${JSON.stringify(data)}`) + expect(data).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} equal Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2800 END`) + }) + + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2900 + * @tc.name : function getOperationType(agent: WantAgent, callback: AsyncCallback): void + * @tc.desc : Obtains the {@link OperationType} of a {@link WantAgent} + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2900 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + await wantAgent.getOperationType(WantAgent, (err, data) => { + if (err.code) { + console.info(`${TAG} getOperationType AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} getOperationType AsyncCallback success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_2900 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3000 + * @tc.name : function getOperationType(agent: WantAgent): Promise + * @tc.desc : Obtains the {@link OperationType} of a {@link WantAgent} + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3000 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo).then((data) => { + WantAgent = data + console.info(`${TAG} getWantAgent Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} getWantAgent Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + await wantAgent.getOperationType(WantAgent) + .then((data) => { + console.info(`${TAG} getOperationType Promise success: ${JSON.stringify(data)}`) + expect(true).assertTrue() + done() + }) + .catch((err) => { + console.info(`${TAG} getOperationType Promise err: ${err.code}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3000 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3100 + * @tc.name : function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback): void + * @tc.desc : Triggers a WantAgent + */ + it('SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3100 START`) + WantAgentInfo.operationType = wantAgent.OperationType.START_ABILITY + WantAgentInfo.wantAgentFlags = wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG + wantAgent.getWantAgent(WantAgentInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} getWantAgent AsyncCallback err: ${err.code}`) + expect(false).assertTrue() + done() + } else { + WantAgent = data + console.info(`${TAG} getWantAgent AsyncCallback success: ${JSON.stringify(data)}`) + + let triggerInfo = { + code: 0, + want: { + deviceId: "deviceId", + bundleName: "com.example.actsnotificationwantagent", + abilityName: "com.example.actsnotificationwantagent.MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: + { + myKey0: 2222, + myKey1: [1, 2, 3], + myKey2: "[1, 2, 3]", + myKey3: "notification", + myKey4: [false, true, false], + myKey5: ["ANS", "WANT", "AGENT"], + myKey6: true, + } + }, + permission: '', + extraInfo: { + test: 'this is a test value' + } + } + wantAgent.trigger(WantAgent, triggerInfo, (err, data) => { + if (err.code) { + console.info(`${TAG} trigger AsyncCallback err: ${JSON.stringify(err)}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} trigger AsyncCallback success: ${JSON.stringify(data)}`) + expect(typeof(data.wantAgent)).assertEqual('object') + expect(data.finalCode).assertEqual(0) + expect(data.finalData).assertEqual('') + expect(typeof(data.extraInfo)).assertEqual('object') + expect(data.want.deviceId).assertEqual('deviceId') + expect(data.want.bundleName).assertEqual('com.example.actsnotificationwantagent') + expect(data.want.abilityName).assertEqual('com.example.actsnotificationwantagent.MainAbility') + done() + } + + }) + } + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_GET_WANT_AGENT_NEW_TEST_3100 END`) + }) + console.info(TAG + 'SUB_NOTIFICATION_ANS_WANT_AGENT_NEW_TEST END') + }) +} diff --git a/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/List.test.js b/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/List.test.js index 64c28d712..a4dd5d50b 100644 --- a/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/List.test.js +++ b/notification/ans_standard/actsNotificationWantAgentTest/src/main/js/test/List.test.js @@ -13,6 +13,8 @@ * limitations under the License. */ import ActsNotificationWantAgentTest from './ActsNotificationWantAgentTest.js' +import ActsNotificationWantAgentNewTest from './ActsNotificationWantAgentNewTest.js' export default function testsuite() { ActsNotificationWantAgentTest() + ActsNotificationWantAgentNewTest() } -- GitLab