• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 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 { paramMock } from "../utils"
17import { NotificationSlot } from "./notification/notificationSlot"
18import { NotificationRequest } from "./notification/notificationRequest"
19
20export const SlotType = {
21  UNKNOWN_TYPE: 0,
22  SOCIAL_COMMUNICATION: 1,
23  SERVICE_INFORMATION: 2,
24  CONTENT_INFORMATION: 3,
25  OTHER_TYPES: 0xFFFF,
26}
27export const ContentType = {
28  NOTIFICATION_CONTENT_BASIC_TEXT: 0,
29  NOTIFICATION_CONTENT_LONG_TEXT: 1,
30  NOTIFICATION_CONTENT_PICTURE: 2,
31  NOTIFICATION_CONTENT_CONVERSATION: 3,
32  NOTIFICATION_CONTENT_MULTILINE: 4,
33}
34export const SlotLevel = {
35  LEVEL_NONE: 0,
36  LEVEL_MIN: 1,
37  LEVEL_LOW: 2,
38  LEVEL_DEFAULT: 3,
39  LEVEL_HIGH: 4,
40}
41export const BundleOption = {
42  bundle: '[PC preview] unknow bundle',
43  uid: '[PC preview] unknow uid',
44}
45export const NotificationKey = {
46  id: '[PC preview] unknow id',
47  label: '[PC preview] unknow label',
48}
49export const DoNotDisturbType = {
50  TYPE_NONE: 0,
51  TYPE_ONCE: 1,
52  TYPE_DAILY: 2,
53  TYPE_CLEARLY: 3,
54}
55const Date = {
56  toString: function () {
57    console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" +
58      " may be different from that on a real device.")
59    return paramMock.paramStringMock
60  },
61  toDateString: function () {
62    console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" +
63      " may be different from that on a real device.")
64    return paramMock.paramStringMock
65  },
66  toTimeString: function () {
67    console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" +
68      " may be different from that on a real device.")
69    return paramMock.paramStringMock
70  },
71  toLocaleString: function () {
72    console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" +
73      " may be different from that on a real device.")
74    return paramMock.paramStringMock
75  },
76  toLocaleDateString: function () {
77    console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" +
78      " may be different from that on a real device.")
79    return paramMock.paramStringMock
80  },
81  toLocaleTimeString: function () {
82    console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" +
83      " may be different from that on a real device.")
84    return paramMock.paramStringMock
85  },
86  valueOf: function () {
87    console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" +
88      " may be different from that on a real device.")
89    return paramMock.paramNumberMock
90  },
91  getTime: function () {
92    console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" +
93      " may be different from that on a real device.")
94    return paramMock.paramNumberMock
95  },
96  getFullYear: function () {
97    console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
98      " may be different from that on a real device.")
99    return paramMock.paramNumberMock
100  },
101  getUTCFullYear: function () {
102    console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
103      " may be different from that on a real device.")
104    return paramMock.paramNumberMock
105  },
106  getMonth: function () {
107    console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" +
108      " may be different from that on a real device.")
109    return paramMock.paramNumberMock
110  },
111  getUTCMonth: function () {
112    console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" +
113      " may be different from that on a real device.")
114    return paramMock.paramNumberMock
115  },
116  getDate: function () {
117    console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" +
118      " may be different from that on a real device.")
119    return paramMock.paramNumberMock
120  },
121  getUTCDate: function () {
122    console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" +
123      " may be different from that on a real device.")
124    return paramMock.paramNumberMock
125  },
126  getDay: function () {
127    console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" +
128      " may be different from that on a real device.")
129    return paramMock.paramNumberMock
130  },
131  getUTCDay: function () {
132    console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" +
133      " may be different from that on a real device.")
134    return paramMock.paramNumberMock
135  },
136  getHours: function () {
137    console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" +
138      " may be different from that on a real device.")
139    return paramMock.paramNumberMock
140  },
141  getUTCHours: function () {
142    console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" +
143      " may be different from that on a real device.")
144    return paramMock.paramNumberMock
145  },
146  getMinutes: function () {
147    console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
148      " may be different from that on a real device.")
149    return paramMock.paramNumberMock
150  },
151  getUTCMinutes: function () {
152    console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
153      " may be different from that on a real device.")
154    return paramMock.paramNumberMock
155  },
156  getSeconds: function () {
157    console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
158      " may be different from that on a real device.")
159    return paramMock.paramNumberMock
160  },
161  getUTCSeconds: function () {
162    console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
163      " may be different from that on a real device.")
164    return paramMock.paramNumberMock
165  },
166  getMilliseconds: function () {
167    console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
168      " may be different from that on a real device.")
169    return paramMock.paramNumberMock
170  },
171  getUTCMilliseconds: function () {
172    console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
173      " may be different from that on a real device.")
174    return paramMock.paramNumberMock
175  },
176  getTimezoneOffset: function () {
177    console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" +
178      " may be different from that on a real device.")
179    return paramMock.paramNumberMock
180  },
181  setTime: function (...args) {
182    console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
183      " may be different from that on a real device.")
184    return paramMock.paramNumberMock
185  },
186  setMilliseconds: function (...args) {
187    console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
188      " may be different from that on a real device.")
189    return paramMock.paramNumberMock
190  },
191  setUTCMilliseconds: function (...args) {
192    console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
193      " may be different from that on a real device.")
194    return paramMock.paramNumberMock
195  },
196  setSeconds: function (...args) {
197    console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
198      " may be different from that on a real device.")
199    return paramMock.paramNumberMock
200  },
201  setUTCSeconds: function (...args) {
202    console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
203      " may be different from that on a real device.")
204    return paramMock.paramNumberMock
205  },
206  setMinutes: function (...args) {
207    console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
208      " may be different from that on a real device.")
209    return paramMock.paramNumberMock
210  },
211  setUTCMinutes: function (...args) {
212    console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
213      " may be different from that on a real device.")
214    return paramMock.paramNumberMock
215  },
216  setHours: function (...args) {
217    console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" +
218      " may be different from that on a real device.")
219    return paramMock.paramNumberMock
220  },
221  setUTCHours: function (...args) {
222    console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" +
223      " may be different from that on a real device.")
224    return paramMock.paramNumberMock
225  },
226  setDate: function (...args) {
227    console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" +
228      " may be different from that on a real device.")
229    return paramMock.paramNumberMock
230  },
231  setUTCDate: function (...args) {
232    console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" +
233      " may be different from that on a real device.")
234    return paramMock.paramNumberMock
235  },
236  setMonth: function (...args) {
237    console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" +
238      " may be different from that on a real device.")
239    return paramMock.paramNumberMock
240  },
241  setUTCMonth: function (...args) {
242    console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" +
243      " may be different from that on a real device.")
244    return paramMock.paramNumberMock
245  },
246  setFullYear: function (...args) {
247    console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
248      " may be different from that on a real device.")
249    return paramMock.paramNumberMock
250  },
251  setUTCFullYear: function (...args) {
252    console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
253      " may be different from that on a real device.")
254    return paramMock.paramNumberMock
255  },
256  toUTCString: function () {
257    console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" +
258      " may be different from that on a real device.")
259    return paramMock.paramStringMock
260  },
261  toISOString: function () {
262    console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" +
263      " may be different from that on a real device.")
264    return paramMock.paramStringMock
265  },
266  toJSON: function (...args) {
267    console.warn("Date.toJSON interface mocked in the Previewer. How this interface works on the Previewer" +
268      " may be different from that on a real device.")
269    return paramMock.paramStringMock
270  },
271}
272export const DoNotDisturbDate = {
273  type: DoNotDisturbType,
274  begin: Date,
275  end: Date,
276}
277export const DeviceRemindType = {
278  IDLE_DONOT_REMIND: 0,
279  IDLE_REMIND: 1,
280  ACTIVE_DONOT_REMIND: 2,
281  ACTIVE_REMIND: 3,
282}
283export const SourceType = {
284  TYPE_NORMAL: 0,
285  TYPE_CONTINUOUS: 1,
286  TYPE_TIMER: 2,
287}
288export function mockNotification() {
289  const notification = {
290    publish: function (...args) {
291      console.warn('notification.publish interface mocked in the Previewer. How this interface works on the' +
292        ' Previewer may be different from that on a real device.');
293      const len = args.length;
294      if (typeof args[len - 1] === 'function') {
295        args[len - 1].call(this, paramMock.businessErrorMock);
296      } else {
297        return new Promise((resolve) => {
298          resolve();
299        });
300      }
301    },
302    publishAsBundle: function (...args) {
303      console.warn('notification.publishAsBundle interface mocked in the Previewer. How this interface works on the' +
304        ' Previewer may be different from that on a real device.');
305      const len = args.length;
306      if (typeof args[len - 1] === 'function') {
307        args[len - 1].call(this, paramMock.businessErrorMock);
308      } else {
309        return new Promise((resolve, reject) => {
310          resolve();
311        });
312      }
313    },
314    cancel: function (...args) {
315      console.warn('notification.cancel interface mocked in the Previewer. How this interface works on the' +
316        ' Previewer may be different from that on a real device.');
317      const len = args.length;
318      if (typeof args[len - 1] === 'function') {
319        args[len - 1].call(this, paramMock.businessErrorMock);
320      } else {
321        return new Promise((resolve) => {
322          resolve();
323        });
324      }
325    },
326    cancelAsBundle: function (...args) {
327      console.warn('notification.cancelAsBundle interface mocked in the Previewer. How this interface works on the' +
328        ' Previewer may be different from that on a real device.');
329      const len = args.length;
330      if (typeof args[len - 1] === 'function') {
331        args[len - 1].call(this, paramMock.businessErrorMock);
332      } else {
333        return new Promise((resolve, reject) => {
334          resolve();
335        });
336      }
337    },
338    cancelAll: function (...args) {
339      console.warn('notification.cancelAll interface mocked in the Previewer. How this interface works on the' +
340        ' Previewer may be different from that on a real device.');
341      const len = args.length;
342      if (typeof args[len - 1] === 'function') {
343        args[len - 1].call(this, paramMock.businessErrorMock);
344      } else {
345        return new Promise((resolve) => {
346          resolve();
347        });
348      }
349    },
350    addSlot: function (...args) {
351      console.warn('notification.addSlot interface mocked in the Previewer. How this interface works on the' +
352        ' Previewer may be different from that on a real device.');
353      const len = args.length;
354      if (typeof args[len - 1] === 'function') {
355        args[len - 1].call(this, paramMock.businessErrorMock);
356      } else {
357        return new Promise((resolve) => {
358          resolve();
359        });
360      }
361    },
362    addSlots: function (...args) {
363      console.warn('notification.addSlots interface mocked in the Previewer. How this interface works on the' +
364        ' Previewer may be different from that on a real device.');
365      const len = args.length;
366      if (typeof args[len - 1] === 'function') {
367        args[len - 1].call(this, paramMock.businessErrorMock);
368      } else {
369        return new Promise((resolve) => {
370          resolve();
371        });
372      }
373    },
374    getSlot: function (...args) {
375      console.warn('notification.getSlot interface mocked in the Previewer. How this interface works on the' +
376        ' Previewer may be different from that on a real device.');
377      const len = args.length;
378      if (typeof args[len - 1] === 'function') {
379        args[len - 1].call(this, paramMock.businessErrorMock, NotificationSlot);
380      } else {
381        return new Promise((resolve) => {
382          resolve(NotificationSlot);
383        });
384      }
385    },
386    getSlots: function (...args) {
387      console.warn('notification.getSlots interface mocked in the Previewer. How this interface works on the' +
388        ' Previewer may be different from that on a real device.');
389      const len = args.length;
390      if (typeof args[len - 1] === 'function') {
391        args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]);
392      } else {
393        return new Promise((resolve) => {
394          resolve([NotificationSlot]);
395        });
396      }
397    },
398    removeSlot: function (...args) {
399      console.warn('notification.removeSlot interface mocked in the Previewer. How this interface works on the' +
400        ' Previewer may be different from that on a real device.');
401      const len = args.length;
402      if (typeof args[len - 1] === 'function') {
403        args[len - 1].call(this, paramMock.businessErrorMock);
404      } else {
405        return new Promise((resolve) => {
406          resolve();
407        });
408      }
409    },
410    removeAllSlots: function (...args) {
411      console.warn('notification.removeAllSlots interface mocked in the Previewer. How this interface works on the' +
412        ' Previewer may be different from that on a real device.');
413      const len = args.length;
414      if (typeof args[len - 1] === 'function') {
415        args[len - 1].call(this, paramMock.businessErrorMock);
416      } else {
417        return new Promise((resolve) => {
418          resolve();
419        });
420      }
421    },
422    SlotType,
423    ContentType,
424    SlotLevel,
425    subscribe: function (...args) {
426      console.warn('notification.subscribe interface mocked in the Previewer. How this interface works on the' +
427        ' Previewer may be different from that on a real device.');
428      const len = args.length;
429      if (typeof args[len - 1] === 'function') {
430        args[len - 1].call(this, paramMock.businessErrorMock);
431      } else {
432        return new Promise((resolve) => {
433          resolve();
434        });
435      }
436    },
437    unsubscribe: function (...args) {
438      console.warn('notification.unsubscribe interface mocked in the Previewer. How this interface works on the' +
439        ' Previewer may be different from that on a real device.');
440      const len = args.length;
441      if (typeof args[len - 1] === 'function') {
442        args[len - 1].call(this, paramMock.businessErrorMock);
443      } else {
444        return new Promise((resolve) => {
445          resolve();
446        });
447      }
448    },
449    enableNotification: function (...args) {
450      console.warn('notification.enableNotification interface mocked in the Previewer. How this interface works on the' +
451        ' Previewer may be different from that on a real device.');
452      const len = args.length;
453      if (typeof args[len - 1] === 'function') {
454        args[len - 1].call(this, paramMock.businessErrorMock);
455      } else {
456        return new Promise((resolve) => {
457          resolve();
458        });
459      }
460    },
461    isNotificationEnabled: function (...args) {
462      console.warn('notification.isNotificationEnabled interface mocked in the Previewer. How this interface works on the' +
463        ' Previewer may be different from that on a real device.');
464      const len = args.length;
465      if (typeof args[len - 1] === 'function') {
466        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
467      } else {
468        return new Promise((resolve) => {
469          resolve(paramMock.paramBooleanMock);
470        });
471      }
472    },
473    displayBadge: function (...args) {
474      console.warn('notification.displayBadge interface mocked in the Previewer. How this interface works on the' +
475        ' Previewer may be different from that on a real device.');
476      const len = args.length;
477      if (typeof args[len - 1] === 'function') {
478        args[len - 1].call(this, paramMock.businessErrorMock);
479      } else {
480        return new Promise((resolve) => {
481          resolve();
482        });
483      }
484    },
485    isBadgeDisplayed: function (...args) {
486      console.warn('notification.isBadgeDisplayed interface mocked in the Previewer. How this interface works on the' +
487        ' Previewer may be different from that on a real device.');
488      const len = args.length;
489      if (typeof args[len - 1] === 'function') {
490        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
491      } else {
492        return new Promise((resolve) => {
493          resolve(paramMock.paramBooleanMock);
494        });
495      }
496    },
497    setSlotByBundle: function (...args) {
498      console.warn('notification.setSlotByBundle interface mocked in the Previewer. How this interface works on the' +
499        ' Previewer may be different from that on a real device.');
500      const len = args.length;
501      if (typeof args[len - 1] === 'function') {
502        args[len - 1].call(this, paramMock.businessErrorMock);
503      } else {
504        return new Promise((resolve) => {
505          resolve();
506        });
507      }
508    },
509    getSlotsByBundle: function (...args) {
510      console.warn('notification.getSlotsByBundle interface mocked in the Previewer. How this interface works on the' +
511        ' Previewer may be different from that on a real device.');
512      const len = args.length;
513      if (typeof args[len - 1] === 'function') {
514        args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]);
515      } else {
516        return new Promise((resolve) => {
517          resolve([NotificationSlot]);
518        });
519      }
520    },
521    getSlotNumByBundle: function (...args) {
522      console.warn('notification.getSlotNumByBundle interface mocked in the Previewer. How this interface works on the' +
523        ' Previewer may be different from that on a real device.');
524      const len = args.length;
525      if (typeof args[len - 1] === 'function') {
526        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
527      } else {
528        return new Promise((resolve) => {
529          resolve(paramMock.paramNumberMock);
530        });
531      }
532    },
533    remove: function (...args) {
534      console.warn('notification.remove interface mocked in the Previewer. How this interface works on the' +
535        ' Previewer may be different from that on a real device.');
536      const len = args.length;
537      if (typeof args[len - 1] === 'function') {
538        args[len - 1].call(this, paramMock.businessErrorMock);
539      } else {
540        return new Promise((resolve) => {
541          resolve();
542        });
543      }
544    },
545    removeAll: function (...args) {
546      console.warn('notification.removeAll interface mocked in the Previewer. How this interface works on the' +
547        ' Previewer may be different from that on a real device.');
548      const len = args.length;
549      if (typeof args[len - 1] === 'function') {
550        args[len - 1].call(this, paramMock.businessErrorMock);
551      } else {
552        return new Promise((resolve) => {
553          resolve();
554        });
555      }
556    },
557    getAllActiveNotifications: function (...args) {
558      console.warn('notification.getAllActiveNotifications interface mocked in the Previewer. How this interface works on the' +
559        ' Previewer may be different from that on a real device.');
560      const len = args.length;
561      if (typeof args[len - 1] === 'function') {
562        args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]);
563      } else {
564        return new Promise((resolve) => {
565          resolve([NotificationRequest]);
566        });
567      }
568    },
569    getActiveNotificationCount: function (...args) {
570      console.warn('notification.getActiveNotificationCount interface mocked in the Previewer. How this interface works on the' +
571        ' Previewer may be different from that on a real device.');
572      const len = args.length;
573      if (typeof args[len - 1] === 'function') {
574        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
575      } else {
576        return new Promise((resolve) => {
577          resolve(paramMock.paramNumberMock);
578        });
579      }
580    },
581    getActiveNotifications: function (...args) {
582      console.warn('notification.getActiveNotifications interface mocked in the Previewer. How this interface works on the' +
583        ' Previewer may be different from that on a real device.');
584      const len = args.length;
585      if (typeof args[len - 1] === 'function') {
586        args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]);
587      } else {
588        return new Promise((resolve) => {
589          resolve([NotificationRequest]);
590        });
591      }
592    },
593    cancelGroup: function (...args) {
594      console.warn("notification.cancelGroup interface mocked in the Previewer. How this interface works on the" +
595        " Previewer may be different from that on a real device.")
596      const len = args.length
597      if (len > 0 && typeof args[len - 1] === 'function') {
598        args[len - 1].call(this, paramMock.businessErrorMock);
599      } else {
600        return new Promise((resolve, reject) => {
601          resolve();
602        })
603      }
604    },
605    removeGroupByBundle: function (...args) {
606      console.warn("notification.removeGroupByBundle interface mocked in the Previewer. How this interface works on the" +
607        " Previewer may be different from that on a real device.")
608      const len = args.length
609      if (len > 0 && typeof args[len - 1] === 'function') {
610        args[len - 1].call(this, paramMock.businessErrorMock);
611      } else {
612        return new Promise((resolve, reject) => {
613          resolve();
614        })
615      }
616    },
617    setDoNotDisturbDate: function (...args) {
618      console.warn("notification.setDoNotDisturbDate interface mocked in the Previewer. How this interface works on the" +
619        " Previewer may be different from that on a real device.")
620      const len = args.length
621      if (len > 0 && typeof args[len - 1] === 'function') {
622        args[len - 1].call(this, paramMock.businessErrorMock);
623      } else {
624        return new Promise((resolve, reject) => {
625          resolve();
626        })
627      }
628    },
629    getDoNotDisturbDate: function (...args) {
630      console.warn("notification.getDoNotDisturbDate interface mocked in the Previewer." +
631        " How this interface works on the Previewer may be different from that on a real device.")
632      const len = args.length
633      if (len > 0 && typeof args[len - 1] === 'function') {
634        args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDate);
635      } else {
636        return new Promise((resolve, reject) => {
637          resolve(DoNotDisturbDate);
638        })
639      }
640    },
641    supportDoNotDisturbMode: function (...args) {
642      console.warn("notification.supportDoNotDisturbMode interface mocked in the Previewer. How this interface works on the" +
643        " Previewer may be different from that on a real device.")
644      const len = args.length
645      if (len > 0 && typeof args[len - 1] === 'function') {
646        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
647      } else {
648        return new Promise((resolve, reject) => {
649          resolve(paramMock.paramBooleanMock);
650        })
651      }
652    },
653    isSupportTemplate: function (...args) {
654      console.warn("notification.isSupportTemplate interface mocked in the Previewer. How this interface works on the" +
655        " Previewer may be different from that on a real device.")
656      const len = args.length
657      if (len > 0 && typeof args[len - 1] === 'function') {
658        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
659      } else {
660        return new Promise((resolve, reject) => {
661          resolve(paramMock.paramBooleanMock);
662        })
663      }
664    },
665    requestEnableNotification: function (...args) {
666      console.warn("notification.requestEnableNotification interface mocked in the Previewer. How this interface works on the" +
667        " Previewer may be different from that on a real device.")
668      const len = args.length
669      if (len > 0 && typeof args[len - 1] === 'function') {
670        args[len - 1].call(this, paramMock.businessErrorMock);
671      } else {
672        return new Promise((resolve, reject) => {
673          resolve();
674        })
675      }
676    },
677    enableDistributed: function (...args) {
678      console.warn("notification.enableDistributed interface mocked in the Previewer. How this interface works on the" +
679        " Previewer may be different from that on a real device.")
680      const len = args.length
681      if (len > 0 && typeof args[len - 1] === 'function') {
682        args[len - 1].call(this, paramMock.businessErrorMock);
683      } else {
684        return new Promise((resolve, reject) => {
685          resolve();
686        })
687      }
688    },
689    isDistributedEnabled: function (...args) {
690      console.warn("notification.isDistributedEnabled interface mocked in the Previewer. How this interface works on the" +
691        " Previewer may be different from that on a real device.")
692      const len = args.length
693      if (len > 0 && typeof args[len - 1] === 'function') {
694        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
695      } else {
696        return new Promise((resolve, reject) => {
697          resolve(paramMock.paramBooleanMock);
698        })
699      }
700    },
701    enableDistributedByBundle: function (...args) {
702      console.warn("notification.enableDistributedByBundle interface mocked in the Previewer. How this interface works on the" +
703        " Previewer may be different from that on a real device.")
704      const len = args.length
705      if (len > 0 && typeof args[len - 1] === 'function') {
706        args[len - 1].call(this, paramMock.businessErrorMock);
707      } else {
708        return new Promise((resolve, reject) => {
709          resolve();
710        })
711      }
712    },
713    isDistributedEnabledByBundle: function (...args) {
714      console.warn("notification.isDistributedEnabledByBundle interface mocked in the Previewer. How this interface works on the" +
715        " Previewer may be different from that on a real device.")
716      const len = args.length
717      if (len > 0 && typeof args[len - 1] === 'function') {
718        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
719      } else {
720        return new Promise((resolve, reject) => {
721          resolve(paramMock.paramBooleanMock);
722        })
723      }
724    },
725    getDeviceRemindType: function (...args) {
726      console.warn("notification.getDeviceRemindType interface mocked in the Previewer. How this interface works on the" +
727        " Previewer may be different from that on a real device.")
728      const len = args.length
729      if (len > 0 && typeof args[len - 1] === 'function') {
730        args[len - 1].call(this, paramMock.businessErrorMock, DeviceRemindType);
731      } else {
732        return new Promise((resolve, reject) => {
733          resolve(DeviceRemindType);
734        })
735      }
736    },
737    isNotificationSlotEnabled: function (...args) {
738      console.warn("notification.isNotificationSlotEnabled interface mocked in the Previewer. How this interface works on the" +
739        " Previewer may be different from that on a real device.")
740      const len = args.length
741      if (len > 0 && typeof args[len - 1] === 'function') {
742        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
743      } else {
744        return new Promise((resolve, reject) => {
745          resolve(paramMock.paramBooleanMock);
746        })
747      }
748    },
749    setSyncNotificationEnabledForUninstallApp: function (...args) {
750      console.warn("notification.setSyncNotificationEnabledForUninstallApp interface mocked in the Previewer. How this interface works on the" +
751        " Previewer may be different from that on a real device.")
752      const len = args.length
753      if (len > 0 && typeof args[len - 1] === 'function') {
754        args[len - 1].call(this, paramMock.businessErrorMock);
755      } else {
756        return new Promise((resolve, reject) => {
757          resolve();
758        })
759      }
760    },
761    enableNotificationSlot: function (...args) {
762      console.warn("notification.enableNotificationSlot interface mocked in the Previewer. How this interface works on the" +
763        " Previewer may be different from that on a real device.")
764      const len = args.length
765      if (len > 0 && typeof args[len - 1] === 'function') {
766        args[len - 1].call(this, paramMock.businessErrorMock);
767      } else {
768        return new Promise((resolve, reject) => {
769          resolve();
770        })
771      }
772    },
773    getSyncNotificationEnabledForUninstallApp: function (...args) {
774      console.warn("notification.getSyncNotificationEnabledForUninstallApp interface mocked in the Previewer. How this interface works on the" +
775        " Previewer may be different from that on a real device.")
776      const len = args.length
777      if (len > 0 && typeof args[len - 1] === 'function') {
778        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
779      } else {
780        return new Promise((resolve, reject) => {
781          resolve(paramMock.paramBooleanMock);
782        })
783      }
784    },
785    BundleOption,
786    NotificationKey,
787    DoNotDisturbType,
788    DoNotDisturbDate,
789    DeviceRemindType,
790    SourceType
791  }
792  return notification
793}
794