systemTimer.test.ets 28.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import WantAgent from '@ohos.wantAgent';
import systemTimer from "@ohos.systemTimer";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';

export default function systemTimerTest() {
  describe('systemTimerTest', function () {
    console.info('systemTimer Test start');
    //wantAgent对象
    var wantAgent;

    //WantAgentInfo对象
    let wantAgentInfo = {
      wants: [
        {
          bundleName: "com.acts.time.test",
          abilityName: "MainAbility"
        }
      ],
      operationType: WantAgent.OperationType.SEND_COMMON_EVENT,
      requestCode: 0,
      wantAgentFlags:[WantAgent.WantAgentFlags.NO_BUILD_FLAG]
    }

    let interval_time = 5000;
    let globalTimerID = undefined;

    /**
     * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
     */
    beforeAll(function () {
      console.info('beforeAll: Prerequisites are executed.');
      WantAgent.getWantAgent(wantAgentInfo)
        .then((data) => {
          if ( data != undefined || data != null) {
            console.info('beforeAll: success to get wantAgent: ' + typeof(data));
            wantAgent = data;
          }
        })
        .catch(error => {
          console.error('beforeAll: failed to get wantAgent!');
        });
    });

    /**
     * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
     */
    beforeEach(function () {
      console.info('beforeEach: Prerequisites is executed.');
    });

    /**
     * afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
     */
    afterEach(function () {
      console.info('afterEach: Test case-level clearance conditions is executed.');
    });

    /**
     * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
     */
    afterAll(function () {
      console.info('afterAll: Test suite-level cleanup condition is executed.');
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0000
     * @tc.name SUB_time_systemTimer_createTimer_0000
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) {
      console.info('SUB_time_systemTimer_createTimer_0000 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_createTimer_0000 create timer.');
        systemTimer.createTimer(options, function (err, timerID) {
          if (err) {
            // 处理业务逻辑错误
            expect().assertTrue();
            done();
          }
          console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
          globalTimerID = timerID;
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0001
     * @tc.name SUB_time_systemTimer_createTimer_0001
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) {
      console.info('SUB_time_systemTimer_createTimer_0001 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: false
      }
      try {
        systemTimer.createTimer(options, function (err, timerID) {
          if (err) {
            console.info('SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
            expect().assertTrue();
            done();
          }
          console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0002
     * @tc.name SUB_time_systemTimer_createTimer_0002
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0002 start")
      WantAgent.getBundleName(wantAgent, (err, data)=>{
        console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
      })
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: true,
        wantAgent: wantAgent,
        interval: interval_time
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0002 create timer")
        systemTimer.createTimer(options, function (err, timerID) {
          if (err) {
            console.info('SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
            expect().assertTrue();
            done();
          }
          console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0003
     * @tc.name SUB_time_systemTimer_createTimer_0003
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0003 start")
      let options = {
        type: systemTimer.TIMER_TYPE_EXACT,
        repeat: false
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0003 create timer")
        systemTimer.createTimer(options, function (err, timerID) {
          if (err) {
            console.info('SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
            expect().assertTrue();
            done();
          }
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0004
     * @tc.name SUB_time_systemTimer_createTimer_0004
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent(callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0004 start")
      WantAgent.getBundleName(wantAgent, (err, data)=>{
        console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
      })
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: true,
        wantAgent: wantAgent,
        interval: interval_time
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0004 create timer")
        systemTimer.createTimer(options, function (err, timerID) {
          if (err) {
            expect().assertTrue();
            done();
          }
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
        expect().assertTrue();
        done();
      }
    });


    /**
 * @tc.number SUB_time_systemTimer_createTimer_0005
 * @tc.name SUB_time_systemTimer_createTimer_0005
 * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback)
 * @tc.size MEDIUM
 * @tc.type Function
 * @tc.level Level 0
 */
    it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) {
      console.info('SUB_time_systemTimer_createTimer_0005 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_createTimer_0005 create timer.');
        systemTimer.createTimer(options).then((timerID) =>{
          console.info('SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
//          globalTimerID = timerID;
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        }).catch(err => {
          console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
          expect().assertTrue();
          done();
        });
      } catch (err) {
        console.info('SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0006
     * @tc.name SUB_time_systemTimer_createTimer_0006
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
      console.info('SUB_time_systemTimer_createTimer_0006 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: false
      }
      try {
        systemTimer.createTimer(options).then((timerID) => {
          console.info('SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        }).catch(err => {
          console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
          expect().assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0007
     * @tc.name SUB_time_systemTimer_createTimer_0007
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0007 start")
      WantAgent.getBundleName(wantAgent, (err, data)=>{
        console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
      })
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: true,
        wantAgent: wantAgent,
        interval: interval_time
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0007 create timer")
        systemTimer.createTimer(options).then((timerID) => {
          console.info('SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        }).catch(err => {
          console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
          expect().assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0008
     * @tc.name SUB_time_systemTimer_createTimer_0008
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0008 start")
      let options = {
        type: systemTimer.TIMER_TYPE_EXACT,
        repeat: false
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0008 create timer")
        systemTimer.createTimer(options).then((timerID) => {
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        }).catch(err => {
          console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
          expect().assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0009
     * @tc.name SUB_time_systemTimer_createTimer_0009
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent(callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) {
      console.info("SUB_time_systemTimer_createTimer_0009 start")
      WantAgent.getBundleName(wantAgent, (err, data)=>{
        console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
      })
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: true,
        wantAgent: wantAgent,
        interval: interval_time
      }
      try {
        console.info("SUB_time_systemTimer_createTimer_0009 create timer")
        systemTimer.createTimer(options).then((timerID) => {
          expect(Number.isInteger(timerID)).assertTrue();
          done();
        }).catch(err => {
          console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
          expect().assertTrue();
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
        expect().assertTrue();
        done();
      }
    });







    /**
     * @tc.number SUB_time_systemTimer_startTimer_0001
     * @tc.name SUB_time_systemTimer_startTimer_0001
     * @tc.desc Test startTimer() interfaces, normal call(callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) {
      console.info("SUB_time_systemTimer_startTimer_0001 start")
      let options = {
        type: systemTimer.TIMER_TYPE_IDLE,
        repeat: false,
      }
      try {
        console.info("SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
        let triggerTime = new Date().getTime() + interval_time * 1.2;
        systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) {
          if (err) {
            console.info('SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
            expect().assertTrue();
            done();
          }
          console.info("SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
          done();
        });
      } catch (e) {
        console.info('SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_stopTimer_0001
     * @tc.name SUB_time_systemTimer_stopTimer_0001
     * @tc.desc Test startTimer() interfaces, normal call(callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) {
      console.info("SUB_time_systemTimer_stopTimer_0001 start")
      let options = {
        type: systemTimer.TIMER_TYPE_IDLE,
        repeat: false,
      }
      try {
        console.info("SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
        systemTimer.stopTimer(globalTimerID, function (err, data) {
          if (err) {
            expect().assertTrue();
            done();
          }
          console.info("SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
          done();
        });

      } catch (e) {
        console.info('SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_destroyTimer_0001
     * @tc.name SUB_time_systemTimer_destroyTimer_0001
     * @tc.desc Test startTimer() interfaces, normal call(callback)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) {
      console.info("SUB_time_systemTimer_destroyTimer_0001 start")
      let options = {
        type: systemTimer.TIMER_TYPE_IDLE,
        repeat: false,
      }
      try {
        console.info("SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
        systemTimer.destroyTimer(globalTimerID, function (err, data) {
          if (err) {
            expect().assertTrue();
            done();
          }
          console.info("SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
          done();
        });

      } catch (e) {
        console.info('SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_createTimer_0006
     * @tc.name SUB_time_systemTimer_createTimer_0006
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
      console.info('SUB_time_systemTimer_createTimer_0006 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_REALTIME,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_createTimer_0006 create timer.');
        systemTimer.createTimer(options).then((timerID)=>{
          console.info('SUB_time_systemTimer_createTimer_0006 timerID:' + timerID);
          expect(Number.isInteger(timerID)).assertTrue();
          globalTimerID = timerID;
          done();
        }, error => {
          // 捕获业务逻辑错误
          console.info('SUB_time_systemTimer_createTimer_0006 failed to create timer.');
          expect().assertTrue();
          done();
        });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_createTimer_0006 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_startTimer_0002
     * @tc.name SUB_time_systemTimer_startTimer_0002
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) {
      console.info('SUB_time_systemTimer_startTimer_0002 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
        let triggerTime = new Date().getTime() + interval_time * 2;
        systemTimer.startTimer(globalTimerID, triggerTime)
          .then(()=>{
            console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
            done();
          })
          .catch(()=>{
            // 捕获业务逻辑错误
            console.info('SUB_time_systemTimer_startTimer_0002 failed to start timer.');
            expect().assertTrue();
            done();
          });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_stopTimer_0002
     * @tc.name SUB_time_systemTimer_stopTimer_0002
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) {
      console.info('SUB_time_systemTimer_stopTimer_0002 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
        systemTimer.stopTimer(globalTimerID)
          .then(()=>{
            console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
            done();
          })
          .catch(()=>{
            // 捕获业务逻辑错误
            console.info('SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
            expect().assertTrue();
            done();
          });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_destroyTimer_0002
     * @tc.name SUB_time_systemTimer_destroyTimer_0002
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) {
      console.info('SUB_time_systemTimer_destroyTimer_0002 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
        systemTimer.destroyTimer(globalTimerID)
          .then(()=>{
            console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
            done();
          })
          .catch(()=>{
            // 捕获业务逻辑错误
            console.info('SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
            expect().assertTrue();
            done();
          });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
      * @tc.number SUB_time_systemTimer_ALL_Promise_0008
      * @tc.name SUB_time_systemTimer_ALL_Promise_0008
      * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
      * @tc.size MEDIUM
      * @tc.type Function
      * @tc.level Level 0
      */
    it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) {
      console.info('SUB_time_systemTimer_ALL_Promise_0008 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.');
        systemTimer.createTimer(options)
          .then((timerID)=>{
            console.info('SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
            expect(Number.isInteger(timerID)).assertTrue();
            try {
              let triggerTime = new Date().getTime() + interval_time * 1.2;
              systemTimer.startTimer(timerID, triggerTime)
                .then(()=>{
                  console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
                  try {
                    systemTimer.stopTimer(timerID)
                      .then(()=>{
                        systemTimer.destroyTimer(timerID, function (err, data) {
                          console.info('SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
                          done();
                        });
                      })
                      .catch(()=>{
                        // 捕获stopTimer业务逻辑错误
                        console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
                        expect().assertTrue();
                        done();
                      })
                  } catch (err) {
                    // 捕获stopTimer参数错误
                    console.info('SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
                    expect().assertTrue();
                    done();
                  }
                })
                .catch(()=>{
                  // 捕获startTimer业务逻辑错误
                  console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
                  expect().assertTrue();
                  done();
                });
            } catch (err) {
              // 捕获参数错误
              console.info('SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
              expect().assertTrue();
              done();
            }
          })
          .catch(()=>{
            // 捕获业务逻辑错误
            console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
            expect().assertTrue();
            done();
          });
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
        expect().assertTrue();
        done();
      }
    });

    /**
     * @tc.number SUB_time_systemTimer_ALL_Callback_0009
     * @tc.name SUB_time_systemTimer_ALL_Callback_0009
     * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 0
     */
    it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) {
      console.info('SUB_time_systemTimer_ALL_Callback_0009 start.');
      let options = {
        type: systemTimer.TIMER_TYPE_WAKEUP,
        repeat: false
      };
      try {
        console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.');
        systemTimer.createTimer(options)
          .then((timerID)=>{
            console.info('SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
            expect(Number.isInteger(timerID)).assertTrue();
            try {
              let triggerTime = new Date().getTime() + interval_time * 1.2;
              systemTimer.startTimer(timerID, triggerTime, ()=>{
                console.info('SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
                try {
                  systemTimer.stopTimer(timerID, ()=>{
                    systemTimer.destroyTimer(timerID, function (err, data) {
                      console.info('SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
                      done();
                    });
                  })
                } catch (err) {
                  // 捕获stopTimer参数错误
                  console.info('SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
                  expect().assertTrue();
                  done();
                }
              })
            } catch (err) {
              // 捕获参数错误
              console.info('SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
              expect().assertTrue();
              done();
            }
          })
      } catch (err) {
        // 捕获参数错误
        console.info('SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
        expect().assertTrue();
        done();
      }
    });

  });
}