diff --git a/notification/ans_standard/actsansnotificationcancel/Test.json b/notification/ans_standard/actsansnotificationcancel/Test.json index 1a5ddb048da74ec2925da50e274b1a813935fa9d..4ca9b73b1aa306ae295919c42826b1c423a46946 100644 --- a/notification/ans_standard/actsansnotificationcancel/Test.json +++ b/notification/ans_standard/actsansnotificationcancel/Test.json @@ -2,9 +2,9 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "21600000", + "test-timeout": "60000", "package": "com.example.actsansnotificationcancel", - "shell-timeout": "21600000" + "shell-timeout": "60000" }, "kits": [ { @@ -15,4 +15,4 @@ "cleanup-apps": true } ] -} \ No newline at end of file +} diff --git a/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js b/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js index 8ec07935696d748612e01e980d808c85cf75def7..bacd6ad9ba1d6f650732f95868862578f5d3a75e 100644 --- a/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js +++ b/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js @@ -19,52 +19,52 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe('ActsAnsNotificationCancel', function () { console.info("===========ActsAnsNotificationCancel start====================>"); var timesOfOnConsume - function onConsume_cancelAll(err, data) { - console.info("================>onConsume_cancelAll_0100=======================>"); - console.info("================>onConsume_cancelAll_0100 data: =======================>" + JSON.stringify(data)); + function onConsumeCancelAll(err, data) { + console.info("================onConsumeCancelAll_0100=======================>"); + console.info("================onConsumeCancelAll_0100 data: =======================>" + JSON.stringify(data)); timesOfOnConsume = timesOfOnConsume + 1 if (timesOfOnConsume == 2){ notify.cancelAll(cancelAllCallBack); - console.info("================>onConsume_cancelAll_0100 cancelAll=======================>"); + console.info("============onConsumeCancelAll_0100 cancelAll=======================>"); } - console.info("================>onConsume_cancelAll_0100 end=======================>"); + console.info("================onConsumeCancelAll_0100 end=======================>"); } var timesOfOnCancel - function onCancel_cancelAll(err, data) { - console.info("==========================>onCancel_cancelAll_0100=======================>"); - console.info("================>onCancel_cancelAll_0100 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_0100 err : =======================>" + JSON.stringify(err)); + function onCancelCancelAll(err, data) { + console.info("================onCancelCancelAll_0100=======================>"); + console.info("================onCancelCancelAll_0100 data : =======================>" + JSON.stringify(data)); + console.info("================onCancelCancelAll_0100 err : =======================>" + JSON.stringify(err)); timesOfOnCancel = timesOfOnCancel + 1 if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(1); } else if (timesOfOnCancel == 2){ expect(data.request.id).assertequal(2); } - console.info("================>onCancel_cancelAll_0100 end=======================>"); + console.info("================onCancel_cancelAll_0100 end=======================>"); } function cancelAllCallBack(err, data){ - console.info("==========================>cancelAllCallBack start=======================>"); + console.info("==================cancelAllCallBack start=======================>"); console.info("==================cancelAllCallBack data==================>" + JSON.stringify(data)); console.info("==================cancelAllCallBack err==================>" + JSON.stringify(err)); - console.info("==========================>cancelAllCallBack end=======================>"); + console.info("==================cancelAllCallBack end=======================>"); } /* * @tc.number: ANS_Cancel_0100 * @tc.name: cancelAll(callback: AsyncCallback): void; - * @tc.desc: Verify that the application successfully cancels all its published notifications by calling the cancelAll(callback: AsyncCallback) interface + * @tc.desc: Verify that the application successfully cancels all its published notifications by calling the + cancelAll(callback: AsyncCallback) interface */ it('ANS_Cancel_0100', 0, async function (done) { console.info("==================ANS_Cancel_0100 start==================>"); timesOfOnConsume = 0 timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancelAll, - onCanceled:onCancel_cancelAll, + onConsume:onConsumeCancelAll, + onCancel:onCancelCancelAll, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -125,59 +125,56 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_0100_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_0100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0100_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_0100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0100_promise==================>"); + setTimeout((function(){ + console.info("==================ANS_Cancel_0100 done==================>"); + }),1000); done(); }) - function onConsume_cancelAll_promise(err, data) { - console.info("================>onConsume_cancelAll_promise_0200=======================>"); - console.info("================>onConsume_cancelAll_promise_0200 data: =======================>" + JSON.stringify(data)); + function onConsumeCancelAllPromise(err, data) { + console.info("================onConsume_cancelAll_promise_0200=======================>"); + console.info("================onConsume_0200 data: =======================>" + JSON.stringify(data)); timesOfOnConsume = timesOfOnConsume + 1 if (timesOfOnConsume == 2){ - notify.cancelAll().then((err, data) => { - console.info("==========cancelAll_promise_0200 start==========>"); - console.info("==========cancelAll_promise_0200 err : =========>" + JSON.stringify(err)); - console.info("==========cancelAll_promise_0200 data : =========>" + JSON.stringify(data)); - console.info("==========cancelAll_promise_0200 end==========>"); - }); + notify.cancelAll(); + console.info("==========cancelAll_promise_0200 end==========>"); } - console.info("================>onConsume_cancelAll_promise_0200 end=======================>"); + console.info("================onConsume_cancelAll_promise_0200 end=======================>"); } - function onCancel_cancelAll_promise(err, data) { + function onCancelCancelAllPromise(err, data) { timesOfOnCancel = timesOfOnCancel + 1 - console.info("==========================>onCancel_cancelAll_promise_0200=======================>"); - console.info("================>onCancel_cancelAll_promise_0200 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_promise_0200 err : =======================>" + JSON.stringify(err)); + console.info("================onCancel_cancelAll_promise_0200=======================>"); + console.info("================onCancel_0200 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_0200 err : =======================>" + JSON.stringify(err)); if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(1); } else if (timesOfOnCancel == 2){ expect(data.request.id).assertequal(2); } - console.info("================>onCancel_cancelAll_promise_0200 end=======================>"); + console.info("================onCancel_cancelAll_promise_0200 end=======================>"); } + /* * @tc.number: ANS_Cancel_0200 * @tc.name: cancelAll(): Promise; - * @tc.desc: Verify that the application successfully cancels all its published notifications by calling the cancelAll(): Promise interface + * @tc.desc: Verify that the application successfully cancels all its published notifications by + calling the cancelAll(): Promise interface */ it('ANS_Cancel_0200', 0, async function (done) { console.info("===============ANS_Cancel_0200 start==========================>"); timesOfOnConsume = 0 timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancelAll_promise, - onCanceled:onCancel_cancelAll_promise, + onConsume:onConsumeCancelAllPromise, + onCancel:onCancelCancelAllPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -238,148 +235,156 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_0200_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_0200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish1_0200_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_0200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0200_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_0200 done==================>"); + }),1000); + }) - function onConsume_cancelAll_noNotify(err, data) { - console.info("================>onConsume_cancelAll_noNotify_0300=======================>"); - console.info("================>onConsume_cancelAll_noNotify_0300 data: =======================>" + JSON.stringify(data)); + function onConsumeCancelAllNoNotify(err, data) { + console.info("================onConsume_cancelAll_noNotify_0300=======================>"); + console.info("================onConsume_0300 data: =======================>" + JSON.stringify(data)); expect(1).assertequal(0); - console.info("================>onConsume_cancelAll_noNotify_0300 end=======================>"); + console.info("================onConsume_cancelAll_noNotify_0300 end=======================>"); } - function onCancel_cancelAll_noNotify(err, data) { - console.info("==========================>onCancel_cancelAll_0300=======================>"); + function onCancelCancelAllNoNotify(err, data) { + console.info("=================onCancel_cancelAll_0300=======================>"); expect(1).assertequal(0); - console.info("================>onCancel_cancelAll_0300 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_0300 err : =======================>" + JSON.stringify(err)); - console.info("================>onCancel_cancelAll_0300 end=======================>"); + console.info("================onCancel_0300 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_0300 err : =======================>" + JSON.stringify(err)); + console.info("================onCancel_0300 end=======================>"); } - function cancelAllCallBack_noNotify(err, data){ - console.info("==========================>cancelAllCallBack_noNotify_0300 start=======================>"); - console.info("================>cancelAllCallBack_noNotify_0300 data : =======================>" + JSON.stringify(data)); - console.info("================>cancelAllCallBack_noNotify_0300 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelAllCallBack_noNotify_0300 end=======================>"); + function cancelAllCallBackNoNotify(err, data){ + console.info("================cancelAllCallBack_noNotify_0300 start=======================>"); + console.info("==========cancelAllCallBack_0300 data : =======================>" + JSON.stringify(data)); + console.info("==========cancelAllCallBack_0300 err : =======================>" + JSON.stringify(err)); + console.info("================cancelAllCallBack_noNotify_0300 end=======================>"); } + /* * @tc.number: ANS_Cancel_0300 * @tc.name: cancelAll(callback: AsyncCallback): void - * @tc.desc: Verify that when there is no notification in the notification list, call the cancelAll(callback: AsyncCallback): void interface, + * @tc.desc: Verify that when there is no notification in the notification list, + call the cancelAll(callback: AsyncCallback): void interface, and the application cancels all its published notifications. - At this time, no notification information is cancelled, and there is no OnCancel notification(Callback mode) + At this time, no notification information is cancelled, + and there is no OnCancel notification(Callback mode) */ it('ANS_Cancel_0300', 0, async function (done) { console.info("===============ANS_Cancel_0300 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancelAll_noNotify, - onCanceled:onCancel_cancelAll_noNotify, + onConsume:onConsumeCancelAllNoNotify, + onCancel:onCancelCancelAllNoNotify, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0300_promise==================>"); - }); - await notify.cancelAll(cancelAllCallBack_noNotify); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0300_promise==================>"); + await notify.cancelAll(cancelAllCallBackNoNotify); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0300_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_0300 done==================>"); + }),1000); }) - function onConsume_cancelAll_noNotify_promise(err, data) { - console.info("================>onConsume_cancelAll_noNotify_promise_0400=======================>"); - console.info("================>onConsume_cancelAll_noNotify_promise_0400 data: =======================>" + JSON.stringify(data)); + function onConsumeCancelAllNoNotifyPromise(err, data) { + console.info("================onConsume_cancelAll_noNotify_promise_0400=======================>"); + console.info("================onConsume_promise_0400 data: =======================>" + JSON.stringify(data)); expect(1).assertequal(0); - console.info("================>onConsume_cancelAll_noNotify_promise_0400 end=======================>"); + console.info("================onConsume_promise_0400 end=======================>"); } - function onCancel_cancelAll_noNotify_promise(err, data) { - console.info("==========================>onCancel_cancelAll_noNotify_promise_0400=======================>"); - console.info("================>onCancel_cancelAll_noNotify_promise_0400 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_noNotify_promise_0400 err : =======================>" + JSON.stringify(err)); + function onCancelCancelAllNoNotifyPromise(err, data) { + console.info("===============onCancel_cancelAll_noNotify_promise_0400=======================>"); + console.info("===============onCancel_promise_0400 data=================>" + JSON.stringify(data)); + console.info("===============onCancel_promise_0400 err=====================>" + JSON.stringify(err)); expect(1).assertequal(0); - console.info("===============`=>onCancel_cancelAll_noNotify_promise_0400 end=======================>"); + console.info("===============onCancel_cancelAll_noNotify_promise_0400 end=======================>"); } + /* * @tc.number: ANS_Cancel_0400 * @tc.name: cancelAll(): Promise; - * @tc.desc: Verify that when there is no notification in the notification list, call the cancelAll(callback: AsyncCallback): void interface, + * @tc.desc: Verify that when there is no notification in the notification list, + call the cancelAll(callback: AsyncCallback): void interface, and the application cancels all its published notifications. - At this time, no notification information is cancelled, and there is no OnCancel notification( Callback mode) + At this time, no notification information is cancelled, + and there is no OnCancel notification( Callback mode) */ it('ANS_Cancel_0400', 0, async function (done) { console.info("===============ANS_Cancel_0400 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancelAll_noNotify_promise, - onCanceled:onCancel_cancelAll_noNotify_promise, + onConsume:onConsumeCancelAllNoNotifyPromise, + onCancel:onCancelCancelAllNoNotifyPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0400_promise==================>"); - }); - await notify.cancelAll().then((err, data) => { - console.info("==========cancelAll_noNotify_promise_0400 start==========>"); - console.info("==========cancelAll_noNotify_promise_0400 err : =========>" + JSON.stringify(err)); - console.info("==========cancelAll_noNotify_promise_0400 data : =========>" + JSON.stringify(data)); - console.info("==========cancelAll_noNotify_promise_0400 start==========>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0400_promise==================>"); + await notify.cancelAll(); + console.info("==========cancelAll_noNotify_promise_0400 start==========>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0400_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_0400 done==================>"); + }),1000); + }) - function onConsume_cancelAll2Times(err, data) { - console.info("================>onConsume_cancelAll2Times_0500=======================>"); - console.info("================>onConsume_cancelAll2Times_0500 data: =======================>" + JSON.stringify(data)); + function onConsumeCancelAll2Times(err, data) { + console.info("================onConsume_cancelAll2Times_0500=======================>"); + console.info("================onConsume_cancelAll2Times_0500 data:==============>" + JSON.stringify(data)); notify.cancelAll(cancelAllCallBack2Times1); - console.info("================>onConsume_cancelAll2Times_0500 cancelAll=======================>"); - console.info("================>onConsume_cancelAll2Times_0500 end=======================>"); + console.info("================onConsume_cancelAll2Times_0500 cancelAll=======================>"); + console.info("================onConsume_cancelAll2Times_0500 end=======================>"); } - function onCancel_cancelAll2Times(err, data) { - console.info("==========================>onCancel_cancelAll2Times_0500=======================>"); - console.info("================>onCancel_cancelAll2Times_0500 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll2Times_0500 err : =======================>" + JSON.stringify(err)); + function onCancelCancelAll2Times(err, data) { + console.info("==========================onCancel_cancelAll2Times_0500=======================>"); + console.info("onCancel_cancelAll2Times_0500 data : =======================>" + JSON.stringify(data)); + console.info("onCancel_cancelAll2Times_0500 err : =======================>" + JSON.stringify(err)); timesOfOnCancel = timesOfOnCancel + 1 if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(5); } else if (timesOfOnCancel){ expect(data.request.id).assertequal(0); } - console.info("================>onCancel_cancelAll2Times_0500 end=======================>"); + console.info("================onCancel_cancelAll2Times_0500 end=======================>"); } function cancelAllCallBack2Times1(err){ - console.info("==========================>cancelAllCallBack2Times1_0500 start=======================>"); - console.info("================>cancelAllCallBack2Times1_0500 err : =======================>" + JSON.stringify(err)); + console.info("cancelAllCallBack2Times1_0500 start=======================>"); + console.info("cancelAllCallBack2Times1_0500 err : =======================>" + JSON.stringify(err)); notify.cancelAll(cancelAllCallBack2Times2); - console.info("==========================>cancelAllCallBack2Times1_0500 cancelAll=======================>"); - console.info("==========================>cancelAllCallBack2Times1_0500 end=======================>"); + console.info("==========================cancelAllCallBack2Times1_0500 cancelAll=======================>"); + console.info("==========================cancelAllCallBack2Times1_0500 end=======================>"); } function cancelAllCallBack2Times2(err){ - console.info("==========================>cancelAllCallBack2Times2_0500 start=======================>"); - console.info("================>cancelAllCallBack2Times2_0500 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelAllCallBack2Times2_0500 end=======================>"); + console.info("==========================cancelAllCallBack2Times2_0500 start=======================>"); + console.info("cancelAllCallBack2Times2_0500 err : =======================>" + JSON.stringify(err)); + console.info("==========================cancelAllCallBack2Times2_0500 end=======================>"); } + /* * @tc.number: ANS_Cancel_0500 * @tc.name: cancelAll(callback: AsyncCallback): void - * @tc.desc: Verify that all notifications are cancelled successfully by calling the cancelAll(callback: AsyncCallback): void interface, and then cancel the notification again + * @tc.desc: Verify that all notifications are cancelled successfully + by calling the cancelAll(callback: AsyncCallback): void interface, + and then cancel the notification again */ it('ANS_Cancel_0500', 0, async function (done) { console.info("===============ANS_Cancel_0500 start==========================>"); timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancelAll2Times, - onCanceled:onCancel_cancelAll2Times, + onConsume:onConsumeCancelAll2Times, + onCancel:onCancelCancelAll2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -410,60 +415,54 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_0500 done==================>"); + }),1000); }) - function onConsume_cancelAll2Times_promise(err, data) { - console.info("================>onConsume_cancelAll2Times_promise_0600=======================>"); - console.info("================>onConsume_cancelAll2Times_promise_0600 data: =======================>" + JSON.stringify(data)); - notify.cancelAll().then((err, data) => { - console.info("==========cancelAll_promise_2times1_0600 start==========>"); - console.info("==========cancelAll_promise_2times1_0600 err : =========>" + JSON.stringify(err)); - console.info("==========cancelAll_promise_2times1_0600 data : =========>" + JSON.stringify(data)); - notify.cancelAll().then((err, data) => { - console.info("==========cancelAll_promise_2times2_0600 start==========>"); - console.info("==========cancelAll_promise_2times2_0600 err : =========>" + JSON.stringify(err)); - console.info("==========cancelAll_promise_2times2_0600 data : =========>" + JSON.stringify(data)); - console.info("==========cancelAll_promise_2times2_0600 end==========>"); - }); - console.info("==========cancelAll_promise_2times1_0600 end==========>"); - }); - console.info("================>onConsume_cancelAll2Times_promise_0600 cancelAll=======================>"); - console.info("================>onConsume_cancelAll2Times_promise_0600 end=======================>"); - } - function onCancel_cancelAll2Times_promise(err, data) { + function onConsumeCancelAll2TimesPromise(err, data) { + console.info("================onConsume_cancelAll2Times_promise_0600=======================>"); + console.info("================onConsume_promise_0600 data: =======================>" + JSON.stringify(data)); + notify.cancelAll(); + console.info("==========cancelAll_promise_2times1_0600 end==========>"); + notify.cancelAll(); + console.info("==========cancelAll_promise_2times2_0600 end==========>"); + console.info("================onConsume_cancelAll2Times_promise_0600 cancelAll=========>"); + console.info("================onConsume_cancelAll2Times_promise_0600 end==========>"); + } + function onCancelCancelAll2TimesPromise(err, data) { timesOfOnCancel = timesOfOnCancel + 1 - console.info("==========================>onCancel_cancelAll2Times_promise_0600=======================>"); - console.info("================>onCancel_cancelAll2Times_promise_0600 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll2Times_promise_0600 err : =======================>" + JSON.stringify(err)); + console.info("==============onCancel_cancelAll2Times_promise_0600=======================>"); + console.info("==============onCancel_0600 data:===================>" + JSON.stringify(data)); + console.info("==============onCancel_0600 err : =======================>" + JSON.stringify(err)); if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(6); } else if (timesOfOnCancel == 2){ expect(data.request.id).assertequal(0); } - console.info("================>onCancel_cancelAll2Times_promise_0600 end=======================>"); + console.info("================onCancel_cancelAll2Times_promise_0600 end=======================>"); } + /* * @tc.number: ANS_Cancel_0600 * @tc.name: cancelAll(): Promise; - * @tc.desc: Verify that all notifications are cancelled successfully by calling the cancelAll(): Promise interface, and then cancel the notification again + * @tc.desc: Verify that all notifications are cancelled successfully by calling the + cancelAll(): Promise interface, and then cancel the notification again */ it('ANS_Cancel_0600', 0, async function (done) { console.info("===============ANS_Cancel_0600 start==========================>"); timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancelAll2Times_promise, - onCanceled:onCancel_cancelAll2Times_promise, + onConsume:onConsumeCancelAll2TimesPromise, + onCancel:onCancelCancelAll2TimesPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -494,49 +493,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0600_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_0600 done==================>"); + }),1000); }) - function onConsume_cancelAll_isUnremovable(err, data) { - console.info("================>onConsume_cancelAll_isUnremovable_0700 start=======================>"); - console.info("================>onConsume_cancelAll_isUnremovable_0700 data: =======================>" + JSON.stringify(data)); - notify.cancelAll(cancelAllCallBack_isUnremovable); - console.info("================>onConsume_cancelAll_isUnremovable_0700 cancelAll=======================>"); - console.info("================>onConsume_cancelAll_isUnremovable_0700 end=======================>"); - } - function onCancel_cancelAll_isUnremovable(err, data) { - console.info("==========================>onCancel_cancelAll_isUnremovable_0700 start=======================>"); - console.info("================>onCancel_cancelAll_isUnremovable_0700 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_isUnremovable_0700 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelAllIsUnremovable(err, data) { + console.info("================onConsume_cancelAll_isUnremovable_0700 start=======================>"); + console.info("================onConsume_0700 data: =======================>" + JSON.stringify(data)); + notify.cancelAll(cancelAllCallBackIsUnremovable); + console.info("================onConsume_0700 cancelAll=======================>"); + console.info("================onConsume__0700 end=======================>"); + } + function onCancelCancelAllIsUnremovable(err, data) { + console.info("================onCancel_cancelAll_isUnremovable_0700 start=======================>"); + console.info("================onCancel_0700 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_0700 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(7); - console.info("================>onCancel_cancelAll_isUnremovable_0700 end=======================>"); + console.info("================onCancel_cancelAll_isUnremovable_0700 end=======================>"); } - function cancelAllCallBack_isUnremovable(err, data){ - console.info("==========================>cancelAllCallBack_isUnremovable_0700 start=======================>"); - console.info("================>cancelAllCallBack_isUnremovable_0700 data : =======================>" + JSON.stringify(err)); - console.info("================>cancelAllCallBack_isUnremovable_0700 err : =======================>" + JSON.stringify(data)); - console.info("==========================>cancelAllCallBack_isUnremovable_0700 end=======================>"); + function cancelAllCallBackIsUnremovable(err, data){ + console.info("================cancelAllCallBack_IsUnremovable_0700 start=======================>"); + console.info("================cancelAllCallBack_0700 data:================>" + JSON.stringify(err)); + console.info("================cancelAllCallBack_0700 err:==============>" + JSON.stringify(data)); + console.info("================cancelAllCallBack_IsUnremovable_0700 end=======================>"); } + /* * @tc.number: ANS_Cancel_0700 * @tc.name: cancelAll(callback: AsyncCallback): void; - * @tc.desc: Verify that by calling the cancelAll(callback: AsyncCallback): void; interface, the application successfully cancels all the notifications that isUnremovable is true that it has published + * @tc.desc: Verify that by calling the cancelAll(callback: AsyncCallback): void; + interface, the application successfully cancels all the notifications + that isUnremovable is true that it has published */ it('ANS_Cancel_0700', 0, async function (done) { console.info("===============ANS_Cancel_0700 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancelAll_isUnremovable, - onCanceled:onCancel_cancelAll_isUnremovable, + onConsume:onConsumeCancelAllIsUnremovable, + onCancel:onCancelCancelAllIsUnremovable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0700_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0700_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -567,47 +569,46 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0700_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0700_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0700_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0700_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_0700 done==================>"); + }),1000); }) - function onConsume_cancelAll_isUnremovabl_promise(err, data) { - console.info("================>onConsume_cancelAll_isUnremovable_0800 start=======================>"); - console.info("================>onConsume_cancelAll_isUnremovable_0800 data: =======================>" + JSON.stringify(data)); - notify.cancelAll().then((err, data) => { - console.info("==========cancelAll_promise__isUnremovable_0800 start==========>"); - console.info("==========cancelAll_promise__isUnremovable_0800 err : =========>" + JSON.stringify(err)); - console.info("==========cancelAll_promise__isUnremovable_0800 data : =========>" + JSON.stringify(data)); - console.info("==========cancelAll_promise__isUnremovable_0800 end==========>"); - }); - console.info("================>onConsume_cancelAll_isUnremovable_0800 end=======================>"); - } - function onCancel_cancelAll_isUnremovable_promise(err, data) { - console.info("==========================>onCancel_cancelAll_isUnremovable_promise_0800 start=======================>"); - console.info("================>onCancel_cancelAll_isUnremovable_promise_0800 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancelAll_isUnremovable_promise_0800 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelAllIsUnremovablPromise(err, data) { + console.info("================onConsume_cancelAll_isUnremovable_0800 start=======================>"); + console.info("================onConsume_0800 data: =======================>" + JSON.stringify(data)); + notify.cancelAll(); + console.info("==========cancelAll_promise_isUnremovable_0800 end==========>"); + console.info("================onConsume_cancelAll_isUnremovable_0800 end=======================>"); + } + function onCancelCancelAllIsUnremovablePromise(err, data) { + console.info("================onCancel_cancelAll_isUnremovable_promise_0800 start================>"); + console.info("================onCancel_promise_0800 data :===============>" + JSON.stringify(data)); + console.info("================onCancel_promise_0800 err :==================>" + JSON.stringify(err)); expect(data.request.id).assertequal(8); - console.info("================>onCancel_cancelAll_isUnremovable_promise_0800 end=======================>"); + console.info("================onCancel_cancelAll_isUnremovable_promise_0800 end==================>"); } + /* * @tc.number: ANS_Cancel_0800 * @tc.name: cancelAll(): Promise; - * @tc.desc: Verify that by calling the cancelAll(): Promise interface, the application successfully cancels all the notifications that isUnremovable is true that it has published + * @tc.desc: Verify that by calling the cancelAll(): Promise interface, + the application successfully cancels all the notifications + that isUnremovable is true that it has published */ it('ANS_Cancel_0800', 0, async function (done) { console.info("===============ANS_Cancel_0800 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancelAll_isUnremovabl_promise, - onCanceled:onCancel_cancelAll_isUnremovable_promise, + onConsume:onConsumeCancelAllIsUnremovablPromise, + onCancel:onCancelCancelAllIsUnremovablePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0800_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0800_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -638,48 +639,50 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0800_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0800_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0800_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0800_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_0800 done==================>"); + }),1000); }) - function onConsume_cancel(err, data) { - console.info("================>onConsume_cancel_0900 start=======================>"); - console.info("================>onConsume_cancel_0900 data: =======================>" + JSON.stringify(data)); - notify.cancel(data.request.id,cancelCallBack_cancel); - console.info("================>onConsume_cancel_0900 cancel=======================>"); - console.info("================>onConsume_cancel_0900 end=======================>"); - } - function onCancel_cancel(err, data) { - console.info("==========================>onCancel_cancel_0900 start=======================>"); - console.info("================>onCancel_cancel_0900 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_0900 err : =======================>" + JSON.stringify(err)); + function onConsumeCancel(err, data) { + console.info("================onConsume_cancel_0900 start=======================>"); + console.info("================onConsume_cancel_0900 data: =======================>" + JSON.stringify(data)); + notify.cancel(data.request.id,cancelCallBackCancel); + console.info("================onConsume_cancel_0900 cancel=======================>"); + console.info("================onConsume_cancel_0900 end=======================>"); + } + function onCancelCancel(err, data) { + console.info("===============onCancel_cancel_0900 start=======================>"); + console.info("===============onCancel_cancel_0900 data : =======================>" + JSON.stringify(data)); + console.info("===============onCancel_cancel_0900 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(9); - console.info("================>onCancel_cancel_0900 end=======================>"); + console.info("===============onCancel_cancel_0900 end=======================>"); } - function cancelCallBack_cancel(err){ - console.info("==========================>cancelAllCallBack_cancel_0900 start=======================>"); - console.info("================>cancelAllCallBack_cancel_0900 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelAllCallBack_cancel_0900 end=======================>"); + function cancelCallBackCancel(err){ + console.info("===========cancelAllCallBack_cancel_0900 start=======================>"); + console.info("===========cancelAllCallBack_0900 err : =======================>" + JSON.stringify(err)); + console.info("===========cancelAllCallBack_cancel_0900 end=======================>"); } + /* * @tc.number: ANS_Cancel_0900 * @tc.name: cancel(id: number, callback: AsyncCallback): void; - * @tc.desc: Verify that the specific ID notification is cancelled successfully by calling the cancel(id: number, callback: AsyncCallback): void; interface + * @tc.desc: Verify that the specific ID notification is cancelled successfully by calling + the cancel(id: number, callback: AsyncCallback): void; interface */ it('ANS_Cancel_0900', 0, async function (done) { console.info("===============ANS_Cancel_0900 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel, - onCanceled:onCancel_cancel, + onConsume:onConsumeCancel, + onCancel:onCancelCancel, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0900_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0900_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -709,51 +712,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0900_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_0900_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0900_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0900_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_0900 done==================>"); + }),1000); }) - function onConsume_cancel_cancel_wrongId(err, data) { - console.info("================>onConsume_cancel_cancel_wrongId_1000 start=======================>"); - console.info("================>onConsume_cancel_cancel_wrongId_1000 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_cancel_wrongId_1000 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_cancel_wrongId_1000 id: =======================>" + data.request.id); - notify.cancel(9999,cancelCallBack_cancel_wrongId); - console.info("================>onConsume_cancel_cancel_wrongId_1000 cancel_id=======================>"); - console.info("================>onConsume_cancel_cancel_wrongId_1000 end=======================>"); - } - function onCancel_cancel_wrongId(err, data) { - console.info("==========================>onCancel_cancel_wrongId_1000 start=======================>"); - console.info("================>onCancel_cancel_wrongId_1000 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_wrongId_1000 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelWrongId(err, data) { + console.info("================onConsume_cancel_cancel_wrongId_1000 start=======================>"); + console.info("================onConsume_1000 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1000 label: =======================>" + data.request.label); + console.info("================onConsume_1000 id: =======================>" + data.request.id); + notify.cancel(9999,cancelCallBackCancelWrongId); + console.info("================onConsume_cancel_cancel_wrongId_1000 cancel_id=======================>"); + console.info("================onConsume_cancel_cancel_wrongId_1000 end=======================>"); + } + function onCancelCancelWrongId(err, data) { + console.info("================onCancel_cancel_wrongId_1000 start=======================>"); + console.info("================onCancel_1000 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1000 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); - console.info("================>onCancel_cancel_wrongId_1000 end=======================>"); + console.info("================onCancel_cancel_wrongId_1000 end=======================>"); } - function cancelCallBack_cancel_wrongId(err){ - console.info("==========================>cancelCallBack_cancel_wrongId_1000 start=======================>"); - console.info("================>cancelCallBack_cancel_wrongId_1000 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_wrongId_1000 end=======================>"); + function cancelCallBackCancelWrongId(err){ + console.info("================cancelCallBack_cancel_wrongId_1000 start=======================>"); + console.info("================cancelCallBac_1000 err : =======================>" + JSON.stringify(err)); + console.info("================cancelCallBack_cancel_wrongId_1000 end=======================>"); } /* * @tc.number: ANS_Cancel_1000 * @tc.name: cancel(id: number, callback: AsyncCallback): void; - * @tc.desc: Verify that when the cancel(id: number, callback: AsyncCallback): void interface is called, when the id is wrong, no notification information is cancelled at this time + * @tc.desc: Verify that when the cancel(id: number, callback: AsyncCallback): void + interface is called, when the id is wrong, no notification information is cancelled at this time */ it('ANS_Cancel_1000', 0, async function (done) { console.info("===============ANS_Cancel_1000 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_cancel_wrongId, - onCanceled:onCancel_cancel_wrongId, + onConsume:onConsumeCancelWrongId, + onCancel:onCancelCancelWrongId, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1000_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -784,50 +788,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1000_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1000_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1000_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1000_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1000 done==================>"); + }),1000); }) - function onConsume_cancel_isUnremovable(err, data) { - console.info("================>onConsume_cancel_isUnremovable_1100 start=======================>"); - console.info("================>onConsume_cancel_isUnremovable_1100 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_isUnremovable_1100 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_isUnremovable_1100 id: =======================>" + data.request.id); - notify.cancel(data.request.id,cancelCallBack_cancel_isUnremovable); - console.info("================>onConsume_cancel_isUnremovable_1100 cancel=======================>"); - console.info("================>onConsume_cancel_isUnremovable_1100 end=======================>"); - } - function onCancel_cancel_isUnremovable(err, data) { - console.info("==========================>onCancel_cancel_isUnremovable_1100 start=======================>"); - console.info("================>onCancel_cancel_isUnremovable_1100 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_isUnremovable_1100 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelIsUnremovable(err, data) { + console.info("================onConsume_cancel_isUnremovable_1100 start=======================>"); + console.info("================onConsume_1100 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1100 label: =======================>" + data.request.label); + console.info("================onConsume_1100 id: =======================>" + data.request.id); + notify.cancel(data.request.id,cancelCallBackCancelIsUnremovable); + console.info("================onConsume_1100 cancel=======================>"); + console.info("================onConsume_cancel_isUnremovable_1100 end=======================>"); + } + function onCancelCancelIsUnremovable(err, data) { + console.info("===============onCancel_cancel_isUnremovable_1100 start=======================>"); + console.info("===============onCancel_1100 data : =======================>" + JSON.stringify(data)); + console.info("===============onCancel_1100 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(11); - console.info("================>onCancel_cancel_isUnremovable_1100 end=======================>"); + console.info("===============onCancel_cancel_isUnremovable_1100 end=======================>"); } - function cancelCallBack_cancel_isUnremovable(err){ - console.info("==========================>cancelCallBack_cancel_isUnremovable_1100 start=======================>"); - console.info("================>cancelCallBack_cancel_isUnremovable_1100 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_isUnremovable_1100 end=======================>"); + function cancelCallBackCancelIsUnremovable(err){ + console.info("================cancelCallBack_cancel_isUnremovable_1100 start=======================>"); + console.info("================cancelCallBack_1100 err : =======================>" + JSON.stringify(err)); + console.info("================cancelCallBack_cancel_isUnremovable_1100 end=======================>"); } + /* * @tc.number: ANS_Cancel_1100 * @tc.name: cancel(id: number, callback: AsyncCallback): void; - * @tc.desc: Verify the success of canceling the notification with the notification attribute isUnremovable being true by calling the cancel(id: number, callback: AsyncCallback): void interface + * @tc.desc: Verify the success of canceling the notification with the notification attribute isUnremovable + being true by calling the cancel(id: number, callback: AsyncCallback): void interface */ it('ANS_Cancel_1100', 0, async function (done) { console.info("===============ANS_Cancel_1100 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_isUnremovable, - onCanceled:onCancel_cancel_isUnremovable, + onConsume:onConsumeCancelIsUnremovable, + onCancel:onCancelCancelIsUnremovable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -857,66 +863,68 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1100_promise==================>"); done(); + setTimeout((function(){ + console.info("==============ANS_Cancel_1100 done==================>"); + }),1000); }) - var id_1200 - function onConsume_cancel_2Times(err, data) { - console.info("================>onConsume_cancel_2Times_1200 start=======================>"); - console.info("================>onConsume_cancel_2Times_1200 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_2Times_1200 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_2Times_1200 id: =======================>" + data.request.id); - id_1200 = data.request.id - notify.cancel(id_1200, cancelCallBack_cancel_2Times1); - console.info("================>onConsume_cancel_2Times_1200 cancel_2Times1=======================>"); - console.info("================>onConsume_cancel_2Times_1200 end=======================>"); - } - function onCancel_cancel_2Times(err, data) { + var id1200 + function onConsumeCancel2Times(err, data) { + console.info("================onConsume_cancel_2Times_1200 start=======================>"); + console.info("================onConsume_1200 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1200 label: =======================>" + data.request.label); + console.info("================onConsume_1200 id: =======================>" + data.request.id); + id1200 = data.request.id + notify.cancel(id1200, cancelCallBackCancel2Times1); + console.info("================onConsume_cancel_2Times_1200 cancel_2Times1=======================>"); + console.info("================onConsume_cancel_2Times_1200 end=======================>"); + } + function onCancelCancel2Times(err, data) { timesOfOnCancel = timesOfOnCancel + 1 - console.info("==========================>onCancel_cancel_2Times_1200 start=======================>"); - console.info("================>onCancel_cancel_2Times_1200 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_2Times_1200 err : =======================>" + JSON.stringify(err)); + console.info("============onCancel_cancel_2Times_1200 start=======================>"); + console.info("===========onCancel_cancel_2Times_1200 data : =======================>" + JSON.stringify(data)); + console.info("===========onCancel_cancel_2Times_1200 err : =======================>" + JSON.stringify(err)); if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(12); }else if(timesOfOnCancel == 2) { expect(data.request.id).assertequal(0); } - console.info("================>onCancel_cancel_2Times_1200 end=======================>"); + console.info("================onCancel_cancel_2Times_1200 end=======================>"); } - function cancelCallBack_cancel_2Times1(err){ - console.info("==========================>cancelCallBack_cancel_2Times1_1200 start=======================>"); - console.info("================>cancelCallBack_cancel_2Times1_1200 err : =======================>" + JSON.stringify(err)); - notify.cancelCallBack_cancel(id_1200,cancelCallBack_cancel_2Times2); - console.info("================>cancelCallBack_cancel_2Times1_1200 cancel=======================>"); - console.info("==========================>cancelCallBack_cancel_2Times1_1200 end=======================>"); + function cancelCallBackCancel2Times1(err){ + console.info("================cancelCallBack_cancel_2Times1_1200 start=======================>"); + console.info("================cancelCallBack_1200 err : =======================>" + JSON.stringify(err)); + notify.cancelCallBack_cancel(id1200,cancelCallBackCancel2Times2); + console.info("================cancelCallBack_cancel_2Times1_1200 cancel=======================>"); + console.info("================cancelCallBack_cancel_2Times1_1200 end=======================>"); } - function cancelCallBack_cancel_2Times2(err){ - console.info("==========================>cancelCallBack_cancel_2Times2_1200 start=======================>"); - console.info("================>cancelCallBack_cancel_2Times2_1200 err : =======================>" + JSON.stringify(err)); + function cancelCallBackCancel2Times2(err){ + console.info("===============cancelCallBack_cancel_2Times2_1200 start=======================>"); + console.info("===============cancelCallBack_1200 err : =======================>" + JSON.stringify(err)); console.info("==========================>cancelCallBack_cancel_2Times2_1200 end=======================>"); } + /* * @tc.number: ANS_Cancel_1200 * @tc.name: cancel(id: number, callback: AsyncCallback): void; - * @tc.desc: Verify that the cancel(id: number, callback: AsyncCallback): void interface is called twice in a row to cancel the notification + * @tc.desc: Verify that the cancel(id: number, callback: AsyncCallback): void + interface is called twice in a row to cancel the notification */ it('ANS_Cancel_1200', 0, async function (done) { console.info("===============ANS_Cancel_1200 start==========================>"); timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancel_2Times, - onCanceled:onCancel_cancel_2Times, + onConsume:onConsumeCancel2Times, + onCancel:onCancelCancel2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -946,53 +954,54 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1200_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1200 done==================>"); + }),1000); }) - function onConsume_cancel_label(err, data) { - console.info("================>onConsume_cancel_label_1300 start=======================>"); - console.info("================>onConsume_cancel_label_1300 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_1300 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_1300 id: =======================>" + data.request.id); - notify.cancel(data.request.id, data.request.label, cancelCallBack_cancel_label); - console.info("================>onConsume_cancel_label_1300 cancel_label=======================>"); - console.info("================>onConsume_cancel_label_1300 end=======================>"); - } - function onCancel_cancel_label(err, data) { - console.info("==========================>onCancel_cancel_label_1300 start=======================>"); - console.info("================>onCancel_cancel_label_1300 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_label_1300 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelLabel(err, data) { + console.info("================onConsume_cancel_label_1300 start=======================>"); + console.info("================onConsume_1300 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1300 label: =======================>" + data.request.label); + console.info("================onConsume_1300 id: =======================>" + data.request.id); + notify.cancel(data.request.id, data.request.label, cancelCallBackCancelLabel); + console.info("================onConsume_cancel_label_1300 cancel_label=======================>"); + console.info("================onConsume_cancel_label_1300 end=======================>"); + } + function onCancelCancelLabel(err, data) { + console.info("================onCancel_cancel_label_1300 start=======================>"); + console.info("================onCancel_1300 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1300 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(13); expect(data.request.label).assertequal("1300"); - console.info("================>onCancel_cancel_label_1300 end=======================>"); + console.info("================onCancel_cancel_label_1300 end=======================>"); } - function cancelCallBack_cancel_label(err){ - console.info("==========================>cancelCallBack_cancel_label_1300 start=======================>"); - console.info("================>cancelCallBack_cancel_label_1300 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_label_1300 end=======================>"); + function cancelCallBackCancelLabel(err){ + console.info("cancelCallBack_cancel_label_1300 start=======================>"); + console.info("cancelCallBack_cancel_label_1300 err : =======================>" + JSON.stringify(err)); + console.info("cancelCallBack_cancel_label_1300 end=======================>"); } /* * @tc.number: ANS_Cancel_1300 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the cancel notification is successful by calling the cancel(id: number, label: string, callback: AsyncCallback): void; interface + * @tc.desc: Verify that the cancel notification is successful by calling the + cancel(id: number, label: string, callback: AsyncCallback): void; interface */ var subscriber it('ANS_Cancel_1300', 0, async function (done) { console.info("===============ANS_Cancel_1300 start==========================>"); subscriber ={ - onConsumed:onConsume_cancel_label, - onCanceled:onCancel_cancel_label, + onConsume:onConsumeCancelLabel, + onCancel:onCancelCancelLabel, } - await notify.subscribe(subscriber).then(() => { - console.info("================>subscribe_1300_promise =======================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1023,50 +1032,46 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("================>publish_1300_promise =======================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("================>unsubscribe_1300_promise =======================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1300_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1300 done==================>"); + }),1000); }) - function onConsume_cancel_label_promise(err, data) { - console.info("================>onConsume_cancel_label_promise start=======================>"); - console.info("================>onConsume_cancel_label_promise data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_promise label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_promise id: =======================>" + data.request.id); - notify.cancel(data.request.id, data.request.label).then((err, data) => { - console.info("==========cancel_labe_lpromise_1400 start==========>"); - console.info("==========cancel_labe_lpromise_1400 err : =========>" + JSON.stringify(err)); - console.info("==========cancel_labe_lpromise_1400 data : =========>" + JSON.stringify(data)); - expect(data.request.id).assertequal(14); - expect(data.request.label).assertequal("1400"); - console.info("==========cancel_labe_lpromise_1400 end==========>"); - }); - console.info("================>onConsume_cancel_label_promise end=======================>"); - } - function onCancel_cancel_label_promise(err, data) { - console.info("==========================>onCancel_cancel_label_promise_1400 start=======================>"); - console.info("================>onCancel_cancel_label_promise_1400 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_label_promise_1400 err : =======================>" + JSON.stringify(err)); - console.info("================>onCancel_cancel_label_promise_1400 end=======================>"); + function onConsumeCancelLabelPromise(err, data) { + console.info("================onConsume_cancel_label_promise start=======================>"); + console.info("================onConsume_promise data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_promise label: =======================>" + data.request.label); + console.info("================onConsume_promise id: =======================>" + data.request.id); + notify.cancel(data.request.id, data.request.label); + console.info("==========cancel_labe_lpromise_1400 end==========>"); + console.info("================onConsume_cancel_label_promise end=======================>"); + } + function onCancelCancelLabelPromise(err, data) { + console.info("================onCancel_cancel_label_promise_1400 start=======================>"); + console.info("================onCancel_1400 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1400 err : =======================>" + JSON.stringify(err)); + console.info("================onCancel_1400 end=======================>"); } + /* * @tc.number: ANS_Cancel_1400 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the cancel notification is successful by calling the cancel(id: number, label?: string): Promise interface + * @tc.desc: Verify that the cancel notification is successful by calling the + cancel(id: number, label?: string): Promise interface */ it('ANS_Cancel_1400', 0, async function (done) { console.info("===============ANS_Cancel_1400 start==========================>"); subscriber ={ - onConsumed:onConsume_cancel_label_promise, - onCanceled:onCancel_cancel_label_promise, + onConsume:onConsumeCancelLabelPromise, + onCancel:onCancelCancelLabelPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("================>subscribe_1400_promise =======================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1097,51 +1102,53 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1400_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1400 done==================>"); + }),1000); }) - function onConsume_cancel_label_isUnremoveable(err, data) { - console.info("================>onConsume_cancel_label_isUnremoveable_1500 start=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 id: =======================>" + data.request.id); - notify.cancel(data.request.id, data.request.label, cancelCallBack_cancel_label_isUnremoveable); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 cancel_label=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 end=======================>"); - } - function onCancel_cancel_label_isUnremoveable(err, data) { - console.info("==========================>onConsume_cancel_label_isUnremoveable_1500 start=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 data : =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelLabelIsUnremoveable(err, data) { + console.info("onConsume_cancel_label_isUnremoveable_1500 start=======================>"); + console.info("================onConsume_1500 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1500 label: =======================>" + data.request.label); + console.info("================onConsume_1500 id: =======================>" + data.request.id); + notify.cancel(data.request.id, data.request.label, cancelCallBackCancelLabelIsUnremoveable); + console.info("================onConsume_1500 cancel_label=======================>"); + console.info("================onConsume_1500 end=======================>"); + } + function onCancelCancelLabelIsUnremoveable(err, data) { + console.info("================onCancel_Cancel_Label_IsUnremoveable_1500 start=======================>"); + console.info("================onCancel_1500 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1500 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(15); expect(data.request.label).assertequal("1500"); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 end=======================>"); + console.info("================onCancel_Cancel_Label_IsUnremoveable_1500 end=======================>"); } - function cancelCallBack_cancel_label_isUnremoveable(err){ - console.info("==========================>onConsume_cancel_label_isUnremoveable_1500 start=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1500 err : =======================>" + JSON.stringify(err)); - console.info("==========================>onConsume_cancel_label_isUnremoveable_1500 end=======================>"); + function cancelCallBackCancelLabelIsUnremoveable(err){ + console.info("===============cancelCallBack_cancel_label_isUnremoveable_1500 start=======================>"); + console.info("================cancelCallBack_1500 err : =======================>" + JSON.stringify(err)); + console.info("============onConsume_cancel_label_isUnremoveable_1500 end=======================>"); } + /* * @tc.number: ANS_Cancel_1500 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void - * @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled successfully by calling the cancel(id: number, label: string, callback: AsyncCallback): void interface + * @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled + successfully by calling the cancel(id: number, label: string, callback: AsyncCallback): void interface */ it('ANS_Cancel_1500', 0, async function (done) { console.info("===============ANS_Cancel_1500 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_label_isUnremoveable, - onCanceled:onCancel_cancel_label_isUnremoveable, + onConsume:onConsumeCancelLabelIsUnremoveable, + onCancel:onCancelCancelLabelIsUnremoveable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1172,50 +1179,46 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1500 done==================>"); + }),1000); }) - function onConsume_cancel_label_isUnremoveable_promise(err, data) { - console.info("================>onConsume_cancel_label_isUnremoveable_1600 start=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 id: =======================>" + data.request.id); - notify.cancel(data.request.id, data.request.label).then((err, data) => { - console.info("==========cancel_label_isUnremoveable_promise_1600 start==========>"); - console.info("==========cancel_label_isUnremoveable_promise_1600 err : =========>" + JSON.stringify(err)); - console.info("==========cancel_label_isUnremoveable_promise_1600 data : =========>" + JSON.stringify(data)); - expect(data.request.id).assertequal(16); - expect(data.request.label).assertequal("1600"); - console.info("==========cancel_label_isUnremoveable_promise_1600 end==========>"); - }); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 end=======================>"); - } - function onCancel_cancel_label_isUnremoveable_promise(err, data) { - console.info("==========================>onConsume_cancel_label_isUnremoveable_1600 start=======================>"); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 data : =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 err : =======================>" + JSON.stringify(err)); - console.info("================>onConsume_cancel_label_isUnremoveable_1600 end=======================>"); + function onConsumeCancelLabelIsUnremoveablePromise(err, data) { + console.info("================onConsume_cancel_label_isUnremoveable_1600 start=======================>"); + console.info("================onConsume_1600 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1600 label: =======================>" + data.request.label); + console.info("================onConsume_1600 id: =======================>" + data.request.id); + notify.cancel(data.request.id, data.request.label) + console.info("==========cancel_label_isUnremoveable_promise_1600 end==========>"); + console.info("================onConsume_cancel_label_isUnremoveable_1600 end=======================>"); + } + function onCancelCancelLabelIsUnremoveablePromise(err, data) { + console.info("===============onConsume_cancel_label_isUnremoveable_1600 start=======================>"); + console.info("===============onConsume_1600 data : =======================>" + JSON.stringify(data)); + console.info("===============onConsume_1600 err : =======================>" + JSON.stringify(err)); + console.info("===============onConsume_cancel_label_isUnremoveable_1600 end=======================>"); } + /* * @tc.number: ANS_Cancel_1600 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled successfully by calling the cancel(id: number, label?: string): Promise interface + * @tc.desc: Verify that the notification whose notification property isUnremovable is true + is canceled successfully by calling the cancel(id: number, label?: string): Promise interface */ it('ANS_Cancel_1600', 0, async function (done) { console.info("===============ANS_Cancel_1600 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_label_isUnremoveable_promise, - onCanceled:onCancel_cancel_label_isUnremoveable_promise, + onConsume:onConsumeCancelLabelIsUnremoveablePromise, + onCancel:onCancelCancelLabelIsUnremoveablePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1246,50 +1249,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1600_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1600 done==================>"); + }),1000); }) - function onConsume_cancel_wrongLabel(err, data) { - console.info("================>onConsume_cancel_wrongLabel_1700 start=======================>"); - console.info("================>onConsume_cancel_wrongLabel_1700 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_wrongLabel_1700 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_wrongLabel_1700 id: =======================>" + data.request.id); - notify.cancel(data.request.id, "9999", cancelCallBack_cancel_wrongLabel); - console.info("================>onConsume_cancel_wrongLabel_1700 cancel_label=======================>"); - console.info("================>onConsume_cancel_wrongLabel_1700 end=======================>"); - } - function onCancel_cancel_wrongLabel(err, data) { - console.info("==========================>onCancel_cancel_wrongLabel_1700 start=======================>"); - console.info("================>onCancel_cancel_wrongLabel_1700 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_wrongLabel_1700 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelWrongLabel(err, data) { + console.info("================onConsume_cancel_wrongLabel_1700 start=======================>"); + console.info("================onConsume_1700 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1700 label: =======================>" + data.request.label); + console.info("================onConsume_1700 id: =======================>" + data.request.id); + notify.cancel(data.request.id, "9999", cancelCallBackCancelWrongLabel); + console.info("================onConsume_1700 cancel_label=======================>"); + console.info("================onConsume_cancel_wrongLabel_1700 end=======================>"); + } + function onCancelCancelWrongLabel(err, data) { + console.info("================onCancel_cancel_wrongLabel_1700 start=======================>"); + console.info("================onCancel_1700 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1700 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); expect(data.request.label).assertequal("0"); - console.info("================>onCancel_cancel_wrongLabel_1700 end=======================>"); + console.info("=================onCancel_cancel_wrongLabel_1700 end=======================>"); } - function cancelCallBack_cancel_wrongLabel(err){ - console.info("==========================>cancelCallBack_cancel_wrongLabel_1700 start=======================>"); - console.info("================>cancelCallBack_cancel_wrongLabel_1700 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_wrongLabel_1700 end=======================>"); + function cancelCallBackCancelWrongLabel(err){ + console.info("================cancelCallBack_cancel_wrongLabel_1700 start=======================>"); + console.info("================cancelCallBack_1700 err : =======================>" + JSON.stringify(err)); + console.info("================cancelCallBack_cancel_wrongLabel_1700 end=======================>"); } + /* * @tc.number: ANS_Cancel_1700 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called, the label is wrong and the ID is correct. + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void + interface is called, the label is wrong and the ID is correct. */ it('ANS_Cancel_1700', 0, async function (done) { console.info("===============ANS_Cancel_1700 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_wrongLabel, - onCanceled:onCancel_cancel_wrongLabel, + onConsume:onConsumeCancelWrongLabel, + onCancel:onCancelCancelWrongLabel, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1700_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("===============subscribe_1700_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1320,51 +1325,47 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1700_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1700_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1700_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1700_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1700 done==================>"); + }),1000); }) - function onConsume_cancel_wrongLabel_promise(err, data) { - console.info("================>onConsume_cancel_wrongLabel_1800 start=======================>"); - console.info("================>onConsume_cancel_wrongLabel_1800 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_wrongLabel_1800 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_wrongLabel_1800 id: =======================>" + data.request.id); - notify.cancel(data.request.id, "9999").then((err, data) => { - console.info("==========cancel_wrongLabel_1800 start==========>"); - console.info("==========cancel_wrongLabel_1800 err : =========>" + JSON.stringify(err)); - console.info("==========cancel_wrongLabel_1800 data : =========>" + JSON.stringify(data)); - console.info("==========cancel_wrongLabel_1800 end==========>"); - }); - console.info("================>onConsume_cancel_wrongLabel_1800 end=======================>"); - } - function onCancel_cancel_wrongLabel_promise(err, data) { - console.info("==========================>onCancel_cancel_wrongLabel_1800 start=======================>"); - console.info("================>onCancel_cancel_wrongLabel_1800 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_wrongLabel_1800 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelWrongLabelPromise(err, data) { + console.info("onConsume_cancel_wrongLabel_1800 start=======================>"); + console.info("onConsume_cancel_wrongLabel_1800 data: =======================>" + JSON.stringify(data)); + console.info("onConsume_cancel_wrongLabel_1800 label: =======================>" + data.request.label); + console.info("onConsume_cancel_wrongLabel_1800 id: =======================>" + data.request.id); + notify.cancel(data.request.id, "9999"); + console.info("================onConsume_cancel_wrongLabel_1800 end=======================>"); + } + function onCancelCancelWrongLabelPromise(err, data) { + console.info("================onCancel_cancel_wrongLabel_1800 start=======================>"); + console.info("================onCancel_1800 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1800 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); expect(data.request.label).assertequal("0"); - console.info("================>onCancel_cancel_wrongLabel_1800 end=======================>"); + console.info("================onCancel_cancel_wrongLabel_1800 end=======================>"); } /* * @tc.number: ANS_Cancel_1800 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, the label is wrong and the ID is correct. + * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, + the label is wrong and the ID is correct. */ it('ANS_Cancel_1800', 0, async function (done) { console.info("===============ANS_Cancel_1800 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_wrongLabel_promise, - onCanceled:onCancel_cancel_wrongLabel_promise, + onConsume:onConsumeCancelWrongLabelPromise, + onCancel:onCancelCancelWrongLabelPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1800_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1800_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1395,52 +1396,53 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1800_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1800_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1800_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1800_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_1800 done==================>"); + }),1000); }) - function onConsume_cancel_label_nullCharacter(err, data) { - console.info("================>onConsume_cancel_label_nullCharacter_1900 start=======================>"); - console.info("================>onConsume_cancel_label_nullCharacter_1900 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_nullCharacter_1900 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_nullCharacter_1900 id: =======================>" + data.request.id); - notify.cancel(data.request.id, "", cancelCallBack_cancel_nullCharacter); - console.info("================>onConsume_cancel_nullCharacte_1900 cancel_label=======================>"); - console.info("================>onConsume_cancel_nullCharacte_1900 end=======================>"); - } - function onCancel_cancel_label_nullCharacter(err, data) { - console.info("==========================>onCancel_cancel_label_nullCharacter_1900 start=======================>"); - console.info("================>onCancel_cancel_nullCharacter_1900 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_nullCharacter_1900 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelLabelNullCharacter(err, data) { + console.info("================onConsume_cancel_label_nullCharacter_1900 start=======================>"); + console.info("================onConsume_1900 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_1900 label: =======================>" + data.request.label); + console.info("================onConsume_1900 id: =======================>" + data.request.id); + notify.cancel(data.request.id, "", cancelCallBackCancelNullCharacter); + console.info("================onConsume_cancel_nullCharacte_1900 cancel_label=======================>"); + console.info("================onConsume_cancel_nullCharacte_1900 end=======================>"); + } + function onCancelCancelLabelNullCharacter(err, data) { + console.info("onCancel_cancel_label_nullCharacter_1900 start=======================>"); + console.info("================onCancel_1900 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_1900 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); expect(data.request.label).assertequal("0"); - console.info("================>onCancel_cancel_nullCharacter_1900 end=======================>"); + console.info("onCancel_cancel_nullCharacter_1900 end=======================>"); } - function cancelCallBack_cancel_nullCharacter(err){ - console.info("==========================>cancelCallBack_cancel_nullCharacter_1900 start=======================>"); - console.info("================>cancelCallBack_cancel_nullCharacter_1900 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_nullCharacter_1900 end=======================>"); + function cancelCallBackCancelNullCharacter(err){ + console.info("==============cancelCallBack_cancel_nullCharacter_1900 start=======================>"); + console.info("==============cancelCallBack_1900 err : =======================>" + JSON.stringify(err)); + console.info("==============cancelCallBack_cancel_nullCharacter_1900 end=======================>"); } /* * @tc.number: ANS_Cancel_1900 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called, and the label uses empty characters + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void + interface is called, and the label uses empty characters */ it('ANS_Cancel_1900', 0, async function (done) { console.info("===============ANS_Cancel_1900 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_label_nullCharacter, - onCanceled:onCancel_cancel_label_nullCharacter, + onConsume:onConsumeCancelLabelNullCharacter, + onCancel:onCancelCancelLabelNullCharacter, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1900_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1900_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1471,50 +1473,48 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1900_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_1900_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1900_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1900_promise==================>"); + setTimeout((function(){ + console.info("==================ANS_Cancel_1900 done==================>"); + }),1000); done(); }) - function onConsume_cancel_nullCharacter(err, data) { - console.info("================>onConsume_cancel_nullCharacte_2000 start=======================>"); - console.info("================>onConsume_cancel_nullCharacte_2000 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_nullCharacte_2000 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_nullCharacte_2000 id: =======================>" + data.request.id); - notify.cancel(data.request.id, "").then((err, data) => { - console.info("==========cancel_nullCharacte_2000 start==========>"); - console.info("==========cancel_nullCharacte_2000 err : =========>" + JSON.stringify(err)); - console.info("==========cancel_nullCharacte_2000 data : =========>" + JSON.stringify(data)); - console.info("==========cancel_nullCharacte_2000 end==========>"); - }); - console.info("================>onConsume_cancel_nullCharacte_2000 end=======================>"); - } - function onCancel_cancel_nullCharacter(err, data) { - console.info("==========================>onCancel_cancel_nullCharacter_2000 start=======================>"); - console.info("================>onCancel_cancel_nullCharacter_2000 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_nullCharacter_2000 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelNullCharacter(err, data) { + console.info("==========onConsume_cancel_nullCharacte_2000 start=======================>"); + console.info("==========onConsume_2000 data: =======================>" + JSON.stringify(data)); + console.info("==========onConsume_2000 label: =======================>" + data.request.label); + console.info("==========onConsume_2000 id: =======================>" + data.request.id); + notify.cancel(data.request.id, ""); + console.info("==========cancel_nullCharacte_2000 end==========>"); + console.info("================onConsume_cancel_nullCharacte_2000 end=======================>"); + } + function onCancelCancelNullCharacter(err, data) { + console.info("================onCancel_cancel_nullCharacter_2000 start=======================>"); + console.info("================onCancel_2000 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_2000 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); expect(data.request.label).assertequal("0"); - console.info("================>onCancel_cancel_nullCharacter_2000 end=======================>"); + console.info("================onCancel_cancel_nullCharacter_2000 end=======================>"); } + /* * @tc.number: ANS_Cancel_2000 * @tc.name: cancel(id: number, label?: string): Promise; - * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, and the label uses empty characters + * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, + and the label uses empty characters */ it('ANS_Cancel_2000', 0, async function (done) { console.info("===============ANS_Cancel_2000 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_nullCharacter, - onCanceled:onCancel_cancel_nullCharacter, + onConsume:onConsumeCancelNullCharacter, + onCancel:onCancelCancelNullCharacter, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2000_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2000_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1545,68 +1545,70 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2000_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2000_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2000_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2000_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2000 done==================>"); + }),1000); }) - var id_2100 - var label_2100 - function onConsume_cancel_label_2Times(err, data) { - console.info("================>onConsume_cancel_label_2Times_2100 start=======================>"); - console.info("================>onConsume_cancel_label_2Times_2100 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_2Times_2100 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_2Times_2100 id: =======================>" + data.request.id); - id_2100 = data.request.id - label_2100 = data.request.label - notify.cancel(id_2100, label_2100, cancelCallBack_cancel_label_2Times1); - console.info("================>onConsume_cancel_label_2Times_2100 cancel_label=======================>"); - console.info("================>onConsume_cancel_label_2Times_2100 end=======================>"); - } - function onCancel_cancel_label_2Times(err, data) { + var id2100 + var label2100 + function onConsumeCancelLabel2Times(err, data) { + console.info("onConsume_cancel_label_2Times_2100 start=======================>"); + console.info("onConsume_cancel_label_2Times_2100 data:====================>" + JSON.stringify(data)); + console.info("onConsume_cancel_label_2Times_2100 label:====================>" + data.request.label); + console.info("onConsume_cancel_label_2Times_2100 id:====================>" + data.request.id); + id2100 = data.request.id + label2100 = data.request.label + notify.cancel(id2100, label2100, cancelCallBackCancelLabel2Times1); + console.info("=============onConsume_cancel_label_2Times_2100 cancel_label=======================>"); + console.info("=============onConsume_cancel_label_2Times_2100 end=======================>"); + } + function onCancelCancelLabel2Times(err, data) { timesOfOnCancel = timesOfOnCancel + 1 - console.info("==========================>onCancel_cancel_label_2Times_2100 start=======================>"); - console.info("================>onCancel_cancel_label_2Times_2100 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_label_2Times_2100 err : =======================>" + JSON.stringify(err)); + console.info("===============onCancel_cancel_label_2Times_2100 start=======================>"); + console.info("===============onCancel_2100 data : =======================>" + JSON.stringify(data)); + console.info("===============onCancel_2100 err : =======================>" + JSON.stringify(err)); if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(21); expect(data.request.label).assertequal("2100"); }else if(timesOfOnCancel == 2){ expect().assertFail(); } - console.info("================>onCancel_cancel_label_2Times_2100 end=======================>"); + console.info("================onCancel_cancel_label_2Times_2100 end=======================>"); } - function cancelCallBack_cancel_label_2Times1(err){ - console.info("==========================>cancelCallBack_cancel_label_2Times1_2100 start=======================>"); - console.info("================>cancelCallBack_cancel_label_2Times1_2100 err : =======================>" + JSON.stringify(err)); - notify.cancel(id_2100, label_2100, cancelCallBack_cancel_label_2Times2); - console.info("================>cancelCallBack_cancel_label_2Times1_2100 cancel_label_2Times1=======================>"); - console.info("==========================>cancelCallBack_cancel_label_2Times1_2100 end=======================>"); + function cancelCallBackCancelLabel2Times1(err){ + console.info("================cancelCallBack_cancel_label_2Times1_2100 start=======================>"); + console.info("================cancelCallBack_2100 err : =======================>" + JSON.stringify(err)); + notify.cancel(id2100, label2100, cancelCallBackCancelLabel2Times2); + console.info("===============cancelCallBack_2100 cancel_label_2Times1=======================>"); + console.info("===============cancelCallBack_2Times1_2100 end=======================>"); } - function cancelCallBack_cancel_label_2Times2(err){ - console.info("==========================>cancelCallBack_cancel_label_2Times2_2100 start=======================>"); - console.info("================>cancelCallBack_cancel_label_2Times2_2100 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_label_2Times2_2100 end=======================>"); + function cancelCallBackCancelLabel2Times2(err){ + console.info("================cancelCallBack_cancel_label_2Times2_2100 start=======================>"); + console.info("================cancelCallBack_2100 err : =======================>" + JSON.stringify(err)); + console.info("================cancelCallBack_cancel_label_2Times2_2100 end=======================>"); } + /* * @tc.number: ANS_Cancel_2100 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called twice in a row + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void + interface is called twice in a row */ it('ANS_Cancel_2100', 0, async function (done) { console.info("===============ANS_Cancel_2100 start==========================>"); timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancel_label_2Times, - onCanceled:onCancel_cancel_label_2Times, + onConsume:onConsumeCancelLabel2Times, + onCancel:onCancelCancelLabel2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1637,62 +1639,60 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2100_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2100 done==================>"); + }),1000); }) - var id_2200 - var label_2200 - function onConsume_cancel_label_promise_2Times(err, data) { - console.info("================>onConsume_cancel_label_2Times_poromise_2200 start=======================>"); - console.info("================>onConsume_cancel_label_2Times_poromise_2200 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_label_2Times_poromise_2200 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_label_2Times_poromise_2200 id: =======================>" + data.request.id); - id_2200 = data.request.id - label_2200 = data.request.label - notify.cancel(id_2200, label_2200).then(() => { - console.info("==========cancel_label_2Times1_promise_2200 start==========>"); - notify.cancel(id_2200, label_2200).then(() => { - console.info("==========cancel_label_2Times2_promise_2200 start==========>"); - console.info("==========cancel_label_2Times2_promise_2200 end==========>"); - }); - console.info("==========cancel_label_2Times1_promise_2200 end==========>"); - }); - console.info("================>onConsume_cancel_label_2Times_poromise_2200 end=======================>"); - } - function onCancel_cancel_label_promise_2Times(err, data) { - console.info("==========================>onCancel_cancel_label_2Times_2200 start=======================>"); + var id2200 + var label2200 + function onConsumeCancelLabelPromise2Times(err, data) { + console.info("================onConsume_cancel_label_2Times_poromise_2200 start=======================>"); + console.info("onConsume_cancel_label_2Times_poromise_2200 data:========>" + JSON.stringify(data)); + console.info("onConsume_cancel_label_2Times_poromise_2200 label:========>" + data.request.label); + console.info("onConsume_cancel_label_2Times_poromise_2200 id:========>" + data.request.id); + id2200 = data.request.id + label2200 = data.request.label + notify.cancel(id2200, label2200); + console.info("==========cancel_label_2Times1_promise_2200 end==========>"); + notify.cancel(id2200, label2200) + console.info("==========cancel_label_2Times2_promise_2200 end==========>"); + console.info("================onConsume_cancel_label_2Times_poromise_2200 end=======================>"); + } + function onCancelCancelLabelPromise2Times(err, data) { + console.info("onCancel_cancel_label_2Times_2200 start=======================>"); timesOfOnCancel = timesOfOnCancel + 1 - console.info("================>onCancel_cancel_label_2Times_2200 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_label_2Times_2200 err : =======================>" + JSON.stringify(err)); + console.info("onCancel_cancel_label_2Times_2200 data : =======================>" + JSON.stringify(data)); + console.info("onCancel_cancel_label_2Times_2200 err : =======================>" + JSON.stringify(err)); if (timesOfOnCancel == 1){ expect(data.request.id).assertequal(22); expect(data.request.label).assertequal("2200"); }else if (timesOfOnCancel == 2){ expect().assertFail(); } - console.info("================>onCancel_cancel_label_2Times_2200 end=======================>"); + console.info("================onCancel_cancel_label_2Times_2200 end=======================>"); } + /* * @tc.number: ANS_Cancel_2200 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called twice in a row + * @tc.desc: Verify that the cancel(id: number, label?: string): Promise + interface is called twice in a row */ it('ANS_Cancel_2200', 0, async function (done) { console.info("===============ANS_Cancel_2200 start==========================>"); timesOfOnCancel = 0 var subscriber ={ - onConsumed:onConsume_cancel_label_promise_2Times, - onCanceled:onCancel_cancel_label_promise_2Times, + onConsume:onConsumeCancelLabelPromise2Times, + onCancel:onCancelCancelLabelPromise2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1723,50 +1723,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2200_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2200 done==================>"); + }),1000); }) - function onConsume_cancel_rightLabel_wrongId(err, data) { - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 start=======================>"); - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 id: =======================>" + data.request.id); - notify.cancel(11111, data.request.label, cancelCallBack_cancel_rightLabel_wrongId); - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 cancel_rightLabel_wrongId=======================>"); - console.info("================>onConsume_cancel_rightLabel_wrongId_2300 end=======================>"); - } - function onCancel_cancel_rightLabel_wrongId(err, data) { - console.info("==========================>onCancel_cancel_rightLabel_wrongId_2300 start=======================>"); - console.info("================>onCancel_cancel_rightLabel_wrongId_2300 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_rightLabel_wrongId_2300 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelRightLabelWrongId(err, data) { + console.info("================onConsume_cancel_rightLabel_wrongId_2300 start=======================>"); + console.info("================onConsume_2300 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_2300 label: =======================>" + data.request.label); + console.info("================onConsume_2300 id: =======================>" + data.request.id); + notify.cancel(11111, data.request.label, cancelCallBackCancelRightLabelWrongId); + console.info("================onConsume_2300 cancel_rightLabel_wrongId=======================>"); + console.info("================onConsume_cancel_rightLabel_wrongId_2300 end=======================>"); + } + function onCancelCancelRightLabelWrongId(err, data) { + console.info("===================onCancel_cancel_rightLabel_wrongId_2300 start=======================>"); + console.info("================onCancel_2300 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_2300 err : =======================>" + JSON.stringify(err)); expect().assertFail(); - console.info("================>onCancel_cancel_rightLabel_wrongId_2300 end=======================>"); + console.info("================onCancel_cancel_rightLabel_wrongId_2300 end=======================>"); } - function cancelCallBack_cancel_rightLabel_wrongId(err){ - console.info("==========================>cancelCallBack_cancel_rightLabel_wrongId_2300 start=======================>"); - console.info("================>cancelCallBack_cancel_rightLabel_wrongId_2300 err : =======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_rightLabel_wrongId_2300 end=======================>"); + function cancelCallBackCancelRightLabelWrongId(err){ + console.info("cancelCallBack_cancel_rightLabel_wrongId_2300 start=======================>"); + console.info("cancelCallBack_cancel_rightLabel_wrongId_2300 err:===============>" + JSON.stringify(err)); + console.info("cancelCallBack_cancel_rightLabel_wrongId_2300 end===================>"); } + /* * @tc.number: ANS_Cancel_2300 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called, the label is correct and the ID is correct wrong. + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): + void interface is called, the label is correct and the ID is correct wrong. */ it('ANS_Cancel_2300', 0, async function (done) { console.info("===============ANS_Cancel_2300 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_rightLabel_wrongId, - onCanceled:onCancel_cancel_rightLabel_wrongId, + onConsume:onConsumeCancelRightLabelWrongId, + onCancel:onCancelCancelRightLabelWrongId, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1797,49 +1799,49 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2300_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2300_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2300_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2300 done==================>"); + }),1000); }) - function onConsume_cancel_rightLabel_wrongId_promise(err, data) { - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 start=======================>"); - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 id: =======================>" + data.request.id); - notify.cancel(11111, data.request.label).then((err, data) => { - console.info("==========cancel_rightLabel_wrongId_promise_2400 start==========>"); - console.info("==========cancel_rightLabel_wrongId_promise_2400 end==========>"); - }); - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 cancel_rightLabel_wrongId=======================>"); - console.info("================>onConsume_cancel_rightLabel_wrongId_promise_2400 end=======================>"); - } - function onCancel_cancel_rightLabel_wrongId_promise(err, data) { - console.info("================>onCancel_cancel_rightLabel_wrongId_2400 start : =======================>"); - console.info("================>onCancel_cancel_rightLabel_wrongId_2400 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_rightLabel_wrongId_2400 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelRightLabelWrongIdPromise(err, data) { + console.info("onConsume_cancel_rightLabel_wrongId_promise_2400 start=======================>"); + console.info("================onConsume_2400 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_2400 label: =======================>" + data.request.label); + console.info("================onConsume_2400 id: =======================>" + data.request.id); + notify.cancel(11111, data.request.label) + console.info("==========cancel_rightLabel_wrongId_promise_2400 end==========>"); + console.info("================onConsume_2400 cancel_rightLabel_wrongId=======================>"); + console.info("================onConsume_2400 end=======================>"); + } + function onCancelCancelRightLabelWrongIdPromise(err, data) { + console.info("================onCancel_cancel_rightLabel_wrongId_2400 start : =======================>"); + console.info("================onCancel_2400 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel_2400 err : =======================>" + JSON.stringify(err)); expect(data.request.id).assertequal(0); expect(data.request.label).assertequal("0"); - console.info("================>onCancel_cancel_rightLabel_wrongId_2400 end=======================>"); + console.info("================onCancel_cancel_rightLabel_wrongId_2400 end=======================>"); } + /* * @tc.number: ANS_Cancel_2400 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called, the label is correct and the ID is correct wrong. + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void + interface is called, the label is correct and the ID is correct wrong. */ it('ANS_Cancel_2400', 0, async function (done) { console.info("===============ANS_Cancel_2400 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_rightLabel_wrongId_promise, - onCanceled:onCancel_cancel_rightLabel_wrongId_promise, + onConsume:onConsumeCancelRightLabelWrongIdPromise, + onCancel:onCancelCancelRightLabelWrongIdPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1870,50 +1872,52 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2400_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2400 done==================>"); + }),1000); }) - function onConsume_cancel_wrongLabel_wrongId(err, data) { - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 start=======================>"); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 id: =======================>" + data.request.id); - notify.cancel(6666, "6666", cancelCallBack_cancel_wrongLabel_wrongId); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 cancel_wrongLabel_wrongId=======================>"); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2500 end=======================>"); - } - function onCancel_cancel_wrongLabel_wrongId(err, data) { - console.info("================>onCancel_cancel_wrongLabel_wrongId_2500 start=======================>"); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2500 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2500 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelWrongLabelWrongId(err, data) { + console.info("================onConsume_cancel_wrongLabel_wrongId_2500 start=======================>"); + console.info("================onConsume_2500 data: =======================>" + JSON.stringify(data)); + console.info("================onConsume_2500 label: =======================>" + data.request.label); + console.info("================onConsume_2500 id: =======================>" + data.request.id); + notify.cancel(6666, "6666", cancelCallBackCancelWrongLabelWrongId); + console.info("================onConsume__2500 cancel=======================>"); + console.info("================onConsume_cancel_wrongLabel_wrongId_2500 end=======================>"); + } + function onCancelCancelWrongLabelWrongId(err, data) { + console.info("================onCancel_cancel_wrongLabel_wrongId_2500 start=======================>"); + console.info("================onCancel_2500 data : =======================>" + JSON.stringify(data)); + console.info("================onCancel__2500 err : =======================>" + JSON.stringify(err)); expect().assertFail(); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2500 end=======================>"); + console.info("================onCancel_cancel_wrongLabel_wrongId_2500 end=======================>"); } - function cancelCallBack_cancel_wrongLabel_wrongId(err){ - console.info("==========================>cancelCallBack_cancel_wrongLabel_wrongId_2500 start=======================>"); - console.info("==========================>cancelCallBack_cancel_wrongLabel_wrongId_2500 err :=======================>" + JSON.stringify(err)); - console.info("==========================>cancelCallBack_cancel_wrongLabel_wrongId_2500 end=======================>"); + function cancelCallBackCancelWrongLabelWrongId(err){ + console.info("cancelCallBack_cancel_wrongLabel_wrongId_2500 start=======================>"); + console.info("cancelCallBack_cancel_wrongLabel_wrongId_2500 err:================>" + JSON.stringify(err)); + console.info("cancelCallBack_cancel_wrongLabel_wrongId_2500 end=======================>"); } + /* * @tc.number: ANS_Cancel_2500 * @tc.name: cancel(id: number, label: string, callback: AsyncCallback): void - * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void interface is called, the label is correct and the ID is correct wrong. + * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback): void +  interface is called, the label is correct and the ID is correct wrong. */ it('ANS_Cancel_2500', 0, async function (done) { console.info("===============ANS_Cancel_2500 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_wrongLabel_wrongId, - onCanceled:onCancel_cancel_wrongLabel_wrongId, + onConsume:onConsumeCancelWrongLabelWrongId, + onCancel:onCancelCancelWrongLabelWrongId, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1944,47 +1948,47 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2500 done==================>"); + }),1000); }) - function onConsume_cancel_wrongLabel_wrongId_promise(err, data) { - console.info("================>onConsume_cancel_wrongLabel_wrongId_2600 start=======================>"); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2600 data: =======================>" + JSON.stringify(data)); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2600 label: =======================>" + data.request.label); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2600 id: =======================>" + data.request.id); - notify.cancel(6666, "6666").then((err, data) => { - console.info("==========cancel_wrongLabel_wrongId_2600 start==========>"); - console.info("==========cancel_wrongLabel_wrongId_2600 end==========>"); - }); - console.info("================>onConsume_cancel_wrongLabel_wrongId_2600 end=======================>"); - } - function onCancel_cancel_wrongLabel_wrongId_promise(err, data) { - console.info("================>onCancel_cancel_wrongLabel_wrongId_2600 start=======================>"); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2600 data : =======================>" + JSON.stringify(data)); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2600 err : =======================>" + JSON.stringify(err)); + function onConsumeCancelWrongLabelWrongIdPromise(err, data) { + console.info("===========onConsume_cancel_wrongLabel_wrongId_2600 start=======================>"); + console.info("onConsume_cancel_2600 data: =======================>" + JSON.stringify(data)); + console.info("onConsume_cancel_2600 label: =======================>" + data.request.label); + console.info("onConsume_cancel_2600 id: =======================>" + data.request.id); + notify.cancel(6666, "6666") + console.info("==========cancel_wrongLabel_wrongId_2600 end==========>"); + console.info("================onConsume_cancel_wrongLabel_wrongId_2600 end=======================>"); + } + function onCancelCancelWrongLabelWrongIdPromise(err, data) { + console.info("================onCancel_cancel_wrongLabel_wrongId_2600 start=======================>"); + console.info("onCancel_2600 data : =======================>" + JSON.stringify(data)); + console.info("onCancel_2600 err : =======================>" + JSON.stringify(err)); expect().assertFail(); - console.info("================>onCancel_cancel_wrongLabel_wrongId_2600 end=======================>"); + console.info("================onCancel_cancel_wrongLabel_wrongId_2600 end=======================>"); } + /* * @tc.number: ANS_Cancel_2600 * @tc.name: cancel(id: number, label?: string): Promise - * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, the label is wrong and the ID is wrong. + * @tc.desc: Verify that the cancel(id: number, label?: string): Promise interface is called, +  the label is wrong and the ID is wrong. */ it('ANS_Cancel_2600', 0, async function (done) { console.info("===============ANS_Cancel_2600 start==========================>"); var subscriber ={ - onConsumed:onConsume_cancel_wrongLabel_wrongId_promise, - onCanceled:onCancel_cancel_wrongLabel_wrongId_promise, + onConsume:onConsumeCancelWrongLabelWrongIdPromise, + onCancel:onCancelCancelWrongLabelWrongIdPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2015,12 +2019,13 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================>unsubscribe_2600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2600_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Cancel_2600 done==================>"); + }),1000); }) }) \ No newline at end of file diff --git a/notification/ans_standard/actsansnotificationremove/Test.json b/notification/ans_standard/actsansnotificationremove/Test.json index d2019f676e60e293da292481d7523c958c8cb71e..78f98aad5c67d2353a5164e9ebd7b26c31aa1354 100644 --- a/notification/ans_standard/actsansnotificationremove/Test.json +++ b/notification/ans_standard/actsansnotificationremove/Test.json @@ -2,9 +2,9 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "21600000", + "test-timeout": "60000", "package": "com.example.actsansnotificationremove", - "shell-timeout": "21600000" + "shell-timeout": "60000" }, "kits": [ { @@ -15,4 +15,4 @@ "cleanup-apps": true } ] -} \ No newline at end of file +} diff --git a/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js b/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js index ec26e2cc38a32c165de3e41440241bd27d7f435d..a9a87c0e7ca3bc2c85f2fc74b3322b77289fa23e 100644 --- a/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js +++ b/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js @@ -24,7 +24,7 @@ describe('ActsAnsNotificationRemove', function () { console.info("================updateCallback======================>"); } function subscribeCallback(err) { - console.info("==========================subscribeCallback=======================>"); + console.info("==================subscribeCallback=======================>"); } function onUnsubscribeCallback(err) { console.info("================onUnsubscribeCallback=======================>"); @@ -36,22 +36,22 @@ describe('ActsAnsNotificationRemove', function () { console.info("==========================publishCallback=======================>"); } var hashCode; - function OnConsume_remove(err, data) { - console.info("================OnConsume_remove_0100=======================>"); - console.info("================OnConsume_remove_0100 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_remove_0100 hascode: =======================>" + data.request.hashCode); + function onConsumeRemove(err, data) { + console.info("=============OnConsume_remove_0100=======================>"); + console.info("=============OnConsume_remove_0100 data:==================>" + JSON.stringify(data)); + console.info("=============OnConsume_remove_0100 hascode:===============>" + data.request.hashCode); hashCode = data.request.hashCode notify.remove(hashCode,removeCallBack); console.info("================OnConsume_remove_0100 remove=======================>"); console.info("================OnConsume_remove_0100 end=======================>"); } - function OnCancel_remove(err, data) { + function onCancelRemove(err, data) { console.info("==========================OnCancel_remove_0100=======================>"); console.info("================OnCancel_remove_0100 data : =======================>" + JSON.stringify(data)); console.info("================OnCancel_remove_0100 err : =======================>" + JSON.stringify(err)); console.info("================OnCancel_remove_0100 hashCode=======================>" + hashCode); - console.info("================OnCancel_remove_0100 data.request.hashCode=======================>" + data.request.hashCode); + console.info("================OnCancel_0100 data.request.hashCode==========>" + data.request.hashCode); expect(hashCode).assertequal(data.request.hashCode); console.info("================OnCancel_remove_0100 end=======================>"); } @@ -73,21 +73,22 @@ describe('ActsAnsNotificationRemove', function () { console.info("================publishCallback err : =======================>" + JSON.stringify(err)); console.info("================publishCallback data : =======================>" + JSON.stringify(data)); } + /* * @tc.number: ANS_Remove_0100 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the call interface remove(hashCode: string, callback: AsyncCallback): void deletes the notification information through hashcode + * @tc.desc: Verify that the call interface remove(hashCode: string, callback: AsyncCallback): void + deletes the notification information through hashcode */ it('ANS_Remove_0100', 0, async function (done) { console.info("===============ANS_Remove_0100==========================>"); hashCode = 0 var subscriber ={ - onConsume:OnConsume_remove, - onCancel:OnCancel_remove, + onConsume:onConsumeRemove, + onCancel:onCancelRemove, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -118,52 +119,52 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0100_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0100 done==================>"); + }),1000); + }) - function OnConsume_remove_promise(err, data) { + function onConsumeRemovePromise(err, data) { console.info("================OnConsume_remove_promise_0200=======================>"); - console.info("================OnConsume_remove_promise_0200 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_remove_promise_0200 hascode: =======================>" + data.request.hashCode); + console.info("================OnConsume_remove_promise_0200 data:================>" + JSON.stringify(data)); + console.info("================OnConsume_remove_promise_0200 hascode:=============>" + data.request.hashCode); hashCode = data.request.hashCode - notify.remove(hashCode).then((err, data) => { - console.info("==========remove_promise_0200 err : =========>" + JSON.stringify(err)); - console.info("==========remove_promise_0200 data : =========>" + JSON.stringify(data)); - }); + notify.remove(hashCode); console.info("================OnConsume_remove_promise_0200 remove=======================>"); console.info("================OnConsume_remove_promise_0200 end=======================>"); } - function OnCancel_remove_promise(err, data) { + function onCancelRemovePromise(err, data) { console.info("==========================OnCancel_remove_0200=======================>"); console.info("================OnCancel_remove_0200 data : =======================>" + JSON.stringify(data)); console.info("================OnCancel_remove_0200 err : =======================>" + JSON.stringify(err)); console.info("================OnCancel_remove_0200 hashCode=======================>" + hashCode); - console.info("================OnCancel_remove_0200 data.request.hashCode=======================>" + data.request.hashCode); + console.info("================OnCancel_remove_0200 data.request.hashCode==========>" + data.request.hashCode); expect(hashCode).assertequal(data.request.hashCode); console.info("================OnCancel_remove_0200 end=======================>"); } + /* * @tc.number: ANS_Remove_0200 * @tc.name: remove(hashCode: string): Promise; - * @tc.desc: Verify that the call interface remove(hashCode: string): Promise deletes the notification information through hashcode + * @tc.desc: Verify that the call interface remove(hashCode: string): Promise + deletes the notification information through hashcode */ it('ANS_Remove_0200', 0, async function (done) { console.info("===============ANS_Remove_0200==========================>"); hashCode = 0 var subscriber ={ - onConsume:OnConsume_remove_promise, - onCancel:OnCancel_remove_promise, + onConsume:onConsumeRemovePromise, + onCancel:onCancelRemovePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -194,22 +195,22 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0200_promise==================>"); - }); + await notify.publish(notificationRequest); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0200_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0200 done==================>"); + }),1000); }) - function OnConsume_removeErrHashCode(err, data) { + function onConsumeRemoveErrHashCode(err, data) { console.info("================OnConsume_removeErrHashCode_0300 start=======================>"); - console.info("================OnConsume_removeErrHashCode_0300 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_removeErrHashCode_0300 data:=============>" + JSON.stringify(data)); notify.remove("errorHashCode",removeErrHashCodeCallBack); console.info("================OnConsume_removeErrHashCode_0300 end=======================>"); } - function OnCancel_removeErrHashCode() { + function onCancelRemoveErrHashCode() { console.info("================OnCancel_removeErrHashCode_0300 start=======================>"); console.info("==========================OnCancel_removeErrHashCode_0300=======================>"); expect().assertFail(); @@ -223,20 +224,21 @@ describe('ActsAnsNotificationRemove', function () { expect(err.code).assertNotEqual(0); console.info("================removeErrHashCodeCallBack_0300 end=======================>"); } + /* * @tc.number: ANS_Remove_0300 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void - * @tc.desc: Verify that the error hashcode is used to call the interface remove(hashCode: string, callback: AsyncCallback) to delete the notification information + * @tc.desc: Verify that the error hashcode is used to call the interface + remove(hashCode: string, callback: AsyncCallback) to delete the notification information */ it('ANS_Remove_0300', 0, async function (done) { console.info("===============ANS_Remove_0300==========================>"); var subscriber ={ - onConsume:OnConsume_removeErrHashCode, - onCancel:OnCancel_removeErrHashCode, + onConsume:onConsumeRemoveErrHashCode, + onCancel:onCancelRemoveErrHashCode, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -267,42 +269,40 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0300_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0300_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0300_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0300 done==================>"); + }),1000); }) - function OnConsume_removeErrHashCode_promise(err, data) { - console.info("================OnConsume_removeErrHashCode_promise_0400 data: =======================>" + JSON.stringify(data)); - notify.remove("errorHashCode").then((err, data) => { - console.info("==========removeErrHashCode_promise_0400 err : =========>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("==========removeErrHashCode_promise_0400 data : =========>" + JSON.stringify(data)); - }); + function onConsumeRemoveErrHashCodePromise(err, data) { + console.info("===========OnConsume_removeErrHashCode_promise_0400 data:===========>" + JSON.stringify(data)); + notify.remove("errorHashCode"); console.info("================OnConsume_removeErrHashCode_promise_0400 end=======================>"); } - function OnCancel_removeErrHashCode_promise() { - console.info("==========================OnCancel_removeErrHashCode_promise_0400=======================>"); + function onCancelRemoveErrHashCodePromise() { + console.info("==========================OnCancel_RemoveErrHashCode_Promise_0400=======================>"); expect().assertFail(); } + /* * @tc.number: ANS_Remove_0400 * @tc.name: remove(hashCode: string): Promise - * @tc.desc: Verify that the error hashcode is used to call the interface remove(hashCode: string): Promise to delete the notification information + * @tc.desc: Verify that the error hashcode is used to call the interface + remove(hashCode: string): Promise to delete the notification information */ it('ANS_Remove_0400', 0, async function (done) { console.info("===============ANS_Remove_0400==========================>"); var subscriber ={ - onConsume:OnConsume_removeErrHashCode_promise, - onCancel:OnCancel_removeErrHashCode_promise, + onConsume:onConsumeRemoveErrHashCodePromise, + onCancel:onCancelRemoveErrHashCodePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -333,48 +333,51 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0400_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0400 done==================>"); + }),1000); }) - function OnConsume_removeUseEmptyCharacter(err, data) { + function onConsumeRemoveUseEmptyCharacter(err, data) { console.info("================OnConsume_removeUseEmptyCharacter_0500 start=======================>"); - console.info("================OnConsume_removeUseEmptyCharacter_0500 data: =======================>" + JSON.stringify(data)); - notify.remove('',removeCallBack_UseEmptyCharacter); + console.info("OnConsume_removeUseEmptyCharacter_0500 data:===================>" + JSON.stringify(data)); + notify.remove('',removeCallBackUseEmptyCharacter); console.info("================OnConsume_removeUseEmptyCharacter_0500 end=======================>"); } - function OnCancel_removeUseEmptyCharacter(err, data) { - console.info("==========================OnCancel_removeUseEmptyCharacter_0500 start=======================>"); - console.info("================OnCancel_removeUseEmptyCharacter_0500 data : =======================>" + JSON.stringify(data));; + function onCancelRemoveUseEmptyCharacter(err, data) { + console.info("OnCancel_removeUseEmptyCharacter_0500 start=======================>"); + console.info("================OnCancel_0500 data : =======================>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeUseEmptyCharacter_0500 end=======================>"); } - function removeCallBack_UseEmptyCharacter(err) { + function removeCallBackUseEmptyCharacter(err) { console.info("================removeCallBack_UseEmptyCharacter_0500 start=======================>"); - console.info("================removeCallBack_UseEmptyCharacter_0500 err=======================>" + JSON.stringify(err)); + console.info("removeCallBack_UseEmptyCharacter_0500 err=======================>" + JSON.stringify(err)); expect(err.code).assertNotEqual(0); console.info("================removeCallBack_UseEmptyCharacter_0500 end=======================>"); } + /* * @tc.number: ANS_Remove_0500 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the Empty Character hashcode is used to call the interface remove(hashCode: string, callback: AsyncCallback): void to delete the notification information + * @tc.desc: Verify that the Empty Character hashcode is used to call the interface + remove(hashCode: string, callback: AsyncCallback): void + to delete the notification information */ it('ANS_Remove_0500', 0, async function (done) { console.info("===============ANS_Remove_0500==========================>"); var subscriber ={ - onConsume:OnConsume_removeUseEmptyCharacter, - onCancel:OnConsume_removeUseEmptyCharacter, + onConsume:onConsumeRemoveUseEmptyCharacter, + onCancel:onCancelRemoveUseEmptyCharacter, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -405,31 +408,27 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0500 done==================>"); + }),1000); }) - function OnConsume_removeUseEmptyCharacter_promise(err, data) { + function OnConsumeRemoveUseEmptyCharacterPromise(err, data) { console.info("================OnConsume_removeUseEmptyCharacter_promise_0600 start=======================>"); - console.info("================OnConsume_removeUseEmptyCharacter_promise_0600 data: =======================>" + JSON.stringify(data)); - notify.remove('',removeCallBack_UseEmptyCharacter).then((err, data) => { - console.info("==========remove_promise_0600 start==========>"); - console.info("==========remove_promise_0600 err : =========>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("==========remove_promise_0600 data : =========>" + JSON.stringify(data)); - console.info("==========remove_promise_0600 end==========>"); - }); + console.info("OnConsume_removeUseEmptyCharacter_promise_0600 data:==================>" + JSON.stringify(data)); + notify.remove('',removeCallBackUseEmptyCharacter); + console.info("================OnConsume_removeUseEmptyCharacter_promise_0600 remove=======================>"); console.info("================OnConsume_removeUseEmptyCharacter_promise_0600 end=======================>"); } - function OnCancel_removeUseEmptyCharacter_promise(err, data) { - console.info("==========================OnCancel_removeUseEmptyCharacter_0600 start=======================>"); - console.info("================OnCancel_removeUseEmptyCharacter_0600 data : =======================>" + JSON.stringify(data)); + function OnCancelRemoveUseEmptyCharacterPromise(err, data) { + console.info("==============OnCancel_removeUseEmptyCharacter_0600 start================>"); + console.info("OnCancel_removeUseEmptyCharacter_0600 data:=============>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeUseEmptyCharacter_0600 end=======================>"); } @@ -437,17 +436,17 @@ describe('ActsAnsNotificationRemove', function () { /* * @tc.number: ANS_Remove_0600 * @tc.name: remove(hashCode: string): Promise; - * @tc.desc: Verify that the Empty Character hashcode is used to call the interface remove(hashCode: string): Promise to delete the notification information + * @tc.desc: Verify that the Empty Character hashcode is used to call the interface + remove(hashCode: string): Promise to delete the notification information */ it('ANS_Remove_0600', 0, async function (done) { console.info("===============ANS_Remove_0600==========================>"); var subscriber ={ - onConsume:OnConsume_removeUseEmptyCharacter_promise, - onCancel:OnCancel_removeUseEmptyCharacter_promise, + onConsume:OnConsumeRemoveUseEmptyCharacterPromise, + onCancel:OnCancelRemoveUseEmptyCharacterPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -478,50 +477,53 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0600_promise==================>"); + setTimeout((function(){ + console.info("==================ANS_Remove_0600 done==================>"); + }),1000); done(); }) - function OnConsume_removeNotExistHashCode(err, data) { + function onConsumeRemoveNotExistHashCode(err, data) { console.info("================OnConsume_removeNotExistHashCode_0700=======================>"); - console.info("================OnConsume_removeNotExistHashCode_0700 data: =======================>" + JSON.stringify(data)); + console.info("OnConsume_removeNotExistHashCode_0700 data: =======================>" + JSON.stringify(data)); notify.remove("9999_9999_9",removeNotExistHashCodeCallBack); console.info("================OnConsume_removeNotExistHashCode_0700 remove=======================>"); console.info("================OnConsume_removeNotExistHashCode_0700 end=======================>"); } - function OnCancelCallback_removeNotExistHashCode(err, data) { - console.info("==========================OnCancelCallback_removeNotExistHashCode_0700 start=======================>"); - console.info("================OnCancelCallback_removeNotExistHashCode_0700 data : =======================>" + JSON.stringify(data)); + function onCancelRemoveNotExistHashCode(err, data) { + console.info("===========OnCancel_removeNotExistHashCode_0700 start=======================>"); + console.info("OnCancel_removeNotExistHashCode_0700 data:============>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancelCallback_removeNotExistHashCode_0700 end=======================>"); + console.info("================OnCancel_removeNotExistHashCode_0700 end=======================>"); } function removeNotExistHashCodeCallBack(err) { console.info("================removeNotExistHashCodeCallBack_0700 start=======================>"); - console.info("================removeNotExistHashCodeCallBack_0700=======================>" + JSON.stringify(err)); + console.info("=============removeNotExistHashCodeCallBack_0700=================>" + JSON.stringify(err)); expect(err.code).assertNotEqual(0); console.info("================removeNotExistHashCodeCallBack_0700 end=======================>"); } + /* * @tc.number: ANS_Remove_0700 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the not exist hashCode is used to call the interface remove(hashCode: string, callback: AsyncCallback): void to delete the notification information + * @tc.desc: Verify that the not exist hashCode is used to call the interface + * remove(hashCode: string, callback: AsyncCallback): void + * to delete the notification information */ it('ANS_Remove_0700', 0, async function (done) { console.info("===============ANS_Remove_0700==========================>"); var subscriber ={ - onConsume:OnConsume_removeNotExistHashCode, - onCancel:OnCancelCallback_removeNotExistHashCode, + onConsume:onConsumeRemoveNotExistHashCode, + onCancel:onCancelRemoveNotExistHashCode, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0700_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0700_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -552,50 +554,46 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0700_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0700_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0700_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0700_promise==================>"); + setTimeout((function(){ + console.info("==================ANS_Remove_0700 done==================>"); + }),1000); done(); }) - function OnConsume_removeNotExistHashCode_promise(err, data) { + function onConsumeRemoveNotExistHashCodePromise(err, data) { console.info("================OnConsume_removeNotExistHashCode_promise_0800=======================>"); - console.info("================OnConsume_removeNotExistHashCode_promise_0800 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeNotExistHashCode_promise_0800 err: =======================>" + JSON.stringify(err)); - notify.remove("9999_9999_9").then((err, data) => { - console.info("================removeNotExistHashCode_promise_0800 start=======================>"); - console.info("================removeNotExistHashCode_promise_0800 data: =======================>" + JSON.stringify(data)); - console.info("================removeNotExistHashCode_promise_0800 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("================removeNotExistHashCode_promise_0800 end=======================>"); - }); + console.info("OnConsume_removeNotExistHashCode_promise_0800 data:===============>" + JSON.stringify(data)); + console.info("OnConsume_removeNotExistHashCode_promise_0800 err:===========>" + JSON.stringify(err)); + notify.remove("9999_9999_9"); console.info("================OnConsume_removeNotExistHashCode_promise_0800 end=======================>"); } - function OnCancelCallback_removeNotExistHashCode_promise(err, data) { - console.info("==========================OnCancelCallback_removeNotExistHashCode_promise_0800=======================>"); - console.info("================OnCancelCallback_removeNotExistHashCode_promise_0800 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeNotExistHashCode_promise_0800 err : =======================>" + JSON.stringify(err)); + function onCancelRemoveNotExistHashCodePromise(err, data) { + console.info("================OnCancelCallback_removeNotExistHashCode_promise_0800=======================>"); + console.info("================OnCancelCallback_0800 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_0800 err : =======================>" + JSON.stringify(err)); expect().assertFail(); - console.info("================OnCancelCallback_removeNotExistHashCode_promise_0800 end=======================>"); + console.info("================OnCancelCallback_removeNotExistHashCode_promise_0800 end===========>"); } + /* * @tc.number: ANS_Remove_0800 * @tc.name: remove(hashCode: string): Promise; - * @tc.desc: Verify that the not exist hashCode is used to call the interface remove(hashCode: string, callback: AsyncCallback): void to delete the notification information + * @tc.desc: Verify that the not exist hashCode is used to call the interface remove(hashCode: string, + * callback: AsyncCallback): void to delete the notification information */ it('ANS_Remove_0800', 0, async function (done) { console.info("===============ANS_Remove_0800==========================>"); var subscriber ={ - onConsume:OnConsume_removeNotExistHashCode_promise, - onCancel:OnCancelCallback_removeNotExistHashCode_promise, + onConsume:onConsumeRemoveNotExistHashCodePromise, + onCancel:onCancelRemoveNotExistHashCodePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0800_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0800_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -626,51 +624,53 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0800_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0800_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0800_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0800_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0800 done==================>"); + }),1000); }) - function OnConsumeCallback_removeNonComplianceHashCode(err, data) { - console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 start=======================>"); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveNonComplianceHashCode(err, data) { + console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 start===================>"); + console.info("================OnConsumeCallback_0900 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsumeCallback_0900 err: =======================>" + JSON.stringify(err)); notify.remove("哈希码",removeNonComplianceHashCallBack); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 remove=======================>"); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 end=======================>"); + console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 remove===================>"); + console.info("================OnConsumeCallback_removeNonComplianceHashCode_0900 end======================>"); } - function OnCancelCallback_removeNonComplianceHashCode(err, data) { - console.info("==========================OnCancelCallback_removeNonComplianceHashCode_0900 start=======================>"); - console.info("================OnCancelCallback_removeNonComplianceHashCode_0900 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancelCallback_removeNonComplianceHashCode_0900 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveNonComplianceHashCode(err, data) { + console.info("================OnCancelCallback_removeNonComplianceHashCode_0900 start====================>"); + console.info("================OnCancelCallback_0900 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancelCallback_0900 data: =======================>" + JSON.stringify(data)); console.info("================OnCancelCallback_removeNonComplianceHashCode_0900 end=======================>"); } function removeNonComplianceHashCallBack(err, data) { console.info("================removeNonComplianceHashCallBack_0900 start=======================>"); - console.info("================removeNonComplianceHashCallBack_0900=======================>" + JSON.stringify(err)); - console.info("================removeNonComplianceHashCallBack_0900=======================>" + JSON.stringify(data)); + console.info("================removeNonComplianceHashCallBack_0900=================>" + JSON.stringify(err)); + console.info("================removeNonComplianceHashCallBack_0900=================>" + JSON.stringify(data)); console.info("================removeNonComplianceHashCallBack_0900 end=======================>"); expect(err.code).assertNotEqual(0); } + /* * @tc.number: ANS_Remove_0900 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the non compliance hashCode is used to call the interface remove(hashCode: string, callback: AsyncCallback): void to delete the notification information + * @tc.desc: Verify that the non compliance hashCode is used to call the interface remove(hashCode: string, + * callback: AsyncCallback): void to delete the notification information */ it('ANS_Remove_0900', 0, async function (done) { console.info("===============ANS_Remove_0900==========================>"); var subscriber ={ - onConsume:OnConsumeCallback_removeNonComplianceHashCode, - onCancel:OnCancelCallback_removeNonComplianceHashCode, + onConsume:onConsumeRemoveNonComplianceHashCode, + onCancel:onCancelRemoveNonComplianceHashCode, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_0900_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_0900_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -701,50 +701,45 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_0900_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_0900_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_0900_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_0900_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_0900 done==================>"); + }),1000); }) - function OnConsumeCallback_removeNonComplianceHashCode_promise(err, data) { - console.info("================OnConsumeCallback_removeNonComplianceHashCode_1000 start=======================>"); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_1000 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsumeCallback_removeNonComplianceHashCode_1000 err: =======================>" + JSON.stringify(err)); - notify.remove("哈希码").then((err, data) => { - console.info("================removeNonComplianceHashCode_promise_1000 start=======================>"); - console.info("================removeNonComplianceHashCode_promise_1000 data: =======================>" + JSON.stringify(data)); - console.info("================removeNonComplianceHashCode_promise_1000 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("================removeNonComplianceHashCode_promise_1000 end=======================>"); - }); + function onConsumeRemoveNonComplianceHashCodePromise(err, data) { + console.info("================OnConsumeCallback_removeNonComplianceHashCode_1000 start================>"); + console.info("================OnConsumeCallback_1000 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsumeCallback_1000 err: =======================>" + JSON.stringify(err)); + notify.remove("哈希码"); console.info("================OnConsumeCallback_removeNonComplianceHashCode_1000 end=======================>"); } - function OnCancelCallback_removeNonComplianceHashCode_promise(err, data) { - console.info("==========================OnCancelCallback_removeNonComplianceHashCode_1000 start=======================>"); - console.info("================OnCancelCallback_removeNonComplianceHashCode_1000 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancelCallback_removeNonComplianceHashCode_1000 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveNonComplianceHashCodePromise(err, data) { + console.info("OnCancel_removeNonComplianceHashCode_1000 start=======================>"); + console.info("================OnCancel_1000 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1000 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancelCallback_removeNonComplianceHashCode_1000 end=======================>"); + console.info("OnCancelCallback_removeNonComplianceHashCode_1000 end=======================>"); } /* * @tc.number: ANS_Remove_1000 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the non compliance hashCode is used to call the interface remove(hashCode: string, callback: AsyncCallback): void to delete the notification information + * @tc.desc: Verify that the non compliance hashCode is used to call the interface + remove(hashCode: string, callback: AsyncCallback): void to delete the notification information */ it('ANS_Remove_1000', 0, async function (done) { console.info("===============ANS_Remove_1000==========================>"); var subscriber ={ - onConsume:OnConsumeCallback_removeNonComplianceHashCode_promise, - onCancel:OnCancelCallback_removeNonComplianceHashCode_promise, + onConsume:onConsumeRemoveNonComplianceHashCodePromise, + onCancel:onCancelRemoveNonComplianceHashCodePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1000_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1000_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -775,13 +770,14 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1000_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1000_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1000_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1000_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1000 done==================>"); + }),1000); }) function removeCallBack2TimesOf2(err) { console.info("================removeCallBack2TimesOf2_1100 start=======================>"); @@ -795,41 +791,42 @@ describe('ActsAnsNotificationRemove', function () { expect(err.code).assertequal(0); notify.remove(hashCode,removeCallBack2TimesOf2); } - function OnConsumeCallback_remove2Times(err, data) { + function onConsumeCallbackRemove2Times(err, data) { console.info("================OnConsumeCallback_remove2Times_1100 start=======================>"); - console.info("================OnConsumeCallback_remove2Times_1100 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsumeCallback_1100 data: =======================>" + JSON.stringify(data)); notify.remove(hashCode,removeCallBack2TimesOf1); console.info("================OnConsumeCallback_remove2Times_1100 remove=======================>"); console.info("================OnConsumeCallback_remove2Times_1100 end=======================>"); } - var timesOfOnCancelCallback_remove2Times - function OnCancelCallback_remove2Times(err, data) { - timesOfOnCancelCallback_remove2Times = timesOfOnCancelCallback_remove2Times + 1 + var timesOfOnCancelCallbackRemove2Times + function onCancelCallbackRemove2Times(err, data) { + timesOfOnCancelCallbackRemove2Times = timesOfOnCancelCallbackRemove2Times + 1 console.info("==========================OnCancelCallback_remove2Times_1100=======================>"); - console.info("================OnCancelCallback_remove2Times_1100 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_remove2Times_1100 err : =======================>" + JSON.stringify(err)); - if (timesOfOnCancelCallback_remove2Times == 1){ + console.info("================OnCancelCallback_1100 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_1100 err : =======================>" + JSON.stringify(err)); + if (timesOfOnCancelCallbackRemove2Times == 1){ expect(data.request.id).assertequal(1); - } else if (timesOfOnCancelCallback_remove2Times == 2){ + } else if (timesOfOnCancelCallbackRemove2Times == 2){ expect().assertFail(); } console.info("================OnCancelCallback_remove2Times_1100 end=======================>"); } + /* * @tc.number: ANS_Remove_1100 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the interface remove(hashCode: string, callback: AsyncCallback): void; is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface remove(hashCode: string, callback: AsyncCallback): void; + is called twice in a row to delete the notification information */ it('ANS_Remove_1100', 0, async function (done) { console.info("===============ANS_Remove_1100==========================>"); - timesOfOnCancelCallback_remove2Times = 0 + timesOfOnCancelCallbackRemove2Times = 0 var subscriber ={ - onConsume:OnConsumeCallback_remove2Times, - onCancel:OnCancelCallback_remove2Times, + onConsume:onConsumeCallbackRemove2Times, + onCancel:onCancelCallbackRemove2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -860,62 +857,55 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1100_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1100 done==================>"); + }),1000); }) - function OnConsumeCallback_remove2Times_promise(err, data) { + function onConsumeCallbackRemove2TimesPromise(err, data) { console.info("================OnConsumeCallback_remove2Times_promise_1200 start=======================>"); - console.info("================OnConsumeCallback_remove2Times_promise_1200 data: =======================>" + JSON.stringify(data)); - notify.remove(hashCode).then((err, data) => { - console.info("================remove_2times1_1200 start=======================>"); - console.info("================remove_2times1_1200 data: =======================>" + JSON.stringify(data)); - console.info("================remove_2times1_1200 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertequal(0); - notify.remove(hashCode).then((err, data) => { - console.info("================remove_2times2_1200 start=======================>"); - console.info("================remove_2times2_1200 data: =======================>" + JSON.stringify(data)); - console.info("================remove_2times2_1200 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("================remove_2times2_1200 end=======================>"); - }); - console.info("================remove_2times1_1200 end=======================>"); - }); + console.info("================OnConsumeCallback_1200 data: =======================>" + JSON.stringify(data)); + notify.remove(hashCode); + console.info("================remove_2times1_1200=======================>"); + notify.remove(hashCode); + console.info("================remove_2times2_1200=======================>"); console.info("================OnConsumeCallback_remove2Times_promise_1200 remove=======================>"); console.info("================OnConsumeCallback_remove2Times_promise_1200 end=======================>"); } - var timesOfOnCancelCallback_remove2Times_promise - function OnCancelCallback_remove2Times_promise(err, data) { - timesOfOnCancelCallback_remove2Times_promise = timesOfOnCancelCallback_remove2Times_promise + 1 + var timesOfOnCancelCallbackRemove2TimesPromise + function onCancelCallbackRemove2TimesPromise(err, data) { + timesOfOnCancelCallbackRemove2TimesPromise = timesOfOnCancelCallbackRemove2TimesPromise + 1 console.info("==========================OnCancelCallback_remove2Times_1200=======================>"); - console.info("================OnCancelCallback_remove2Times_1200 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_remove2Times_1200 err : =======================>" + JSON.stringify(err)); - if (timesOfOnCancelCallback_remove2Times_promise == 1){ + console.info("================OnCancelCallback_1200 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_1200 err : =======================>" + JSON.stringify(err)); + if (timesOfOnCancelCallbackRemove2TimesPromise == 1){ expect(data.request.id).assertequal(1); - } else if (timesOfOnCancelCallback_remove2Times_promise == 2){ + } else if (timesOfOnCancelCallbackRemove2TimesPromise == 2){ expect().assertFail(); } console.info("================OnCancelCallback_remove2Times_1200 end=======================>"); } + /* * @tc.number: ANS_Remove_1200 * @tc.name: remove(hashCode: string): Promise; - * @tc.desc: Verify that the interface remove(hashCode: string): Promise is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface remove(hashCode: string): Promise is called twice in a row to + * delete the notification information */ it('ANS_Remove_1200', 0, async function (done) { console.info("===============ANS_Remove_1200==========================>"); - timesOfOnCancelCallback_remove2Times_promise = 0 + timesOfOnCancelCallbackRemove2TimesPromise = 0 var subscriber ={ - onConsume:OnConsumeCallback_remove2Times_promise, - onCancel:OnCancelCallback_remove2Times_promise, + onConsume:onConsumeCallbackRemove2TimesPromise, + onCancel:onCancelCallbackRemove2TimesPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -946,53 +936,55 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1200_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1200 done==================>"); + }),1000); }) - function OnConsume_removeIsUnremovable(err, data) { - console.info("================OnConsume_removeIsUnremovable_1300 start=======================>"); - console.info("================OnConsume_removeIsUnremovable_1300 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeIsUnremovable_1300 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveIsUnremovable(err, data) { + console.info("OnConsume_removeIsUnremovable_1300 start=================>"); + console.info("OnConsume_removeIsUnremovable_1300 data:===================>" + JSON.stringify(data)); + console.info("OnConsume_removeIsUnremovable_1300 err:=================>" + JSON.stringify(err)); notify.remove(data.request.hashCode,removeIsUnremovableCallBack); - console.info("================OnConsume_removeIsUnremovable_1300 remove=======================>"); - console.info("================OnConsume_removeIsUnremovable_1300 end=======================>"); + console.info("OnConsume_removeIsUnremovable_1300 remove=============>"); + console.info("OnConsume_removeIsUnremovable_1300 end=============>"); } - function OnCancel_removeIsUnremovable(err, data) { + function onCancelRemoveIsUnremovable(err, data) { console.info("==========================OnCancel_removeIsUnremovable_1300 start=======================>"); - console.info("================OnCancel_removeIsUnremovable_1300 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeIsUnremovable_1300 data: =======================>" + JSON.stringify(data)); + console.info("================OnCancel_removeIsUnremovable_1300 err: ===============>" + JSON.stringify(err)); + console.info("================OnCancel_removeIsUnremovable_1300 data: ==============>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeIsUnremovable_1300 end=======================>"); } function removeIsUnremovableCallBack(err, data) { console.info("================removeIsUnremovableCallBack_1300 start=======================>"); - console.info("================removeIsUnremovableCallBack_1300=======================>" + JSON.stringify(err)); + console.info("================removeIsUnremovableCallBack_1300=====================>" + JSON.stringify(err)); expect(err.code).assertNotEqual(0); - console.info("================removeIsUnremovableCallBack_1300=======================>" + JSON.stringify(data)); + console.info("================removeIsUnremovableCallBack_1300=====================>" + JSON.stringify(data)); console.info("================removeIsUnremovableCallBack_1300 end=======================>"); } + /* * @tc.number: ANS_Remove_1300 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(hashCode: string, callback: AsyncCallback): void; deletes the notification information that the property isunremovable is true + * @tc.desc: Verify that the calling interface remove(hashCode: string, callback: AsyncCallback): void; + * deletes the notification information that the property isunremovable is true */ it('ANS_Remove_1300', 0, async function (done) { console.info("===============ANS_Remove_1300==========================>"); var subscriber ={ - onConsume:OnConsume_removeIsUnremovable, - onCancel:OnCancel_removeIsUnremovable, + onConsume:onConsumeRemoveIsUnremovable, + onCancel:onCancelRemoveIsUnremovable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1023,49 +1015,48 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1300_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1300_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1300_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1300 done==================>"); + }),1000); }) - function OnConsume_removeIsUnremovable_promise(err, data) { + function OnConsumeRemoveIsUnremovablePromise(err, data) { console.info("================OnConsume_removeIsUnremovable_promise_1400 start=======================>"); - console.info("================OnConsume_removeIsUnremovable_promise_1400 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeIsUnremovable_promise_1400 err: =======================>" + JSON.stringify(err)); - notify.remove(data.request.hashCode).then((err, data) => { - console.info("================removeIsUnremovable_promise_1400 start=======================>"); - console.info("================removeIsUnremovable_promise_1400 data: =======================>" + JSON.stringify(data)); - console.info("================removeIsUnremovable_promise_1400 err: =======================>" + JSON.stringify(err)); - console.info("================removeIsUnremovable_promise_1400 end=======================>"); - }); + console.info("================OnConsume_1400 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_1400 err: =======================>" + JSON.stringify(err)); + notify.remove(data.request.hashCode); + console.info("================removeIsUnremovable_promise_1400=======================>"); console.info("================OnConsume_removeIsUnremovable_promise_1400 end=======================>"); } - function OnCancel_removeIsUnremovable_promise(err, data) { - console.info("==========================OnCancel_removeIsUnremovable_promise_1400 start=======================>"); - console.info("================OnCancel_removeIsUnremovable_promise_1400 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeIsUnremovable_promise_1400 data: =======================>" + JSON.stringify(data)); + function OnCancelRemoveIsUnremovablePromise(err, data) { + console.info("=====OnCancel_removeIsUnremovable_promise_1400 start=======================>"); + console.info("================OnCancel_1400 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1400 data: =======================>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeIsUnremovable_promise_1400 end=======================>"); } + /* * @tc.number: ANS_Remove_1400 * @tc.name: remove(hashCode: string): Promise; - * @tc.desc: Verify that the calling interface remove(hashCode: string): Promise; deletes the notification information that the property isunremovable is true + * @tc.desc: Verify that the calling interface remove(hashCode: string): Promise; + deletes the notification information that the property isunremovable is true */ it('ANS_Remove_1400', 0, async function (done) { console.info("===============ANS_Remove_1400==========================>"); var subscriber ={ - onConsume:OnConsume_removeIsUnremovable_promise, - onCancel:OnCancel_removeIsUnremovable_promise, + onConsume:OnConsumeRemoveIsUnremovablePromise, + onCancel:OnCancelRemoveIsUnremovablePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1096,66 +1087,69 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1400_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1400 done==================>"); + }),1000); }) - var timesOfOnConsume_removeAllByBundleOption - function OnConsume_removeAllByBundleOption(err, data) { - timesOfOnConsume_removeAllByBundleOption = timesOfOnConsume_removeAllByBundleOption + 1 + var timesOfOnConsumeRemoveAllByBundleOption + function onConsumeRemoveAllByBundleOption(err, data) { + timesOfOnConsumeRemoveAllByBundleOption = timesOfOnConsumeRemoveAllByBundleOption + 1 console.info("================OnConsume_removeAllByBundleOption_1500 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_1500 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_1500 err: =======================>" + JSON.stringify(err)); + console.info("================OnConsume_1500 data: ====================>" + JSON.stringify(data)); + console.info("================OnConsume_1500 err: =====================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, } - if (timesOfOnConsume_removeAllByBundleOption == 2){ + if (timesOfOnConsumeRemoveAllByBundleOption == 2){ notify.removeAll(bundleOption,removeAllByBundleOptionCallBack); console.info("================OnConsume_removeAllByBundleOption_1500 remove=======================>"); } console.info("================OnConsume_removeAllByBundleOption_1500 end=======================>"); } - var timesOfOnCancel_removeAllByBundleOption - function OnCancel_removeAllByBundleOption(err, data) { - timesOfOnCancel_removeAllByBundleOption = timesOfOnCancel_removeAllByBundleOption + 1 + var timesOfOnCancelRemoveAllByBundleOption + function onCancelRemoveAllByBundleOption(err, data) { + timesOfOnCancelRemoveAllByBundleOption = timesOfOnCancelRemoveAllByBundleOption + 1 console.info("==========================OnCancel_removeAllByBundleOption_1500 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_1500 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_1500 data: =======================>" + JSON.stringify(data)); - if (timesOfOnCancel_removeAllByBundleOption == 1){ + console.info("================OnCancel_1500 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1500 data: =======================>" + JSON.stringify(data)); + if (timesOfOnCancelRemoveAllByBundleOption == 1){ expect(data.request.label).assertequal("1500_1"); - }else if (timesOfOnCancel_removeAllByBundleOption == 2){ + }else if (timesOfOnCancelRemoveAllByBundleOption == 2){ expect(data.request.label).assertequal("1500_2"); } console.info("================OnCancel_removeIsUnremovable_1500 end=======================>"); } function removeAllByBundleOptionCallBack(err, data) { console.info("================removeAllByBundleOptionCallBack_1500 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_1500=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_1500=======================>" + JSON.stringify(data)); + console.info("================removeAllByBundleOptionCallBack_1500==================>" + JSON.stringify(err)); + console.info("================removeAllByBundleOptionCallBack_1500==================>" + JSON.stringify(data)); console.info("================removeAllByBundleOptionCallBack_1500 end=======================>"); } + /* * @tc.number: ANS_Remove_1500 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption */ it('ANS_Remove_1500', 0, async function (done) { console.info("===============ANS_Remove_1500==========================>"); - timesOfOnCancel_removeAllByBundleOption = 0 - timesOfOnConsume_removeAllByBundleOption = 0 + timesOfOnCancelRemoveAllByBundleOption = 0 + timesOfOnConsumeRemoveAllByBundleOption = 0 var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption, - onCancel:OnCancel_removeAllByBundleOption, + onConsume:onConsumeRemoveAllByBundleOption, + onCancel:onCancelRemoveAllByBundleOption, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1216,70 +1210,71 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_1500_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_1500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish1_1500_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_1500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1500_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1500 done==================>"); + }),1000); }) - var timesOfOnConsume_removeAllByBundleOption_nullUid - function OnConsume_removeAllByBundleOption_nullUid(err, data) { - console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 err: =======================>" + JSON.stringify(err)); + var timesOfOnConsumeRemoveAllByBundleOptionNullUid + function onConsumeRemoveAllByBundleOptionNullUid(err, data) { + console.info("OnConsume_removeAllByBundleOption_nullUid_1600 start==========>"); + console.info("OnConsume_removeAllByBundleOption_nullUid_1600 data:========>" + JSON.stringify(data)); + console.info("OnConsume_removeAllByBundleOption_nullUid_1600 err:======>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, } - timesOfOnConsume_removeAllByBundleOption_nullUid = timesOfOnConsume_removeAllByBundleOption_nullUid + 1 - if (timesOfOnConsume_removeAllByBundleOption_nullUid == 2){ - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_nullUid); - console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 remove=======================>"); + timesOfOnConsumeRemoveAllByBundleOptionNullUid = timesOfOnConsumeRemoveAllByBundleOptionNullUid + 1 + if (timesOfOnConsumeRemoveAllByBundleOptionNullUid == 2){ + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackNullUid); + console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 remove==================>"); } console.info("================OnConsume_removeAllByBundleOption_nullUid_1600 end=======================>"); } - var timesOfOnCancel_removeAllByBundleOption_nullUid - function OnCancel_removeAllByBundleOption_nullUid(err, data) { - timesOfOnCancel_removeAllByBundleOption_nullUid = timesOfOnCancel_removeAllByBundleOption_nullUid + 1 - console.info("==========================OnCancel_removeAllByBundleOption_nullUid_1600 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_nullUid_1600 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_nullUid_1600 data: =======================>" + JSON.stringify(data)); - if (timesOfOnCancel_removeAllByBundleOption_nullUid == 1){ + var timesOfOnCancelRemoveAllByBundleOptionNullUid + function onCancelRemoveAllByBundleOptionNullUid(err, data) { + timesOfOnCancelRemoveAllByBundleOptionNullUid = timesOfOnCancelRemoveAllByBundleOptionNullUid + 1 + console.info("================OnCancel_removeAllByBundleOption_nullUid_1600 start=======================>"); + console.info("================OnCancel_1600 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1600 data: =======================>" + JSON.stringify(data)); + if (timesOfOnCancelRemoveAllByBundleOptionNullUid == 1){ expect(data.request.label).assertequal("1600_1"); - }else if (timesOfOnCancel_removeAllByBundleOption_nullUid == 2){ + }else if (timesOfOnCancelRemoveAllByBundleOptionNullUid == 2){ expect(data.request.label).assertequal("1600_2"); } console.info("================OnCancel_removeAllByBundleOption_nullUid_1600 end=======================>"); } - function removeAllByBundleOptionCallBack_nullUid(err, data) { + function removeAllByBundleOptionCallBackNullUid(err, data) { console.info("================removeAllByBundleOptionCallBack_nullUid_1600 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_nullUid_1600=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_nullUid_1600=======================>" + JSON.stringify(data)); + console.info("================removeAllByBundleOption_1600=======================>" + JSON.stringify(err)); + console.info("================removeAllByBundleOption_1600=======================>" + JSON.stringify(data)); console.info("================removeAllByBundleOptionCallBack_nullUid_1600 end=======================>"); } + /* * @tc.number: ANS_Remove_1600 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - Correct bundle, null uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption Correct bundle, null uid. */ it('ANS_Remove_1600', 0, async function (done) { console.info("===============ANS_Remove_1600==========================>"); - timesOfOnConsume_removeAllByBundleOption_nullUid = 0 - timesOfOnCancel_removeAllByBundleOption_nullUid = 0 + timesOfOnConsumeRemoveAllByBundleOptionNullUid = 0 + timesOfOnCancelRemoveAllByBundleOptionNullUid = 0 var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_nullUid, - onCancel:OnCancel_removeAllByBundleOption_nullUid, + onConsume:onConsumeRemoveAllByBundleOptionNullUid, + onCancel:onCancelRemoveAllByBundleOptionNullUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1340,59 +1335,60 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_1600_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_1600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish1_1600_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_1600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1600_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1600 done==================>"); + }),1000); }) - function OnConsume_removeAllByBundleOption_wrongUid(err, data) { + function onConsumeRemoveAllByBundleOptionWrongUid(err, data) { console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 err: =======================>" + JSON.stringify(err)); + console.info("================OnConsume_1700 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_1700 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:123456789 } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_wrongUid); - console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 remove=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackWrongUid); + console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 remove====================>"); console.info("================OnConsume_removeAllByBundleOption_wrongUid_1700 end=======================>"); } - function OnCancel_removeAllByBundleOption_wrongUid(err, data) { - console.info("==========================OnCancel_removeAllByBundleOption_wrongUid_1700 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_wrongUid_1700 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_wrongUid_1700 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveAllByBundleOptionWrongUid(err, data) { + console.info("================OnCancel_removeAllByBundleOption_wrongUid_1700 start======================>"); + console.info("================OnCancel_1700 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1700 data: =======================>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeAllByBundleOption_wrongUid_1700 end=======================>"); } - function removeAllByBundleOptionCallBack_wrongUid(err, data) { + function removeAllByBundleOptionCallBackWrongUid(err, data) { console.info("================removeAllByBundleOptionCallBack_wrongUid_1700 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_wrongUid_1700=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_wrongUid_1700=======================>" + JSON.stringify(data)); + console.info("================removeAllByBundleOption_1700=======================>" + JSON.stringify(err)); + console.info("================removeAllByBundleOption_1700=======================>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); console.info("================removeAllByBundleOptionCallBack_wrongUid_1700 end=======================>"); } + /* * @tc.number: ANS_Remove_1700 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - Correct bundle, wrong uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption Correct bundle, wrong uid. */ it('ANS_Remove_1700', 0, async function (done) { console.info("===============ANS_Remove_1700==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_nullUid, - onCancel:OnCancel_removeAllByBundleOption_nullUid, + onConsume:onConsumeRemoveAllByBundleOptionWrongUid, + onCancel:onCancelRemoveAllByBundleOptionWrongUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1700_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1700_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1423,56 +1419,59 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1700_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1700_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1700_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1700_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1700 done==================>"); + }),1000); + }) - function OnConsume_removeAllByBundleOption_wrongBundle_correctUid(err, data) { - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveAllByBundleOptionWrongBundleCorrectUid(err, data) { + console.info("OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 start=============>"); + console.info("================OnConsume_1800 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_1800 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:"wrongBundleName", uid:data.request.creatorUid, } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_wrongBundle_correctUid); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 remove=======================>"); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_correctUid_1800 end=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackWrongBundleCorrectUid); + console.info("================OnConsume_wrongBundle_correctUid_1800 remove=======================>"); + console.info("================OnConsume_wrongBundle_correctUid_1800 end=======================>"); } - function OnCancel_removeAllByBundleOption_wrongBundle_correctUid(err, data) { - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 data: =======================>" + JSON.stringify(data)); + function onCancelremoveAllByBundleOptionwrongBundleCorrectUid(err, data) { + console.info("OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 start=======================>"); + console.info("================OnCancel_1800 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_1800 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 end=======================>"); + console.info("OnCancel_removeAllByBundleOption_wrongBundle_correctUid_1800 end=======================>"); } - function removeAllByBundleOptionCallBack_wrongBundle_correctUid(err, data) { - console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800=======================>" + JSON.stringify(data)); + function removeAllByBundleOptionCallBackWrongBundleCorrectUid(err, data) { + console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800 start==========>"); + console.info("================wrongBundle_correctUid_1800=======================>" + JSON.stringify(err)); + console.info("================wrongBundle_correctUid_1800=======================>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800 end=======================>"); + console.info("================removeAllByBundleOptionCallBack_wrongBundle_correctUid_1800 end============>"); } + /* * @tc.number: ANS_Remove_1800 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - wrong bundle, correct uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption wrong bundle, correct uid. */ it('ANS_Remove_1800', 0, async function (done) { console.info("===============ANS_Remove_1800==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_wrongBundle_correctUid, - onCancel:OnCancel_removeAllByBundleOption_wrongBundle_correctUid, + onConsume:onConsumeRemoveAllByBundleOptionWrongBundleCorrectUid, + onCancel:onCancelremoveAllByBundleOptionwrongBundleCorrectUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1800_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1800_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1503,56 +1502,58 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1800_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1800_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1800_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1800_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1800 done==================>"); + }),1000); }) - function OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid(err, data) { - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveAllByBundleOptionNullCharacterBundleCorrectUid(err, data) { + console.info("================OnConsume_nullCharacterBundle_correctUid_1900 start=======================>"); + console.info("================OnConsume_correctUid_1900 data: ============>" + JSON.stringify(data)); + console.info("================OnConsume_correctUid_1900 err: =============>" + JSON.stringify(err)); var bundleOption = { bundle:"", uid:data.request.creatorUid, } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 remove=======================>"); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 end=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackNullCharacterBundleCorrectUid); + console.info("================OnConsume_nullCharacterBundle_correctUid_1900 remove====================>"); + console.info("================OnConsume_nullCharacterBundle_correctUid_1900 end=======================>"); } - function OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid(err, data) { - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveAllByBundleOptionNullCharacterBundleCorrectUid(err, data) { + console.info("OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 start===========>"); + console.info("OnCancel_1900 err:=======>" + JSON.stringify(err)); + console.info("OnCancel_1900 data:==========>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 end=======================>"); + console.info("OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid_1900 end=============>"); } - function removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid(err, data) { - console.info("================removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid_1900 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid_1900=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid_1900=======================>" + JSON.stringify(data)); + function removeAllByBundleOptionCallBackNullCharacterBundleCorrectUid(err, data) { + console.info("================nullCharacterBundle_correctUid_1900 start=======================>"); + console.info("================nullCharacterBundle_correctUid_1900===================>" + JSON.stringify(err)); + console.info("================nullCharacterBundle_correctUid_1900==================>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); - console.info("================removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid_1900 end=======================>"); + console.info("================removeAllByBundleOptionCallBack_nullCharacterBundle_correctUid_1900 end=====>"); } + /* * @tc.number: ANS_Remove_1900 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - null character bundle, correct uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption null character bundle, correct uid. */ it('ANS_Remove_1900', 0, async function (done) { console.info("===============ANS_Remove_1900==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid, - onCancel:OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid, + onConsume:onConsumeRemoveAllByBundleOptionNullCharacterBundleCorrectUid, + onCancel:onCancelRemoveAllByBundleOptionNullCharacterBundleCorrectUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_1900_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_1900_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1583,56 +1584,57 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_1900_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_1900_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_1900_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_1900_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_1900 done==================>"); + }),1000); }) - function OnConsume_removeAllByBundleOption_wrongBundle_wrongUid(err, data) { - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveAllByBundleOptionWrongBundleWrongUid(err, data) { + console.info("OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 start=======================>"); + console.info("OnConsume_2000 data: =======================>" + JSON.stringify(data)); + console.info("OnConsume_2000 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:"wrongBundleName", uid:123456789, } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_wrongBundle_wrongUid); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 remove=======================>"); - console.info("================OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 end=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackWrongBundleWrongUid); + console.info("================OnConsume_2000 remove=======================>"); + console.info("OnConsume_removeAllByBundleOption_wrongBundle_wrongUid_2000 end=======================>"); } - function OnCancel_removeAllByBundleOption_wrongBundle_wrongUid(err, data) { - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_wrongUid_2000 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_wrongUid_2000 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_wrongUid_2000 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveAllByBundleOptionWrongBundleWrongUid(err, data) { + console.info("================OnCancel_wrongBundle_wrongUid_2000 start======================>"); + console.info("================OnCancel_wrongBundle_wrongUid_2000 err: =============>" + JSON.stringify(err)); + console.info("================OnCancel_wrongUid_2000 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeAllByBundleOption_wrongBundle_wrongUid_2000 end=======================>"); + console.info("================OnCancel_removeAllByBundleOption_wrongBundle_wrongUid_2000 end==============>"); } - function removeAllByBundleOptionCallBack_wrongBundle_wrongUid(err, data) { - console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000 start=======================>"); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000=======================>" + JSON.stringify(data)); + function removeAllByBundleOptionCallBackWrongBundleWrongUid(err, data) { + console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000 start=============>"); + console.info("================wrongBundle_wrongUid_2000=======================>" + JSON.stringify(err)); + console.info("================wrongBundle_wrongUid_2000=======================>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); - console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000 end=======================>"); + console.info("================removeAllByBundleOptionCallBack_wrongBundle_wrongUid_2000 end===============>"); } + /* * @tc.number: ANS_Remove_2000 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - wrong bundle, wrong uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption wrong bundle, wrong uid. */ it('ANS_Remove_2000', 0, async function (done) { console.info("===============ANS_Remove_2000==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_nullCharacterBundle_correctUid, - onCancel:OnCancel_removeAllByBundleOption_nullCharacterBundle_correctUid, + onConsume:onConsumeRemoveAllByBundleOptionWrongBundleWrongUid, + onCancel:onCancelRemoveAllByBundleOptionWrongBundleWrongUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2000_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2000_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1663,56 +1665,57 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2000_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2000_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2000_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2000_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2000 done==================>"); + }),1000); }) - function OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid(err, data) { - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveAllByBundleOptionNullCharacterBundleWrongUid(err, data) { + console.info("OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 start===================>"); + console.info("OnConsume_2100 data:======>" + JSON.stringify(data)); + console.info("OnConsume_2100 err:=====>" + JSON.stringify(err)); var bundleOption = { bundle:"", uid:123456789, } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_nullCharacterBundle_wrongUid); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 remove=======================>"); - console.info("================OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 end=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackNullCharacterBundleWrongUid); + console.info("OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 remove==============>"); + console.info("OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 end=================>"); } - function OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid(err, data) { - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveAllByBundleOptionNullCharacterBundleWrongUid(err, data) { + console.info("OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 start============>"); + console.info("OnCancel_2100 err:===========>" + JSON.stringify(err)); + console.info("OnCancel_2100 data:==========>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 end=======================>"); + console.info("OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2100 end=====================>"); } - function removeAllByBundleOptionCallBack_nullCharacterBundle_wrongUid(err, data) { - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2100 start=======================>"); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2100=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2100=======================>" + JSON.stringify(data)); + function removeAllByBundleOptionCallBackNullCharacterBundleWrongUid(err, data) { + console.info("removeAllByBundleOptionCallBack_nullCharacterBundle_wrongUid_2100 start====================>"); + console.info("CallBack_2100=========>" + JSON.stringify(err)); + console.info("CallBack_2100=========>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2100 end=======================>"); + console.info("removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2100 end=======================>"); } + /* * @tc.number: ANS_Remove_2100 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; deletes all notification information through BundleOption - null character bundle, wrong uid. + * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; + * deletes all notification information through BundleOption null character bundle, wrong uid. */ it('ANS_Remove_2100', 0, async function (done) { console.info("===============ANS_Remove_2100==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_nullCharacterBundle_wrongUid, - onCancel:OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid, + onConsume:onConsumeRemoveAllByBundleOptionNullCharacterBundleWrongUid, + onCancel:onCancelRemoveAllByBundleOptionNullCharacterBundleWrongUid, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1743,54 +1746,56 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2100_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2100 done==================>"); + }),1000); }) - function OnConsume_removeAllByBundleOption_isUnremovable(err, data) { - console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 start=======================>"); - console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveAllByBundleOptionIsUnremovable(err, data) { + console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 start==================>"); + console.info("================OnConsume_2200 data: ==================>" + JSON.stringify(data)); + console.info("================OnConsume_2200 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.bundle, uid:data.request.creatorUidss, } - notify.removeAll(bundleOption,removeAllByBundleOptionCallBack_isUnremovable); - console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 removeAll=======================>"); - console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 end=======================>"); + notify.removeAll(bundleOption,removeAllByBundleOptionCallBackIsUnremovable); + console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 removeAll==============>"); + console.info("================OnConsume_removeAllByBundleOption_isUnremovable_2200 end====================>"); } - function OnCancel_removeAllByBundleOption_isUnremovable(err, data) { - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2200 start=======================>"); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2200 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2200 data: =======================>" + JSON.stringify(data)); + function onCancelRemoveAllByBundleOptionIsUnremovable(err, data) { + console.info("================OnCancel_2200 start=======================>"); + console.info("================OnCancel_2200 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_2200 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeAllByBundleOption_nullCharacterBundle_wrongUid_2200 end=======================>"); + console.info("================OnCancel_2200 end=======================>"); } - function removeAllByBundleOptionCallBack_isUnremovable(err, data) { - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2200 start=======================>"); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2200=======================>" + JSON.stringify(err)); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2200=======================>" + JSON.stringify(data)); - console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2200 end=======================>"); + function removeAllByBundleOptionCallBackIsUnremovable(err, data) { + console.info("removeAllByBundleOptionCallBack_nullCharacterBundle_wrongUid_2200 start=====================>"); + console.info("================Callback_2200=======================>" + JSON.stringify(err)); + console.info("================Callback_2200=======================>" + JSON.stringify(data)); + console.info("================removeAllByBundleOptionCallBac_nullCharacterBundle_wrongUid_2200 end========>"); } + /* * @tc.number: ANS_Remove_2200 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * @tc.desc: Verify that the removeAll(bundle: BundleOption, callback: AsyncCallback):void interface is called to delete the notification information whose attribute isUnremovable is true + * @tc.desc: Verify that the removeAll(bundle: BundleOption, callback: AsyncCallback):void + interface is called to delete the notification information whose attribute isUnremovable is true */ it('ANS_Remove_2200', 0, async function (done) { console.info("===============ANS_Remove_2200==========================>"); var subscriber ={ - onConsume:OnConsume_removeAllByBundleOption_isUnremovable, - onCancel:OnCancel_removeAllByBundleOption_isUnremovable, + onConsume:onConsumeRemoveAllByBundleOptionIsUnremovable, + onCancel:onCancelRemoveAllByBundleOptionIsUnremovable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1821,12 +1826,14 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2200_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2200 done==================>"); + }),1000); done(); }) @@ -1836,47 +1843,50 @@ describe('ActsAnsNotificationRemove', function () { console.info("================removeAllCallBack_2300 data: =======================>" + JSON.stringify(data)); console.info("================removeAllCallBack_2300 end: =======================>"); } - var timesOfOnConsume_removeAll = 0 - function OnConsume_removeAll(err, data, ) { - timesOfOnConsume_removeAll = timesOfOnConsume_removeAll + 1 + var timesOfOnConsumeRemoveAll + function onConsumeRemoveAll(err, data, ) { + timesOfOnConsumeRemoveAll = timesOfOnConsumeRemoveAll + 1 console.info("================OnConsume_removeAll_2300 start=======================>"); console.info("================OnConsume_removeAll_2300 data: =======================>" + JSON.stringify(data)); - if (timesOfOnConsume_removeAll == 2) + if (timesOfOnConsumeRemoveAll == 2) { notify.removeAll(removeAllCallBack); console.info("================OnConsume_removeAll_2300 removeAll=======================>"); } console.info("================OnConsume_removeAll_2300 end=======================>"); } - var timesOfOnCancel_removeAll - function OnCancel_removeAll(err, data) { - timesOfOnCancel_removeAll = timesOfOnCancel_removeAll + 1 + var timesOfOnCancelRemoveAll + function onCancelRemoveAll(err, data) { + timesOfOnCancelRemoveAll = timesOfOnCancelRemoveAll + 1 console.info("==========================OnCancel_removeAll_2300=======================>"); console.info("================OnCancel_removeAll_2300 data : =======================>" + JSON.stringify(data)); - if (timesOfOnCancel_removeAll == 1) + if (timesOfOnCancelRemoveAll == 1) { expect(data.request.label).assertequal("2300_1"); } - if (timesOfOnCancel_removeAll == 2) + if (timesOfOnCancelRemoveAll == 2) { expect(data.request.label).assertequal("2300_2"); } console.info("================cancelCallback_removeAll_0200 end=======================>"); } + /* * @tc.number: ANS_Remove_2300 * @tc.name: removeAll(callback: AsyncCallback): void; - * @tc.desc: Verify that the removeAll(callback: AsyncCallback): void interface is called to delete the notification information + * @tc.desc: Verify that the removeAll(callback: AsyncCallback): void interface is called to delete the + * notification information */ it('ANS_Remove_2300', 0, async function (done) { console.info("===============ANS_Remove_2300==========================>"); + timesOfOnConsumeRemoveAll = 0; + timesOfOnCancelRemoveAll = 0; var subscriber ={ - onConsume:OnConsume_removeAll, - onCancel:OnCancel_removeAll, + onConsume:onConsumeRemoveAll, + onCancel:onCancelRemoveAll, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -1937,64 +1947,62 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_2300_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_2300_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2300_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish1_2300_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_2300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2300_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2300 done==================>"); + }),1000); }) - var timesOfOnConsume_removeAll = 0 - function OnConsume_removeAll_promise(err, data) { - timesOfOnConsume_removeAll = timesOfOnConsume_removeAll + 1 + var timesOfOnConsumeRemoveAll + function onConsumeRemoveAllPromise(err, data) { + timesOfOnConsumeRemoveAll = timesOfOnConsumeRemoveAll + 1 console.info("================OnConsume_removeAll_promise_2400 start=======================>"); - console.info("================OnConsume_removeAll_promise_2400 data: =======================>" + JSON.stringify(data)); - if (timesOfOnConsume_removeAll == 2) + console.info("================OnConsume_removeAll_promise_2400 data: =============>" + JSON.stringify(data)); + if (timesOfOnConsumeRemoveAll == 2) { - notify.removeAll().then((err, data) => { - console.info("================removeAll_promise_2400 start=======================>"); - console.info("================removeAll_promise_2400 data: =======================>" + JSON.stringify(data)); - console.info("================removeAll_promise_2400 err: =======================>" + JSON.stringify(err)); - console.info("================removeAll_promise_2400 end=======================>"); - }); + notify.removeAll(); console.info("================OnConsume_removeAll_promise_2400 removeAll=======================>"); } console.info("================OnConsume_removeAll_promise_2400 end=======================>"); } - var timesOfOnCancel_removeAll - function OnCancel_removeAll_promise(err, data) { - timesOfOnCancel_removeAll = timesOfOnCancel_removeAll + 1 + var timesOfOnCancelRemoveAll + function onCancelRemoveAllPromise(err, data) { + timesOfOnCancelRemoveAll = timesOfOnCancelRemoveAll + 1 console.info("==========================OnCancel_removeAll_promise_2400 start=======================>"); - console.info("================OnCancel_removeAll_promise_2400 data : =======================>" + JSON.stringify(data)); - if (timesOfOnCancel_removeAll == 1) + console.info("================OnCancel_removeAll_promise_2400 data : =============>" + JSON.stringify(data)); + if (timesOfOnCancelRemoveAll == 1) { expect(data.request.label).assertequal("2400_1"); } - if (timesOfOnCancel_removeAll == 2) + if (timesOfOnCancelRemoveAll == 2) { expect(data.request.label).assertequal("2400_2"); } console.info("================OnCancel_removeAll_promise_2400 end=======================>"); } + /* * @tc.number: ANS_Remove_2400 * @tc.name: removeAll(bundle?: BundleOption): Promise - * @tc.desc: Verify that the removeAll(bundle?: BundleOption): Promise interface is called to delete the notification information + * @tc.desc: Verify that the removeAll(bundle?: BundleOption): Promise interface is called to delete the + * notification information */ it('ANS_Remove_2400', 0, async function (done) { console.info("===============ANS_Remove_2400==========================>"); + timesOfOnConsumeRemoveAll = 0 + timesOfOnCancelRemoveAll = 0 var subscriber ={ - onConsume:OnConsume_removeAll, - onCancel:OnCancel_removeAll, + onConsume:onConsumeRemoveAllPromise, + onCancel:onCancelRemoveAllPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2055,51 +2063,52 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish1_2400_promise==================>"); - }); - await notify.publish(notificationRequest1).then(() => { - console.info("==================publish2_2400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish1_2400_promise==================>"); + await notify.publish(notificationRequest1); + console.info("==================publish2_2400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2400_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2400 done==================>"); + }),1000); }) - function removeAllCallBack_isUnremovable(err,data) { + function removeAllCallBackIsUnremovable(err,data) { console.info("================removeAllCallBack_isUnremovable_2500 start=======================>"); - console.info("================removeAllCallBack_isUnremovable_2500 JSON.stringify(err): =======================>" + JSON.stringify(err)); - console.info("================removeAllCallBack_isUnremovable_2500 JSON.stringify(data): =======================>" + JSON.stringify(data)); + console.info("================removeAllCallBack_2500 JSON.stringify(err): ===========>" + JSON.stringify(err)); + console.info("================removeAllCallBack_2500 JSON.stringify(data): =========>" + JSON.stringify(data)); console.info("================removeAllCallBack_isUnremovable_2500 end=======================>"); } - function OnConsume_removeAll_isUnremovable(err, data) { + function onConsumeRemoveAllIsUnremovable(err, data) { console.info("================OnConsume_removeAll_isUnremovable_2500 start=======================>"); - console.info("================OnConsume_removeAll_isUnremovable_2500 data: =======================>" + JSON.stringify(data)); - notify.removeAll(removeAllCallBack_isUnremovable); + console.info("================OnConsume_2500 data: =======================>" + JSON.stringify(data)); + notify.removeAll(removeAllCallBackIsUnremovable); console.info("================removeAll_isUnremovable_2500 =======================>"); console.info("================OnConsume_removeAll_isUnremovable_2500 end=======================>"); } - function OnCancelCallback_removeAll_isUnremovable(err, data) { + function onCancelCallbackRemoveAllIsUnremovable(err, data) { console.info("================OnCancelCallback_removeAll_isUnremovable_2500 start=======================>"); - console.info("================OnCancelCallback_removeAll_isUnremovable_2500 err : =======================>" + JSON.stringify(err)); - console.info("================OnCancelCallback_removeAll_isUnremovable_2500 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_2500 err : =======================>" + JSON.stringify(err)); + console.info("================OnCancelCallback_2500 data : =======================>" + JSON.stringify(data)); console.info("================OnCancelCallback_removeAll_isUnremovable_2500 end=======================>"); } + /* * @tc.number: ANS_Remove_2500 * @tc.name: removeAll(callback: AsyncCallback): void; - * @tc.desc: Verify that the removeAll(callback: AsyncCallback): void interface is called to delete the notification information whose attribute isUnremovable is true + * @tc.desc: Verify that the removeAll(callback: AsyncCallback): void interface is called to delete the + * notification information whose attribute isUnremovable is true */ it('ANS_Remove_2500', 0, async function (done) { console.info("===============ANS_Remove_2500==========================>"); var subscriber ={ - onConsume:OnConsume_removeAll_isUnremovable, - onCancel:OnCancelCallback_removeAll_isUnremovable, + onConsume:onConsumeRemoveAllIsUnremovable, + onCancel:onCancelCallbackRemoveAllIsUnremovable, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2130,48 +2139,45 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2500 done==================>"); + }),1000); }) - function OnConsume_removeAll_isUnremovable_promise(err, data) { + function OnConsumeRemoveAllIsUnremovablePromise(err, data) { console.info("================OnConsume_removeAll_isUnremovable_promise_2600 start=======================>"); - console.info("================OnConsume_removeAll_isUnremovable_promise_2600 data=======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeAll_isUnremovable_promise_2600 err=======================>" + JSON.stringify(err)); - notify.removeAll().then((err, data) => { - console.info("================removeAll_isUnremovable_2600 start=======================>"); - console.info("================removeAll_isUnremovable_2600 data: =======================>" + JSON.stringify(data)); - console.info("================removeAll_isUnremovable_2600 err: =======================>" + JSON.stringify(err)); - console.info("================removeAll_isUnremovable_2600 end=======================>"); - }); - console.info("================OnConsume_removeAll_isUnremovable_promise_2600=======================>"); + console.info("================OnConsume_2600 data=======================>" + JSON.stringify(data)); + console.info("================OnConsume_2600 err=======================>" + JSON.stringify(err)); + notify.removeAll() + console.info("================removeAll_isUnremovable_2600 end=======================>"); console.info("================OnConsume_removeAll_isUnremovable_promise_2600 end=======================>"); } - function OnCancelCallback_removeAll_isUnremovable_promise(err, data) { - console.info("================OnCancelCallback_removeAll_isUnremovable_promise_2600 start=======================>"); - console.info("================OnCancelCallback_removeAll_isUnremovable_promise_2600 err : =======================>" + JSON.stringify(err)); - console.info("================OnCancelCallback_removeAll_isUnremovable_promise_2600 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeAll_isUnremovable_promise_2600 end=======================>"); + function OnCancelCallbackRemoveAllIsUnremovablePromise(err, data) { + console.info("================OnCancelCallback_removeAll_isUnremovable_promise_2600 start================>"); + console.info("================OnCancelCallback_2600 err : =======================>" + JSON.stringify(err)); + console.info("================OnCancelCallback_2600 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_2600 end=======================>"); } + /* * @tc.number: ANS_Remove_2600 * @tc.name: removeAll(bundle?: BundleOption): Promise; - * @tc.desc: Verify that the removeAll(bundle?: BundleOption): Promise interface is called to delete the notification information whose attribute isUnremovable is true + * @tc.desc: Verify that the removeAll(bundle?: BundleOption): Promise interface is called to delete the + * notification information whose attribute isUnremovable is true */ it('ANS_Remove_2600', 0, async function (done) { console.info("===============ANS_Remove_2600==========================>"); var subscriber ={ - onConsume:OnConsume_removeAll_isUnremovable_promise, - onCancel:OnCancelCallback_removeAll_isUnremovable_promise, + onConsume:OnConsumeRemoveAllIsUnremovablePromise, + onCancel:OnCancelCallbackRemoveAllIsUnremovablePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2202,66 +2208,68 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2600_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2600 done==================>"); + }),1000); }) function removeAllCallBack2TimesOf2(err,data) { console.info("================removeAllCallBack2TimesOf2_2700 start=======================>"); - console.info("================removeAllCallBack2TimesOf2_2700 err=======================>" + JSON.stringify(err)); - console.info("================removeAllCallBack2TimesOf2_2700 data=======================>" + JSON.stringify(data)); + console.info("================removeAllCallBack2TimesOf2_2700 err=================>" + JSON.stringify(err)); + console.info("================removeAllCallBack2TimesOf2_2700 data===============>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); console.info("================removeAllCallBack2TimesOf2_2700 end=======================>"); } function removeAllCallBack2TimesOf1(err,data) { console.info("================removeAllCallBack2TimesOf1_2700 start=======================>"); - console.info("================removeAllCallBack2TimesOf1_2700 err=======================>" + JSON.stringify(err)); - console.info("================removeAllCallBack2TimesOf1_2700 data=======================>" + JSON.stringify(data)); + console.info("================removeAllCallBack2TimesOf1_2700 err===================>" + JSON.stringify(err)); + console.info("================removeAllCallBack2TimesOf1_2700 data=================>" + JSON.stringify(data)); expect(err.code).assertequal(0); notify.removeAll(removeCallBack2TimesOf2); - console.info("================removeAllCallBack2TimesOf1_2700 removeCallBack2TimesOf2=======================>"); + console.info("================removeAllCallBack2TimesOf1_2700 removeCallBack2TimesOf2====================>"); console.info("================removeAllCallBack2TimesOf1_2700 end=======================>"); } - function OnConsumeCallback_removeAll2Times(err, data) { + function onConsumeRemoveAll2Times(err, data) { console.info("================OnConsumeCallback_removeAll2Times_2700 start=======================>"); - console.info("================OnConsumeCallback_removeAll2Times_2700 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsumeCallback_removeAll2Times_2700 data: ========>" + JSON.stringify(data)); notify.removeAll(removeCallBack2TimesOf1); console.info("================OnConsumeCallback_removeAll2Times_2700 remove=======================>"); console.info("================OnConsumeCallback_removeAll2Times_2700 end=======================>"); } - var timesOfOnCancelCallback_removeAll2Times - function OnCancelCallback_removeAll2Times(err, data) { - timesOfOnCancelCallback_removeAll2Times = timesOfOnCancelCallback_removeAll2Times + 1 + var timesOfOnCancelCallbackRemoveAll2Times + function onCancelRemoveAll2Times(err, data) { + timesOfOnCancelCallbackRemoveAll2Times = timesOfOnCancelCallbackRemoveAll2Times + 1 console.info("================OnCancelCallback_removeAll2Times_2700 start=======================>"); - console.info("================OnCancelCallback_removeAll2Times_2700 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeAll2Times_2700 err : =======================>" + JSON.stringify(err)); - if (timesOfOnCancelCallback_removeAll2Times == 1){ + console.info("================OnCancelCallback_2700 data : =======================>" + JSON.stringify(data)); + console.info("================OnCancelCallback_2700 err : =======================>" + JSON.stringify(err)); + if (timesOfOnCancelCallbackRemoveAll2Times == 1){ expect(data.request.id).assertequal(1); - } else if (timesOfOnCancelCallback_removeAll2Times == 2){ + } else if (timesOfOnCancelCallbackRemoveAll2Times == 2){ expect().assertFail(); } console.info("================OnCancelCallback_removeAll2Times_2700 end=======================>"); } + /* * @tc.number: ANS_Remove_2700 * @tc.name: remove(hashCode: string, callback: AsyncCallback): void; - * @tc.desc: Verify that the interface remove(hashCode: string, callback: AsyncCallback): void; is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface remove(hashCode: string, callback: AsyncCallback): void; is called + * twice in a row to delete the notification information */ it('ANS_Remove_2700', 0, async function (done) { console.info("===============ANS_Remove_2700==========================>"); - timesOfOnCancelCallback_removeAll2Times = 0 + timesOfOnCancelCallbackRemoveAll2Times = 0 var subscriber ={ - onConsume:OnConsumeCallback_removeAll2Times, - onCancel:OnCancelCallback_removeAll2Times, + onConsume:onConsumeRemoveAll2Times, + onCancel:onCancelRemoveAll2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2700_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2700_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2292,63 +2300,55 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2700_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2700_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2700_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2700_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2700 done==================>"); + }),1000); }) - function OnConsumeCallback_removeAll2Times_promise(err, data) { + function onConsumeCallbackRemoveAll2TimesPromise(err, data) { console.info("================OnConsumeCallback_removeAll2Times_promise_2800 start=======================>"); - console.info("================OnConsumeCallback_removeAll2Times_promise_2800 data: =======================>" + JSON.stringify(data)); - notify.removeAll().then((err, data) => { - console.info("================removeAll_2times1_2800 start=======================>"); - console.info("================removeAll_2times1_2800 data: =======================>" + JSON.stringify(data)); - console.info("================removeAll_2times1_2800 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertequal(0); - notify.removeAll().then((err, data) => { - console.info("================removeAll_2times2_2800 start=======================>"); - console.info("================removeAll_2times2_2800 data: =======================>" + JSON.stringify(data)); - console.info("================removeAll_2times2_2800 err: =======================>" + JSON.stringify(err)); - expect(err.code).assertNotEqual(0); - console.info("================removeAll_2times2_2800 end=======================>"); - }); - console.info("================removeAll_2times1_2800 end=======================>"); - }); + console.info("================OnConsumeCallback_2800 data: =======================>" + JSON.stringify(data)); + notify.removeAll() + console.info("================removeAll_2times2_2800 end=======================>"); + notify.removeAll() + console.info("================removeAll_2times2_2800 end=======================>"); console.info("================OnConsumeCallback_removeAll2Times_promise_2800 remove=======================>"); console.info("================OnConsumeCallback_removeAll2Times_promise_2800 end=======================>"); } - var timesOfOnCancelCallback_removeAll2Times_promise - function OnCancelCallback_removeAll2Times_promise(err, data) { - timesOfOnCancelCallback_removeAll2Times_promise = timesOfOnCancelCallback_removeAll2Times_promise + 1 + var timesOfOnCancelCallbackRemoveAll2TimesPromise + function onCancelCallbackRemoveAll2TimesPromise(err, data) { + timesOfOnCancelCallbackRemoveAll2TimesPromise = timesOfOnCancelCallbackRemoveAll2TimesPromise + 1 console.info("==========================OnCancelCallback_removeAll2Times_2800 start=======================>"); - console.info("================OnCancelCallback_removeAll2Times_2800 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeAll2Times_2800 err : =======================>" + JSON.stringify(err)); - if (timesOfOnCancelCallback_removeAll2Times_promise == 1){ + console.info("================OnCancelCallback_removeAll2Times_2800 data : ========>" + JSON.stringify(data)); + console.info("================OnCancelCallback_removeAll2Times_2800 err : ==========>" + JSON.stringify(err)); + if (timesOfOnCancelCallbackRemoveAll2TimesPromise == 1){ expect(data.request.id).assertequal(1); - } else if (timesOfOnCancelCallback_removeAll2Times_promise == 2){ + } else if (timesOfOnCancelCallbackRemoveAll2TimesPromise == 2){ expect().assertFail(); } console.info("================OnCancelCallback_removeAll2Times_2800 end=======================>"); } + /* * @tc.number: ANS_Remove_2800 * @tc.name: removeAll(bundle?: BundleOption): Promise; - * @tc.desc: Verify that the interface removeAll(bundle?: BundleOption): Promise; is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface removeAll(bundle?: BundleOption): Promise; is called twice in a row + * to delete the notification information */ it('ANS_Remove_2800', 0, async function (done) { console.info("===============ANS_Remove_2800==========================>"); - timesOfOnCancelCallback_removeAll2Times_promise = 0 + timesOfOnCancelCallbackRemoveAll2TimesPromise = 0 var subscriber ={ - onConsume:OnConsumeCallback_removeAll2Times_promise, - onCancel:OnCancelCallback_removeAll2Times_promise, + onConsume:onConsumeCallbackRemoveAll2TimesPromise, + onCancel:onCancelCallbackRemoveAll2TimesPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2800_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2800_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2379,23 +2379,24 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2800_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2800_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2800_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2800_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2800 done==================>"); + }),1000); }) - function OnConsume_removeByNotificationKey(err, data) { + function onConsumeRemoveByNotificationKey(err, data) { console.info("================OnConsume_removeByNotificationKey_2900 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_2900 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_2900 err: =======================>" + JSON.stringify(err)); - console.info("================OnConsume_removeByNotificationKey_2900 creatorBundleName: =======================>" + data.request.creatorBundleName); - console.info("================OnConsume_removeByNotificationKey_2900 creatorUid: =======================>" + data.request.creatorUid); - console.info("================OnConsume_removeByNotificationKey_2900 id: =======================>" + data.request.id); - console.info("================OnConsume_removeByNotificationKey_2900 label: =======================>" + data.request.label); + console.info("================OnConsume_2900 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_2900 err: =======================>" + JSON.stringify(err)); + console.info("OnConsume_2900 creatorBundleName: =======================>" + data.request.creatorBundleName); + console.info("================OnConsume_2900 creatorUid: =======================>" + data.request.creatorUid); + console.info("================OnConsume_2900 id: =======================>" + data.request.id); + console.info("================OnConsume_2900 label: =======================>" + data.request.label); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -2408,10 +2409,10 @@ describe('ActsAnsNotificationRemove', function () { console.info("================OnConsume_removeByNotificationKey_2900 remove=======================>"); console.info("================OnConsume_removeByNotificationKey_2900 end=======================>"); } - function OnCancel_removeByNotificationKey(err, data) { + function onCancelRemoveByNotificationKey(err, data) { console.info("================OnCancel_removeByNotificationKey_2900 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_2900 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_2900 data: =======================>" + JSON.stringify(data)); + console.info("================OnCancel_removeByNotificationKey_2900 err: ===========>" + JSON.stringify(err)); + console.info("================OnCancel_removeByNotificationKey_2900 data: ==========>" + JSON.stringify(data)); expect(data.request.label).assertequal("2900"); expect(data.request.id).assertequal(29); console.info("================OnCancel_removeByNotificationKey_2900 end=======================>"); @@ -2422,20 +2423,22 @@ describe('ActsAnsNotificationRemove', function () { console.info("================removeByNotificationKeyCB_2900=======================>" + JSON.stringify(data)); console.info("================removeByNotificationKeyCB_2900 end=======================>"); } + /* * @tc.number: ANS_Remove_2900 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; deletes notification information through BundleOption and NotificationKey + * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, + * callback: AsyncCallback): void; deletes notification information through BundleOption and + * NotificationKey */ it('ANS_Remove_2900', 0, async function (done) { console.info("===============ANS_Remove_2900==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey, - onCancel:OnCancel_removeByNotificationKey, + onConsume:onConsumeRemoveByNotificationKey, + onCancel:onCancelRemoveByNotificationKey, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_2900_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_2900_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2466,19 +2469,20 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_2900_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_2900_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_2900_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_2900_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_2900 done==================>"); + }),1000); }) - function OnConsume_removeByNotificationKey_promise(err, data) { + function onConsumeRemoveByNotificationKeyPromise(err, data) { console.info("================OnConsume_removeByNotificationKey_promise_3000 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_promise_3000 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_promise_3000 err: =======================>" + JSON.stringify(err)); + console.info("================OnConsume_3000 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3000 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -2487,37 +2491,34 @@ describe('ActsAnsNotificationRemove', function () { id:30, label:"3000" } - notify.remove(bundleOption,notificationKey).then((err, data) => { - console.info("================removeByNotificationKey_promise_3000 start=======================>"); - console.info("================removeByNotificationKey_promise_3000 data: =======================>" + JSON.stringify(data)); - console.info("================removeByNotificationKey_promise_3000 err: =======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey_promise_3000 end=======================>"); - }); + notify.remove(bundleOption,notificationKey) console.info("================OnConsume_removeByNotificationKey_promise_3000 remove=======================>"); console.info("================OnConsume_removeByNotificationKey_promise_3000 end=======================>"); } - function OnCancel_removeByNotificationKey_promise(err, data) { + function onCancelRemoveByNotificationKeyPromise(err, data) { console.info("================OnCancel_removeByNotificationKey_promise_3000 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_promise_3000 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_promise_3000 data: =======================>" + JSON.stringify(data)); + console.info("================OnCancel_3000 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_3000 data: =======================>" + JSON.stringify(data)); expect(data.request.label).assertequal("3000"); expect(data.request.id).assertequal(30); console.info("================OnCancel_removeByNotificationKey_promise_3000 end=======================>"); } + /* * @tc.number: ANS_Remove_3000 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey): Promise; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey): Promise deletes notification information through BundleOption and NotificationKey + * @tc.desc: Verify that the calling interface + remove(bundle: BundleOption, notificationKey: NotificationKey): Promise + deletes notification information through BundleOption and NotificationKey */ it('ANS_Remove_3000', 0, async function (done) { console.info("===============ANS_Remove_3000==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey_promise, - onCancel:OnCancel_removeByNotificationKey_promise, + onConsume:onConsumeRemoveByNotificationKeyPromise, + onCancel:onCancelRemoveByNotificationKeyPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3000_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3000_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2548,19 +2549,20 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3000_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3000_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3000_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3000_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3000 done==================>"); + }),1000); }) - function OnConsume_removeByNotificationKey_wrongKey(err, data) { + function onConsumeRemoveByNotificationKeyWrongKey(err, data) { console.info("================OnConsume_removeByNotificationKey_wrongKey_3100 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_wrongKey_3100 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_wrongKey_3100 err: =======================>" + JSON.stringify(err)); + console.info("================OnConsume_3100 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3100 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -2569,39 +2571,40 @@ describe('ActsAnsNotificationRemove', function () { id:0, label:"wrongLabel" } - notify.remove(bundleOption,notificationKey,removeByNotificationKeyCB_wrongKey); + notify.remove(bundleOption,notificationKey,removeByNotificationKeyCBWrongKey); console.info("================OnConsume_removeByNotificationKey_wrongKey_3100 remove=======================>"); console.info("================OnConsume_removeByNotificationKey_wrongKey_3100 end=======================>"); } - function OnCancel_removeByNotificationKey_wrongKey(err, data) { + function onCancelRemoveByNotificationKeyWrongKey(err, data) { console.info("================OnCancel_removeByNotificationKey_wrongKey_3100 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_wrongKey_3100 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_wrongKey_3100 data: =======================>" + JSON.stringify(data)); + console.info("================OnCancel_3100 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_3100 data: =======================>" + JSON.stringify(data)); expect().assertFail(); console.info("================OnCancel_removeByNotificationKey_wrongKey_3100 end=======================>"); } - function removeByNotificationKeyCB_wrongKey(err, data) { + function removeByNotificationKeyCBWrongKey(err, data) { console.info("================removeByNotificationKeyCB_3100 start=======================>"); console.info("================removeByNotificationKeyCB_3100=======================>" + JSON.stringify(err)); expect(err.code).assertNotEqual(0); console.info("================removeByNotificationKeyCB_3100=======================>" + JSON.stringify(data)); console.info("================removeByNotificationKeyCB_3100 end=======================>"); } + /* * @tc.number: ANS_Remove_3100 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; deletes notification information through BundleOption and NotificationKey - correct bundleOption,wrong notificationKey. + * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, + * callback: AsyncCallback): void; deletes notification information through BundleOption and + * NotificationKey correct bundleOption,wrong notificationKey. */ it('ANS_Remove_3100', 0, async function (done) { console.info("===============ANS_Remove_3100==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey_wrongKey, - onCancel:OnCancel_removeByNotificationKey_wrongKey, + onConsume:onConsumeRemoveByNotificationKeyWrongKey, + onCancel:onCancelRemoveByNotificationKeyWrongKey, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3100_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3100_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2632,19 +2635,20 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3100_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3100_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3100_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3100_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3100 done==================>"); + }),1000); }) - function OnConsume_removeByNotificationKey_wrongKey_promise(err, data) { - console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveByNotificationKeyWrongKeyPromise(err, data) { + console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 start===============>"); + console.info("================OnConsume_3200 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3200 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -2653,36 +2657,33 @@ describe('ActsAnsNotificationRemove', function () { id:0, label:"wrongLabel" } - notify.remove(bundleOption, notificationKey).then((err, data) => { - console.info("================removeByNotificationKey_wrongKey_promise_3200 start=======================>"); - console.info("================removeByNotificationKey_wrongKey_promise_3200 data: =======================>" + JSON.stringify(data)); - console.info("================removeByNotificationKey_wrongKey_promise_3200 err: =======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey_wrongKey_promise_3200 end=======================>"); - }); - console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 end=======================>"); - } - function OnCancel_removeByNotificationKey_wrongKey_promise(err, data) { - console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 data: =======================>" + JSON.stringify(data)); + notify.remove(bundleOption, notificationKey); + console.info("================removeByNotificationKey_wrongKey_promise_3200 end=======================>"); + console.info("================OnConsume_removeByNotificationKey_wrongKey_promise_3200 end==================>"); + } + function onCancelRemoveByNotificationKeyWrongKeyPromise(err, data) { + console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 start=================>"); + console.info("================OnCancel_3200 err: =====================>" + JSON.stringify(err)); + console.info("================OnCancel_3200 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 end=======================>"); + console.info("================OnCancel_removeByNotificationKey_wrongKey_promise_3200 end===================>"); } + /* * @tc.number: ANS_Remove_3200 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey): Promise deletes notification information through BundleOption and NotificationKey - correct bundleOption,wrong notificationKey. + * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey): + * Promise deletes notification information through BundleOption and NotificationKey correct + * bundleOption,wrong notificationKey. */ it('ANS_Remove_3200', 0, async function (done) { console.info("===============ANS_Remove_3200==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey_wrongKey_promise, - onCancel:OnCancel_removeByNotificationKey_wrongKey_promise, + onConsume:onConsumeRemoveByNotificationKeyWrongKeyPromise, + onCancel:onCancelRemoveByNotificationKeyWrongKeyPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3200_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3200_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2713,19 +2714,21 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3200_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3200_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3200_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3200_promise==================>"); + done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3200 done==================>"); + }),1000); done(); }) - function OnConsume_removeByNotificationKey_wrongBundle(err, data) { - console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 err: =======================>" + JSON.stringify(err)); + function OnConsumeRemoveByNotificationKeyWrongBundle(err, data) { + console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 start==================>"); + console.info("================OnConsume_3300 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3300 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:"wrongBundleName", uid:0, @@ -2734,39 +2737,40 @@ describe('ActsAnsNotificationRemove', function () { id:33, label:"3300" } - notify.remove(bundleOption,notificationKey,removeByNotificationKeyCB_wrongKey); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 remove=======================>"); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 end=======================>"); + notify.remove(bundleOption,notificationKey,removeByNotificationKeyCBWrongBundle); + console.info("================OnConsume_3300 remove=======================>"); + console.info("================OnConsume_removeByNotificationKey_wrongBundle_3300 end=====================>"); } - function OnCancel_removeByNotificationKey_wrongBundle(err, data) { - console.info("================OnCancel_removeByNotificationKey_wrongBundle_3300 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_3300 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_3300 data: =======================>" + JSON.stringify(data)); + function OnCancelRemoveByNotificationKeyWrongBundle(err, data) { + console.info("OnCancel_removeByNotificationKey_wrongBundle_3300 start==========>"); + console.info("OnCancel_removeByNotificationKey_wrongBundle_3300 err:============>" + JSON.stringify(err)); + console.info("OnCancel_removeByNotificationKey_wrongBundle_3300 data:===========>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_3300 end=======================>"); + console.info("================OnCancel_removeByNotificationKey_wrongBundle_3300 end======================>"); } - function removeByNotificationKeyCB_wrongBundle(err, data) { + function removeByNotificationKeyCBWrongBundle(err, data) { console.info("================removeByNotificationKeyCB_wrongBundle_3300 start=======================>"); - console.info("================removeByNotificationKeyCB_wrongBundle_3300=======================>" + JSON.stringify(err)); + console.info("removeByNotificationKeyCB_wrongBundle_3300=======================>" + JSON.stringify(err)); expect(err.code).assertNotEqual(0); - console.info("================removeByNotificationKeyCB_wrongBundle_3300=======================>" + JSON.stringify(data)); + console.info("removeByNotificationKeyCB_wrongBundle_3300=======================>" + JSON.stringify(data)); console.info("================removeByNotificationKeyCB_wrongBundle_3300 end=======================>"); } + /* * @tc.number: ANS_Remove_3300 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; deletes notification information through BundleOption and NotificationKey - wrong bundleOption,correct notificationKey. + * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey, + * callback: AsyncCallback): void; deletes notification information through BundleOption and + * NotificationKey wrong bundleOption,correct notificationKey. */ it('ANS_Remove_3300', 0, async function (done) { console.info("===============ANS_Remove_3300==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey_wrongBundle, - onCancel:OnCancel_removeByNotificationKey_wrongBundle, + onConsume:OnConsumeRemoveByNotificationKeyWrongBundle, + onCancel:OnCancelRemoveByNotificationKeyWrongBundle, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3300_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3300_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2797,19 +2801,20 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3300_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3300_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3300_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3300_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3300 done==================>"); + }),1000); }) - function OnConsume_removeByNotificationKey_wrongBundle_promise(err, data) { - console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 start=======================>"); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 data: =======================>" + JSON.stringify(data)); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 err: =======================>" + JSON.stringify(err)); + function onConsumeRemoveByNotificationKeyWrongBundlePromise(err, data) { + console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 start============>"); + console.info("================OnConsume_3400 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3400 err: =======================>" + JSON.stringify(err)); var bundleOption = { bundle:"wrongBundleName", uid:0, @@ -2818,36 +2823,33 @@ describe('ActsAnsNotificationRemove', function () { id:34, label:"3400" } - notify.remove(bundleOption, notificationKey).then((err, data) => { - console.info("================removeByNotificationKey_wrongBundle_promise_3400 start=======================>"); - console.info("================removeByNotificationKey_wrongBundle_promise_3400 data: =======================>" + JSON.stringify(data)); - console.info("================removeByNotificationKey_wrongBundle_promise_3400 err: =======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey_wrongBundle_promise_3400 end=======================>"); - }); - console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 end=======================>"); - } - function OnCancel_removeByNotificationKey_wrongBundle_promise(err, data) { - console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 start=======================>"); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 err: =======================>" + JSON.stringify(err)); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 data: =======================>" + JSON.stringify(data)); + notify.remove(bundleOption, notificationKey) + console.info("================removeByNotificationKey_wrongBundle_promise_3400 end=====================>"); + console.info("================OnConsume_removeByNotificationKey_wrongBundle_promise_3400 end==============>"); + } + function onCancelRemoveByNotificationKeyWrongBundlePromise(err, data) { + console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 start=============>"); + console.info("================OnCancel_3400 err: =======================>" + JSON.stringify(err)); + console.info("================OnCancel_3400 data: =======================>" + JSON.stringify(data)); expect().assertFail(); - console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 end=======================>"); + console.info("================OnCancel_removeByNotificationKey_wrongBundle_promise_3400 end================>"); } + /* * @tc.number: ANS_Remove_3400 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey): Promise deletes notification information through BundleOption and NotificationKey - correct bundleOption,wrong notificationKey. + * @tc.desc: Verify that the calling interface remove(bundle: BundleOption, notificationKey: NotificationKey): + * Promise deletes notification information through BundleOption and NotificationKey correct + * bundleOption,wrong notificationKey. */ it('ANS_Remove_3400', 0, async function (done) { console.info("===============ANS_Remove_3400==========================>"); var subscriber ={ - onConsume:OnConsume_removeByNotificationKey_wrongBundle_promise, - onCancel:OnCancel_removeByNotificationKey_wrongBundle_promise, + onConsume:onConsumeRemoveByNotificationKeyWrongBundlePromise, + onCancel:onCancelRemoveByNotificationKeyWrongBundlePromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3400_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3400_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2878,26 +2880,27 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3400_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3400_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3400_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3400_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3400 done==================>"); + }),1000); }) function removeByNotificationKey2Times2CB(err,data) { console.info("================removeByNotificationKey2Times2CB_3500 start=======================>"); - console.info("================removeByNotificationKey2Times2CB_3500 err=======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey2Times2CB_3500 data=======================>" + JSON.stringify(data)); + console.info("================removeByNotificationKey2Times2CB_3500 err==============>" + JSON.stringify(err)); + console.info("================removeByNotificationKey2Times2CB_3500 data============>" + JSON.stringify(data)); expect(err.code).assertNotEqual(0); console.info("================removeByNotificationKey2Times2CB_3500 end=======================>"); } function removeByNotificationKey2Times1CB(err,data) { console.info("================removeByNotificationKey2Times1CB_3500 start=======================>"); - console.info("================removeByNotificationKey2Times1CB_3500 err=======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey2Times1CB_3500 data=======================>" + JSON.stringify(data)); + console.info("================removeByNotificationKey2Times1CB_3500 err==============>" + JSON.stringify(err)); + console.info("================removeByNotificationKey2Times1CB_3500 data============>" + JSON.stringify(data)); expect(err.code).assertequal(0); var bundleOption = { bundle:data.request.creatorBundleName, @@ -2908,12 +2911,12 @@ describe('ActsAnsNotificationRemove', function () { label:"3500" } notify.remove(bundleOption,notificationKey,removeByNotificationKey2Times2CB); - console.info("================removeByNotificationKey2Times1CB_3500 removeCallBack2TimesOf2=======================>"); + console.info("================removeByNotificationKey2Times1CB_3500 removeCallBack2TimesOf2===============>"); console.info("================removeByNotificationKey2Times1CB_3500 end=======================>"); } - function OnConsume_removeByNotificationKey2Times(err, data) { + function onConsumeRemoveByNotificationKey2Times(err, data) { console.info("================OnConsume_removeByNotificationKey2Times_3500 start=======================>"); - console.info("================OnConsume_removeByNotificationKey2Times_3500 data: =======================>" + JSON.stringify(data)); + console.info("================OnConsume_3500 data: ========>" + JSON.stringify(data)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -2926,35 +2929,36 @@ describe('ActsAnsNotificationRemove', function () { console.info("================OnConsume_removeByNotificationKey2Times_3500 remove=======================>"); console.info("================OnConsume_removeByNotificationKey2Times_3500 end=======================>"); } - var timesOfOnCancel__removeByNotificationKey2Times - function OnCancel_removeByNotificationKey2Times(err, data) { - timesOfOnCancel__removeByNotificationKey2Times = timesOfOnCancel__removeByNotificationKey2Times + 1 + var timesOfOnCancelRemoveByNotificationKey2Times + function onCancelRemoveByNotificationKey2Times(err, data) { + timesOfOnCancelRemoveByNotificationKey2Times = timesOfOnCancelRemoveByNotificationKey2Times + 1 console.info("================OnCancelCallback_removeAll2Times_2700 start=======================>"); - console.info("================OnCancelCallback_removeAll2Times_2700 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeAll2Times_2700 err : =======================>" + JSON.stringify(err)); - if (timesOfOnCancel__removeByNotificationKey2Times == 1){ + console.info("================OnCancelCallback_removeAll2Times_2700 data : ========>" + JSON.stringify(data)); + console.info("================OnCancelCallback_removeAll2Times_2700 err : =======>" + JSON.stringify(err)); + if (timesOfOnCancelRemoveByNotificationKey2Times == 1){ expect(data.request.id).assertequal(35); expect(data.request.label).assertequal("3500"); - } else if (timesOfOnCancel__removeByNotificationKey2Times == 2){ + } else if (timesOfOnCancelRemoveByNotificationKey2Times == 2){ expect().assertFail(); } console.info("================OnCancelCallback_removeAll2Times_2700 end=======================>"); } + /* * @tc.number: ANS_Remove_3500 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; - * @tc.desc: Verify that the interface remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; void; is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface remove(bundle: BundleOption, notificationKey: NotificationKey, callback: + * AsyncCallback): void; void; is called twice in a row to delete the notification information */ it('ANS_Remove_3500', 0, async function (done) { console.info("===============ANS_Remove_3500==========================>"); - timesOfOnCancel__removeByNotificationKey2Times = 0 + timesOfOnCancelRemoveByNotificationKey2Times = 0 var subscriber ={ - onConsume:OnConsume_removeByNotificationKey2Times, - onCancel:OnCancel_removeByNotificationKey2Times, + onConsume:onConsumeRemoveByNotificationKey2Times, + onCancel:onCancelRemoveByNotificationKey2Times, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3500_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3500_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2985,18 +2989,19 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3500_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3500_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3500_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3500_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3500 done==================>"); + }),1000); }) - function OnConsumeCallback_removeByNotificationKey2Times_promise(err, data) { - console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 start=======================>"); - console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 data: =======================>" + JSON.stringify(data)); + function onConsumeRemoveByNotificationKey2TimesPromise(err, data) { + console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 start===========>"); + console.info("================OnConsumeCallback_3600 data: =======================>" + JSON.stringify(data)); var bundleOption = { bundle:data.request.creatorBundleName, uid:data.request.creatorUid, @@ -3005,50 +3010,43 @@ describe('ActsAnsNotificationRemove', function () { id:36, label:"3600" } - notify.remove(bundleOption, notificationKey).then((err, data) => { - console.info("================removeByNotificationKey2Times1_promise_3600 start=======================>"); - console.info("================removeByNotificationKey2Times1_promise_3600 data: =======================>" + JSON.stringify(data)); - console.info("================removeByNotificationKey2Times1_promise_3600 err: =======================>" + JSON.stringify(err)); - notify.remove(bundleOption, notificationKey).then((err, data) => { - console.info("================removeByNotificationKey2Times2_promise_3600 start=======================>"); - console.info("================removeByNotificationKey2Times2_promise_3600 data: =======================>" + JSON.stringify(data)); - console.info("================removeByNotificationKey2Times2_promise_3600 err: =======================>" + JSON.stringify(err)); - console.info("================removeByNotificationKey2Times2_promise_3600 end=======================>"); - }); - console.info("================removeByNotificationKey2Times1_promise_3600 end=======================>"); - }); - console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 remove=======================>"); - console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 end=======================>"); - } - var timesOnCancelCallback_removeByNotificationKey2Times_promise - function OnCancelCallback_removeByNotificationKey2Times_promise(err, data) { - timesOnCancelCallback_removeByNotificationKey2Times_promise = timesOnCancelCallback_removeByNotificationKey2Times_promise + 1 - console.info("==========================OnCancelCallback_removeByNotificationKey2Times_promise_3600 start=======================>"); - console.info("================OnCancelCallback_removeByNotificationKey2Times_promise_3600 data : =======================>" + JSON.stringify(data)); - console.info("================OnCancelCallback_removeByNotificationKey2Times_promise_3600 err : =======================>" + JSON.stringify(err)); - if (timesOnCancelCallback_removeByNotificationKey2Times_promise == 1){ + notify.remove(bundleOption, notificationKey) + console.info("================removeByNotificationKey2Times1_promise_3600 end=======================>"); + notify.remove(bundleOption, notificationKey); + console.info("================removeByNotificationKey2Times2_promise_3600 end=====================>"); + console.info("================OnConsumeCallback_removeByNotificationKey2Times_promise_3600 end============>"); + } + var timesOnCancelcbRemoveByKey2TimesPromise + function onCancelRemoveByNotificationKey2TimesPromise(err, data) { + timesOnCancelcbRemoveByKey2TimesPromise = timesOnCancelcbRemoveByKey2TimesPromise + 1 + console.info("OnCancelCallback_removeByNotificationKey2Times_promise_3600 start=======================>"); + console.info("OnCancelCallback_removeByNotificationKey2Times_promise_3600 data:====>" + JSON.stringify(data)); + console.info("OnCancelCallback_removeByNotificationKey2Times_promise_3600 err:====>" + JSON.stringify(err)); + if (timesOnCancelcbRemoveByKey2TimesPromise == 1){ expect(data.request.id).assertequal(36); expect(data.request.label).assertequal("3600"); - } else if (timesOnCancelCallback_removeByNotificationKey2Times_promise == 2){ + } else if (timesOnCancelcbRemoveByKey2TimesPromise == 2){ expect().assertFail(); } - console.info("================OnCancelCallback_removeByNotificationKey2Times_promise_3600 end=======================>"); + console.info("================OnCancelCallback_removeByNotificationKey2Times_promise_3600 end============>"); } + /* * @tc.number: ANS_Remove_3600 * @tc.name: remove(bundle: BundleOption, notificationKey: NotificationKey): Promise; - * @tc.desc: Verify that the interface remove(bundle: BundleOption, notificationKey: NotificationKey): Promise is called twice in a row to delete the notification information + * @tc.desc: Verify that the interface remove(bundle: BundleOption, notificationKey: NotificationKey): + * Promise is called twice in a row to delete the notification information */ it('ANS_Remove_3600', 0, async function (done) { console.info("===============ANS_Remove_3600==========================>"); - timesOnCancelCallback_removeByNotificationKey2Times_promise = 0 + timesOnCancelcbRemoveByKey2TimesPromise = 0 + timesOnCancelcbRemoveByKey2TimesPromise = 0 var subscriber ={ - onConsume:OnConsumeCallback_removeByNotificationKey2Times_promise, - onCancel:OnCancelCallback_removeByNotificationKey2Times_promise, + onConsume:onConsumeRemoveByNotificationKey2TimesPromise, + onCancel:onCancelRemoveByNotificationKey2TimesPromise, } - await notify.subscribe(subscriber).then(() => { - console.info("==================subscribe_3600_promise==================>"); - }); + await notify.subscribe(subscriber); + console.info("==================subscribe_3600_promise==================>"); var notificationRequest = { content:{ contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -3079,12 +3077,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest).then(() => { - console.info("==================publish_3600_promise==================>"); - }); - await notify.unsubscribe(subscriber).then(() => { - console.info("==================unsubscribe_3600_promise==================>"); - }); + await notify.publish(notificationRequest); + console.info("==================publish_3600_promise==================>"); + await notify.unsubscribe(subscriber); + console.info("==================unsubscribe_3600_promise==================>"); done(); + setTimeout((function(){ + console.info("==================ANS_Remove_3600 done==================>"); + }),1000); }) }) \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/BUILD.gn b/notification/ans_standard/actsansslottest/BUILD.gn index 351d6873cb8f38478917801ac65ae49b08cc80bf..d996119071be3e9afe10db9faca57530d1b41ffc 100644 --- a/notification/ans_standard/actsansslottest/BUILD.gn +++ b/notification/ans_standard/actsansslottest/BUILD.gn @@ -20,6 +20,8 @@ group("ActsAnsSlotTest") { "actsansgetslottestcallback:ActsAnsGetSlotTestCallback", "actsansgetslottestpromise:ActsAnsGetSlotTestPromise", "actsansremoveslottest:ActsAnsRemoveSlotTest", + "actsansslotsystemcallback:ActsAnsSlotSystemCallback", + "actsansslotsystempromise:ActsAnsSlotSystemPromise", ] } } diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/BUILD.gn b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..1e410fb08148ce1e4eccc50a36ba9b96c62bec7f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsSlotSystemCallback") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsSlotSystemCallback" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/Test.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..5d9a94f55be1b7f644f9d7004dbd7bf23fb9176f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansslotsystemcallback", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsSlotSystemCallback.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/package.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/package.json new file mode 100755 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/config.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..044a903cd3feeb911b55eac07e443659ecfaabfd --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsansslotsystemcallback", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansslotsystemcallback", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansslotsystemcallback.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/app.js b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..485c1ea4f2631a1045e84574a6e492429c6152db --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + activeButton + +
diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..7aff3db5909dc68ab4a5c524e768bfb6b2b8832d --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,48 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "测试slot接口callback形式:系统应用" + }, + onInit() { + this.title = this.data.title; + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d72e9b5082dd736e5edef2041303460fcb5d64f7 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAnsSlotSystemCallback" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..1e18628d2a31ca437fd7e9283baf45d69c1610fb --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,238 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsAnsSlotSystemCallback', function () { + + /* + * @tc.number : ActsAnsSlotSystemCallback_0100 + * @tc.name : Verify getSlots after adding slots and removeSlot + * @tc.desc : getSlots after adding all type slots and removing slot + */ + it('ActsAnsSlotSystemCallback_0100', 0, async function (done) { + console.debug("====>ActsAnsSlotSystemCallback_0100 start====>"); + function timeOut(){ + console.debug("====>time out enter ActsAnsSlotSystemCallback_0100====>"); + } + console.debug("====>addSlot SOCIAL_COMMUNICATION====>"); + await notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_NONE, + desc: "slot_SOCIAL_COMMUNICATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_sound", + lightEnabled: true, + lightColor: 1 + }, + (err)=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION callback====>"); + expect(err.code).assertEqual(0); + }) + console.debug("====>addSlot SERVICE_INFORMATION====>"); + await notification.addSlot( + { + type: notification.SlotType.SERVICE_INFORMATION, + level: notification.SlotLevel.LEVEL_MIN, + desc: "slot_SERVICE_INFORMATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SERVICE_INFORMATION_sound", + lightEnabled: true, + lightColor: 2 + }, + (err)=>{ + console.debug("====>addSlot SERVICE_INFORMATION callback====>"); + expect(err.code).assertEqual(0); + }) + console.debug("====>addSlot CONTENT_INFORMATION====>"); + await notification.addSlot( + { + type: notification.SlotType.CONTENT_INFORMATION, + level: notification.SlotLevel.LEVEL_LOW, + desc: "slot_CONTENT_INFORMATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_CONTENT_INFORMATION_sound", + lightEnabled: true, + lightColor: 3 + }, + (err)=>{ + console.debug("====>addSlot CONTENT_INFORMATION callback====>"); + expect(err.code).assertEqual(0); + }) + console.debug("====>addSlot OTHER_TYPES====>"); + await notification.addSlot( + { + type: notification.SlotType.OTHER_TYPES, + level: notification.SlotLevel.LEVEL_DEFAULT, + desc: "slot_OTHER_TYPES_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_OTHER_TYPES_sound", + lightEnabled: true, + lightColor: 4 + }, + (err)=>{ + console.debug("====>addSlot OTHER_TYPES callback====>"); + expect(err.code).assertEqual(0); + }) + console.debug("====>addSlot UNKNOWN_TYPE====>"); + await notification.addSlot( + { + type: notification.SlotType.UNKNOWN_TYPE, + level: notification.SlotLevel.LEVEL_HIGH, + desc: "slot_UNKNOWN_TYPE_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_UNKNOWN_TYPE_sound", + lightEnabled: true, + lightColor: 5 + }, + (err)=>{ + console.debug("====>addSlot UNKNOWN_TYPE callback====>"); + expect(err.code).assertEqual(0); + }) + + await notification.getSlots((err, data)=>{ + console.debug("====>getSlots enter====>"); + console.debug("====>getSlots data====>" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>getSlots data====>" + JSON.stringify(data)); + try{ + expect(data[0].type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); + expect(data[0].level).assertEqual(notification.SlotLevel.LEVEL_NONE); + expect(data[0].desc).assertEqual("slot_SOCIAL_COMMUNICATION_desc"); + expect(data[0].badgeFlag).assertEqual(false); + expect(data[0].bypassDnd).assertEqual(true); + expect(data[0].vibrationEnabled).assertEqual(true); + expect(data[0].sound).assertEqual("slot_SOCIAL_COMMUNICATION_sound"); + expect(data[0].lightEnabled).assertEqual(true); + expect(data[0].lightColor).assertEqual(1); + + expect(data[1].type).assertEqual(notification.SlotType.SERVICE_INFORMATION); + expect(data[1].level).assertEqual(notification.SlotLevel.LEVEL_MIN); + expect(data[1].desc).assertEqual("slot_SERVICE_INFORMATION_desc"); + expect(data[1].badgeFlag).assertEqual(false); + expect(data[1].bypassDnd).assertEqual(true); + expect(data[1].vibrationEnabled).assertEqual(true); + expect(data[1].sound).assertEqual("slot_SERVICE_INFORMATION_sound"); + expect(data[1].lightEnabled).assertEqual(true); + expect(data[1].lightColor).assertEqual(2); + + expect(data[2].type).assertEqual(notification.SlotType.CONTENT_INFORMATION); + expect(data[2].level).assertEqual(notification.SlotLevel.LEVEL_LOW); + expect(data[2].desc).assertEqual("slot_CONTENT_INFORMATION_desc"); + expect(data[2].badgeFlag).assertEqual(false); + expect(data[2].bypassDnd).assertEqual(true); + expect(data[2].vibrationEnabled).assertEqual(true); + expect(data[2].sound).assertEqual("slot_CONTENT_INFORMATION_sound"); + expect(data[2].lightEnabled).assertEqual(true); + expect(data[2].lightColor).assertEqual(3); + + expect(data[3].type).assertEqual(notification.SlotType.OTHER_TYPES); + expect(data[3].level).assertEqual(notification.SlotLevel.LEVEL_DEFAULT); + expect(data[3].desc).assertEqual("slot_OTHER_TYPES_desc"); + expect(data[3].badgeFlag).assertEqual(false); + expect(data[3].bypassDnd).assertEqual(true); + expect(data[3].vibrationEnabled).assertEqual(true); + expect(data[3].sound).assertEqual("slot_OTHER_TYPES_sound"); + expect(data[3].lightEnabled).assertEqual(true); + expect(data[3].lightColor).assertEqual(4); + console.debug("====>getSlots end====>"); + console.debug("====>ActsAnsSlotSystemCallback_0100 end====>"); + notification.removeSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err)=>{ + console.debug("====>removeSlot ActsAnsSlotSystemCallback_0100 err====>" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + }) + }catch(err){ + console.error("====>getSlots catch err====>" + JSON.stringify(err)); + expect().assertFail(); + } + }) + setTimeout(timeOut, 10000); + }) + + /* + * @tc.number : ActsAnsSlotSystemPromise_0200 + * @tc.name : Verify that the same type of slot is added repeatedly + * @tc.desc : the same type of slot is added repeatedly, and the obtained slot is added for the first time + */ + it('ActsAnsSlotSystemCallback_0200', 0, async function (done) { + console.debug("====>ActsAnsSlotSystemCallback_0200 start====>"); + async function timeOutTwo(){ + console.debug("====>time out enter ActsAnsSlotSystemCallback_0200====>"); + } + console.debug("====>addSlot SOCIAL_COMMUNICATION====>"); + notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_NONE, + desc: "slot_SOCIAL_COMMUNICATION_Desc_First", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_Sound_First", + lightEnabled: true, + lightColor: 1 + } + ).then(()=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION callback====>"); + }) + notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_DEFAULT, + desc: "slot_SOCIAL_COMMUNICATION_Desc_Second", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_Sound_Second", + lightEnabled: true, + lightColor: 1 + } + ).then(()=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION callback====>"); + }) + console.debug("====>getSlot SlotType.SOCIAL_COMMUNICATION: ====>"); + await notification.getSlot(notification.SlotType.SOCIAL_COMMUNICATION, (err, data) => { + console.debug("====>getSlotActsAnsSlotSystemCallback_0200 enter====>"); + console.debug("====>getSlotActsAnsSlotSystemCallback_0200 err====>" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>getSlotActsAnsSlotSystemCallback_0200 data====>" + JSON.stringify(data)); + expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); + expect(data.level).assertEqual(notification.SlotLevel.LEVEL_NONE); + expect(data.desc).assertEqual("slot_SOCIAL_COMMUNICATION_Desc_First"); + expect(data.badgeFlag).assertEqual(false); + expect(data.bypassDnd).assertEqual(true); + expect(data.vibrationEnabled).assertEqual(true); + expect(data.sound).assertEqual("slot_SOCIAL_COMMUNICATION_Sound_First"); + expect(data.lightEnabled).assertEqual(true); + expect(data.lightColor).assertEqual(1); + console.debug("====>getSlotActsAnsSlotSystemCallback_0200 finish====>"); + console.debug("====>ActsAnsSlotSystemCallback_0200 end====>"); + done(); + }) + setTimeout(timeOutTwo, 10000); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/List.test.js b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystemcallback/signature/openharmony_sx.p7b b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/actsansslottest/actsansslotsystemcallback/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/BUILD.gn b/notification/ans_standard/actsansslottest/actsansslotsystempromise/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..4ec4705a05147eadd7300d70d4bde58244afe80e --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsSlotSystemPromise") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsSlotSystemPromise" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/Test.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..edc71d2d5fafb06b1c20c953c36ab2d4226505f7 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansslotsystempromise", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsSlotSystemPromise.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/package.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/package.json new file mode 100755 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/config.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..25b845cb00399524e0248a14bf056ed781aff039 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsansslotsystempromise", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansslotsystempromise", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansslotsystempromise.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/app.js b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..485c1ea4f2631a1045e84574a6e492429c6152db --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + activeButton + +
diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..3f54ed774fbdcb38038484efc69ed8fcbeed51d3 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,48 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "测试slot接口promise形式:系统应用" + }, + onInit() { + this.title = this.data.title; + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..754b2f285a7e24f9f6bac79868bd9cff48810575 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAnsSlotSystemPromise" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..acbae78c837b2028c7f817c606c1b2ebefefbe02 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,262 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsAnsSlotSystemPromise', function () { + + /* + * @tc.number : ActsAnsSlotSystemPromise_0100 + * @tc.name : Verify getSlots after adding slots and removeSlot + * @tc.desc : getSlots after adding all type slots and adding again after removing slot + */ + it('ActsAnsSlotSystemPromise_0100', 0, async function (done) { + console.debug("====>ActsAnsSlotTestSystem_0100 start====>"); + console.debug("====>addSlot SOCIAL_COMMUNICATION====>"); + notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_NONE, + desc: "slot_SOCIAL_COMMUNICATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_sound", + lightEnabled: true, + lightColor: 1 + } + ).then(()=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION promise====>"); + }) + console.debug("====>addSlot SERVICE_INFORMATION====>"); + notification.addSlot( + { + type: notification.SlotType.SERVICE_INFORMATION, + level: notification.SlotLevel.LEVEL_MIN, + desc: "slot_SERVICE_INFORMATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SERVICE_INFORMATION_sound", + lightEnabled: true, + lightColor: 2 + } + ).then(()=>{ + console.debug("====>addSlot SERVICE_INFORMATION promise====>"); + }) + console.debug("====>addSlot CONTENT_INFORMATION====>"); + notification.addSlot( + { + type: notification.SlotType.CONTENT_INFORMATION, + level: notification.SlotLevel.LEVEL_LOW, + desc: "slot_CONTENT_INFORMATION_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_CONTENT_INFORMATION_sound", + lightEnabled: true, + lightColor: 3 + } + ).then(()=>{ + console.debug("====>addSlot CONTENT_INFORMATION promise====>"); + }) + console.debug("====>addSlot OTHER_TYPES====>"); + notification.addSlot( + { + type: notification.SlotType.OTHER_TYPES, + level: notification.SlotLevel.LEVEL_DEFAULT, + desc: "slot_OTHER_TYPES_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_OTHER_TYPES_sound", + lightEnabled: true, + lightColor: 4 + } + ).then(()=>{ + console.debug("====>addSlot OTHER_TYPES promise====>"); + }) + console.debug("====>addSlot UNKNOWN_TYPE====>"); + notification.addSlot( + { + type: notification.SlotType.UNKNOWN_TYPE, + level: notification.SlotLevel.LEVEL_HIGH, + desc: "slot_UNKNOWN_TYPE_desc", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_UNKNOWN_TYPE_sound", + lightEnabled: true, + lightColor: 5 + } + ).then(()=>{ + console.debug("====>addSlot UNKNOWN_TYPE promise====>"); + }) + notification.getSlots().then((data)=>{ + console.debug("====>getSlots enter====>"); + console.debug("====>getSlots data====>" + JSON.stringify(data)); + try{ + expect(data[0].type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); + expect(data[0].level).assertEqual(notification.SlotLevel.LEVEL_NONE); + expect(data[0].desc).assertEqual("slot_SOCIAL_COMMUNICATION_desc"); + expect(data[0].badgeFlag).assertEqual(false); + expect(data[0].bypassDnd).assertEqual(true); + expect(data[0].vibrationEnabled).assertEqual(true); + expect(data[0].sound).assertEqual("slot_SOCIAL_COMMUNICATION_sound"); + expect(data[0].lightEnabled).assertEqual(true); + expect(data[0].lightColor).assertEqual(1); + + expect(data[1].type).assertEqual(notification.SlotType.SERVICE_INFORMATION); + expect(data[1].level).assertEqual(notification.SlotLevel.LEVEL_MIN); + expect(data[1].desc).assertEqual("slot_SERVICE_INFORMATION_desc"); + expect(data[1].badgeFlag).assertEqual(false); + expect(data[1].bypassDnd).assertEqual(true); + expect(data[1].vibrationEnabled).assertEqual(true); + expect(data[1].sound).assertEqual("slot_SERVICE_INFORMATION_sound"); + expect(data[1].lightEnabled).assertEqual(true); + expect(data[1].lightColor).assertEqual(2); + + expect(data[2].type).assertEqual(notification.SlotType.CONTENT_INFORMATION); + expect(data[2].level).assertEqual(notification.SlotLevel.LEVEL_LOW); + expect(data[2].desc).assertEqual("slot_CONTENT_INFORMATION_desc"); + expect(data[2].badgeFlag).assertEqual(false); + expect(data[2].bypassDnd).assertEqual(true); + expect(data[2].vibrationEnabled).assertEqual(true); + expect(data[2].sound).assertEqual("slot_CONTENT_INFORMATION_sound"); + expect(data[2].lightEnabled).assertEqual(true); + expect(data[2].lightColor).assertEqual(3); + + expect(data[3].type).assertEqual(notification.SlotType.OTHER_TYPES); + expect(data[3].level).assertEqual(notification.SlotLevel.LEVEL_DEFAULT); + expect(data[3].desc).assertEqual("slot_OTHER_TYPES_desc"); + expect(data[3].badgeFlag).assertEqual(false); + expect(data[3].bypassDnd).assertEqual(true); + expect(data[3].vibrationEnabled).assertEqual(true); + expect(data[3].sound).assertEqual("slot_OTHER_TYPES_sound"); + expect(data[3].lightEnabled).assertEqual(true); + expect(data[3].lightColor).assertEqual(4); + console.debug("====>getSlots end====>"); + }catch(err){ + console.error("====>getSlots catch err====>" + JSON.stringify(err)); + expect().assertFail(); + } + }) + + notification.removeAllSlots().then(()=>{ + console.debug("====>removeAllSlots ActsAnsSlotSystemPromise_0100====>"); + }) + + notification.getSlots().then((data)=>{ + console.debug("====>getSlots enter====>"); + console.debug("====>getSlots data====>" + JSON.stringify(data)); + }) + console.debug("====>addSlot SERVICE_INFORMATION second====>"); + notification.addSlot( + { + type: notification.SlotType.SERVICE_INFORMATION, + level: notification.SlotLevel.LEVEL_DEFAULT, + desc: "slot_SERVICE_INFORMATION_Desc_Second", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SERVICE_INFORMATION_Sound_Second", + lightEnabled: true, + lightColor: 2 + } + ).then(()=>{ + console.debug("====>addSlot SERVICE_INFORMATION second====>"); + }) + notification.getSlot(notification.SlotType.SERVICE_INFORMATION).then((data) => { + console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsSlotSystemPromise_0100 enter====>"); + console.debug("====>getSlotPromise ActsAnsSlotSystemPromise_0100 data====>" + JSON.stringify(data)); + expect(data.type).assertEqual(notification.SlotType.SERVICE_INFORMATION); + expect(data.level).assertEqual(notification.SlotLevel.LEVEL_DEFAULT); + expect(data.desc).assertEqual("slot_SERVICE_INFORMATION_Desc_Second"); + expect(data.badgeFlag).assertEqual(false); + expect(data.bypassDnd).assertEqual(true); + expect(data.vibrationEnabled).assertEqual(true); + expect(data.sound).assertEqual("slot_SERVICE_INFORMATION_Sound_Second"); + expect(data.lightEnabled).assertEqual(true); + expect(data.lightColor).assertEqual(2); + console.debug("====>getSlotPromise SERVICE_INFORMATION ActsAnsSlotSystemPromise_0100 finish====>"); + done(); + }) + console.debug("====>ActsAnsSlotTestSystem_0100 end====>"); + setTimeout(function (){ + console.debug("====>time out ActsAnsSlotTestSystem_0100====>"); + }, 10000); + + }) + + /* + * @tc.number : ActsAnsSlotSystemPromise_0200 + * @tc.name : Verify that the same type of slot is added repeatedly + * @tc.desc : the same type of slot is added repeatedly, and the obtained slot is added for the first time + */ + it('ActsAnsSlotSystemPromise_0200', 0, async function (done) { + console.debug("====>ActsAnsSlotSystemPromise_0200 start====>"); + console.debug("====>addSlot SOCIAL_COMMUNICATION====>"); + notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_NONE, + desc: "slot_SOCIAL_COMMUNICATION_Desc_First", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_Sound_First", + lightEnabled: true, + lightColor: 1 + } + ).then(()=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION promise====>"); + }) + notification.addSlot( + { + type: notification.SlotType.SOCIAL_COMMUNICATION, + level: notification.SlotLevel.LEVEL_DEFAULT, + desc: "slot_SOCIAL_COMMUNICATION_Desc_Second", + badgeFlag: false, + bypassDnd: true, + vibrationEnabled: true, + sound: "slot_SOCIAL_COMMUNICATION_Sound_Second", + lightEnabled: true, + lightColor: 1 + } + ).then(()=>{ + console.debug("====>addSlot SOCIAL_COMMUNICATION promise====>"); + }) + console.debug("====>getSlot SlotType.SOCIAL_COMMUNICATION: ====>"); + notification.getSlot(notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { + console.debug("====>getSlotActsAnsSlotSystemPromise_0200 enter====>"); + console.debug("====>getSlotActsAnsSlotSystemPromise_0200 data====>" + JSON.stringify(data)); + expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); + expect(data.level).assertEqual(notification.SlotLevel.LEVEL_NONE); + expect(data.desc).assertEqual("slot_SOCIAL_COMMUNICATION_Desc_First"); + expect(data.badgeFlag).assertEqual(false); + expect(data.bypassDnd).assertEqual(true); + expect(data.vibrationEnabled).assertEqual(true); + expect(data.sound).assertEqual("slot_SOCIAL_COMMUNICATION_Sound_First"); + expect(data.lightEnabled).assertEqual(true); + expect(data.lightColor).assertEqual(1); + console.debug("====>getSlotActsAnsSlotSystemPromise_0200 finish====>"); + done(); + }) + console.debug("====>ActsAnsSlotSystemPromise_0200 end====>"); + setTimeout(function (){ + console.debug("====>time out ActsAnsSlotSystemPromise_0200====>"); + }, 10000); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/List.test.js b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/actsansslottest/actsansslotsystempromise/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/actsansslottest/actsansslotsystempromise/signature/openharmony_sx.p7b b/notification/ans_standard/actsansslottest/actsansslotsystempromise/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/actsansslottest/actsansslotsystempromise/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/BUILD.gn b/notification/ans_standard/publish_test/BUILD.gn index 13945e26936c43a7b4df3cd48de980263b65c212..c9bd21b8c818f2b6479e957edd68dc909939fc17 100644 --- a/notification/ans_standard/publish_test/BUILD.gn +++ b/notification/ans_standard/publish_test/BUILD.gn @@ -21,7 +21,11 @@ group("publish_test") { "badgedisplayedset:badgedisplayedset", "enablenotification:enablenotification", "enablenotificationset:enablenotificationset", + "getactive:getactive", "getwantagentinfo:getwantagentinfo", + "publishcontentype:ActsAnsNotificationTest", + "subscribe:subscribe", + "unsubscribe:ActsAnsUnSubscriberTest", "wantagent:wantagent", ] } diff --git a/notification/ans_standard/publish_test/getactive/BUILD.gn b/notification/ans_standard/publish_test/getactive/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..60a230cf9217cb09fa53b91ba047cb391b88ec8f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/BUILD.gn @@ -0,0 +1,24 @@ +# 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("//test/xts/tools/build/suite.gni") + +group("getactive") { + testonly = true + if (is_standard_system) { + deps = [ + "getactivenormal:getactivenormal", + "getcancelactivenum:ActsAnsGetCancelActiveNumTest", + ] + } +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/BUILD.gn b/notification/ans_standard/publish_test/getactive/getactivenormal/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..975f4301e1de0f0d7ea99eee1c94df0fae3c369c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/BUILD.gn @@ -0,0 +1,26 @@ +# 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("//test/xts/tools/build/suite.gni") + +group("getactivenormal") { + testonly = true + if (is_standard_system) { + deps = [ + "active:ActsAnsGetActiveTest", + + # "sub:ActsAnsActiveSubscriberTest", + "publish:ActsAnsActivePublishTest", + ] + } +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/BUILD.gn b/notification/ans_standard/publish_test/getactive/getactivenormal/active/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e244dcb6447df0f9e15d22c46aad00918c380582 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsGetActiveTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsGetActiveTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/Test.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..15f312f41d6e1af2905300eaba37b60bbc3914dc --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansgetactivetest", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsGetActiveTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/package.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/config.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..3d323e181c539a7aa28aa9cc660f4d9b98953de3 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansgetactivetest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansgetactivetest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansgetactivetest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..8e5bbd698cf7316754b1666319656dfd7bae644f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + active程序启动 + +
diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..55a7f240d259f83a1ceddc76d3c5def91aee2308 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Active" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/GetActiveInfo.test.js b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/GetActiveInfo.test.js new file mode 100644 index 0000000000000000000000000000000000000000..67ebf059a243ca323360d724b2e99e89d5dc75c3 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/GetActiveInfo.test.js @@ -0,0 +1,64 @@ +/* + * 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 notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var time = 1000 +describe('ActsAnsGetActiveTest', function () { + console.info("===========ActsSubscriberTest start====================>"); + + /* + * @tc.number: ActsActive_test_0100 + * @tc.name: getAllActiveNotifications() + * @tc.desc: verify the function of getAllActiveNotifications + */ + it('ActsActive_test_0100', 0, async function (done) { + await notify.getAllActiveNotifications((error, data) => { + console.log("==========================>getAllActiveNotifications1=======================>" + data) + expect(typeof(data)).assertEqual('object') + for (let i = 0; i < data.length; i++) { + console.log("==========================>getAllActiveNotificationshashCode1=======================>" + data[i].hashCode) + console.log("==========================>getAllActiveNotificationsid1=======================>" + data[i].id) + console.log("==========================>getAllActiveNotificationslotType1=======================>" + data[i].slotType) + console.log("==========================>getAllActiveNotificationclassification1=======================>" + data[i].classification) + console.log("==========================>getAllActiveNotificationsortingKey1=======================>" + data[i].sortingKey) + console.log("==========================>getAllActiveNotificationscontentType1=======================>" + data[i].content.contentType) + console.log("==========================>getAllActiveNotificationstitle1=======================>" + data[i].content.normal.title) + console.log("==========================>getAllActiveNotificationstext1=======================>" + data[i].content.normal.text) + console.log("==========================>getAllActiveNotificationsadditionalText1=======================>" + data[i].content.normal.additionalText) + } + }) + + var promise = await notify.getAllActiveNotifications() + expect(typeof(promise)).assertEqual('object') + for (let i = 0; i < promise.length; i++) { + console.log("==========================>getAllActiveNotificationsPromisehashCode1=======================>" + promise[i].hashCode) + console.log("==========================>getAllActiveNotificationsPromiseid1=======================>" + promise[i].id) + console.log("==========================>getAllActiveNotificationsPromiseslotType1=======================>" + promise[i].slotType) + console.log("==========================>getAllActiveNotificationsPromiseclassification1=======================>" + promise[i].classification) + console.log("==========================>getAllActiveNotificationsPromisesortingKey1=======================>" + promise[i].sortingKey) + console.log("==========================>getAllActiveNotificationsPromisecontentType1=======================>" + promise[i].content.contentType) + console.log("==========================>getAllActiveNotificationsPromisetitle1=======================>" + promise[i].content.normal.title) + console.log("==========================>getAllActiveNotificationsPromisetext1=======================>" + promise[i].content.normal.text) + console.log("==========================>getAllActiveNotificationsPromiseadditionalText1=======================>" + promise[i].content.normal.additionalText) + } + done(); + setTimeout(function(){ + console.debug("====>time out ActsActive_test_0100====>"); + }, time); + }) + +}) + diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..36f3624a07c34f04eaac62fab64814215be2fd18 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/active/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./GetActiveInfo.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/active/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/getactive/getactivenormal/active/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/active/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/BUILD.gn b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1ce0eb7222a98988859964c7ea8995c7983a8333 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsActivePublishTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsActivePublishTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/Test.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c03963b33598f9bc15158fe7ca161d9c17fddeb7 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansactivepublishtest", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsActivePublishTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/package.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/config.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..10b5c3b052989b7a4a1036e97ba3851230434b88 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansactivepublishtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansactivepublishtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansactivepublishtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..fc2437b2b0af5bd75dfc14e0ea743d011159ede3 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 发布接口调用 + +
diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a83a041be69ed1ded7913caee6fa1906315c41a0 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "publish1" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..61ff84a8dbb89ee3c1cf59f7ee9757ef3b113842 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,104 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var time = 1000 +describe('ActsAnsActivePublishTest', function () { + function publishCallback001(){ + console.log('ActsNotificationTest ACTS_Publish_0100 asyncCallback') + } + + /* + * @tc.number: ACTS_GetActiveNumTest_0100 + * @tc.name: getActiveNotifications(),getActiveNotificationNums() + * @tc.desc: verify the function of getActiveNotifications,getActiveNotificationNums + */ + it('ACTS_GetActiveNumTest_0100', 0,async function (done) { + await notification.publish({ + id: 1, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test1_title", + text: "test1_text", + additionalText: "test1_additionalText" + }, + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION, + classification:"classification1", + sortingKey:"sortingKey1", + },publishCallback001); + await notification.publish({ + id: 2, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test2_title", + text: "test2_text", + additionalText: "test2_additionalText" + }, + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION, + classification:"classification2", + sortingKey:"sortingKey2", + },publishCallback001); + + await notification.getActiveNotifications( + (error,data) => { + console.log("============PublishgetActiveNotificationsTest1============"+data) + expect(typeof(data)).assertEqual('object') + for (let i = 0; i < data.length; i++) { + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].hashCode) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].id) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].classification) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].sortingKey) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].slotType) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.contentType) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.normal.title) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.normal.text) + console.log("==========================>PublishgetActiveNotificationsTest1=======================>" + data[i].content.normal.additionalText) + } + }) + + var promise = await notification.getActiveNotifications(); + expect(typeof(promise)).assertEqual('object') + for (let i = 0; i < promise.length; i++) { + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].hashCode) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].id) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].slotType) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].classification) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].sortingKey) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.contentType) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.title) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.text) + console.log("==========================>publishgetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.additionalText) + } + + await notification.getActiveNotificationCount((error,data) => { + console.log("============getActiveNotificationNumsTest1============"+JSON.stringify(data)) + expect(typeof(data)).assertEqual('number') + }) + + var promise = await notification.getActiveNotificationCount(); + console.log("============getActiveNotificationNumsTest1Promise============"+JSON.stringify(promise)) + console.log("============ACTS_PublishTest1_0100 finished============") + expect(typeof(promise)).assertEqual('number') + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_GetActiveNumTest_0100====>"); + }, time); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/publish/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/publish/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/BUILD.gn b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..19f81bfe930bef22db042d0c7b1258521c0ff739 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsActiveSubscriberTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsActiveSubscriberTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/Test.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..033380827174c51e440686645549042efc4d04f4 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansactivesubscribertest", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsActiveSubscriberTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/package.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/config.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..38ceab0b83f034b4fcc5f84dd7ef9199e388791c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansactivesubscribertest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansactivesubscribertest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansactivesubscribertest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..0ac24eaf6f6b6e2b1ff1f01dc0c724b2692299c5 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 订阅程序1启动 + +
diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6d530caefcdbe79f49db0b49fb864ed4daaeaac0 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sub1" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..41999288d49304127387014dc88894130a148ab4 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./Subscriber.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/Subscriber.js b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/Subscriber.js new file mode 100644 index 0000000000000000000000000000000000000000..27a4f7b528a7f6b7b2c57ebd28812bc229b1a095 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/entry/src/main/js/test/Subscriber.js @@ -0,0 +1,59 @@ +/* + * 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 notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var time = 1000 +describe('ActsAnsActiveSubscriberTest', function () { + console.info("===========ActsSubscriberTest start====================>"); + + //consume + function consumeCallback(err, data) { + console.debug("==========================>consumeCallback data : =======================>" + JSON.stringify(data)); + } + //subscribeOn + function subscribeOnCallback(err) { + console.debug("==========================>subscribeOnCallback=======================>"); + } + //subscribe + function subscribeCallback(err) { + console.debug("==========================>subscribeCallback=======================>"); + } + + /* + * @tc.number: ActsWantAgent_test_0100 + * @tc.name: createSubscriber(),subscribe() + * @tc.desc: verify the function of createSubscriber,subscribe + */ + it('ActsActiveSubscriber_test_0100', 0, async function (done) { + console.debug("===============ActsWantAgent_test_0100======begin====================>"); + + var subInfo ={ + onConsume:consumeCallback, + onConnect:subscribeOnCallback, + } + try{ + await notify.subscribe(subInfo,subscribeCallback); + }catch(err) { + console.error('=ActsActiveSubscriber_test_0100 订阅 subscribeCallback err:'+err); + } + console.debug("===============ActsActiveSubscriber_test_0100=======end===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsActiveSubscriber_test_0100====>"); + }, time); + }) +}) + diff --git a/notification/ans_standard/publish_test/getactive/getactivenormal/sub/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getactivenormal/sub/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/BUILD.gn b/notification/ans_standard/publish_test/getactive/getcancelactivenum/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4c8b8a239aa508386a7a21375c99c0edbe866043 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsGetCancelActiveNumTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsGetCancelActiveNumTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/Test.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9136f33e0a49bc25f9626f7f5b98cd43d2215f51 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "21600000", + "package": "com.example.actsansgetcancelactivenumtest", + "shell-timeout": "21600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsGetCancelActiveNumTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/package.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/config.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..fdfef954b2f394f8a094b5edb2b02117636e6537 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansgetcancelactivenumtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansgetcancelactivenumtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansgetcancelactivenumtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..4a5287619f9cfd05dd47ad8bc78fe606a254d45b --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + GetCancelActiveNum启动 + +
diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2d0b6a30c006e4468343aef65f7e168626226f72 --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CancelActiveNum" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/GetCancelActiveNum.test.js b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/GetCancelActiveNum.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6f8c7160756974fd10de66bb89e3cbbe2838b6fa --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/GetCancelActiveNum.test.js @@ -0,0 +1,176 @@ +/* + * 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 notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var time = 1000 +describe('ActsAnsGetCancelActiveNumTest', function () { + console.info("===========ActsGetCancelActiveNumTest start====================>"); + + //consume + function consumeCallback(err, data) { + console.debug("==========================>consumeCallback data : =======================>" + JSON.stringify(data)); + console.debug("==========================>consumeCallback===notificationId:====================>" + data.request.id); + console.debug("==========================>consumeCallback===sortingMap.sortedHashCode.length:====================>" + data.sortingMap.sortedHashCode.length); + } + + function cancelAllCallBack(){ + console.info("==========================>cancelAllCallBack start=======================>"); + } + + //subscribeOn + function subscribeOnCallback(err) { + console.debug("==========================>subscribeOnCallback=======================>"); + } + //subscribe + function subscribeCallback(err) { + console.debug("==========================>subscribeCallback=======================>"); + + } + //publish + function publishCallback001(){ + console.log('ActsAnsGetCancelActiveNumTest ActsGetCancelActiveNum_test_0200 publish asyncCallback') + } + + /* + * @tc.number: ActsGetCancelActiveNum_test_0100 + * @tc.name: createSubscriber(),subscriber() + * @tc.desc: verify the function of createSubscriber,subscriber + */ + it('ActsGetCancelActiveNum_test_0100', 0, async function (done) { + console.debug("===============ActsGetCancelActiveNum_test_0100======begin====================>"); + var subInfo ={ + onConsume:consumeCallback, + onConnecte:subscribeOnCallback, + } + try{ + await notify.subscribe(subInfo,subscribeCallback); + }catch(err) { + console.error('=ActsWantAgent_test_0100 订阅 subscribeCallback err:'+err); + } + console.debug("===============ActsGetCancelActiveNum_test_0100=======end===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsGetCancelActiveNum_test_0100====>"); + }, time); + }) + + /* + * @tc.number: ActsGetCancelActiveNum_test_0200 + * @tc.name: getActiveNotifications(),getActiveNotificationNums() + * @tc.desc: verify the function of getActiveNotifications,getActiveNotificationNums + */ + it('ActsGetCancelActiveNum_test_0200', 0,async function (done) { + await notify.publish({ + id: 1, + content: { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test1_title", + text: "test1_text", + additionalText: "test1_additionalText" + }, + } + },publishCallback001); + await notify.publish({ + id: 2, + content: { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test2_title", + text: "test2_text", + additionalText: "test2_additionalText" + }, + } + },publishCallback001); + await notify.publish({ + id: 3, + content: { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test3_title", + text: "test3_text", + additionalText: "test3_additionalText" + }, + } + },publishCallback001); + + await notify.getActiveNotifications( + (error,data) => { + console.log("============PublishGetActiveNotificationsTest1============"+data) + expect(typeof(data)).assertEqual('object') + for (let i = 0; i < data.length; i++) { + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].hashCode) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].Id) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].slotType) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].content.contentType) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].content.normal.title) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].content.normal.text) + console.log("==========================>PublishGetActiveNotificationsTest1=======================>" + data[i].content.normal.additionalText) + } + }) + + var promise = await notify.getActiveNotifications(); + expect(typeof(promise)).assertEqual('object') + for (let i = 0; i < promise.length; i++) { + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].hashCode) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].Id) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].slotType) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.contentType) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.title) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.text) + console.log("==========================>publishGetAllActiveNotificationsPromisehashCode=======================>" + promise[i].content.normal.additionalText) + } + + await notify.getActiveNotificationCount((error,data) => { + console.log("============getActiveNotificationNumsTest1============"+JSON.stringify(data)) + expect(typeof(data)).assertEqual('number') + }) + + var promise = await notify.getActiveNotificationCount(); + expect(typeof(promise)).assertEqual('number') + console.log("============getActiveNotificationNumsTest1Promise============"+JSON.stringify(promise)) + console.log("============ActsGetCancelActiveNum_test_0200 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ActsGetCancelActiveNum_test_0200====>"); + }, time); + }) + + /* + * @tc.number: ActsGetCancelActiveNum_test_0300 + * @tc.name: cancel(),getActiveNotificationNums() + * @tc.desc: verify the function of cancel,getActiveNotificationNums + */ + it('ActsGetCancelActiveNum_test_0300', 0,async function (done) { + + await notify.cancel(1,cancelAllCallBack); + + await notify.getActiveNotificationCount((error,data) => { + expect(typeof(data)).assertEqual('number') + console.log("============getActiveNotificationCancelNums============"+data) + }) + + var promise = await notify.getActiveNotificationCount(); + expect(typeof(promise)).assertEqual('number') + console.log("============getActiveNotificationCancelNumsPromise============"+JSON.stringify(promise)) + console.log("============ActsGetCancelActiveNum_test_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ActsGetCancelActiveNum_test_0300====>"); + }, time); + }) +}) + diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5500d70bae42c3eeb4b53873a4b8052b553817ee --- /dev/null +++ b/notification/ans_standard/publish_test/getactive/getcancelactivenum/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./GetCancelActiveNum.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/getactive/getcancelactivenum/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/getactive/getcancelactivenum/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/getactive/getcancelactivenum/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoone/entry/src/main/config.json b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoone/entry/src/main/config.json index f9cd73ac9f3db0470bbbdd1684586776cb75e7fa..0b9e3c77886a03e60720a4b02bbb40168e9fda64 100644 --- a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoone/entry/src/main/config.json +++ b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoone/entry/src/main/config.json @@ -42,7 +42,8 @@ "label": "$string:app_name", "type": "page", "isVisible": "true", - "launchType": "standard" + "launchType": "standard", + "visible": true } ], "js": [ diff --git a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoonepro/entry/src/main/config.json b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoonepro/entry/src/main/config.json index 82e46c1f15c96d4eb10381c8bab21bafc50bb681..7cc8658ee9726f2a6201f1f2d60f2df3c7cb6409 100644 --- a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoonepro/entry/src/main/config.json +++ b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfoonepro/entry/src/main/config.json @@ -42,7 +42,8 @@ "label": "$string:app_name", "type": "page", "isVisible": "true", - "launchType": "standard" + "launchType": "standard", + "visible": true } ], "js": [ diff --git a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwo/entry/src/main/config.json b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwo/entry/src/main/config.json index 86d30655940660b8c57acfed03370eb00f41d1b6..8a44e1bbc5f044f71373413ae992dbec76870053 100644 --- a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwo/entry/src/main/config.json +++ b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwo/entry/src/main/config.json @@ -42,7 +42,8 @@ "label": "$string:app_name", "type": "page", "isVisible": "true", - "launchType": "standard" + "launchType": "standard", + "visible": true } ], "js": [ diff --git a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwopro/entry/src/main/config.json b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwopro/entry/src/main/config.json index 3d907b88a2689e72494b85a5e18a18009ec158fe..3c2d69ade480bfbcd14595949d219aeb707be991 100644 --- a/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwopro/entry/src/main/config.json +++ b/notification/ans_standard/publish_test/getwantagentinfo/getwantagentinfotwopro/entry/src/main/config.json @@ -42,7 +42,8 @@ "label": "$string:app_name", "type": "page", "isVisible": "true", - "launchType": "standard" + "launchType": "standard", + "visible": true } ], "js": [ diff --git a/notification/ans_standard/publish_test/publishcontentype/BUILD.gn b/notification/ans_standard/publish_test/publishcontentype/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..08c6cff2ad0da28da79d75e8dfe432081083f3c6 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/BUILD.gn @@ -0,0 +1,30 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsNotificationTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsNotificationTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/publishcontentype/Test.json b/notification/ans_standard/publish_test/publishcontentype/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e8c76a7ea3155d211a5f47ae50555b22d7abf4f7 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsansnotificationtest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsNotificationTest" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/package.json b/notification/ans_standard/publish_test/publishcontentype/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/config.json b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..242abd2cb083f4ee5063fb77d281228c932ad3e8 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansnotificationtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansnotificationtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansnotificationtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..aa3c315a654f57cc17e475108f24b775d5d559d1 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + contentType + +
diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e95e981b01b0db8c7b3b033a7cb790815eb09abd --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ContentType" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a8a93f0e9a80a524326e28e88978515ddecf0cee --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,1280 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var comsumData +var time = 1000 +describe('ActsAnsNotificationTest', function () { + function publishMULTILINEContentCallback001(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0100 asyncCallback'+JSON.stringify(error.code)) + } + function publishMULTILINEContentCallback002(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0200 asyncCallback'+JSON.stringify(error.code)) + } + function publishMULTILINEContentCallback003(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0300 asyncCallback'+JSON.stringify(error.code)) + } + function publishLONGContentCallback001(error){ + console.log('ActsNotificationTest ACTS_PublishLONGContent_0100 asyncCallback'+JSON.stringify(error.code)) + } + function publishLONGContentCallback002(error){ + console.log('ActsNotificationTest ACTS_PublishLONGContent_0200 asyncCallback'+JSON.stringify(error.code)) + } + function publishLONGContentCallback003(error){ + console.log('ActsNotificationTest ACTS_PublishLONGContent_0300 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotTypeContentCallback001(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeContent_0100 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotTypeContentCallback002(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeContent_0200 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotTypeContentCallback003(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeContent_0300 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotTypeContentCallback004(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeContent_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotOtherCallback001(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeOther_0100 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotOtherCallback002(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeOther_0200 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotOtherCallback003(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeOther_0300 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotOtherCallback004(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeOther_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotServiceCallback001(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0100 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotServiceCallback002(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0200 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotServiceCallback003(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0300 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotServiceCallback004(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotSocialCallback001(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotSocialCallback002(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotSocialCallback003(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0400 asyncCallback'+JSON.stringify(error.code)) + } + function publishSlotSocialCallback004(error){ + console.log('ActsNotificationTest ACTS_Publish_SlotTypeService_0400 asyncCallback'+JSON.stringify(error.code)) + } + //consume + function consumeCallback(err,data) { + console.debug("==========================>consumeDoNotCallback1 data : =======================>" + err + JSON.stringify(data)); + comsumData = data + } + //subscribeOn + function subscribeOnCallback(err) { + console.debug("==========================>subscribeDoNotOnCallback=======================>"); + } + //subscribe + function subscribeCallback(err) { + console.debug("==========================>subscribeDoNotCallback=======================>"); + } + /* + * @tc.number: ActsDoNotSubscriber_test_0100 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0100', 0, async function (done) { + console.debug("===============ActsDoNotSubscriber_test_0100======begin====================>"); + + var subInfo ={ + onConsume:consumeCallback, + onConnect:subscribeOnCallback, + } + try { + await notification.subscribe(subInfo, subscribeCallback); + } + catch(err) { + console.error('ActsSubscriber_test_0100 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0100=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0100====>"); + }, time); + }) + + /* + * @tc.number: ACTS_PublishMULTILINEContent_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MULTILINE) + */ + it('ACTS_PublishMULTILINEContent_0100', 0,async function (done) { + try { + await notification.publish({ + id: 1, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText: "briefText", + longTitle: "longTitle", + lines: ["123", "234", "345", "456"] + }, + } + }, publishMULTILINEContentCallback001); + }catch(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0100 error'+JSON.stringify(error.code))} +// console.log("============ACTS_PublishMULTILINEContent_0100 finished============"+comsumData.request.id) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(1) + + }) + + /* + * @tc.number: ACTS_PublishMULTILINEContent_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish() + */ + it('ACTS_PublishMULTILINEContent_0200', 0,async function (done) { + try { + var notificationInfo = { + id: 2, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText: "briefText", + longTitle: "longTitle", + lines: ["123", "234", "345", "456"] + }, + } + } + }catch(err){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent11111111'+err) + } + try{ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent222222222222') + await notification.publish(notificationInfo,publishMULTILINEContentCallback002); + }catch(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0200 asyncCallback'+error) + } +// console.log("============ACTS_PublishMULTILINEContent_0200 finished============"+comsumData.request.id) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(2) + }) + + /* + * @tc.number: ACTS_PublishMULTILINEContent_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_PICTURE) + */ + it('ACTS_PublishMULTILINEContent_0300', 0,async function (done) { + try { + await notification.publish({ + id: 3, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_PICTURE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText: "briefText", + longTitle: "longTitle", + lines: ["123", "234", "345", "456"] + }, + } + }, publishMULTILINEContentCallback003); + }catch(error){ + console.log('ActsNotificationTest ACTS_PublishMULTILINEContent_0300 asyncCallback'+JSON.stringify(error.code)) + } + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(3) + }) + + /* + * @tc.number: ACTS_PublishMULTILINEContent_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MULTILINE) promise + */ + it('ACTS_PublishMULTILINEContent_0400', 0,async function (done) { + notification.publish({ + id: 4, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText:"briefText", + longTitle:"longTitle", + lines:["123","234","345","456"] + }, + } + }).then(console.log("============ACTS_PublishMULTILINEContent_0400 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(4) + }) + /* + * @tc.number: ACTS_PublishMULTILINEContent_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish() promise + */ + it('ACTS_PublishMULTILINEContent_0500', 0,async function (done) { + notification.publish({ + id: 5, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText:"briefText", + longTitle:"longTitle", + lines:["123","234","345","456"] + }, + } + }).then(console.log("============ACTS_PublishMULTILINEContent_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(5) + }) + + /* + * @tc.number: ACTS_PublishMULTILINEContent_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_PICTURE) promise + */ + it('ACTS_PublishMULTILINEContent_0600', 0,async function (done) { + notification.publish({ + id: 6, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_PICTURE, + multiLine: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + briefText:"briefText", + longTitle:"longTitle", + lines:["123","234","345","456"] + }, + } + }).then(console.log("============ACTS_PublishMULTILINEContent_0300 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishMULTILINEContent_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(6) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_LONG_TEXT) + */ + it('ACTS_PublishLONGContent_0100', 0,async function (done) { + await notification.publish({ + id: 7, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + },publishLONGContentCallback001); + console.log("============ACTS_PublishLONGContent_0100 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(7) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish() + */ + it('ACTS_PublishLONGContent_0200', 0,async function (done) { + await notification.publish({ + id: 8, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + },publishLONGContentCallback002); + console.log("============ACTS_PublishLONGContent_0200 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(8) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MEDIA) + */ + it('ACTS_PublishLONGContent_0300', 0,async function (done) { + await notification.publish({ + id: 9, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_MEDIA, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + },publishLONGContentCallback003); + console.log("============ACTS_PublishLONGContent_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(9) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_LONG_TEXT) promise + */ + it('ACTS_PublishLONGContent_0400', 0,async function (done) { + notification.publish({ + id: 10, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + }).then(console.log("============ACTS_PublishLONGContent_0400 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(10) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish() promise + */ + it('ACTS_PublishLONGContent_0500', 0,async function (done) { + notification.publish({ + id: 11, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + }).then(console.log("============ACTS_PublishLONGContent_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(11) + }) + + /* + * @tc.number: ACTS_PublishLONGContent_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MEDIA) promise + */ + it('ACTS_PublishLONGContent_0600', 0,async function (done) { + notification.publish({ + id: 12, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_MEDIA, + longText: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText", + longText:"longText", + briefText:"briefText", + expandedTitle:"expandedTitle" + }} + }).then(console.log("============ACTS_PublishLONGContent_0600 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishLONGContent_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(12) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION) + */ + it('ACTS_Publish_SlotTypeContent_0100', 0,async function (done) { + await notification.publish({ + id: 13, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.CONTENT_INFORMATION + },publishSlotTypeContentCallback001); + console.log("============ACTS_Publish_SlotTypeContent_0100 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(13) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:CONTENT_INFORMATION) + */ + it('ACTS_Publish_SlotTypeContent_0200', 0,async function (done) { + await notification.publish({ + id: 14, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.CONTENT_INFORMATION + },publishSlotTypeContentCallback002); + console.log("============ACTS_Publish_SlotTypeContent_0200 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(14) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) + */ + it('ACTS_Publish_SlotTypeContent_0300', 0,async function (done) { + await notification.publish({ + id: 15, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + // slotType:notification.SlotType.CONTENT_INFORMATION + },publishSlotTypeContentCallback003); + console.log("============ACTS_Publish_SlotTypeContent_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(15) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION) + */ + it('ACTS_Publish_SlotTypeContent_0400', 0,async function (done) { + await notification.publish({ + id: 16, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.SERVICE_INFORMATION + },publishSlotTypeContentCallback004); + console.log("============ACTS_Publish_SlotTypeContent_0400 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(16) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION) promise + */ + it('ACTS_Publish_SlotTypeContent_0500', 0,async function (done) { + notification.publish({ + id: 17, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.CONTENT_INFORMATION + }).then( console.log("============ACTS_Publish_SlotTypeContent_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(17) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:CONTENT_INFORMATION) promise + */ + it('ACTS_Publish_SlotTypeContent_0600', 0,async function (done) { + notification.publish({ + id: 18, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.CONTENT_INFORMATION + }).then(console.log("============ACTS_Publish_SlotTypeContent_0600 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(18) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0700 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise + */ + it('ACTS_Publish_SlotTypeContent_0700', 0,async function (done) { + notification.publish({ + id: 19, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + // slotType:notification.SlotType.CONTENT_INFORMATION + }).then(console.log("============ACTS_Publish_SlotTypeContent_0700 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0700====>"); + }, time); + expect(comsumData.request.id).assertEqual(19) + }) + + /* + * @tc.number: ACTS_Publish_SlotTypeContent_0800 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION) promise + */ + it('ACTS_Publish_SlotTypeContent_0800', 0,async function (done) { + notification.publish({ + id: 20, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + }, + slotType:notification.SlotType.SERVICE_INFORMATION + }).then(console.log("============ACTS_Publish_SlotTypeContent_0800 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_Publish_SlotTypeContent_0800====>"); + }, time); + expect(comsumData.request.id).assertEqual(20) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:OTHER_TYPES) + */ + it('ACTS_PublishSlotTypeOther_0100', 0,async function (done) { + await notification.publish({ + id:21, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.OTHER_TYPES + } + },publishSlotOtherCallback001); + console.log("============ACTS_PublishSlotTypeOther_0100 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(21) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:OTHER_TYPES) + */ + it('ACTS_PublishSlotTypeOther_0200', 0,async function (done) { + await notification.publish({ + id:22, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.OTHER_TYPES + } + },publishSlotOtherCallback002); + console.log("============ACTS_PublishSlotTypeOther_0200 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(22) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) + */ + it('ACTS_PublishSlotTypeOther_0300', 0,async function (done) { + await notification.publish({ + id:23, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + // slotType:notification.SlotType.OTHER_TYPES + } + },publishSlotOtherCallback003); + console.log("============ACTS_PublishSlotTypeOther_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(23) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION) + */ + it('ACTS_PublishSlotTypeOther_0400', 0,async function (done) { + await notification.publish({ + id:24, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + },publishSlotOtherCallback004); + console.log("============ACTS_PublishSlotTypeOther_0400 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(24) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:OTHER_TYPES) promise + */ + it('ACTS_PublishSlotTypeOther_0500', 0,async function (done) { + notification.publish({ + id:25, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.OTHER_TYPES + } + }).then(console.log("============ACTS_PublishSlotTypeOther_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(25) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:OTHER_TYPES) promise + */ + it('ACTS_PublishSlotTypeOther_0600', 0,async function (done) { + notification.publish({ + id:26, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.OTHER_TYPES + } + }).then(console.log("============ACTS_PublishSlotTypeOther_0600 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(26) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0700 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise + */ + it('ACTS_PublishSlotTypeOther_0700', 0,async function (done) { + notification.publish({ + id:27, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + // slotType:notification.SlotType.OTHER_TYPES + } + }).then(console.log("============ACTS_PublishSlotTypeOther_0700 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0700====>"); + }, time); + expect(comsumData.request.id).assertEqual(27) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeOther_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION) promise + */ + it('ACTS_PublishSlotTypeOther_0800', 0,async function (done) { + notification.publish({ + id:28, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + }).then(console.log("============ACTS_PublishSlotTypeOther_0800 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeOther_0800====>"); + }, time); + expect(comsumData.request.id).assertEqual(28) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION) + */ + it('ACTS_PublishSlotTypeService_0100', 0,async function (done) { + await notification.publish({ + id:29, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.SERVICE_INFORMATION + },publishSlotServiceCallback001); + console.log("============ACTS_PublishSlotTypeService_0100 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(29) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:SERVICE_INFORMATION) + */ + it('ACTS_PublishSlotTypeService_0200', 0,async function (done) { + await notification.publish({ + id: 30, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.SERVICE_INFORMATION + },publishSlotServiceCallback002); + console.log("============ACTS_PublishSlotTypeService_0200 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(30) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) + */ + it('ACTS_PublishSlotTypeService_0300', 0,async function (done) { + await notification.publish({ + id: 31, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + // slotType:notification.SlotType.SERVICE_INFORMATION + },publishSlotServiceCallback003); + console.log("============ACTS_PublishSlotTypeService_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(31) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:UNKNOWN_TYPE) + */ + it('ACTS_PublishSlotTypeService_0400', 0,async function (done) { + await notification.publish({ + id: 32, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.UNKNOWN_TYPE + },publishSlotServiceCallback004); + console.log("============ACTS_PublishSlotTypeService_0400 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(32) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION) promise + */ + it('ACTS_PublishSlotTypeService_0500', 0,async function (done) { + notification.publish({ + id: 33, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.SERVICE_INFORMATION + }).then(console.log("============ACTS_PublishSlotTypeService_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(33) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:SERVICE_INFORMATION) promise + */ + it('ACTS_PublishSlotTypeService_0600', 0,async function (done) { + notification.publish({ + id: 34, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.SERVICE_INFORMATION + }).then(console.log("============ACTS_PublishSlotTypeService_0600 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(34) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0700 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise + */ + it('ACTS_PublishSlotTypeService_0700', 0,async function (done) { + notification.publish({ + id: 35, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + // slotType:notification.SlotType.SERVICE_INFORMATION + }).then(console.log("============ACTS_PublishSlotTypeService_0700 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0700====>"); + }, time); + expect(comsumData.request.id).assertEqual(35) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeService_0800 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:UNKNOWN_TYPE) promise + */ + it('ACTS_PublishSlotTypeService_0800', 0,async function (done) { + notification.publish({ + id: 36, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + slotType:notification.SlotType.UNKNOWN_TYPE + }).then(console.log("============ACTS_PublishSlotTypeService_0800 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeService_0800====>"); + }, time); + expect(comsumData.request.id).assertEqual(36) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION) + */ + it('ACTS_PublishSlotTypeSocial_0100', 0,async function (done) { + await notification.publish({ + id: 37, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + },publishSlotSocialCallback001); + console.log("============ACTS_PublishSlotTypeSocial_0600 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0100====>"); + }, time); + expect(comsumData.request.id).assertEqual(37) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:SOCIAL_COMMUNICATION) + */ + it('ACTS_PublishSlotTypeSocial_0200', 0,async function (done) { + await notification.publish({ + id: 38, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + },publishSlotSocialCallback002); + console.log("============ACTS_PublishSlotTypeSocial_0600 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0200====>"); + }, time); + expect(comsumData.request.id).assertEqual(38) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0300 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) + */ + it('ACTS_PublishSlotTypeSocial_0300', 0,async function (done) { + await notification.publish({ + id: 39, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + // slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + },publishSlotSocialCallback003); + console.log("============ACTS_PublishSlotTypeSocial_0300 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0300====>"); + }, time); + expect(comsumData.request.id).assertEqual(39) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0400 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION) + */ + it('ACTS_PublishSlotTypeSocial_0400', 0,async function (done) { + await notification.publish({ + id: 40, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.CONTENT_INFORMATION + } + },publishSlotSocialCallback004); + console.log("============ACTS_PublishSlotTypeSocial_0400 finished============") + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0400====>"); + }, time); + expect(comsumData.request.id).assertEqual(40) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0500 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION) promise + */ + it('ACTS_PublishSlotTypeSocial_0500', 0,async function (done) { + notification.publish({ + id: 41, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + }).then(console.log("============ACTS_PublishSlotTypeSocial_0500 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0500====>"); + }, time); + expect(comsumData.request.id).assertEqual(41) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0600 + * @tc.name: publish() + * @tc.desc: verify the function of publish(slotType:SOCIAL_COMMUNICATION) promise + */ + it('ACTS_PublishSlotTypeSocial_0600', 0,async function (done) { + notification.publish({ + id: 42, + content: { + // contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + }).then(console.log("============ACTS_PublishSlotTypeSocial_0600 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0600====>"); + }, time); + expect(comsumData.request.id).assertEqual(42) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0700 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise + */ + it('ACTS_PublishSlotTypeSocial_0700', 0,async function (done) { + notification.publish({ + id: 43, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + // slotType:notification.SlotType.SOCIAL_COMMUNICATION + } + }).then(console.log("============ACTS_PublishSlotTypeSocial_0700 finished============"), + ) + done() + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0700====>"); + }, time); + expect(comsumData.request.id).assertEqual(43) + }) + + /* + * @tc.number: ACTS_PublishSlotTypeSocial_0800 + * @tc.name: publish() + * @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION) promise + */ + it('ACTS_PublishSlotTypeSocial_0800', 0,async function (done) { + notification.publish({ + id: 44, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + slotType:notification.SlotType.CONTENT_INFORMATION + } + }).then(console.log("============ACTS_PublishSlotTypeSocial_0800 finished============")) + done(); + setTimeout(function(){ + console.debug("====>time out ACTS_PublishSlotTypeSocial_0800====>"); + }, time); + expect(comsumData.request.id).assertEqual(44) + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/publish_test/publishcontentype/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishcontentype/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/publishcontentype/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/publishcontentype/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/subscribe/BUILD.gn b/notification/ans_standard/publish_test/subscribe/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a2b04dc63be55da8145a4f9c33205b8f037d333c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/BUILD.gn @@ -0,0 +1,25 @@ +# 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("//test/xts/tools/build/suite.gni") + +group("subscribe") { + testonly = true + if (is_standard_system) { + deps = [ + "publishfirst:ActsAnsPublishOneTest", + "publishsecond:ActsAnsPublishTwoTest", + "subscribe:ActsAnsSubscriberTest", + ] + } +} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/BUILD.gn b/notification/ans_standard/publish_test/subscribe/publishfirst/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9f205f33395723b30d707a5c54c49d74080fb87c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsPublishOneTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsPublishOneTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/Test.json b/notification/ans_standard/publish_test/subscribe/publishfirst/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..76d4dedbe985af96c43ce5255ee930d628e72559 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsanspublishonetest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsPublishOneTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/.gitignore b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3543521e9fef8e7322940a87c2b45dd0061b0f45 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/package.json b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/config.json b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..87172985b138bf2c3fcfb40c8866fbf857d4ccd6 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsanspublishonetest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsanspublishonetest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsanspublishonetest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..fc2437b2b0af5bd75dfc14e0ea743d011159ede3 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 发布接口调用 + +
diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e896cb97197887cb4e2ffe9fa7acf74be61160f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "publish" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..2907d31f53f87061a1a9d4d59ad367e6d261a0d3 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,46 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsAnsPublishOneTest', function () { + function publishCallback001(){ + console.log('ActsAnsPublishTest ACTS_PublishTest_0100 asyncCallback') + } + + /* + * @tc.number: ACTS_PublishTest_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish + */ + it('ACTS_PublishTest_0100', 0,async function (done) { + await notification.publish({ + id: 1, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test1_title", + text: "test1_text", + additionalText: "test1_additionalText" + }, + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION, + classification:"classification1", + sortingKey:"sortingKey1", + },publishCallback001); + done(); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishfirst/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishfirst/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/subscribe/publishfirst/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/publishfirst/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/BUILD.gn b/notification/ans_standard/publish_test/subscribe/publishsecond/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3136d32fdbfd033a9efed67a68b70d61245122ea --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsPublishTwoTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsPublishTwoTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/Test.json b/notification/ans_standard/publish_test/subscribe/publishsecond/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9c9a3aabb09bcb217240f053b152e5b4d300849c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsanspublishtwotest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsPublishTwoTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/.gitignore b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3543521e9fef8e7322940a87c2b45dd0061b0f45 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/package.json b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/config.json b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..cfa8a91f0e7874c6f4fb028027206c86f1b35729 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsanspublishtwotest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsanspublishtwotest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsanspublishtwotest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..b235e58c10080925fdcea67bc3da34a5cb097f9b --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 第二个发布接口 + +
diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2af91e1045f5460ee1cae9c38ef54f7cc158a4a0 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "publish2" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c2be5ce06737ea7c5c2d902be01f8a2a704c8a0c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,46 @@ +/* + * 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 notification from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsAnsPublishTwoTest', function () { + function publishCallback002(){ + console.log('ActsAnsPublishTest ACTS_PublishTest_0200 asyncCallback') + } + + /* + * @tc.number: ACTS_PublishTwoTest_0200 + * @tc.name: publish() + * @tc.desc: verify the function of publish + */ + it('ACTS_PublishTwoTest_0200', 0,async function (done) { + await notification.publish({ + id: 2, + content: { + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test2_title", + text: "test2_text", + additionalText: "test2_additionalText" + }, + }, + slotType:notification.SlotType.SOCIAL_COMMUNICATION, + classification:"classification2", + sortingKey:"sortingKey2", + },publishCallback002); + done(); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/publishsecond/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/publishsecond/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/subscribe/publishsecond/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/publishsecond/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/BUILD.gn b/notification/ans_standard/publish_test/subscribe/subscribe/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..47ae08aed320cd07fa5d97564dfa1e851a7ed091 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsSubscriberTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsSubscriberTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/Test.json b/notification/ans_standard/publish_test/subscribe/subscribe/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..40fa4640de566352afd604e687ad2f1888cd3171 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsanssubscribertest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsSubscriberTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/package.json b/notification/ans_standard/publish_test/subscribe/subscribe/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/config.json b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..b1343a9f3451353f85e8a72532bcee8d7814de70 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsanssubscribertest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsanssubscribertest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsanssubscribertest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..e42bdfdd29c1e18681d7f2924d1b98191d47fa4a --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 订阅发布 + +
diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..30895093f1f793272b0638cbde300dd08dfcf1c0 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Subscriber" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..41999288d49304127387014dc88894130a148ab4 --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./Subscriber.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/Subscriber.js b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/Subscriber.js new file mode 100644 index 0000000000000000000000000000000000000000..5c4d6a511b9e718de8cc2062adfa6d280cac8c1a --- /dev/null +++ b/notification/ans_standard/publish_test/subscribe/subscribe/entry/src/main/js/test/Subscriber.js @@ -0,0 +1,358 @@ +/* + * 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 notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsAnsSubscriberTest', function () { + console.info("===========ActsDoNotSubscriberTest start====================>"); + + //consume + function consumeCallbackOne(err,data) { + console.debug("==========================>consumeDoNotCallback1 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackTwo(err,data) { + console.debug("==========================>consumeDoNotCallback2 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackTree(err,data) { + console.debug("==========================>consumeDoNotCallback3 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackFour(err,data) { + console.debug("==========================>consumeDoNotCallback4 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackFive(err,data) { + console.debug("==========================>consumeDoNotCallback5 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackSix(err,data) { + console.debug("==========================>consumeDoNotCallback6 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackSeven(err,data) { + console.debug("==========================>consumeDoNotCallback7 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackEight(err,data) { + console.debug("==========================>consumeDoNotCallback8 data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbacka(err,data) { + console.debug("==========================>consumeCallbacka data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackb(err,data) { + console.debug("==========================>consumeCallbackb data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackc(err,data) { + console.debug("==========================>consumeCallbackc data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackd(err,data) { + console.debug("==========================>consumeCallbackd data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbacke(err,data) { + console.debug("==========================>consumeCallbacke data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + function consumeCallbackf(err,data) { + console.debug("==========================>consumeCallbackf data : =======================>" +err+ JSON.stringify(data)); + expect(typeof(data)).assertEqual("object") + } + //subscribeOn + function subscribeOnCallback(err) { + console.debug("==========================>subscribeDoNotOnCallback=======================>"); + } + //subscribe + function subscribeCallback(err) { + console.debug("==========================>subscribeDoNotCallback=======================>"); + + } + function publishCallback001(){ + console.log('ActsAnsSubscriberTest ACTS_Publish_0100 asyncCallback') + } + /* + * @tc.number: ActsDoNotSubscriber_test_0100 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0100', 0, async function (done) { + console.debug("===============ActsDoNotSubscriber_test_0100======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackOne, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, subscribeCallback); + } + catch(err) { + console.error('=ActsDoNotSubscriber_test_0100 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0100=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0200 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0200', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0200======begin====================>"); + var subInfo ={ + onConsumed:consumeCallbackTwo, + onConnected:subscribeOnCallback, + } + try{ + await notify.subscribe(subInfo,subscribeCallback); + await notify.subscribe(subInfo,subscribeCallback); + }catch(err) { + console.error('=ActsDoNotSubscriber_test_0200 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0200=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0300 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0300', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0300======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackTree, + onConnected:subscribeOnCallback, + } + var subInfo2 ={ + onConsumed:consumeCallbackFour, + onConnected:subscribeOnCallback, + } + try{ + await notify.subscribe(subInfo,subscribeCallback); + await notify.subscribe(subInfo2,subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0300 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0300=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0400 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0400', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0400======begin====================>"); + try{ + await notify.subscribe({ + onConsumed:consumeCallbackFive, + onConnected:subscribeOnCallback, + },subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0400 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0400=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0500 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0500', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0500======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackSix, + onConnected:subscribeOnCallback, + } + var subInfo2 ={ + onConsumed:consumeCallbackSeven, + onConnected:subscribeOnCallback, + } + try{ + await notify.subscribe(subInfo,subscribeCallback); + await notify.subscribe(subInfo,subscribeCallback); + await notify.subscribe(subInfo2,subscribeCallback); + await notify.subscribe({ + onConsumed:consumeCallbackEight, + onConnected:subscribeOnCallback, + },subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0500 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0500=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0600 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0600', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0600======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbacka, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest"]},subscribeCallback); + } + catch(err) { + console.error('=ActsSubscriber_test_0600 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0600=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0700 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0700', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0700======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackb, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest"]}).then( + console.log("ActsSubscriber_test_0700=======promise") + ); + } + catch(err) { + console.error('=ActsSubscriber_test_0700 订阅 promise err:'+err); + } + console.debug("===============ActsSubscriber_test_0700=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0800 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0800', 0, async function (done) { + console.debug("===============ActsDoNotSubscriber_test_0100======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackc, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest","com.neu.actsanspublishtwotest"]},subscribeCallback); + } + catch(err) { + console.error('=ActsSubscriber_test_0800 订阅 subscribeCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0800=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_0900 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0900', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0800======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackd, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest","com.neu.actsanspublishtwotest"],}).then( + console.log("ActsSubscriber_test_0900=======promise") + ); + } + catch(err) { + console.error('=ActsSubscriber_test_0900 订阅 promise err:'+err); + } + console.debug("===============ActsSubscriber_test_0900=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_1000 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_1000', 0, async function (done) { + console.debug("===============ActsSubscriber_test_1000======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbacke, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest","com.neu.actsanspublishonetest"]},subscribeCallback); + } + catch(err) { + console.error('=ActsSubscriber_test_1000 订阅 subscribeCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_1000=======end3===================>"); + done(); + }) + /* + * @tc.number: ActsSubscriber_test_1100 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_1100', 0, async function (done) { + console.debug("===============ActsSubscriber_test_1100======begin====================>"); + + var subInfo ={ + onConsumed:consumeCallbackf, + onConnected:subscribeOnCallback, + } + try { + await notify.subscribe(subInfo, {bundleNames:["com.neu.actsanspublishonetest","com.neu.actsanspublishonetest"]}).then( + console.log("ActsSubscriber_test_1100=======promise") + ); + } + catch(err) { + console.error('=ActsSubscriber_test_1100 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_1100=======end3===================>"); + done(); + }) + /* + * @tc.number: ACTS_publishTest_0100 + * @tc.name: publish() + * @tc.desc: verify the function of publish + */ + it('ACTS_publishTest_0100', 0,async function (done) { + await notify.publish({ + id: 1, + content: { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test1_title", + text: "test1_text", + additionalText: "test1_additionalText" + }, + }, + slotType:notify.SlotType.SOCIAL_COMMUNICATION, + classification:"classification1", + sortingKey:"sortingKey1", + },publishCallback001); + }) +}) + diff --git a/notification/ans_standard/publish_test/subscribe/subscribe/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/subscribe/subscribe/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/subscribe/subscribe/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/unsubscribe/BUILD.gn b/notification/ans_standard/publish_test/unsubscribe/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8c499e5be37ad7ecee772330bffde1b22e5630d7 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/BUILD.gn @@ -0,0 +1,31 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsUnSubscriberTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsUnSubscriberTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/unsubscribe/Test.json b/notification/ans_standard/publish_test/unsubscribe/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e5161e007ca60dc0b83c09f9083920ad18af8b06 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsansunsubscribertest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsUnSubscriberTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/package.json b/notification/ans_standard/publish_test/unsubscribe/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/config.json b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..0e966bd42b046c1e32c4cb558d83863534cef842 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.neu.actsansunsubscribertest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansunsubscribertest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansunsubscribertest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..778bf5f51bb09c729b47edf6d1695b65d1efd188 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 取消订阅 + +
diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * 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 file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..30895093f1f793272b0638cbde300dd08dfcf1c0 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Subscriber" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..41999288d49304127387014dc88894130a148ab4 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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. + */ +require('./Subscriber.js') \ No newline at end of file diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/Subscriber.js b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/Subscriber.js new file mode 100644 index 0000000000000000000000000000000000000000..192a180395bbf856d4080340928bf87d499e3c82 --- /dev/null +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/Subscriber.js @@ -0,0 +1,321 @@ +/* + * 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 notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var time = 1000 +describe('ActsAnsUnSubscriberTest', function () { + console.info("===========ActsDoNotSubscriberTest start====================>"); + //subscribeOn + function subscribeOnCallback(err) { + console.debug("==========================>subscribeDoNotOnCallback=======================>"); + } + //subscribe + function subscribeCallback(err) { + console.debug("==========================>subscribeDoNotCallback=======================>"); + + } + function unSubscribeCallbackOne(err) { + console.debug("==========================>unSubscribeCallbackOne=======================>"); + } + function unSubscribeCallbackTwo(err) { + console.debug("==========================>unSubscribeCallbackTwo=======================>"); + } + function unSubscribeCallbackThree(err) { + console.debug("==========================>unSubscribeCallbackThree=======================>"); + } + function unSubscribeCallbackFour(err) { + console.debug("==========================>unSubscribeCallbackFour=======================>"); + } + function unSubscribeCallbackFive(err) { + console.debug("==========================>unSubscribeCallbackFive=======================>"); + } + function unSubscribeCallbackSix(err) { + console.debug("==========================>unSubscribeCallbackSix=======================>"); + } + function unSubscribeCallbackSeven(err) { + console.debug("==========================>unSubscribeCallbackSeven=======================>"); + } + function unSubscribeCallbackEight(err) { + console.debug("==========================>unSubscribeCallbackEight=======================>"); + } + + function publishCallback001(){ + console.log('ActsAnsSubscriberTest ACTS_Publish_0100 asyncCallback') + } + + /* + * @tc.number: ActsDoNotSubscriber_test_0100 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0100', 0, async function (done) { + console.debug("===============ActsDoNotSubscriber_test_0100======begin====================>"); + + var subInfoOne ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackOne + } + try { + await notify.subscribe(subInfoOne, subscribeCallback); + } + catch(err) { + console.error('=ActsDoNotSubscriber_test_0100 订阅 subscribeDoNotCallback err:'+err); + } + try{ + await notify.unsubscribe(subInfoOne, unSubscribeCallbackOne); + } + catch(err) { + console.error('=ActsSubscriber_test_0100 取消订阅 unSubscribeCallbackOne err:'+err); + } + console.debug("===============ActsSubscriber_test_0100=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0100====>"); + }, time); + }) + /* + * @tc.number: ActsDoNotSubscriber_test_0200 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0200', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0200======begin====================>"); + + var subInfoOne ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackOne + } + try { + await notify.subscribe(subInfoOne, subscribeCallback); + } + catch(err) { + console.error('=ActsSubscriber_test_0200 订阅 subscribeDoNotCallback err:'+err); + } + try{ + notify.unsubscribe(subInfoOne).then(()=> + console.log("============promise============") + ) + } + catch(err) { + console.error('=ActsSubscriber_test_0200 取消订阅 unSubscribeCallbackOne err:'+err); + } + console.debug("===============ActsSubscriber_test_0200=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0200====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0300 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0300', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0300======begin====================>"); + var subInfoTwo ={ + // onConsumed:consumeCallbackTwo, + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackTwo + } + try{ + await notify.subscribe(subInfoTwo,subscribeCallback); + await notify.subscribe(subInfoTwo,subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0300 订阅 subscribeDoNotCallback err:'+err); + } + try{ + await notify.unsubscribe(subInfoTwo, unSubscribeCallbackTwo); + await notify.unsubscribe(subInfoTwo, unSubscribeCallbackTwo); + } + catch(err) { + console.error('=ActsSubscriber_test_0300 取消订阅 unSubscribeCallbackOne err:'+err); + } + console.debug("===============ActsSubscriber_test_0300=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0300====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0400 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0400', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0400======begin====================>"); + var subInfoTwo ={ + // onConsumed:consumeCallbackTwo, + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackTwo + } + try{ + await notify.subscribe(subInfoTwo,subscribeCallback); + await notify.subscribe(subInfoTwo,subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0400 订阅 subscribeDoNotCallback err:'+err); + } + try{ + notify.unsubscribe(subInfoTwo).then( + console.log("=======unsubscribeTwo Promise=======") + ) + notify.unsubscribe(subInfoTwo).then( + console.log("=======unsubscribeTwo Promise=======") + ) + } + catch(err) { + console.error('=ActsSubscriber_test_0400 取消订阅 unSubscribeCallbackOne err:'+err); + } + console.debug("===============ActsSubscriber_test_0400=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0400====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0500 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0500', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0500======begin====================>"); + + var subInfo1 ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackThree, + } + var subInfo2 ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFour, + } + try{ + await notify.subscribe(subInfo1,subscribeCallback); + await notify.subscribe(subInfo2,subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0500 订阅 subscribeDoNotCallback err:'+err); + } + try{ + await notify.unsubscribe(subInfo1, unSubscribeCallbackThree); + await notify.unsubscribe(subInfo2, unSubscribeCallbackFour); + } + catch(err) { + console.error('=ActsSubscriber_test_0500 取消订阅 unSubscribeCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0500=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0500====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0600 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0600', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0600======begin====================>"); + + var subInfo1 ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackThree, + } + var subInfo2 ={ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFour, + } + try{ + await notify.subscribe(subInfo1,subscribeCallback); + await notify.subscribe(subInfo2,subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0600 订阅 subscribeDoNotCallback err:'+err); + } + try{ + notify.unsubscribe(subInfo1).then( + console.log("=======unsubscribeTree Promise=======") + ) + notify.unsubscribe(subInfo2).then( + console.log("=======unsubscribeTree Promise=======") + ) + } + catch(err) { + console.error('=ActsSubscriber_test_0600 取消订阅 unSubscribeCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0600=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0600====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0700 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0700', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0700======begin====================>"); + try{ + await notify.subscribe({ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFive + },subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0700 订阅 subscribeDoNotCallback err:'+err); + } + try{ + await notify.unsubscribe({ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFive + },unSubscribeCallbackFive); + }catch(err) { + console.error('=ActsSubscriber_test_0700 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0700=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0700====>"); + }, time); + }) + /* + * @tc.number: ActsSubscriber_test_0800 + * @tc.name: subscribe() + * @tc.desc: verify the function of subscribe + */ + it('ActsSubscriber_test_0800', 0, async function (done) { + console.debug("===============ActsSubscriber_test_0800======begin====================>"); + try{ + await notify.subscribe({ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFive + },subscribeCallback); + }catch(err) { + console.error('=ActsSubscriber_test_0800 订阅 subscribeDoNotCallback err:'+err); + } + try{ + notify.unsubscribe({ + onConnecte:subscribeOnCallback, + onDestroy:unSubscribeCallbackFive + }).then( + console.log("=======unsubscribeFour Promise=======") + ) + }catch(err) { + console.error('=ActsSubscriber_test_0800 订阅 subscribeDoNotCallback err:'+err); + } + console.debug("===============ActsSubscriber_test_0800=======end3===================>"); + done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriber_test_0800====>"); + }, time); + }) +}) + diff --git a/notification/ans_standard/publish_test/unsubscribe/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/unsubscribe/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/unsubscribe/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/wantagent/sub/entry/src/main/js/test/Subscriber.js b/notification/ans_standard/publish_test/wantagent/sub/entry/src/main/js/test/Subscriber.js index ba431795376f870fa97cf5b6e2d13ae028a6f92d..fb36e13c234e17e17583e908d143a3a921e260c2 100644 --- a/notification/ans_standard/publish_test/wantagent/sub/entry/src/main/js/test/Subscriber.js +++ b/notification/ans_standard/publish_test/wantagent/sub/entry/src/main/js/test/Subscriber.js @@ -20,6 +20,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' var commonEventSubscribeInfo; var commonEventSubscriber; var WantAgent; +var time = 1000 describe('ActsAnsActiveSubscriberTest', function () { console.info("===========ActsSubscriberTest start====================>"); @@ -64,6 +65,9 @@ describe('ActsAnsActiveSubscriberTest', function () { }) console.info("===============ActsSubscriberTestUnorder_0100==============================>"); done(); + setTimeout(function(){ + console.debug("====>time out ActsSubscriberTestUnorder_0100====>"); + }, time) }) })