• 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
16// @ts-nocheck
17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
18import systemTimer from '@ohos.systemTimer'
19
20describe('SystemTimerExceptionTest', function () {
21    console.log('start################################start');
22
23    async function testCreateTimerPromise(options, done) {
24        try {
25            systemTimer.createTimer(options).then(() => {
26                expect(false).assertTrue();
27                done();
28            })
29        } catch (err) {
30            expect(err.code).assertEqual(401);
31            done();
32        }
33    }
34
35    async function testCreateTimerCallback(options, done) {
36        try {
37            systemTimer.createTimer(options, (err) => {
38                if (err) {
39                    expect(err.code).assertEqual(401);
40                } else {
41                    expect(false).assertTrue();
42                }
43                done();
44            })
45        } catch (err) {
46            expect(err.code).assertEqual(401);
47            done();
48        }
49    }
50
51    let timeErr = function (err, done) {
52        if (err) {
53            expect(true).assertTrue();
54        } else {
55            expect(false).assertTrue();
56        }
57        done();
58    }
59
60    /**
61     * @tc.number: TestCreateTimerType001
62     * @tc.name: TestCreateTimerType001
63     * @tc.desc: Test createTimer for promise when type is 16.
64     * @tc.size: MediumTest
65     * @tc.type: Function
66     * @tc.level: Level 1
67     * @tc.require:
68     */
69    it('testCreateTimerType001', 0, async function (done) {
70        console.log("testCreateTimerType001 start")
71        let options = {
72            type: 16,
73            repeat: false
74        }
75        let timerId = await systemTimer.createTimer(options)
76        console.info(`timerId ${timerId}`)
77        expect(timerId !== 0).assertTrue();
78        done();
79        console.log('testCreateTimerType001 end');
80    });
81
82    /**
83     * @tc.number: TestCreateTimerType002
84     * @tc.name: TestCreateTimerType002
85     * @tc.desc: Test createTimer for promise when type is string.
86     * @tc.size: MediumTest
87     * @tc.type: Function
88     * @tc.level: Level 1
89     * @tc.require:
90     */
91    it('testCreateTimerType002', 0, async function (done) {
92        console.log("testCreateTimerType002 start")
93        let options = {
94            type: "type",
95            repeat: false
96        }
97        await testCreateTimerPromise(options, done);
98        console.log('testCreateTimerType002 end');
99    });
100
101    /**
102     * @tc.number: TestCreateTimerRepeat003
103     * @tc.name: TestCreateTimerRepeat003
104     * @tc.desc: Test createTimer for promise when repeat is string.
105     * @tc.size: MediumTest
106     * @tc.type: Function
107     * @tc.level: Level 1
108     * @tc.require:
109     */
110    it('testCreateTimerRepeat003', 0, async function (done) {
111        console.log("testCreateTimerRepeat003 start")
112        let options = {
113            type: systemTimer.TIMER_TYPE_EXACT,
114            repeat: "true"
115        }
116        await testCreateTimerPromise(options, done);
117        console.log('testCreateTimerRepeat003 end');
118    });
119
120
121    /**
122     * @tc.number: TestCreateTimerWantAgent004
123     * @tc.name: TestCreateTimerWantAgent004
124     * @tc.desc: Test createTimer for promise when wantAgent is number.
125     * @tc.size: MediumTest
126     * @tc.type: Function
127     * @tc.level: Level 1
128     * @tc.require:
129     */
130    it('testCreateTimerWantAgent004', 0, async function (done) {
131        console.log("testCreateTimerWantAgent004 start")
132        let options = {
133            type: systemTimer.TIMER_TYPE_EXACT,
134            repeat: false,
135            wantAgent: 123,
136        }
137        await testCreateTimerPromise(options, done);
138        console.log('testCreateTimerWantAgent004 end');
139    });
140
141    /**
142     * @tc.number: TestCreateTimerCallback005
143     * @tc.name: TestCreateTimerCallback005
144     * @tc.desc: Test createTimer for promise when callback is number.
145     * @tc.size: MediumTest
146     * @tc.type: Function
147     * @tc.level: Level 1
148     * @tc.require:
149     */
150    it('testCreateTimerCallback005', 0, async function (done) {
151        console.log("testCreateTimerCallback005 start")
152        let options = {
153            type: systemTimer.TIMER_TYPE_EXACT,
154            repeat: false,
155            callback: 123,
156        }
157        await testCreateTimerPromise(options, done);
158        console.log('testCreateTimerCallback005 end');
159    });
160
161    /**
162     * @tc.number: TestCreateTimerNull006
163     * @tc.name: TestCreateTimerNull006
164     * @tc.desc: Test createTimer for promise when option is null.
165     * @tc.size: MediumTest
166     * @tc.type: Function
167     * @tc.level: Level 1
168     * @tc.require:
169     */
170    it('testCreateTimerNull006', 0, async function (done) {
171        console.log("testCreateTimerNull006 start")
172        try {
173            systemTimer.createTimer(null).then(() => {
174                expect(false).assertTrue();
175                done();
176            })
177        } catch (err) {
178            expect(err.code).assertEqual(401);
179            done();
180        }
181        console.log('testCreateTimerNull006 end');
182    });
183
184    /**
185     * @tc.number: TestCreateTimerRepeat007
186     * @tc.name: TestCreateTimerRepeat007
187     * @tc.desc: Test createTimer for promise when not repeat.
188     * @tc.size: MediumTest
189     * @tc.type: Function
190     * @tc.level: Level 1
191     * @tc.require:
192     */
193    it('testCreateTimerRepeat007', 0, async function (done) {
194        console.log("testCreateTimerRepeat007 start")
195        let options = {
196            type: systemTimer.TIMER_TYPE_EXACT
197        }
198        await testCreateTimerPromise(options, done);
199        console.log('testCreateTimerRepeat007 end');
200    });
201
202    /**
203     * @tc.number: TestCreateTimerInterval008
204     * @tc.name: TestCreateTimerInterval008
205     * @tc.desc: Test createTimer for promise when interval is string .
206     * @tc.size: MediumTest
207     * @tc.type: Function
208     * @tc.level: Level 1
209     * @tc.require:
210     */
211    it('testCreateTimerInterval008', 0, async function (done) {
212        console.log("testCreateTimerInterval008 start")
213        let options = {
214            type: systemTimer.TIMER_TYPE_EXACT,
215            repeat: false,
216            interval: "1000"
217        }
218        await testCreateTimerPromise(options, done);
219        console.log('testCreateTimerInterval008 end');
220    });
221
222    /**
223     * @tc.number: TestCreateTimerType009
224     * @tc.name: TestCreateTimerType009
225     * @tc.desc: Test createTimer for callback when type is 16.
226     * @tc.size: MediumTest
227     * @tc.type: Function
228     * @tc.level: Level 1
229     * @tc.require:
230     */
231    it('testCreateTimerType009', 0, async function (done) {
232        console.log("testCreateTimerType009 start")
233        let options = {
234            type: 16,
235            repeat: false
236        }
237        try {
238            systemTimer.createTimer(options, (err) => {
239                if (err) {
240                    expect(false).assertTrue();
241                }
242                expect(true).assertTrue();
243                done();
244            })
245        } catch (err) {
246            expect(false).assertTrue();
247            done();
248        }
249        console.log('testCreateTimerType009 end');
250    });
251
252    /**
253     * @tc.number: TestCreateTimerType010
254     * @tc.name: TestCreateTimerType010
255     * @tc.desc: Test createTimer for callback when type is string .
256     * @tc.size: MediumTest
257     * @tc.type: Function
258     * @tc.level: Level 1
259     * @tc.require:
260     */
261    it('testCreateTimerType010', 0, async function (done) {
262        console.log("testCreateTimerType010 start")
263        let options = {
264            type: "type",
265            repeat: false
266        }
267        await testCreateTimerCallback(options, done);
268        console.log('testCreateTimerType010 end');
269    });
270
271    /**
272     * @tc.number: TestCreateTimerRepeat011
273     * @tc.name: TestCreateTimerRepeat011
274     * @tc.desc: Test createTimer for callback when repeat is string .
275     * @tc.size: MediumTest
276     * @tc.type: Function
277     * @tc.level: Level 1
278     * @tc.require:
279     */
280    it('testCreateTimerRepeat011', 0, async function (done) {
281        console.log("testCreateTimerRepeat011 start")
282        let options = {
283            type: systemTimer.TIMER_TYPE_EXACT,
284            repeat: "true"
285        }
286        await testCreateTimerCallback(options, done);
287        console.log('testCreateTimerRepeat011 end');
288    });
289
290    /**
291     * @tc.number: TestCreateTimerWantAgent012
292     * @tc.name: TestCreateTimerWantAgent012
293     * @tc.desc: Test createTimer for callback when wantAgent is number.
294     * @tc.size: MediumTest
295     * @tc.type: Function
296     * @tc.level: Level 1
297     * @tc.require:
298     */
299    it('testCreateTimerWantAgent012', 0, async function (done) {
300        console.log("testCreateTimerWantAgent012 start")
301        let options = {
302            type: systemTimer.TIMER_TYPE_EXACT,
303            repeat: false,
304            wantAgent: 123,
305        }
306        await testCreateTimerCallback(options, done);
307        console.log('testCreateTimerWantAgent012 end');
308    });
309
310    /**
311     * @tc.number: TestCreateTimerCallback013
312     * @tc.name: TestCreateTimerCallback013
313     * @tc.desc: Test createTimer for callback when callback is number.
314     * @tc.size: MediumTest
315     * @tc.type: Function
316     * @tc.level: Level 1
317     * @tc.require:
318     */
319    it('testCreateTimerCallback013', 0, async function (done) {
320        console.log("testCreateTimerCallback013 start")
321        let options = {
322            type: systemTimer.TIMER_TYPE_EXACT,
323            repeat: false,
324            callback: 123,
325        }
326        await testCreateTimerCallback(options, done);
327        console.log('testCreateTimerCallback013 end');
328    });
329
330    /**
331     * @tc.number: TestCreateTimerNull014
332     * @tc.name: TestCreateTimerNull014
333     * @tc.desc: Test createTimer for callback when option is null.
334     * @tc.size: MediumTest
335     * @tc.type: Function
336     * @tc.level: Level 1
337     * @tc.require:
338     */
339    it('testCreateTimerNull014', 0, async function (done) {
340        console.log("testCreateTimerNull014 start")
341        try {
342            systemTimer.createTimer(null, (err) => {
343                if (err) {
344                    expect(err.code).assertEqual(401);
345                } else {
346                    expect(false).assertTrue();
347                }
348                done();
349            })
350        } catch (err) {
351            expect(err.code).assertEqual(401);
352            done();
353        }
354        console.log('testCreateTimerNull014 end');
355    });
356
357    /**
358     * @tc.number: TestCreateTimerRepeat015
359     * @tc.name: TestCreateTimerRepeat015
360     * @tc.desc: Test createTimer for callback when not repeat.
361     * @tc.size: MediumTest
362     * @tc.type: Function
363     * @tc.level: Level 1
364     * @tc.require:
365     */
366    it('testCreateTimerRepeat015', 0, async function (done) {
367        console.log("testCreateTimerRepeat015 start")
368        let options = {
369            type: systemTimer.TIMER_TYPE_EXACT
370        }
371        await testCreateTimerCallback(options, done);
372        console.log('testCreateTimerRepeat015 end');
373    });
374
375    /**
376     * @tc.number: TestCreateTimerInterval016
377     * @tc.name: TestCreateTimerInterval016
378     * @tc.desc: Test createTimer for callback when interval is string .
379     * @tc.size: MediumTest
380     * @tc.type: Function
381     * @tc.level: Level 1
382     * @tc.require:
383     */
384    it('testCreateTimerInterval016', 0, async function (done) {
385        console.log("testCreateTimerInterval008 start")
386        let options = {
387            type: systemTimer.TIMER_TYPE_EXACT,
388            repeat: false,
389            interval: "1000"
390        }
391        try {
392            systemTimer.createTimer(options, (err) => {
393                if (err) {
394                    expect(err.code).assertEqual(401);
395                } else {
396                    expect(false).assertTrue();
397                }
398                done();
399            })
400        } catch (err) {
401            expect(err.code).assertEqual(401);
402            done();
403        }
404        console.log('testCreateTimerInterval016 end');
405    });
406
407    /**
408     * @tc.number: TestStartTimerLackParam001
409     * @tc.name: TestStartTimerLackParam001
410     * @tc.desc: Test startTimer for callback when not triggerTime.
411     * @tc.size: MediumTest
412     * @tc.type: Function
413     * @tc.level: Level 1
414     * @tc.require:
415     */
416    it('testStartTimerLackParam001', 0, async function (done) {
417        console.log("testStartTimerLackParam001 start")
418        let options = {
419            type: systemTimer.TIMER_TYPE_REALTIME,
420            repeat: true,
421            interval: 5001
422        }
423        try {
424            let timerId = await systemTimer.createTimer(options);
425            expect(Number.isInteger(timerId)).assertTrue();
426            systemTimer.startTimer(timerId, function (err) {
427                expect(false).assertTrue();
428                done();
429            });
430        } catch (err) {
431            expect(err.code).assertEqual(401);
432            done();
433        }
434        console.log('testStartTimerLackParam001 end');
435    });
436
437    /**
438     * @tc.number: TestStartTimerLackParam002
439     * @tc.name: TestStartTimerLackParam002
440     * @tc.desc: Test startTimer for promise when not triggerTime.
441     * @tc.size: MediumTest
442     * @tc.type: Function
443     * @tc.level: Level 1
444     * @tc.require:
445     */
446    it('testStartTimerLackParam002', 0, async function (done) {
447        console.log("testStartTimerLackParam002 start")
448        let options = {
449            type: systemTimer.TIMER_TYPE_REALTIME,
450            repeat: true,
451            interval: 5001
452        }
453        try {
454            let timerId = await systemTimer.createTimer(options);
455            expect(Number.isInteger(timerId)).assertTrue();
456            systemTimer.startTimer(timerId).then(() => {
457                expect(false).assertTrue();
458                done();
459            })
460        } catch (err) {
461            expect(err.code).assertEqual(401);
462            done();
463        }
464        console.log('testStartTimerLackParam002 end');
465    });
466
467    /**
468     * @tc.number: TestStartTimerInvalidParam003
469     * @tc.name: TestStartTimerInvalidParam003
470     * @tc.desc: Test startTimer for callback when timerId is string.
471     * @tc.size: MediumTest
472     * @tc.type: Function
473     * @tc.level: Level 1
474     * @tc.require:
475     */
476    it('testStartTimerInvalidParam003', 0, async function (done) {
477        console.log("testStartTimerInvalidParam003 start")
478        try {
479            systemTimer.startTimer("timerId", function (err) {
480                expect(false).assertTrue();
481                done();
482            });
483        } catch (err) {
484            expect(err.code).assertEqual(401);
485            done();
486        }
487        console.log('testStartTimerInvalidParam003 end');
488    });
489
490    /**
491     * @tc.number: TestStartTimerInvalidParam004
492     * @tc.name: TestStartTimerInvalidParam004
493     * @tc.desc: Test startTimer for promise when timerId is string.
494     * @tc.size: MediumTest
495     * @tc.type: Function
496     * @tc.level: Level 1
497     * @tc.require:
498     */
499    it('testStartTimerInvalidParam004', 0, async function (done) {
500        console.log("testStartTimerInvalidParam004 start")
501        try {
502            systemTimer.startTimer("timerId").then(() => {
503                expect(false).assertTrue();
504                done();
505            })
506        } catch (err) {
507            expect(err.code).assertEqual(401);
508            done();
509        }
510        console.log('testStartTimerInvalidParam004 end');
511    });
512
513    /**
514     * @tc.number: TestStartTimerInvalidValue005
515     * @tc.name: TestStartTimerInvalidValue005
516     * @tc.desc: Test startTimer for callback when timerId is invalid.
517     * @tc.size: MediumTest
518     * @tc.type: Function
519     * @tc.level: Level 1
520     * @tc.require:
521     */
522    it('testStartTimerInvalidValue005', 0, async function (done) {
523        console.log("testStartTimerInvalidValue005 start")
524        let triggerTime = new Date().getTime();
525        triggerTime += 3000;
526        systemTimer.startTimer(123456, triggerTime, function (err) {
527            if (err) {
528                expect(true).assertTrue();
529            } else {
530                expect(false).assertTrue();
531            }
532            done();
533        });
534        console.log('testStartTimerInvalidValue005 end');
535    });
536
537    /**
538     * @tc.number: TestStartTimerInvalidValue006
539     * @tc.name: TestStartTimerInvalidValue006
540     * @tc.desc: Test startTimer for promise when timerId is invalid.
541     * @tc.size: MediumTest
542     * @tc.type: Function
543     * @tc.level: Level 1
544     * @tc.require:
545     */
546    it('testStartTimerInvalidValue006', 0, async function (done) {
547        console.log("testStartTimerInvalidValue006 start")
548        try {
549            let triggerTime = new Date().getTime();
550            triggerTime += 300
551            systemTimer.startTimer(123456, triggerTime).then(() => {
552                expect(false).assertTrue();
553                done();
554            }).catch((e) => {
555                expect(true).assertTrue();
556                done();
557            })
558        } catch (err) {
559            expect(true).assertTrue();
560            done()
561        }
562        console.log('testStartTimerInvalidValue006 end');
563    });
564
565    /**
566     * @tc.number: TestStartTimerInvalidValue007
567     * @tc.name: TestStartTimerInvalidValue007
568     * @tc.desc: Test startTimer for callback when triggerTime is -1.
569     * @tc.size: MediumTest
570     * @tc.type: Function
571     * @tc.level: Level 1
572     * @tc.require:
573     */
574    it('testStartTimerInvalidValue007', 0, async function (done) {
575        console.log("testStartTimerInvalidValue007 start")
576        let options = {
577            type: systemTimer.TIMER_TYPE_REALTIME,
578            repeat: false
579        }
580        let timerId = await systemTimer.createTimer(options);
581        systemTimer.startTimer(timerId, -1, function (err) {
582            if (err) {
583                expect(false).assertTrue();
584            }
585            expect(true).assertTrue();
586            systemTimer.destroyTimer(timerId);
587            done();
588        });
589        console.log('testStartTimerInvalidValue007 end');
590    });
591
592    /**
593     * @tc.number: TestStartTimerInvalidValue008
594     * @tc.name: TestStartTimerInvalidValue008
595     * @tc.desc: Test startTimer for callback when triggerTime is -1.
596     * @tc.size: MediumTest
597     * @tc.type: Function
598     * @tc.level: Level 1
599     * @tc.require:
600     */
601    it('SUB_time_systemTimer_startTimer_0008', 0, async function (done) {
602        console.log("SUB_time_systemTimer_startTimer_0008 start")
603        let options = {
604            type: systemTimer.TIMER_TYPE_REALTIME,
605            repeat: false
606        }
607        try {
608            let timerId = await systemTimer.createTimer(options);
609            systemTimer.startTimer(timerId, -1).then(() => {
610                expect(true).assertTrue();
611                done();
612            }).catch((e) => {
613                expect(false).assertTrue();
614                done();
615            })
616        } catch (err) {
617            expect(false).assertTrue();
618            done()
619        }
620        console.log('SUB_time_systemTimer_startTimer_0008 end');
621    });
622
623    /**
624     * @tc.number: TestDestroyTimerInvalidParam001
625     * @tc.name: TestDestroyTimerInvalidParam001
626     * @tc.desc: Test destroyTimer for callback when timerId is string.
627     * @tc.size: MediumTest
628     * @tc.type: Function
629     * @tc.level: Level 1
630     * @tc.require:
631     */
632    it('testDestroyTimerInvalidParam001', 0, async function (done) {
633        console.log("testDestroyTimerInvalidParam001 start");
634        try {
635            systemTimer.destroyTimer("timerID", function (e) {
636                expect(false).assertTrue();
637                done();
638            });
639        } catch (err) {
640            expect(err.code).assertEqual(401);
641            done();
642        }
643        console.log('testDestroyTimerInvalidParam001 end');
644    });
645
646    /**
647     * @tc.number: TestDestroyTimerInvalidParam002
648     * @tc.name: TestDestroyTimerInvalidParam002
649     * @tc.desc: Test destroyTimer for promise when timerId is string.
650     * @tc.size: MediumTest
651     * @tc.type: Function
652     * @tc.level: Level 1
653     * @tc.require:
654     */
655    it('testDestroyTimerInvalidParam002', 0, async function (done) {
656        console.log("testDestroyTimerInvalidParam002 start");
657        try {
658            systemTimer.destroyTimer("timerID").then(() => {
659                expect(false).assertTrue();
660                done();
661            })
662        } catch (err) {
663            expect(err.code).assertEqual(401);
664            done();
665        }
666        console.log("testDestroyTimerInvalidParam002 end");
667    });
668
669    /**
670     * @tc.number: TestDestroyTimerInvalidValue003
671     * @tc.name: TestDestroyTimerInvalidValue003
672     * @tc.desc: Test destroyTimer for callback when timerId is invalid.
673     * @tc.size: MediumTest
674     * @tc.type: Function
675     * @tc.level: Level 1
676     * @tc.require:
677     */
678    it('testDestroyTimerInvalidValue003', 0, async function (done) {
679        console.log("testDestroyTimerInvalidValue003 start");
680        try {
681            systemTimer.destroyTimer(123456, timeErr(err, done));
682        } catch (err) {
683            expect(true).assertTrue();
684            done();
685        }
686        console.log('testDestroyTimerInvalidValue003 end');
687    });
688
689    /**
690     * @tc.number: TestDestroyTimerInvalidValue004
691     * @tc.name: TestDestroyTimerInvalidValue004
692     * @tc.desc: Test destroyTimer for promise when timerId is invalid.
693     * @tc.size: MediumTest
694     * @tc.type: Function
695     * @tc.level: Level 1
696     * @tc.require:
697     */
698    it('testDestroyTimerInvalidValue004', 0, async function (done) {
699        console.log("testDestroyTimerInvalidValue004 start");
700        try {
701            systemTimer.destroyTimer(123456).then(() => {
702                expect(false).assertTrue();
703                done();
704            }).catch((e) => {
705                expect(true).assertTrue();
706                done();
707            })
708        } catch (err) {
709            expect(true).assertTrue();
710            done();
711        }
712        console.log("testDestroyTimerInvalidValue004 end");
713    });
714
715    /**
716     * @tc.number: TestStopTimerInvalidParam001
717     * @tc.name: TestStopTimerInvalidParam001
718     * @tc.desc: Test stopTimer for promise when timerId is string.
719     * @tc.size: MediumTest
720     * @tc.type: Function
721     * @tc.level: Level 1
722     * @tc.require:
723     */
724    it('testStopTimerInvalidParam001', 0, async function (done) {
725        try {
726            systemTimer.stopTimer("timerID").then(() => {
727                expect(false).assertTrue();
728                done();
729            });
730        } catch (err) {
731            expect(err.code).assertEqual(401);
732            done();
733        }
734    });
735
736    /**
737     * @tc.number: TestStopTimerInvalidParam002
738     * @tc.name: TestStopTimerInvalidParam002
739     * @tc.desc: Test stopTimer for callback when timerId is string.
740     * @tc.size: MediumTest
741     * @tc.type: Function
742     * @tc.level: Level 1
743     * @tc.require:
744     */
745    it('testStopTimerInvalidParam002', 0, async function (done) {
746        try {
747            systemTimer.stopTimer("timerID", function (err) {
748                expect(false).assertTrue();
749                done();
750            });
751        } catch (err) {
752            expect(err.code).assertEqual(401);
753            done();
754        }
755    });
756
757    /**
758     * @tc.number: TestStopTimerInvalidValue003
759     * @tc.name: TestStopTimerInvalidValue003
760     * @tc.desc: Test stopTimer for callback when timerId is invalid.
761     * @tc.size: MediumTest
762     * @tc.type: Function
763     * @tc.level: Level 1
764     * @tc.require:
765     */
766    it('testStopTimerInvalidValue003', 0, async function (done) {
767        try {
768            systemTimer.stopTimer(123456, timeErr(err ,done));
769        } catch (err) {
770            expect(true).assertTrue();
771            done();
772        }
773    });
774
775    /**
776     * @tc.number: TestStopTimerInvalidValue004
777     * @tc.name: TestStopTimerInvalidValue004
778     * @tc.desc: Test stopTimer for promise when timerId is invalid.
779     * @tc.size: MediumTest
780     * @tc.type: Function
781     * @tc.level: Level 1
782     * @tc.require:
783     */
784    it('testStopTimerInvalidValue004', 0, async function (done) {
785        try {
786            systemTimer.stopTimer(123456).then(() => {
787                expect(false).assertTrue();
788                done();
789            }).catch((err) => {
790                expect(true).assertTrue();
791                done();
792            })
793        } catch (err) {
794            expect(true).assertTrue();
795            done();
796        }
797    });
798})