• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2021 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7*     http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import notify from '@ohos.notification'
17import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
18let timeout = 500;
19describe('ActsAnsNotificationCancel', function () {
20    console.info('===========ActsAnsNotificationCancel start====================>');
21    let timesOfOnConsume
22    function onConsumeCancelAll(data) {
23        console.info('================ANS_Cancel_0100 onConsume start=======================>');
24        console.info('================ANS_Cancel_0100 onConsume data:=================>' + JSON.stringify(data));
25        timesOfOnConsume = timesOfOnConsume + 1
26        if (timesOfOnConsume == 2){
27            notify.cancelAll(cancelAllCallBack);
28            console.info('================ANS_Cancel_0100 onConsume cancelAll=======================>');
29        }
30        console.info('================ANS_Cancel_0100 onConsume end=======================>');
31    }
32    let timesOfOnCancel
33    function onCancelCancelAll(data) {
34        console.info('================ANS_Cancel_0100 onCancel start===============>');
35        console.info('================ANS_Cancel_0100 onCancel data:===============>' + JSON.stringify(data));
36        timesOfOnCancel = timesOfOnCancel + 1
37        if (timesOfOnCancel == 1){
38            expect(data.request.id).assertEqual(1);
39        } else if (timesOfOnCancel == 2){
40            expect(data.request.id).assertEqual(2);
41        }
42        console.info('================ANS_Cancel_0100 onCancel end=======================>');
43    }
44    function cancelAllCallBack(err, data){
45        console.info('========ANS_Cancel_0100 cancelAllCallBack start==============>');
46        console.info('========ANS_Cancel_0100 cancelAllCallBack data===============>' + JSON.stringify(data));
47        console.info('========ANS_Cancel_0100 cancelAllCallBack err================>' + JSON.stringify(err));
48        console.info('========ANS_Cancel_0100 cancelAllCallBack end================>');
49    }
50
51    /*
52     * @tc.number: ANS_Cancel_0100
53     * @tc.name: cancelAll(callback: AsyncCallback<void>): void;
54     * @tc.desc: Verify that the application successfully cancels all its published notifications by calling the
55                 cancelAll(callback: AsyncCallback<void>) interface
56     */
57    it('ANS_Cancel_0100', 0, async function (done) {
58        console.info('==================ANS_Cancel_0100 start==================>');
59        timesOfOnConsume = 0
60        timesOfOnCancel = 0
61        let subscriber ={
62            onConsume:onConsumeCancelAll,
63            onCancel:onCancelCancelAll,
64        }
65        let notificationRequest = {
66            content:{
67                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
68                normal: {
69                    title: 'test_title',
70                    text: 'test_text',
71                    additionalText: 'test_additionalText'
72                },
73            },
74            id: 1,
75            slotType : notify.SlotType.OTHER_TYPES,
76            isOngoing : true,
77            isUnremovable : false,
78            deliveryTime : 1624950453,
79            tapDismissed : true,
80            autoDeletedTime: 1625036817,
81            color: 2,
82            colorEnabled: true,
83            isAlertOnce: true,
84            isStopwatch: true,
85            isCountDown: true,
86            progressValue: 12,
87            progressMaxValue: 100,
88            isIndeterminate: true,
89            statusBarText: 'statusBarText',
90            isFloatingIcon : true,
91            label: '0100_1',
92            badgeIconStyle: 1,
93            showDeliveryTime: true,
94        }
95        let notificationRequest1 = {
96            content:{
97                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
98                normal: {
99                    title: 'test_title',
100                    text: 'test_text',
101                    additionalText: 'test_additionalText'
102                },
103            },
104            id: 2,
105            slotType : notify.SlotType.OTHER_TYPES,
106            isOngoing : true,
107            isUnremovable : false,
108            deliveryTime : 1624950453,
109            tapDismissed : true,
110            autoDeletedTime: 1625036817,
111            color: 2,
112            colorEnabled: true,
113            isAlertOnce: true,
114            isStopwatch: true,
115            isCountDown: true,
116            progressValue: 12,
117            progressMaxValue: 100,
118            isIndeterminate: true,
119            statusBarText: 'statusBarText',
120            isFloatingIcon : true,
121            label: '0100_2',
122            badgeIconStyle: 1,
123            showDeliveryTime: true,
124        }
125        await notify.subscribe(subscriber);
126        console.info('===========ANS_Cancel_0100 subscribe promise=======>');
127        await notify.publish(notificationRequest);
128        console.info('===========ANS_Cancel_0100 publish1 promise=======>');
129        await notify.publish(notificationRequest1);
130        console.info('===========ANS_Cancel_0100 publish2 promise=======>');
131        setTimeout((async function(){
132            console.info('======ANS_Cancel_0100 setTimeout==================>');
133            await notify.unsubscribe(subscriber);
134            console.info('======ANS_Cancel_0100 setTimeout unsubscribe==================>');
135            done();
136        }),timeout);
137    })
138
139
140    function onConsumeCancelAllPromise(data) {
141        timesOfOnConsume = timesOfOnConsume + 1
142        console.info('================ANS_Cancel_0200 onConsume start===========>');
143        console.info('================ANS_Cancel_0200 onConsume data:============>' + JSON.stringify(data));
144        if (timesOfOnConsume == 2){
145            notify.cancelAll();
146            console.info('==========ANS_Cancel_0200 onConsume cancelAll promise==========>');
147        }
148        console.info('================ANS_Cancel_0200 onConsume end===============>');
149    }
150
151    function onCancelCancelAllPromise(data) {
152        timesOfOnCancel = timesOfOnCancel + 1
153        console.info('=========ANS_Cancel_0200 onCancel start==========>');
154        console.info('=========ANS_Cancel_0200 onCancel data:==========>' + JSON.stringify(data));
155        if (timesOfOnCancel == 1){
156            expect(data.request.id).assertEqual(1);
157        } else if (timesOfOnCancel == 2){
158            expect(data.request.id).assertEqual(2);
159        }
160        console.info('==========ANS_Cancel_0200 onCancel end=======================>');
161    }
162
163    /*
164     * @tc.number: ANS_Cancel_0200
165     * @tc.name: cancelAll(): Promise<void>;
166     * @tc.desc: Verify that the application successfully cancels all its published notifications by
167                 calling the  cancelAll(): Promise<void> interface
168     */
169    it('ANS_Cancel_0200', 0, async function (done) {
170        console.info('===============ANS_Cancel_0200 start==========================>');
171        timesOfOnConsume = 0
172        timesOfOnCancel = 0
173        let subscriber ={
174            onConsume:onConsumeCancelAllPromise,
175            onCancel:onCancelCancelAllPromise,
176        }
177        await notify.subscribe(subscriber);
178        console.info('==================ANS_Cancel_0200 subscribe promise==================>');
179        let notificationRequest = {
180            content:{
181                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
182                normal: {
183                    title: 'test_title',
184                    text: 'test_text',
185                    additionalText: 'test_additionalText'
186                },
187            },
188            id: 1,
189            slotType : notify.SlotType.OTHER_TYPES,
190            isOngoing : true,
191            isUnremovable : false,
192            deliveryTime : 1624950453,
193            tapDismissed : true,
194            autoDeletedTime: 1625036817,
195            color: 2,
196            colorEnabled: true,
197            isAlertOnce: true,
198            isStopwatch: true,
199            isCountDown: true,
200            progressValue: 12,
201            progressMaxValue: 100,
202            isIndeterminate: true,
203            statusBarText: 'statusBarText',
204            isFloatingIcon : true,
205            label: '0200',
206            badgeIconStyle: 1,
207            showDeliveryTime: true,
208        }
209        let notificationRequest1 = {
210            content:{
211                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
212                normal: {
213                    title: 'test_title',
214                    text: 'test_text',
215                    additionalText: 'test_additionalText'
216                },
217            },
218            id: 2,
219            slotType : notify.SlotType.OTHER_TYPES,
220            isOngoing : true,
221            isUnremovable : false,
222            deliveryTime : 1624950453,
223            tapDismissed : true,
224            autoDeletedTime: 1625036817,
225            color: 2,
226            colorEnabled: true,
227            isAlertOnce: true,
228            isStopwatch: true,
229            isCountDown: true,
230            progressValue: 12,
231            progressMaxValue: 100,
232            isIndeterminate: true,
233            statusBarText: 'statusBarText',
234            isFloatingIcon : true,
235            label: '0200',
236            badgeIconStyle: 1,
237            showDeliveryTime: true,
238        }
239        await notify.publish(notificationRequest);
240        console.info('==========ANS_Cancel_0200 publish1 promise==================>');
241        await notify.publish(notificationRequest1);
242        console.info('==========ANS_Cancel_0200 publish2 promise==================>');
243        setTimeout((async function(){
244            await notify.unsubscribe(subscriber);
245            console.info('======ANS_Cancel_0200 setTimeout unsubscribe end==================>');
246            done();
247        }),timeout);
248    })
249
250    function onConsumeCancelAllNoNotify(data) {
251        console.info('================ANS_Cancel_0300 onConsume start========>');
252        console.info('================ANS_Cancel_0300 onConsume data:========>' + JSON.stringify(data));
253        expect().assertFail();
254        console.info('================ANS_Cancel_0300 onConsume end=======================>');
255    }
256    function onCancelCancelAllNoNotify(data) {
257        console.info('=================ANS_Cancel_0300 onCancel start=============>');
258        expect().assertFail();
259        console.info('================ANS_Cancel_0300 onCancel data:==============>' + JSON.stringify(data));
260        console.info('================ANS_Cancel_0300 onCancel end================>');
261    }
262    function cancelAllCallBackNoNotify(err, data){
263        console.info('==========ANS_Cancel_0300 cancelAllCallBack start=============>');
264        console.info('==========ANS_Cancel_0300 cancelAllCallBack data:=============>' + JSON.stringify(data));
265        console.info('==========ANS_Cancel_0300 cancelAllCallBack  err:=============>' + JSON.stringify(err));
266        console.info('==========ANS_Cancel_0300 cancelAllCallBack end===============>');
267    }
268
269    /*
270     * @tc.number: ANS_Cancel_0300
271     * @tc.name: cancelAll(callback: AsyncCallback<void>): void
272     * @tc.desc: Verify that when there is no notification in the notification list,
273                 call the cancelAll(callback: AsyncCallback<void>): void interface,
274                 and the application cancels all its published notifications.
275                 At this time, no notification information is cancelled,
276                 and there is no OnCancel notification(Callback mode)
277     */
278    it('ANS_Cancel_0300', 0, async function (done) {
279        console.info('===============ANS_Cancel_0300 start==========================>');
280        let subscriber ={
281            onConsume:onConsumeCancelAllNoNotify,
282            onCancel:onCancelCancelAllNoNotify,
283        }
284        await notify.subscribe(subscriber);
285        console.info('===============ANS_Cancel_0300 subscribe promise===============>');
286        await notify.cancelAll(cancelAllCallBackNoNotify);
287        console.info('===============ANS_Cancel_0300 cancelAll promise===============>');
288        setTimeout((async function(){
289            await notify.unsubscribe(subscriber);
290            console.info('======ANS_Cancel_0300 setTimeout unsubscribe end==================>');
291            done();
292        }),timeout);
293    })
294
295    function onConsumeCancelAllNoNotifyPromise(data) {
296        console.info('================ANS_Cancel_0400 onConsume===============>');
297        console.info('================ANS_Cancel_0400 onConsume data:===========>' + JSON.stringify(data));
298        expect().assertFail();
299        console.info('================ANS_Cancel_0400 onConsume end===========>');
300    }
301    function onCancelCancelAllNoNotifyPromise(data) {
302        console.info('===============ANS_Cancel_0400 onCancel ==================>');
303        console.info('===============ANS_Cancel_0400 onCancel data==============>' + JSON.stringify(data));
304        expect().assertFail();
305        console.info('===============ANS_Cancel_0400 onCancel end===============>');
306    }
307
308    /*
309     * @tc.number: ANS_Cancel_0400
310     * @tc.name: cancelAll(): Promise<void>;
311     * @tc.desc: Verify that when there is no notification in the notification list,
312                 call the cancelAll(callback: AsyncCallback<void>): void interface,
313                 and the application cancels all its published notifications.
314                 At this time, no notification information is cancelled,
315                 and there is no OnCancel notification( Callback mode)
316     */
317    it('ANS_Cancel_0400', 0, async function (done) {
318        console.info('===============ANS_Cancel_0400 start==========================>');
319        let subscriber ={
320            onConsume:onConsumeCancelAllNoNotifyPromise,
321            onCancel:onCancelCancelAllNoNotifyPromise,
322        }
323        await notify.subscribe(subscriber);
324        console.info('================ANS_Cancel_0400 subscribe promise=============>');
325        await notify.cancelAll();
326        console.info('================ANS_Cancel_0400 cancelAll promise=============>');
327        setTimeout((async function(){
328            await notify.unsubscribe(subscriber);
329            console.info('======ANS_Cancel_0400 setTimeout unsubscribe end==================>');
330            done();
331        }),timeout);
332
333    })
334
335    function onConsumeCancelAll2Times(data) {
336        console.info('==========ANS_Cancel_0500 onConsume start==============>');
337        console.info('==========ANS_Cancel_0500 onConsume data:==============>' + JSON.stringify(data));
338        notify.cancelAll(cancelAllCallBack2Times1);
339        console.info('==========ANS_Cancel_0500 onConsume cancelAll=================>');
340        console.info('==========ANS_Cancel_0500 onConsume end=======================>');
341    }
342
343    function onCancelCancelAll2Times(data) {
344        console.info('=========ANS_Cancel_0500 onCancel start===============>');
345        console.info('=========ANS_Cancel_0500 onCancel data:===============>' + JSON.stringify(data));
346        timesOfOnCancel = timesOfOnCancel + 1
347        if (timesOfOnCancel == 1){
348            expect(data.request.id).assertEqual(5);
349        } else if (timesOfOnCancel){
350            expect(data.request.id).assertEqual(0);
351        }
352        console.info('==========ANS_Cancel_0500 onCancel end===============>');
353    }
354    function cancelAllCallBack2Times1(err){
355        console.info('==========ANS_Cancel_0500 cancelAllCallBack1 start==========>');
356        console.info('==========ANS_Cancel_0500 cancelAllCallBack1 err:===========>' + JSON.stringify(err));
357        notify.cancelAll(cancelAllCallBack2Times2);
358        console.info('==========ANS_Cancel_0500 cancelAllCallBack1 cancelAll======>');
359        console.info('==========ANS_Cancel_0500 cancelAllCallBack1  end===========>');
360    }
361    function cancelAllCallBack2Times2(err){
362        console.info('==========ANS_Cancel_0500 cancelAllCallBack2 start=============>');
363        console.info('==========ANS_Cancel_0500 cancelAllCallBack2 err:==============>' + JSON.stringify(err));
364        console.info('==========ANS_Cancel_0500 cancelAllCallBack2 end===============>');
365    }
366
367    /*
368     * @tc.number: ANS_Cancel_0500
369     * @tc.name: cancelAll(callback: AsyncCallback<void>): void
370     * @tc.desc: Verify that all notifications are cancelled successfully
371                 by calling the cancelAll(callback: AsyncCallback<void>): void interface,
372                 and then cancel the notification again
373     */
374    it('ANS_Cancel_0500', 0, async function (done) {
375        console.info('============ANS_Cancel_0500 start==================>');
376        timesOfOnCancel = 0
377        let subscriber ={
378            onConsume:onConsumeCancelAll2Times,
379            onCancel:onCancelCancelAll2Times,
380        }
381        await notify.subscribe(subscriber);
382        console.info('============ANS_Cancel_0500 subscribe promise======>');
383        let notificationRequest = {
384            content:{
385                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
386                normal: {
387                    title: 'test_title',
388                    text: 'test_text',
389                    additionalText: 'test_additionalText'
390                },
391            },
392            id: 5,
393            slotType : notify.SlotType.OTHER_TYPES,
394            isOngoing : true,
395            isUnremovable : false,
396            deliveryTime : 1624950453,
397            tapDismissed : true,
398            autoDeletedTime: 1625036817,
399            color: 2,
400            colorEnabled: true,
401            isAlertOnce: true,
402            isStopwatch: true,
403            isCountDown: true,
404            progressValue: 12,
405            progressMaxValue: 100,
406            isIndeterminate: true,
407            statusBarText: 'statusBarText',
408            isFloatingIcon : true,
409            label: '0500',
410            badgeIconStyle: 1,
411            showDeliveryTime: true,
412        }
413        await notify.publish(notificationRequest);
414        console.info('==============ANS_Cancel_0500 publish promise end==============>');
415        setTimeout((async function(){
416            await notify.unsubscribe(subscriber);
417            console.info('======ANS_Cancel_0500 setTimeout unsubscribe end==================>');
418            done();
419        }),timeout);
420    })
421
422    function onConsumeCancelAll2TimesPromise(data) {
423        console.info('==========ANS_Cancel_0600 onConsume start============>');
424        console.info('==========ANS_Cancel_0600 onConsume data=============>' + JSON.stringify(data));
425        notify.cancelAll();
426        console.info('==========ANS_Cancel_0600 onConsume cancelAll 2times1 end======>');
427        notify.cancelAll();
428        console.info('==========ANS_Cancel_0600 onConsume cancelAll 2times2 end======>');
429        console.info('==========ANS_Cancel_0600 onConsume end========>');
430    }
431    function onCancelCancelAll2TimesPromise(data) {
432        timesOfOnCancel = timesOfOnCancel + 1
433        console.info('==========ANS_Cancel_0600 onCancel===================>');
434        console.info('==========ANS_Cancel_0600 onCancel data:============>' + JSON.stringify(data));
435        if (timesOfOnCancel == 1){
436            expect(data.request.id).assertEqual(6);
437        } else if (timesOfOnCancel == 2){
438            expect().assertFail();
439        }
440        console.info('==========ANS_Cancel_0600 onCancel end=============>');
441    }
442
443    /*
444     * @tc.number: ANS_Cancel_0600
445     * @tc.name: cancelAll(): Promise<void>;
446     * @tc.desc: Verify that all notifications are cancelled successfully by calling the
447                 cancelAll(): Promise<void> interface, and then cancel the notification again
448     */
449    it('ANS_Cancel_0600', 0, async function (done) {
450        console.info('===============ANS_Cancel_0600 start==========================>');
451        timesOfOnCancel = 0
452        let subscriber ={
453            onConsume:onConsumeCancelAll2TimesPromise,
454            onCancel:onCancelCancelAll2TimesPromise,
455        }
456        await notify.subscribe(subscriber);
457        console.info('==================ANS_Cancel_0600 subscribe promise==================>');
458        let notificationRequest = {
459            content:{
460                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
461                normal: {
462                    title: 'test_title',
463                    text: 'test_text',
464                    additionalText: 'test_additionalText'
465                },
466            },
467            id: 6,
468            slotType : notify.SlotType.OTHER_TYPES,
469            isOngoing : true,
470            isUnremovable : false,
471            deliveryTime : 1624950453,
472            tapDismissed : true,
473            autoDeletedTime: 1625036817,
474            color: 2,
475            colorEnabled: true,
476            isAlertOnce: true,
477            isStopwatch: true,
478            isCountDown: true,
479            progressValue: 12,
480            progressMaxValue: 100,
481            isIndeterminate: true,
482            statusBarText: 'statusBarText',
483            isFloatingIcon : true,
484            label: '0600',
485            badgeIconStyle: 1,
486            showDeliveryTime: true,
487        }
488        await notify.publish(notificationRequest);
489        console.info('==================ANS_Cancel_0600 publish promise==================>');
490        setTimeout((async function(){
491            await notify.unsubscribe(subscriber);
492            console.info('======ANS_Cancel_0600 setTimeout unsubscribe end==================>');
493            done();
494        }),timeout);
495    })
496
497    function onConsumeCancelAllIsUnremovable(data) {
498        console.info('========ANS_Cancel_0700 onConsume start===========>');
499        console.info('========ANS_Cancel_0700 onConsume data: ===========>' + JSON.stringify(data));
500        notify.cancelAll(cancelAllCallBackIsUnremovable);
501        console.info('========ANS_Cancel_0700 onConsume cancelAll===========>');
502        console.info('========ANS_Cancel_0700 onConsume end============>');
503    }
504    function onCancelCancelAllIsUnremovable(data) {
505        console.info('================ANS_Cancel_0700 onCancel start=======================>');
506        console.info('================ANS_Cancel_0700 onCancel data:====================>' + JSON.stringify(data));
507        expect(data.request.id).assertEqual(7);
508        console.info('================ANS_Cancel_0700 onCancel end=======================>');
509    }
510    function cancelAllCallBackIsUnremovable(err, data){
511        console.info('===========ANS_Cancel_0700 cancelAllCallBack start==========>');
512        console.info('===========ANS_Cancel_0700 cancelAllCallBack err:===========>' + JSON.stringify(err));
513        console.info('===========ANS_Cancel_0700 cancelAllCallBack data:==========>' + JSON.stringify(data));
514        console.info('===========ANS_Cancel_0700 cancelAllCallBack end=======================>');
515    }
516
517    /*
518     * @tc.number: ANS_Cancel_0700
519     * @tc.name: cancelAll(callback: AsyncCallback<void>): void;
520     * @tc.desc: Verify that by calling the cancelAll(callback: AsyncCallback<void>): void;
521                 interface, the application successfully cancels all the notifications
522                 that isUnremovable is true that it has published
523     */
524    it('ANS_Cancel_0700', 0, async function (done) {
525        console.info('===============ANS_Cancel_0700 start==========================>');
526        let subscriber ={
527            onConsume:onConsumeCancelAllIsUnremovable,
528            onCancel:onCancelCancelAllIsUnremovable,
529        }
530        await notify.subscribe(subscriber);
531        console.info('========ANS_Cancel_0700 subscribe promise==================>');
532        let notificationRequest = {
533            content:{
534                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
535                normal: {
536                    title: 'test_title',
537                    text: 'test_text',
538                    additionalText: 'test_additionalText'
539                },
540            },
541            id: 7,
542            slotType : notify.SlotType.OTHER_TYPES,
543            isOngoing : true,
544            isUnremovable : true,
545            deliveryTime : 1624950453,
546            tapDismissed : true,
547            autoDeletedTime: 1625036817,
548            color: 2,
549            colorEnabled: true,
550            isAlertOnce: true,
551            isStopwatch: true,
552            isCountDown: true,
553            progressValue: 12,
554            progressMaxValue: 100,
555            isIndeterminate: true,
556            statusBarText: 'statusBarText',
557            isFloatingIcon : true,
558            label: '0700',
559            badgeIconStyle: 1,
560            showDeliveryTime: true,
561        }
562        await notify.publish(notificationRequest);
563        console.info('===========ANS_Cancel_0700 publish promise==================>');
564        setTimeout((async function(){
565            await notify.unsubscribe(subscriber);
566            console.info('======ANS_Cancel_0700 setTimeout unsubscribe end==================>');
567            done();
568        }),timeout);
569    })
570
571    function onConsumeCancelAllIsUnremovablPromise(data) {
572        console.info('================ANS_Cancel_0800 onConsume start=============>');
573        console.info('================ANS_Cancel_0800 onConsume data:=============>' + JSON.stringify(data));
574        notify.cancelAll();
575        console.info('================ANS_Cancel_0800 cancelAll==========>');
576        console.info('================ANS_Cancel_0800 onConsume end===============>');
577    }
578    function onCancelCancelAllIsUnremovablePromise(data) {
579        console.info('================ANS_Cancel_0800 onCancel start================>');
580        console.info('================ANS_Cancel_0800 onCancel data :===============>' + JSON.stringify(data));
581        expect(data.request.id).assertEqual(8);
582        console.info('================ANS_Cancel_0800 onCancel end================>');
583    }
584
585    /*
586     * @tc.number: ANS_Cancel_0800
587     * @tc.name: cancelAll(): Promise<void>;
588     * @tc.desc: Verify that by calling the cancelAll(): Promise<void> interface,
589                 the application successfully cancels all the notifications
590                 that isUnremovable is true that it has published
591     */
592    it('ANS_Cancel_0800', 0, async function (done) {
593        console.info('===============ANS_Cancel_0800 start==========================>');
594        let subscriber ={
595            onConsume:onConsumeCancelAllIsUnremovablPromise,
596            onCancel:onCancelCancelAllIsUnremovablePromise,
597        }
598        await notify.subscribe(subscriber);
599        console.info('==================ANS_Cancel_0800 subscribe promsie==================>');
600        let notificationRequest = {
601            content:{
602                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
603                normal: {
604                    title: 'test_title',
605                    text: 'test_text',
606                    additionalText: 'test_additionalText'
607                },
608            },
609            id: 8,
610            slotType : notify.SlotType.OTHER_TYPES,
611            isOngoing : true,
612            isUnremovable : true,
613            deliveryTime : 1624950453,
614            tapDismissed : true,
615            autoDeletedTime: 1625036817,
616            color: 2,
617            colorEnabled: true,
618            isAlertOnce: true,
619            isStopwatch: true,
620            isCountDown: true,
621            progressValue: 12,
622            progressMaxValue: 100,
623            isIndeterminate: true,
624            statusBarText: 'statusBarText',
625            isFloatingIcon : true,
626            label: '0800',
627            badgeIconStyle: 1,
628            showDeliveryTime: true,
629        }
630        await notify.publish(notificationRequest);
631        console.info('=========ANS_Cancel_0800 publish promise==================>');
632        setTimeout((async function(){
633            await notify.unsubscribe(subscriber);
634            console.info('======ANS_Cancel_0800 setTimeout unsubscribe end==================>');
635            done();
636        }),timeout);
637    })
638
639    function onConsumeCancel(data) {
640        console.info('=========ANS_Cancel_0900 onConsume start================>');
641        console.info('=========ANS_Cancel_0900 onConsume data:================>' + JSON.stringify(data));
642        notify.cancel(data.request.id,cancelCallBackCancel);
643        console.info('=========ANS_Cancel_0900 onConsume cancel=============>');
644        console.info('=========ANS_Cancel_0900 onConsume end================>');
645    }
646    function onCancelCancel(data) {
647        console.info('=========ANS_Cancel_0900 onCancel start================>');
648        console.info('=========ANS_Cancel_0900 onCancel data:================>' + JSON.stringify(data));
649        expect(data.request.id).assertEqual(9);
650        console.info('=========ANS_Cancel_0900 onCancel end================>');
651    }
652    function cancelCallBackCancel(err){
653        console.info('===========ANS_Cancel_0900 cancelCallBack start================>');
654        console.info('===========ANS_Cancel_0900 cancelCallBack err:=================>' + JSON.stringify(err));
655        console.info('===========ANS_Cancel_0900 cancelCallBack end==================>');
656    }
657
658    /*
659     * @tc.number: ANS_Cancel_0900
660     * @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
661     * @tc.desc: Verify that the specific ID notification is cancelled successfully by calling
662                 the cancel(id: number, callback: AsyncCallback<void>): void; interface
663     */
664    it('ANS_Cancel_0900', 0, async function (done) {
665        console.info('===============ANS_Cancel_0900 start==========================>');
666        let subscriber ={
667            onConsume:onConsumeCancel,
668            onCancel:onCancelCancel,
669        }
670        await notify.subscribe(subscriber);
671        console.info('==================ANS_Cancel_0900 subscribe promise==================>');
672        let notificationRequest = {
673            content:{
674                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
675                normal: {
676                    title: 'test_title',
677                    text: 'test_text',
678                    additionalText: 'test_additionalText'
679                },
680            },
681            id: 9,
682            slotType : notify.SlotType.OTHER_TYPES,
683            isOngoing : true,
684            isUnremovable : false,
685            deliveryTime : 1624950453,
686            tapDismissed : true,
687            autoDeletedTime: 1625036817,
688            color: 2,
689            colorEnabled: true,
690            isAlertOnce: true,
691            isStopwatch: true,
692            isCountDown: true,
693            progressValue: 12,
694            progressMaxValue: 100,
695            isIndeterminate: true,
696            statusBarText: 'statusBarText',
697            isFloatingIcon : true,
698            badgeIconStyle: 1,
699            showDeliveryTime: true,
700        }
701        await notify.publish(notificationRequest);
702        console.info('==================ANS_Cancel_0900 publish promise==================>');
703        setTimeout((async function(){
704            await notify.unsubscribe(subscriber);
705            console.info('======ANS_Cancel_0900 setTimeout unsubscribe end==================>');
706            done();
707        }),timeout);
708    })
709
710    function onConsumeCancelWrongId(data) {
711        console.info('========ANS_Cancel_1000 onConsume start==============>');
712        console.info('========ANS_Cancel_1000 onConsume data:==============>' + JSON.stringify(data));
713        console.info('========ANS_Cancel_1000 onConsume label:=============>' + data.request.label);
714        console.info('========ANS_Cancel_1000 onConsume id:================>' + data.request.id);
715        notify.cancel(9999,cancelCallBackCancelWrongId);
716        console.info('========ANS_Cancel_1000 onConsume cancel==========>');
717        console.info('========ANS_Cancel_1000 onConsume end============>');
718    }
719    function onCancelCancelWrongId(data) {
720        console.info('================ANS_Cancel_1000 onCancel start=============>');
721        console.info('================ANS_Cancel_1000 onCancel data:=============>' + JSON.stringify(data));
722        expect().assertFail();
723        console.info('================ANS_Cancel_1000 onCancel end===============>');
724    }
725    function cancelCallBackCancelWrongId(err){
726        console.info('==============ANS_Cancel_1000 cancelCallBack start===============>');
727        console.info('==============ANS_Cancel_1000 cancelCallBack err:================>' + JSON.stringify(err));
728        expect(err.code != 0).assertEqual(true);
729        console.info('==============ANS_Cancel_1000 cancelCallBack end=================>');
730    }
731
732    /*
733     * @tc.number: ANS_Cancel_1000
734     * @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
735     * @tc.desc: Verify that when the cancel(id: number, callback: AsyncCallback<void>): void
736                 interface is called, when the id is wrong, no notification information is cancelled at this time
737     */
738    it('ANS_Cancel_1000', 0, async function (done) {
739        console.info('===============ANS_Cancel_1000 start==========================>');
740        let subscriber ={
741            onConsume:onConsumeCancelWrongId,
742            onCancel:onCancelCancelWrongId,
743        }
744        await notify.subscribe(subscriber);
745        console.info('================ANS_Cancel_1000 subscribe promise==================>');
746        let notificationRequest = {
747            content:{
748                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
749                normal: {
750                    title: 'test_title',
751                    text: 'test_text',
752                    additionalText: 'test_additionalText'
753                },
754            },
755            id: 10,
756            slotType : notify.SlotType.OTHER_TYPES,
757            isOngoing : true,
758            isUnremovable : false,
759            deliveryTime : 1624950453,
760            tapDismissed : true,
761            autoDeletedTime: 1625036817,
762            color: 2,
763            colorEnabled: true,
764            isAlertOnce: true,
765            isStopwatch: true,
766            isCountDown: true,
767            progressValue: 12,
768            progressMaxValue: 100,
769            isIndeterminate: true,
770            statusBarText: 'statusBarText',
771            isFloatingIcon : true,
772            label: '1000',
773            badgeIconStyle: 1,
774            showDeliveryTime: true,
775        }
776        await notify.publish(notificationRequest);
777        console.info('===========ANS_Cancel_1000 publish promise==================>');
778        setTimeout((async function(){
779            await notify.unsubscribe(subscriber);
780            console.info('======ANS_Cancel_1000 setTimeout unsubscribe end==================>');
781            done();
782        }),timeout);
783    })
784
785    function onConsumeCancelIsUnremovable(data) {
786        console.info('============ANS_Cancel_1100 onConsume start===============>');
787        console.info('============ANS_Cancel_1100 onConsume data:===============>' + JSON.stringify(data));
788        console.info('============ANS_Cancel_1100 onConsume label:==============>' + data.request.label);
789        console.info('============ANS_Cancel_1100 onConsume id: =======================>' + data.request.id);
790        notify.cancel(data.request.id,cancelCallBackCancelIsUnremovable);
791        console.info('============ANS_Cancel_1100 onConsume cancel=======================>');
792        console.info('============ANS_Cancel_1100 onConsume end=======================>');
793    }
794    function onCancelCancelIsUnremovable(data) {
795        console.info('============ANS_Cancel_1100 onCancel start================>');
796        console.info('============ANS_Cancel_1100 onCancel data:================>' + JSON.stringify(data));
797        console.info('============ANS_Cancel_1100 onCancel id:================>' + data.request.id);
798        expect(data.request.id).assertEqual(11);
799        console.info('============ANS_Cancel_1100 onCancel end=======================>');
800    }
801    function cancelCallBackCancelIsUnremovable(err){
802        console.info('============ANS_Cancel_1100 cancelCallBack start=================>');
803        console.info('============ANS_Cancel_1100 cancelCallBack err:==================>' + JSON.stringify(err));
804        console.info('============ANS_Cancel_1100 cancelCallBack end===================>');
805    }
806
807    /*
808     * @tc.number: ANS_Cancel_1100
809     * @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
810     * @tc.desc: Verify the success of canceling the notification with the notification attribute isUnremovable
811                 being true by calling the cancel(id: number, callback: AsyncCallback<void>): void interface
812     */
813    it('ANS_Cancel_1100', 0, async function (done) {
814        console.info('===============ANS_Cancel_1100 start==========================>');
815        let subscriber ={
816            onConsume:onConsumeCancelIsUnremovable,
817            onCancel:onCancelCancelIsUnremovable,
818        }
819        await notify.subscribe(subscriber);
820        console.info('===============ANS_Cancel_1100 subscribe promise=============>');
821        let notificationRequest = {
822            content:{
823                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
824                normal: {
825                    title: 'test_title',
826                    text: 'test_text',
827                    additionalText: 'test_additionalText'
828                },
829            },
830            id: 11,
831            slotType : notify.SlotType.OTHER_TYPES,
832            isOngoing : true,
833            isUnremovable : true,
834            deliveryTime : 1624950453,
835            tapDismissed : true,
836            autoDeletedTime: 1625036817,
837            color: 2,
838            colorEnabled: true,
839            isAlertOnce: true,
840            isStopwatch: true,
841            isCountDown: true,
842            progressValue: 12,
843            progressMaxValue: 100,
844            isIndeterminate: true,
845            statusBarText: 'statusBarText',
846            isFloatingIcon : true,
847            badgeIconStyle: 1,
848            showDeliveryTime: true,
849        }
850        await notify.publish(notificationRequest);
851        console.info('============ANS_Cancel_1100 publish promise===========>');
852        setTimeout((async function(){
853            await notify.unsubscribe(subscriber);
854            console.info('======ANS_Cancel_1100 setTimeout unsubscribe end==================>');
855            done();
856        }),timeout);
857    })
858
859    let id1200
860    function onConsumeCancel2Times(data) {
861        console.info('=========ANS_Cancel_1200 onConsume start=====================>');
862        console.info('=========ANS_Cancel_1200 onConsume data:=====================>' + JSON.stringify(data));
863        console.info('=========ANS_Cancel_1200 onConsume label:====================>' + data.request.label);
864        console.info('=========ANS_Cancel_1200 onConsume id:=======================>' + data.request.id);
865        id1200 = data.request.id
866        notify.cancel(id1200, cancelCallBackCancel2Times1);
867        console.info('=========ANS_Cancel_1200 onConsume cancel====================>');
868        console.info('=========ANS_Cancel_1200 onConsume end=======================>');
869    }
870    function onCancelCancel2Times(data) {
871        timesOfOnCancel = timesOfOnCancel + 1
872        console.info('=========ANS_Cancel_1200 onCancel start======================>');
873        console.info('=========ANS_Cancel_1200 onCancel data:===========>' + JSON.stringify(data));
874        console.info('=========ANS_Cancel_1200 onCancel timesOfOnCancel========>'+timesOfOnCancel);
875        if (timesOfOnCancel == 1){
876            expect(data.request.id).assertEqual(12);
877            console.info('=========ANS_Cancel_1200 onCancel id:======================>' + data.request.id);
878            notify.cancel(id1200, cancelCallBackCancel2Times2);
879            console.info('=========ANS_Cancel_1200 onCancel cancelCallBack_cancel 2Times2===========>');
880        }else if(timesOfOnCancel == 2) {
881            expect().assertFail();
882        }
883        console.info('=========ANS_Cancel_1200 onCancel end=======================>');
884    }
885    function cancelCallBackCancel2Times1(err){
886        console.info('===========ANS_Cancel_1200 cancelCallBack1 start================>');
887        console.info('===========ANS_Cancel_1200 cancelCallBack1 err:=================>' + JSON.stringify(err));
888        console.info('===========ANS_Cancel_1200 cancelCallBack1 end=======================>');
889    }
890
891    function cancelCallBackCancel2Times2(err){
892        console.info('===========ANS_Cancel_1200 cancelCallBack2 start===========>');
893        console.info('===========ANS_Cancel_1200 cancelCallBack2 err:============>' + JSON.stringify(err));
894        expect(err.code != 0).assertEqual(true);
895        console.info('===========ANS_Cancel_1200 cancelCallBack2 end============>');
896    }
897
898    /*
899     * @tc.number: ANS_Cancel_1200
900     * @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
901     * @tc.desc: Verify that the cancel(id: number, callback: AsyncCallback<void>): void
902                 interface is called twice in a row to cancel the notification
903     */
904    it('ANS_Cancel_1200', 0, async function (done) {
905        console.info('=============ANS_Cancel_1200 start==========================>');
906        timesOfOnCancel = 0
907        let subscriber ={
908            onConsume:onConsumeCancel2Times,
909            onCancel:onCancelCancel2Times,
910        }
911        await notify.subscribe(subscriber);
912        console.info('=============ANS_Cancel_1200 subscribe promise==================>');
913        let notificationRequest = {
914            content:{
915                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
916                normal: {
917                    title: 'test_title',
918                    text: 'test_text',
919                    additionalText: 'test_additionalText'
920                },
921            },
922            id: 12,
923            slotType : notify.SlotType.OTHER_TYPES,
924            isOngoing : true,
925            isUnremovable : false,
926            deliveryTime : 1624950453,
927            tapDismissed : true,
928            autoDeletedTime: 1625036817,
929            color: 2,
930            colorEnabled: true,
931            isAlertOnce: true,
932            isStopwatch: true,
933            isCountDown: true,
934            progressValue: 12,
935            progressMaxValue: 100,
936            isIndeterminate: true,
937            statusBarText: 'statusBarText',
938            isFloatingIcon : true,
939            badgeIconStyle: 1,
940            showDeliveryTime: true,
941        }
942        await notify.publish(notificationRequest);
943        console.info('========ANS_Cancel_1200 publish promise=================>');
944        setTimeout((async function(){
945            await notify.unsubscribe(subscriber);
946            console.info('======ANS_Cancel_1200 setTimeout unsubscribe end==================>');
947            done();
948        }),1500);
949    })
950
951    function onConsumeCancelLabel(data) {
952        console.info('============ANS_Cancel_1300 onConsume start=============>');
953        console.info('============ANS_Cancel_1300 onConsume data:=============>' + JSON.stringify(data));
954        console.info('============ANS_Cancel_1300 onConsume label: ===========>' + data.request.label);
955        console.info('============ANS_Cancel_1300 onConsume id: ==============>' + data.request.id);
956        notify.cancel(data.request.id, data.request.label, cancelCallBackCancelLabel);
957        console.info('============ANS_Cancel_1300 onConsume cance=============>');
958        console.info('============ANS_Cancel_1300 onConsume end===============>');
959    }
960    function onCancelCancelLabel(data) {
961        console.info('=========ANS_Cancel_1300 onCancel start============>');
962        console.info('=========ANS_Cancel_1300 onCancel data:============>' + JSON.stringify(data));
963        expect(data.request.id).assertEqual(13);
964        console.info('=========ANS_Cancel_1300 onCancel id:============>' + data.request.id);
965        expect(data.request.label).assertEqual('1300');
966        console.info('=========ANS_Cancel_1300 onCancel label:============>' + data.request.label);
967        console.info('=========ANS_Cancel_1300 onCancel end==============>');
968    }
969    function cancelCallBackCancelLabel(err){
970        console.info('=========ANS_Cancel_1300 cancelCallBack start====================>');
971        console.info('=========ANS_Cancel_1300 cancelCallBack err:=====================>' + JSON.stringify(err));
972        console.info('=========ANS_Cancel_1300 cancelCallBack end=====================>');
973    }
974
975    /*
976     * @tc.number: ANS_Cancel_1300
977     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
978     * @tc.desc: Verify that the cancel notification is successful by calling the
979                 cancel(id: number, label: string, callback: AsyncCallback<void>): void; interface
980     */
981    let subscriber
982    it('ANS_Cancel_1300', 0, async function (done) {
983        console.info('===============ANS_Cancel_1300 start==========================>');
984        subscriber ={
985            onConsume:onConsumeCancelLabel,
986            onCancel:onCancelCancelLabel,
987        }
988        await notify.subscribe(subscriber);
989        console.info('================ANS_Cancel_1300 subscribe promise==============>');
990        let notificationRequest = {
991            content:{
992                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
993                normal: {
994                    title: 'test_title',
995                    text: 'test_text',
996                    additionalText: 'test_additionalText'
997                },
998            },
999            id: 13,
1000            slotType : notify.SlotType.OTHER_TYPES,
1001            isOngoing : true,
1002            isUnremovable : false,
1003            deliveryTime : 1624950453,
1004            tapDismissed : true,
1005            autoDeletedTime: 1625036817,
1006            color: 2,
1007            colorEnabled: true,
1008            isAlertOnce: true,
1009            isStopwatch: true,
1010            isCountDown: true,
1011            progressValue: 12,
1012            progressMaxValue: 100,
1013            isIndeterminate: true,
1014            statusBarText: 'statusBarText',
1015            isFloatingIcon : true,
1016            label: '1300',
1017            badgeIconStyle: 1,
1018            showDeliveryTime: true,
1019        }
1020        await notify.publish(notificationRequest);
1021        console.info('===========ANS_Cancel_1300 publish promise==================>');
1022        setTimeout((async function(){
1023            await notify.unsubscribe(subscriber);
1024            console.info('======ANS_Cancel_1300 setTimeout unsubscribe end==================>');
1025            done();
1026        }),timeout);
1027    })
1028
1029    function onConsumeCancelLabelPromise(data) {
1030        console.info('==========ANS_Cancel_1400 onConsume start=================>');
1031        console.info('==========ANS_Cancel_1400 onConsume data:=================>' + JSON.stringify(data));
1032        console.info('==========ANS_Cancel_1400 onConsume label:================>' + data.request.label);
1033        console.info('==========ANS_Cancel_1400 onConsume id:===================>' + data.request.id);
1034        notify.cancel(data.request.id, data.request.label);
1035        console.info('==========ANS_Cancel_1400 onConsume cancel==========>');
1036        console.info('==========ANS_Cancel_1400 onConsume end=============>');
1037    }
1038    function onCancelCancelLabelPromise(data) {
1039        console.info('==========ANS_Cancel_1400 onCancel start============>');
1040        console.info('==========ANS_Cancel_1400 onCancel data:============>' + JSON.stringify(data));
1041        expect(data.request.id).assertEqual(14);
1042        console.info('==========ANS_Cancel_1400 onCancel id:================>' + data.request.id);
1043        expect(data.request.label).assertEqual('1400');
1044        console.info('==========ANS_Cancel_1400 onCancel label:================>' + data.request.label);
1045        console.info('==========ANS_Cancel_1400 onCancel end==============>');
1046    }
1047
1048    /*
1049     * @tc.number: ANS_Cancel_1400
1050     * @tc.name: cancel(id: number, label?: string): Promise<void>
1051     * @tc.desc: Verify that the cancel notification is successful by calling the
1052                 cancel(id: number, label?: string): Promise<void> interface
1053     */
1054    it('ANS_Cancel_1400', 0, async function (done) {
1055        console.info('===============ANS_Cancel_1400 start==========================>');
1056        subscriber ={
1057            onConsume:onConsumeCancelLabelPromise,
1058            onCancel:onCancelCancelLabelPromise,
1059        }
1060        await notify.subscribe(subscriber);
1061        console.info('==========ANS_Cancel_1400 subscribe promise==================>');
1062        let notificationRequest = {
1063            content:{
1064                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1065                normal: {
1066                    title: 'test_title',
1067                    text: 'test_text',
1068                    additionalText: 'test_additionalText'
1069                },
1070            },
1071            id: 14,
1072            slotType : notify.SlotType.OTHER_TYPES,
1073            isOngoing : true,
1074            isUnremovable : false,
1075            deliveryTime : 1624950453,
1076            tapDismissed : true,
1077            autoDeletedTime: 1625036817,
1078            color: 2,
1079            colorEnabled: true,
1080            isAlertOnce: true,
1081            isStopwatch: true,
1082            isCountDown: true,
1083            progressValue: 12,
1084            progressMaxValue: 100,
1085            isIndeterminate: true,
1086            statusBarText: 'statusBarText',
1087            isFloatingIcon : true,
1088            label: '1400',
1089            badgeIconStyle: 1,
1090            showDeliveryTime: true,
1091        }
1092        await notify.publish(notificationRequest);
1093        console.info('===============ANS_Cancel_1400 publish promise==============>');
1094        setTimeout((async function(){
1095            await notify.unsubscribe(subscriber);
1096            console.info('======ANS_Cancel_1400 setTimeout unsubscribe end==================>');
1097            done();
1098        }),timeout);
1099    })
1100
1101    function onConsumeCancelLabelIsUnremoveable(data) {
1102        console.info('========ANS_Cancel_1500 onConsume start=====================>');
1103        console.info('========ANS_Cancel_1500 onConsume data:=====================>' + JSON.stringify(data));
1104        console.info('========ANS_Cancel_1500 onConsume label:====================>' + data.request.label);
1105        console.info('========ANS_Cancel_1500 onConsume id:=======================>' + data.request.id);
1106        notify.cancel(data.request.id, data.request.label, cancelCallBackCancelLabelIsUnremoveable);
1107        console.info('========ANS_Cancel_1500 onConsume cancel====================>');
1108        console.info('========ANS_Cancel_1500 onConsume end=======================>');
1109    }
1110    function onCancelCancelLabelIsUnremoveable(data) {
1111        console.info('========ANS_Cancel_1500 onCancel start=======================>');
1112        console.info('========ANS_Cancel_1500 onCancel data : =======================>' + JSON.stringify(data));
1113        expect(data.request.id).assertEqual(15);
1114        console.info('========ANS_Cancel_1500 onCancel id : =======================>' + data.request.id);
1115        expect(data.request.label).assertEqual('1500');
1116        console.info('========ANS_Cancel_1500 onCancel label : =======================>' + data.request.label);
1117        console.info('========ANS_Cancel_1500 onCancel end=======================>');
1118    }
1119    function cancelCallBackCancelLabelIsUnremoveable(err){
1120        console.info('========ANS_Cancel_1500 cancelCallBack start=========>');
1121        console.info('========ANS_Cancel_1500 cancelCallBack err:==========>' + JSON.stringify(err));
1122        console.info('========ANS_Cancel_1500 cancelCallBack end===========>');
1123    }
1124
1125    /*
1126     * @tc.number: ANS_Cancel_1500
1127     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
1128     * @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled
1129     successfully by calling the cancel(id: number, label: string, callback: AsyncCallback<void>): void interface
1130     */
1131    it('ANS_Cancel_1500', 0, async function (done) {
1132        console.info('===============ANS_Cancel_1500 start==========================>');
1133        let subscriber ={
1134            onConsume:onConsumeCancelLabelIsUnremoveable,
1135            onCancel:onCancelCancelLabelIsUnremoveable,
1136        }
1137        await notify.subscribe(subscriber);
1138        console.info('=======ANS_Cancel_1500 subscribe promise==================>');
1139        let notificationRequest = {
1140            content:{
1141                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1142                normal: {
1143                    title: 'test_title',
1144                    text: 'test_text',
1145                    additionalText: 'test_additionalText'
1146                },
1147            },
1148            id: 15,
1149            slotType : notify.SlotType.OTHER_TYPES,
1150            isOngoing : true,
1151            isUnremovable : true,
1152            deliveryTime : 1624950453,
1153            tapDismissed : true,
1154            autoDeletedTime: 1625036817,
1155            color: 2,
1156            colorEnabled: true,
1157            isAlertOnce: true,
1158            isStopwatch: true,
1159            isCountDown: true,
1160            progressValue: 12,
1161            progressMaxValue: 100,
1162            isIndeterminate: true,
1163            statusBarText: 'statusBarText',
1164            isFloatingIcon : true,
1165            label: '1500',
1166            badgeIconStyle: 1,
1167            showDeliveryTime: true,
1168        }
1169        await notify.publish(notificationRequest);
1170        console.info('===========ANS_Cancel_1500 publish promise=============>');
1171        setTimeout((async function(){
1172            await notify.unsubscribe(subscriber);
1173            console.info('======ANS_Cancel_1500 setTimeout unsubscribe end==================>');
1174            done();
1175        }),timeout);
1176    })
1177
1178    function onConsumeCancelLabelIsUnremoveablePromise(data) {
1179        console.info('============ANS_Cancel_1600 onConsume start==================>');
1180        console.info('============ANS_Cancel_1600 onConsume data:==================>' + JSON.stringify(data));
1181        console.info('============ANS_Cancel_1600 onConsume label:=================>' + data.request.label);
1182        console.info('============ANS_Cancel_1600 onConsume id:====================>' + data.request.id);
1183        notify.cancel(data.request.id, data.request.label)
1184        console.info('============ANS_Cancel_1600 onConsume cancel end==========>');
1185        console.info('============ANS_Cancel_1600 onConsume end====================>');
1186    }
1187    function onCancelCancelLabelIsUnremoveablePromise(data) {
1188        console.info('============ANS_Cancel_1600 onCancel start=================>');
1189        console.info('============ANS_Cancel_1600 onCancel data:=================>' + JSON.stringify(data));
1190        expect(data.request.id).assertEqual(16);
1191        console.info('============ANS_Cancel_1600 onCancel id : =======================>' + data.request.id);
1192        expect(data.request.label).assertEqual('1600');
1193        console.info('============ANS_Cancel_1600 onCancel label : =======================>' + data.request.label);
1194        console.info('============ANS_Cancel_1600 onCancel end===================>');
1195    }
1196
1197    /*
1198     * @tc.number: ANS_Cancel_1600
1199     * @tc.name: cancel(id: number, label?: string): Promise<void>
1200     * @tc.desc: Verify that the notification whose notification property isUnremovable is true
1201                 is canceled successfully by calling the cancel(id: number, label?: string): Promise<void> interface
1202     */
1203    it('ANS_Cancel_1600', 0, async function (done) {
1204        console.info('===============ANS_Cancel_1600 start==========================>');
1205        let subscriber ={
1206            onConsume:onConsumeCancelLabelIsUnremoveablePromise,
1207            onCancel:onCancelCancelLabelIsUnremoveablePromise,
1208        }
1209        await notify.subscribe(subscriber);
1210        console.info('==============ANS_Cancel_1600 subscribe promise==================>');
1211        let notificationRequest = {
1212            content:{
1213                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1214                normal: {
1215                    title: 'test_title',
1216                    text: 'test_text',
1217                    additionalText: 'test_additionalText'
1218                },
1219            },
1220            id: 16,
1221            slotType : notify.SlotType.OTHER_TYPES,
1222            isOngoing : true,
1223            isUnremovable : true,
1224            deliveryTime : 1624950453,
1225            tapDismissed : true,
1226            autoDeletedTime: 1625036817,
1227            color: 2,
1228            colorEnabled: true,
1229            isAlertOnce: true,
1230            isStopwatch: true,
1231            isCountDown: true,
1232            progressValue: 12,
1233            progressMaxValue: 100,
1234            isIndeterminate: true,
1235            statusBarText: 'statusBarText',
1236            isFloatingIcon : true,
1237            label: '1600',
1238            badgeIconStyle: 1,
1239            showDeliveryTime: true,
1240        }
1241        await notify.publish(notificationRequest);
1242        console.info('==============ANS_Cancel_1600 publish promise==================>');
1243        setTimeout((async function(){
1244            await notify.unsubscribe(subscriber);
1245            console.info('======ANS_Cancel_1600 setTimeout unsubscribe end==================>');
1246            done();
1247        }),timeout);
1248    })
1249    function onConsumeCancelWrongLabel(data) {
1250        console.info('================ANS_Cancel_1700 onConsume start===============>');
1251        console.info('================ANS_Cancel_1700 onConsume data:===============>' + JSON.stringify(data));
1252        console.info('================ANS_Cancel_1700 onConsume label:==============>' + data.request.label);
1253        console.info('================ANS_Cancel_1700 onConsume id:=================>' + data.request.id);
1254        notify.cancel(data.request.id, '9999', cancelCallBackCancelWrongLabel);
1255        console.info('================ANS_Cancel_1700 onConsume cancel=======================>');
1256        console.info('================ANS_Cancel_1700 onConsume end=======================>');
1257    }
1258    function onCancelCancelWrongLabel(data) {
1259        console.info('================ANS_Cancel_1700 onCancel start===============>');
1260        console.info('================ANS_Cancel_1700 onCancel data:===============>' + JSON.stringify(data));
1261        expect().assertFail(0);
1262        console.info('================ANS_Cancel_1700 onCancel end=================>');
1263    }
1264    function cancelCallBackCancelWrongLabel(err){
1265        console.info('================ANS_Cancel_1700 cancelCallBack start=================>');
1266        console.info('================ANS_Cancel_1700 cancelCallBack err:==================>' + JSON.stringify(err));
1267        expect(err.code != 0).assertEqual(true);
1268        console.info('================ANS_Cancel_1700 cancelCallBack end===================>');
1269    }
1270
1271    /*
1272     * @tc.number: ANS_Cancel_1700
1273     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
1274     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
1275                 interface is called, the label is wrong and the ID is correct.
1276     */
1277    it('ANS_Cancel_1700', 0, async function (done) {
1278        console.info('===============ANS_Cancel_1700 start==========================>');
1279        let subscriber ={
1280            onConsume:onConsumeCancelWrongLabel,
1281            onCancel:onCancelCancelWrongLabel,
1282        }
1283        await notify.subscribe(subscriber);
1284        console.info('==============ANS_Cancel_1700 subscribe promise==================>');
1285        let notificationRequest = {
1286            content:{
1287                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1288                normal: {
1289                    title: 'test_title',
1290                    text: 'test_text',
1291                    additionalText: 'test_additionalText'
1292                },
1293            },
1294            id: 17,
1295            slotType : notify.SlotType.OTHER_TYPES,
1296            isOngoing : true,
1297            isUnremovable : false,
1298            deliveryTime : 1624950453,
1299            tapDismissed : true,
1300            autoDeletedTime: 1625036817,
1301            color: 2,
1302            colorEnabled: true,
1303            isAlertOnce: true,
1304            isStopwatch: true,
1305            isCountDown: true,
1306            progressValue: 12,
1307            progressMaxValue: 100,
1308            isIndeterminate: true,
1309            statusBarText: 'statusBarText',
1310            isFloatingIcon : true,
1311            label: '1700',
1312            badgeIconStyle: 1,
1313            showDeliveryTime: true,
1314        }
1315        await notify.publish(notificationRequest);
1316        console.info('==============ANS_Cancel_1700 publish promise==================>');
1317        setTimeout((async function(){
1318            await notify.unsubscribe(subscriber);
1319            console.info('======ANS_Cancel_1700 setTimeout unsubscribe end==================>');
1320            done();
1321        }),timeout);
1322    })
1323
1324    function onConsumeCancelWrongLabelPromise(data) {
1325        console.info('=========ANS_Cancel_1800 onConsume start================>');
1326        console.info('=========ANS_Cancel_1800 onConsume data:================>' + JSON.stringify(data));
1327        console.info('=========ANS_Cancel_1800 onConsume label:===============>' + data.request.label);
1328        console.info('=========ANS_Cancel_1800 onConsume id:==================>' + data.request.id);
1329        notify.cancel(data.request.id, '9999').then(()=>{
1330            console.info('=========ANS_Cancel_1800 onConsume cancel then======>');
1331        }).catch((err)=>{
1332            console.info('=========ANS_Cancel_1800 onConsume cancel catch err======>'+JSON.stringify(err));
1333            expect(err.code != 0).assertEqual(true);
1334        });
1335        console.info('=========ANS_Cancel_1800 onConsume end=======================>');
1336    }
1337    function onCancelCancelWrongLabelPromise(data) {
1338        console.info('=========ANS_Cancel_1800 onCancel start=======================>');
1339        console.info('=========ANS_Cancel_1800 onCancel data : =======================>' + JSON.stringify(data));
1340        expect().assertFail(0);
1341        console.info('=========ANS_Cancel_1800 onCancel end=======================>');
1342    }
1343
1344    /*
1345     * @tc.number: ANS_Cancel_1800
1346     * @tc.name: cancel(id: number, label?: string): Promise<void>
1347     * @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
1348                 the label is wrong and the ID is correct.
1349     */
1350    it('ANS_Cancel_1800', 0, async function (done) {
1351        console.info('===============ANS_Cancel_1800 start==========================>');
1352        let subscriber ={
1353            onConsume:onConsumeCancelWrongLabelPromise,
1354            onCancel:onCancelCancelWrongLabelPromise,
1355        }
1356        await notify.subscribe(subscriber);
1357        console.info('==============ANS_Cancel_1800 subscribe promise==================>');
1358        let notificationRequest = {
1359            content:{
1360                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1361                normal: {
1362                    title: 'test_title',
1363                    text: 'test_text',
1364                    additionalText: 'test_additionalText'
1365                },
1366            },
1367            id: 18,
1368            slotType : notify.SlotType.OTHER_TYPES,
1369            isOngoing : true,
1370            isUnremovable : false,
1371            deliveryTime : 1624950453,
1372            tapDismissed : true,
1373            autoDeletedTime: 1625036817,
1374            color: 2,
1375            colorEnabled: true,
1376            isAlertOnce: true,
1377            isStopwatch: true,
1378            isCountDown: true,
1379            progressValue: 12,
1380            progressMaxValue: 100,
1381            isIndeterminate: true,
1382            statusBarText: 'statusBarText',
1383            isFloatingIcon : true,
1384            label: '1800',
1385            badgeIconStyle: 1,
1386            showDeliveryTime: true,
1387        }
1388        await notify.publish(notificationRequest);
1389        console.info('==============ANS_Cancel_1800 publish promise==================>');
1390        setTimeout((async function(){
1391            await notify.unsubscribe(subscriber);
1392            console.info('======ANS_Cancel_1800 setTimeout unsubscribe end==================>');
1393            done();
1394        }),timeout);
1395    })
1396
1397    function onConsumeCancelLabelNullCharacter(data) {
1398        console.info('===========ANS_Cancel_1900 onConsume start==================>');
1399        console.info('===========ANS_Cancel_1900 onConsume data:==================>' + JSON.stringify(data));
1400        console.info('===========ANS_Cancel_1900 onConsume label:=================>' + data.request.label);
1401        console.info('===========ANS_Cancel_1900 onConsume id:====================>' + data.request.id);
1402        notify.cancel(data.request.id, '', cancelCallBackCancelNullCharacter);
1403        console.info('===========ANS_Cancel_1900 onConsume cancel=======================>');
1404        console.info('===========ANS_Cancel_1900 onConsume end=======================>');
1405    }
1406    function onCancelCancelLabelNullCharacter(data) {
1407        console.info('===========ANS_Cancel_1900 onCancel start================>');
1408        console.info('===========ANS_Cancel_1900 onCancel data:================>' + JSON.stringify(data));
1409        expect().assertFail(0);
1410        console.info('===========ANS_Cancel_1900 onCancel end=======================>');
1411    }
1412    function cancelCallBackCancelNullCharacter(err){
1413        console.info('===========ANS_Cancel_1900 cancelCallBack start=================>');
1414        console.info('===========ANS_Cancel_1900 cancelCallBack err:==================>' + JSON.stringify(err));
1415        expect(err.code != 0).assertEqual(true);
1416        console.info('===========ANS_Cancel_1900 cancelCallBack end===================>');
1417    }
1418
1419    /*
1420     * @tc.number: ANS_Cancel_1900
1421     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
1422     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
1423                 interface is called, and the label uses empty characters
1424     */
1425    it('ANS_Cancel_1900', 0, async function (done) {
1426        console.info('===============ANS_Cancel_1900 start==========================>');
1427        let subscriber ={
1428            onConsume:onConsumeCancelLabelNullCharacter,
1429            onCancel:onCancelCancelLabelNullCharacter,
1430        }
1431        await notify.subscribe(subscriber);
1432        console.info('=============ANS_Cancel_1900 subscribe promise==================>');
1433        let notificationRequest = {
1434            content:{
1435                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1436                normal: {
1437                    title: 'test_title',
1438                    text: 'test_text',
1439                    additionalText: 'test_additionalText'
1440                },
1441            },
1442            id: 19,
1443            slotType : notify.SlotType.OTHER_TYPES,
1444            isOngoing : true,
1445            isUnremovable : false,
1446            deliveryTime : 1624950453,
1447            tapDismissed : true,
1448            autoDeletedTime: 1625036817,
1449            color: 2,
1450            colorEnabled: true,
1451            isAlertOnce: true,
1452            isStopwatch: true,
1453            isCountDown: true,
1454            progressValue: 12,
1455            progressMaxValue: 100,
1456            isIndeterminate: true,
1457            statusBarText: 'statusBarText',
1458            isFloatingIcon : true,
1459            label: '1900',
1460            badgeIconStyle: 1,
1461            showDeliveryTime: true,
1462        }
1463        await notify.publish(notificationRequest);
1464        console.info('==========ANS_Cancel_1900 publish promise==============>');
1465        setTimeout((async function(){
1466            await notify.unsubscribe(subscriber);
1467            console.info('======ANS_Cancel_1900 setTimeout unsubscribe end==================>');
1468            done();
1469        }),timeout);
1470    })
1471
1472    function onConsumeCancelNullCharacter(data) {
1473        console.info('==========ANS_Cancel_2000 onConsume start=================>');
1474        console.info('==========ANS_Cancel_2000 onConsume data:=================>' + JSON.stringify(data));
1475        console.info('==========ANS_Cancel_2000 onConsume label:================>' + data.request.label);
1476        console.info('==========ANS_Cancel_2000 onConsume id:===================>' + data.request.id);
1477        notify.cancel(data.request.id, '').then(()=>{
1478            console.info('=========ANS_Cancel_2000 onConsume cancel then======>');
1479        }).catch((err)=>{
1480            console.info('=========ANS_Cancel_2000 onConsume cancel catch err======>'+JSON.stringify(err));
1481            expect(err.code != 0).assertEqual(true);
1482        });
1483        console.info('==========ANS_Cancel_2000 onConsume cancel end==========>');
1484        console.info('==========ANS_Cancel_2000 onConsume end=================>');
1485    }
1486    function onCancelCancelNullCharacter(data) {
1487        console.info('==========ANS_Cancel_2000 onCancel start====================>');
1488        console.info('==========ANS_Cancel_2000 onCancel data:======================>' + JSON.stringify(data));
1489        expect().assertFail(0);
1490        console.info('==========ANS_Cancel_2000 onCancel end=======================>');
1491    }
1492
1493    /*
1494     * @tc.number: ANS_Cancel_2000
1495     * @tc.name: cancel(id: number, label?: string): Promise<void>;
1496     * @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
1497                 and the label uses empty characters
1498     */
1499    it('ANS_Cancel_2000', 0, async function (done) {
1500        console.info('===============ANS_Cancel_2000 start==========================>');
1501        let subscriber ={
1502            onConsume:onConsumeCancelNullCharacter,
1503            onCancel:onCancelCancelNullCharacter,
1504        }
1505        await notify.subscribe(subscriber);
1506        console.info('=========ANS_Cancel_2000 subscribe promise==================>');
1507        let notificationRequest = {
1508            content:{
1509                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1510                normal: {
1511                    title: 'test_title',
1512                    text: 'test_text',
1513                    additionalText: 'test_additionalText'
1514                },
1515            },
1516            id: 20,
1517            slotType : notify.SlotType.OTHER_TYPES,
1518            isOngoing : true,
1519            isUnremovable : false,
1520            deliveryTime : 1624950453,
1521            tapDismissed : true,
1522            autoDeletedTime: 1625036817,
1523            color: 2,
1524            colorEnabled: true,
1525            isAlertOnce: true,
1526            isStopwatch: true,
1527            isCountDown: true,
1528            progressValue: 12,
1529            progressMaxValue: 100,
1530            isIndeterminate: true,
1531            statusBarText: 'statusBarText',
1532            isFloatingIcon : true,
1533            label: '2000',
1534            badgeIconStyle: 1,
1535            showDeliveryTime: true,
1536        }
1537        await notify.publish(notificationRequest);
1538        console.info('============ANS_Cancel_2000 publish promise===============>');
1539        setTimeout((async function(){
1540            await notify.unsubscribe(subscriber);
1541            console.info('======ANS_Cancel_2000 setTimeout unsubscribe end==================>');
1542            done();
1543        }),timeout);
1544    })
1545
1546    let id2100
1547    let label2100
1548    function onConsumeCancelLabel2Times(data) {
1549        console.info('=========ANS_Cancel_2100 onConsume start==================>');
1550        console.info('=========ANS_Cancel_2100 onConsume data:==================>' + JSON.stringify(data));
1551        console.info('=========ANS_Cancel_2100 onConsume label:=================>' + data.request.label);
1552        console.info('=========ANS_Cancel_2100 onConsume id:====================>' + data.request.id);
1553        id2100 = data.request.id
1554        label2100 = data.request.label
1555        notify.cancel(id2100, label2100, cancelCallBackCancelLabel2Times1);
1556        console.info('=========ANS_Cancel_2100 onConsume cancel=======================>');
1557        console.info('=========ANS_Cancel_2100 onConsume end=======================>');
1558    }
1559    function onCancelCancelLabel2Times(data) {
1560        timesOfOnCancel = timesOfOnCancel + 1
1561        console.info('=========ANS_Cancel_2100 onCancel start==========>');
1562        console.info('=========ANS_Cancel_2100 onCancel data===========>' + JSON.stringify(data));
1563        if (timesOfOnCancel == 1){
1564            expect(data.request.id).assertEqual(21);
1565            expect(data.request.label).assertEqual('2100');
1566        }else if(timesOfOnCancel == 2){
1567            expect().assertFail();
1568        }
1569        console.info('=========ANS_Cancel_2100 onCancel end==========>');
1570    }
1571    function cancelCallBackCancelLabel2Times1(err){
1572        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times1 start============>');
1573        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times1 err==============>' + JSON.stringify(err));
1574        expect(err.code).assertEqual(0);
1575        notify.cancel(id2100, label2100, cancelCallBackCancelLabel2Times2);
1576        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times1 cancel =======================>');
1577        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times1 end=======================>');
1578    }
1579    function cancelCallBackCancelLabel2Times2(err){
1580        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times2 start================>');
1581        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times2 err:=================>' + JSON.stringify(err));
1582        expect(err.code != 0).assertEqual(true);
1583        console.info('=========ANS_Cancel_2100 cancelCallBack 2Times2 end==================>');
1584    }
1585
1586    /*
1587     * @tc.number: ANS_Cancel_2100
1588     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
1589     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
1590                 interface is called twice in a row
1591     */
1592    it('ANS_Cancel_2100', 0, async function (done) {
1593        console.info('===============ANS_Cancel_2100 start==========================>');
1594        timesOfOnCancel = 0
1595        let subscriber ={
1596            onConsume:onConsumeCancelLabel2Times,
1597            onCancel:onCancelCancelLabel2Times,
1598        }
1599        await notify.subscribe(subscriber);
1600        console.info('=============ANS_Cancel_2100 subscribe promise==================>');
1601        let notificationRequest = {
1602            content:{
1603                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1604                normal: {
1605                    title: 'test_title',
1606                    text: 'test_text',
1607                    additionalText: 'test_additionalText'
1608                },
1609            },
1610            id: 21,
1611            slotType : notify.SlotType.OTHER_TYPES,
1612            isOngoing : true,
1613            isUnremovable : false,
1614            deliveryTime : 1624950453,
1615            tapDismissed : true,
1616            autoDeletedTime: 1625036817,
1617            color: 2,
1618            colorEnabled: true,
1619            isAlertOnce: true,
1620            isStopwatch: true,
1621            isCountDown: true,
1622            progressValue: 12,
1623            progressMaxValue: 100,
1624            isIndeterminate: true,
1625            statusBarText: 'statusBarText',
1626            isFloatingIcon : true,
1627            label: '2100',
1628            badgeIconStyle: 1,
1629            showDeliveryTime: true,
1630        }
1631        await notify.publish(notificationRequest);
1632        console.info('=============ANS_Cancel_2100 publish promise================>');
1633        setTimeout((async function(){
1634            await notify.unsubscribe(subscriber);
1635            console.info('======ANS_Cancel_2100 setTimeout unsubscribe end==================>');
1636            done();
1637        }),timeout);
1638    })
1639
1640    let id2200
1641    let label2200
1642    function onConsumeCancelLabelPromise2Times(data) {
1643        console.info('===========ANS_Cancel_2200 onConsume start=======================>');
1644        console.info('===========ANS_Cancel_2200 onConsume data:=========>' + JSON.stringify(data));
1645        console.info('===========ANS_Cancel_2200 onConsume label:========>' + data.request.label);
1646        console.info('===========ANS_Cancel_2200 onConsume id:===========>' + data.request.id);
1647        id2200 = data.request.id
1648        label2200 = data.request.label
1649        notify.cancel(id2200, label2200);
1650        console.info('===========ANS_Cancel_2200 onConsume cancel1==========>');
1651        notify.cancel(id2200, label2200).then(()=>{
1652            console.info('=========ANS_Cancel_2200 onConsume cancel2 then======>');
1653        }).catch((err)=>{
1654            console.info('=========ANS_Cancel_2200 onConsume cancel2 catch err======>'+JSON.stringify(err));
1655            expect(err.code != 0).assertEqual(true);
1656        });
1657        console.info('===========ANS_Cancel_2200 onConsume cancel2==========>');
1658        console.info('===========ANS_Cancel_2200 onConsume end==============>');
1659    }
1660    function onCancelCancelLabelPromise2Times(data) {
1661        console.info('===========ANS_Cancel_2200 onCancel start===================>');
1662        console.info('===========ANS_Cancel_2200 onCancel data:===================>' + JSON.stringify(data));
1663        timesOfOnCancel = timesOfOnCancel + 1
1664        if (timesOfOnCancel == 1){
1665            expect(data.request.id).assertEqual(22);
1666            expect(data.request.label).assertEqual('2200');
1667        }else if (timesOfOnCancel == 2){
1668            expect().assertFail();
1669        }
1670        console.info('===========ANS_Cancel_2200 onCancel end=======================>');
1671    }
1672
1673    /*
1674     * @tc.number: ANS_Cancel_2200
1675     * @tc.name: cancel(id: number, label?: string): Promise<void>
1676     * @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void>
1677                 interface is called twice in a row
1678     */
1679    it('ANS_Cancel_2200', 0, async function (done) {
1680        console.info('===============ANS_Cancel_2200 start==========================>');
1681        timesOfOnCancel = 0
1682        let subscriber ={
1683            onConsume:onConsumeCancelLabelPromise2Times,
1684            onCancel:onCancelCancelLabelPromise2Times,
1685        }
1686        await notify.subscribe(subscriber);
1687        console.info('================ANS_Cancel_2200 subscribe_2200_promise=============>');
1688        let notificationRequest = {
1689            content:{
1690                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1691                normal: {
1692                    title: 'test_title',
1693                    text: 'test_text',
1694                    additionalText: 'test_additionalText'
1695                },
1696            },
1697            id: 22,
1698            slotType : notify.SlotType.OTHER_TYPES,
1699            isOngoing : true,
1700            isUnremovable : false,
1701            deliveryTime : 1624950453,
1702            tapDismissed : true,
1703            autoDeletedTime: 1625036817,
1704            color: 2,
1705            colorEnabled: true,
1706            isAlertOnce: true,
1707            isStopwatch: true,
1708            isCountDown: true,
1709            progressValue: 12,
1710            progressMaxValue: 100,
1711            isIndeterminate: true,
1712            statusBarText: 'statusBarText',
1713            isFloatingIcon : true,
1714            label: '2200',
1715            badgeIconStyle: 1,
1716            showDeliveryTime: true,
1717        }
1718        await notify.publish(notificationRequest);
1719        console.info('================ANS_Cancel_2200 publish promise==================>');
1720        setTimeout((async function(){
1721            await notify.unsubscribe(subscriber);
1722            console.info('======ANS_Cancel_2200 setTimeout unsubscribe end==================>');
1723            done();
1724        }),timeout);
1725    })
1726
1727    function onConsumeCancelRightLabelWrongId(data) {
1728        console.info('============ANS_Cancel_2300 onConsume start=======================>');
1729        console.info('============ANS_Cancel_2300 onConsume data: =======================>' + JSON.stringify(data));
1730        console.info('============ANS_Cancel_2300 onConsume label: =======================>' + data.request.label);
1731        console.info('============ANS_Cancel_2300 onConsume id: =======================>' + data.request.id);
1732        notify.cancel(11111, data.request.label, cancelCallBackCancelRightLabelWrongId);
1733        console.info('============ANS_Cancel_2300 onConsume cancel=======================>');
1734        console.info('============ANS_Cancel_2300 onConsume end=======================>');
1735    }
1736    function onCancelCancelRightLabelWrongId(data) {
1737        console.info('============ANS_Cancel_2300 onCancel start=======================>');
1738        console.info('============ANS_Cancel_2300 onCancel data:=======================>' + JSON.stringify(data));
1739        expect().assertFail();
1740        console.info('============ANS_Cancel_2300 onCancel end=======================>');
1741    }
1742    function cancelCallBackCancelRightLabelWrongId(err){
1743        console.info('============ANS_Cancel_2300 cancelCallBack start=======================>');
1744        console.info('============ANS_Cancel_2300 cancelCallBack err:===============>' + JSON.stringify(err));
1745        expect(err.code != 0).assertEqual(true);
1746        console.info('============ANS_Cancel_2300 cancelCallBack end===================>');
1747    }
1748
1749    /*
1750     * @tc.number: ANS_Cancel_2300
1751     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
1752     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>):
1753     void interface is called, the label is correct and the ID is wrong.
1754     */
1755    it('ANS_Cancel_2300', 0, async function (done) {
1756        console.info('===============ANS_Cancel_2300 start==========================>');
1757        let subscriber ={
1758            onConsume:onConsumeCancelRightLabelWrongId,
1759            onCancel:onCancelCancelRightLabelWrongId,
1760        }
1761        await notify.subscribe(subscriber);
1762        console.info('================ANS_Cancel_2300 promise==================>');
1763        let notificationRequest = {
1764            content:{
1765                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1766                normal: {
1767                    title: 'test_title',
1768                    text: 'test_text',
1769                    additionalText: 'test_additionalText'
1770                },
1771            },
1772            id: 23,
1773            slotType : notify.SlotType.OTHER_TYPES,
1774            isOngoing : true,
1775            isUnremovable : false,
1776            deliveryTime : 1624950453,
1777            tapDismissed : true,
1778            autoDeletedTime: 1625036817,
1779            color: 2,
1780            colorEnabled: true,
1781            isAlertOnce: true,
1782            isStopwatch: true,
1783            isCountDown: true,
1784            progressValue: 12,
1785            progressMaxValue: 100,
1786            isIndeterminate: true,
1787            statusBarText: 'statusBarText',
1788            isFloatingIcon : true,
1789            label: '2300',
1790            badgeIconStyle: 1,
1791            showDeliveryTime: true,
1792        }
1793        await notify.publish(notificationRequest);
1794        console.info('============ANS_Cancel_2300 publish promise==================>');
1795        setTimeout((async function(){
1796            await notify.unsubscribe(subscriber);
1797            console.info('======ANS_Cancel_2300 setTimeout unsubscribe end==================>');
1798            done();
1799        }),timeout);
1800    })
1801
1802    function onConsumeCancelRightLabelWrongIdPromise(data) {
1803        console.info('============ANS_Cancel_2400 onConsume start==============>');
1804        console.info('============ANS_Cancel_2400 onConsume data:==============>' + JSON.stringify(data));
1805        console.info('============ANS_Cancel_2400 onConsume label:=============>' + data.request.label);
1806        console.info('============ANS_Cancel_2400 onConsume id:================>' + data.request.id);
1807        notify.cancel(11111, data.request.label).then(()=>{
1808            console.info('=========ANS_Cancel_2400 onConsume cancel then======>');
1809        }).catch((err)=>{
1810            console.info('=========ANS_Cancel_2400 onConsume cancel catch err======>'+JSON.stringify(err));
1811            expect(err.code != 0).assertEqual(true);
1812        });
1813        console.info('============ANS_Cancel_2400 onConsume cancel==========>');
1814        console.info('============ANS_Cancel_2400 onConsume end=============>');
1815    }
1816    function onCancelCancelRightLabelWrongIdPromise(data) {
1817        console.info('============ANS_Cancel_2400 onCancel start:==============>');
1818        console.info('============ANS_Cancel_2400 onCancel data:===============>' + JSON.stringify(data));
1819        expect().assertFail();
1820        console.info('============ANS_Cancel_2400 onCancel end=======================>');
1821    }
1822
1823    /*
1824     * @tc.number: ANS_Cancel_2400
1825     * @tc.name: cancel(id: number, label?: string): Promise<void>
1826     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
1827                 interface is called, the label is correct and the ID is correct wrong.
1828     */
1829    it('ANS_Cancel_2400', 0, async function (done) {
1830        console.info('===============ANS_Cancel_2400 start==========================>');
1831        let subscriber ={
1832            onConsume:onConsumeCancelRightLabelWrongIdPromise,
1833            onCancel:onCancelCancelRightLabelWrongIdPromise,
1834        }
1835        await notify.subscribe(subscriber);
1836        console.info('============ANS_Cancel_2400 subscribe promise========>');
1837        let notificationRequest = {
1838            content:{
1839                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1840                normal: {
1841                    title: 'test_title',
1842                    text: 'test_text',
1843                    additionalText: 'test_additionalText'
1844                },
1845            },
1846            id: 24,
1847            slotType : notify.SlotType.OTHER_TYPES,
1848            isOngoing : true,
1849            isUnremovable : false,
1850            deliveryTime : 1624950453,
1851            tapDismissed : true,
1852            autoDeletedTime: 1625036817,
1853            color: 2,
1854            colorEnabled: true,
1855            isAlertOnce: true,
1856            isStopwatch: true,
1857            isCountDown: true,
1858            progressValue: 12,
1859            progressMaxValue: 100,
1860            isIndeterminate: true,
1861            statusBarText: 'statusBarText',
1862            isFloatingIcon : true,
1863            label: '2400',
1864            badgeIconStyle: 1,
1865            showDeliveryTime: true,
1866        }
1867        await notify.publish(notificationRequest);
1868        console.info('============ANS_Cancel_2400 publish promise==================>');
1869        setTimeout((async function(){
1870            await notify.unsubscribe(subscriber);
1871            console.info('======ANS_Cancel_2400 setTimeout unsubscribe end==================>');
1872            done();
1873        }),timeout);
1874    })
1875
1876    function onConsumeCancelWrongLabelWrongId(data) {
1877        console.info('==========ANS_Cancel_2500 onConsume start=======================>');
1878        console.info('==========ANS_Cancel_2500 onConsume data:=======================>' + JSON.stringify(data));
1879        console.info('==========ANS_Cancel_2500 onConsume label:======================>' + data.request.label);
1880        console.info('==========ANS_Cancel_2500 onConsume id==========================>' + data.request.id);
1881        notify.cancel(6666, '6666', cancelCallBackCancelWrongLabelWrongId);
1882        console.info('==========ANS_Cancel_2500 onConsume cancel====================>');
1883        console.info('==========ANS_Cancel_2500 onConsume end=======================>');
1884    }
1885    function onCancelCancelWrongLabelWrongId(data) {
1886        console.info('==========ANS_Cancel_2500 onCancel start====================>');
1887        console.info('==========ANS_Cancel_2500 onCancel data:====================>' + JSON.stringify(data));
1888        expect().assertFail();
1889        console.info('==========ANS_Cancel_2500 onCancel end======================>');
1890    }
1891    function cancelCallBackCancelWrongLabelWrongId(err){
1892        console.info('==========ANS_Cancel_2500 cancelCallBack start=======================>');
1893        console.info('==========ANS_Cancel_2500 cancelCallBack err:================>' + JSON.stringify(err));
1894        expect(err.code != 0).assertEqual(true);
1895        console.info('==========ANS_Cancel_2500 cancelCallBack end=======================>');
1896    }
1897
1898    /*
1899     * @tc.number: ANS_Cancel_2500
1900     * @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
1901     * @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
1902                 interface is called, the label is correct and the ID is correct wrong.
1903     */
1904    it('ANS_Cancel_2500', 0, async function (done) {
1905        console.info('===============ANS_Cancel_2500 start==========================>');
1906        let subscriber ={
1907            onConsume:onConsumeCancelWrongLabelWrongId,
1908            onCancel:onCancelCancelWrongLabelWrongId,
1909        }
1910        await notify.subscribe(subscriber);
1911        console.info('================ANS_Cancel_2500 subscribe promise==================>');
1912        let notificationRequest = {
1913            content:{
1914                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1915                normal: {
1916                    title: 'test_title',
1917                    text: 'test_text',
1918                    additionalText: 'test_additionalText'
1919                },
1920            },
1921            id: 25,
1922            slotType : notify.SlotType.OTHER_TYPES,
1923            isOngoing : true,
1924            isUnremovable : false,
1925            deliveryTime : 1624950453,
1926            tapDismissed : true,
1927            autoDeletedTime: 1625036817,
1928            color: 2,
1929            colorEnabled: true,
1930            isAlertOnce: true,
1931            isStopwatch: true,
1932            isCountDown: true,
1933            progressValue: 12,
1934            progressMaxValue: 100,
1935            isIndeterminate: true,
1936            statusBarText: 'statusBarText',
1937            isFloatingIcon : true,
1938            label: '2500',
1939            badgeIconStyle: 1,
1940            showDeliveryTime: true,
1941        }
1942        await notify.publish(notificationRequest);
1943        console.info('==========ANS_Cancel_2500 publish promise==================>');
1944        setTimeout((async function(){
1945            await notify.unsubscribe(subscriber);
1946            console.info('======ANS_Cancel_2500 setTimeout unsubscribe end==================>');
1947            done();
1948        }),timeout);
1949    })
1950
1951    function onConsumeCancelWrongLabelWrongIdPromise(data) {
1952        console.info('========ANS_Cancel_2600 onConsume start:=============>');
1953        console.info('========ANS_Cancel_2600 onConsume data:==============>' + JSON.stringify(data));
1954        console.info('========ANS_Cancel_2600 onConsume label:=============>' + data.request.label);
1955        console.info('========ANS_Cancel_2600 onConsume id:================>' + data.request.id);
1956        notify.cancel(6666, '6666').then(()=>{
1957            console.info('=========ANS_Cancel_2600 onConsume cancel then======>');
1958        }).catch((err)=>{
1959            console.info('=========ANS_Cancel_2600 onConsume cancel catch err======>'+JSON.stringify(err));
1960            expect(err.code != 0).assertEqual(true);
1961        });
1962        console.info('========ANS_Cancel_2600 onConsume end================>');
1963        console.info('========ANS_Cancel_2600 onConsume end================>');
1964    }
1965    function onCancelCancelWrongLabelWrongIdPromise(data) {
1966        console.info('========ANS_Cancel_2600 onCancel start=======================>');
1967        console.info('========ANS_Cancel_2600 onCancel data:=======================>' + JSON.stringify(data));
1968        expect().assertFail();
1969        console.info('========ANS_Cancel_2600 onCancel end=======================>');
1970    }
1971
1972    /*
1973     * @tc.number: ANS_Cancel_2600
1974     * @tc.name: cancel(id: number, label?: string): Promise<void>
1975     * @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
1976                 the label is wrong and the ID is wrong.
1977     */
1978    it('ANS_Cancel_2600', 0, async function (done) {
1979        console.info('===============ANS_Cancel_2600 start==========================>');
1980        let subscriber ={
1981            onConsume:onConsumeCancelWrongLabelWrongIdPromise,
1982            onCancel:onCancelCancelWrongLabelWrongIdPromise,
1983        }
1984        await notify.subscribe(subscriber);
1985        console.info('===============ANS_Cancel_2600 subscribe promise==================>');
1986        let notificationRequest = {
1987            content:{
1988                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
1989                normal: {
1990                    title: 'test_title',
1991                    text: 'test_text',
1992                    additionalText: 'test_additionalText'
1993                },
1994            },
1995            id: 26,
1996            slotType : notify.SlotType.OTHER_TYPES,
1997            isOngoing : true,
1998            isUnremovable : false,
1999            deliveryTime : 1624950453,
2000            tapDismissed : true,
2001            autoDeletedTime: 1625036817,
2002            color: 2,
2003            colorEnabled: true,
2004            isAlertOnce: true,
2005            isStopwatch: true,
2006            isCountDown: true,
2007            progressValue: 12,
2008            progressMaxValue: 100,
2009            isIndeterminate: true,
2010            statusBarText: 'statusBarText',
2011            isFloatingIcon : true,
2012            label: '2600',
2013            badgeIconStyle: 1,
2014            showDeliveryTime: true,
2015        }
2016        await notify.publish(notificationRequest);
2017        console.info('===============ANS_Cancel_2600 publish promise==================>');
2018        setTimeout((async function(){
2019            await notify.unsubscribe(subscriber);
2020            console.info('======ANS_Cancel_2600 setTimeout unsubscribe end==================>');
2021            done();
2022        }),timeout);
2023    })
2024
2025    /*
2026     * @tc.number: ANS_Cancel_2700
2027     * @tc.name: cancel(id: number, label?: string): Promise<void>
2028     * @tc.desc: add
2029     */
2030    it('ANS_Cancel_2700', 0, async function (done) {
2031        console.info('===============ANS_Cancel_2700 start==========================>');
2032        let subscriber ={
2033            onConsume:onConsumeCancelWrongLabelWrongIdPromise,
2034            onCancel:onCancelCancelWrongLabelWrongIdPromise,
2035        }
2036        await notify.subscribe(subscriber);
2037        console.info('===============ANS_Cancel_2700 subscribe promise==================>');
2038        let notificationRequest = {
2039            content:{
2040                contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2041                normal: {
2042                    title: 'test_title',
2043                    text: 'test_text',
2044                    additionalText: 'test_additionalText'
2045                },
2046            },
2047            extraInfo:{
2048                key1: "1231",
2049                key2:"456"
2050            },
2051            template:{
2052                name:'/system/etc/notification_template/assets/js/downloadTemplate.js',
2053                data:{key3:"789",key4:"111"}
2054            },
2055            badgeNumber:1,
2056        }
2057        await notify.publish(notificationRequest);
2058        console.info('===============ANS_Cancel_2700 publish promise==================>');
2059        setTimeout((async function(){
2060            await notify.unsubscribe(subscriber);
2061            console.info('======ANS_Cancel_2700 setTimeout unsubscribe end==================>');
2062            done();
2063        }),timeout);
2064    })
2065})