SystemTimerJsunit.test.js 27.3 KB
Newer Older
G
guduhanyan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// @ts-nocheck
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import systemTimer from '@ohos.systemtimer'

describe('TimerTest', function() {
    console.log('start################################start');
G
guduhanyan 已提交
22

G
guduhanyan 已提交
23 24
	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0100
G
guduhanyan 已提交
25
     * @tc.name      Test systemTimer.createTimer type = TIMER_TYPE_REALTIME
G
guduhanyan 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test1',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0100 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
39
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
40 41 42
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
43
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
44 45
		
		console.log("stop timer")
G
guduhanyan 已提交
46
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
47 48
		
		console.log("destroy timer")
G
guduhanyan 已提交
49
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
50 51 52 53 54
		console.log('SUB_systemTimer_Timer_JS_API_0100 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0200
G
guduhanyan 已提交
55
     * @tc.name      Test systemTimer.createTimer type = TIMER_TYPE_REALTIME_WAKEUP
G
guduhanyan 已提交
56 57 58 59 60 61 62 63
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test2',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0200 start")
        var options = {
G
guduhanyan 已提交
64
			type:TIMER_TYPE_WAKEUP,
G
guduhanyan 已提交
65 66 67 68
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
69
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
70 71 72
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
73
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
74 75
		
		console.log("stop timer")
G
guduhanyan 已提交
76
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
77 78
		
		console.log("destroy timer")
G
guduhanyan 已提交
79
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
80 81 82 83 84
		console.log('SUB_systemTimer_Timer_JS_API_0200 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0300
G
guduhanyan 已提交
85
     * @tc.name      Test systemTimer.createTimer type = TIMER_TYPE_EXACT
G
guduhanyan 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test3',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0300 start")
        var options = {
			type:TIMER_TYPE_EXACT,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
99
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
100 101 102
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
103
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
104 105
		
		console.log("stop timer")
G
guduhanyan 已提交
106
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
107 108
		
		console.log("destroy timer")
G
guduhanyan 已提交
109
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
110 111 112 113 114
		console.log('SUB_systemTimer_Timer_JS_API_0300 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0400
G
guduhanyan 已提交
115
     * @tc.name      Test systemTimer.createTimer type = TIMER_TYPE_REALTIME
G
guduhanyan 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test4',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0400 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
129
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
130 131 132
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
133
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
134 135
		
		console.log("stop timer")
G
guduhanyan 已提交
136
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
137 138
		
		console.log("destroy timer")
G
guduhanyan 已提交
139
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
140 141 142 143 144
		console.log('SUB_systemTimer_Timer_JS_API_0400 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0500
G
guduhanyan 已提交
145
     * @tc.name      Test systemTimer.createTimer triggerTime = 0
G
guduhanyan 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test5',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0500 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
159
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
160 161 162
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
163
		systemTimer.startTimer(timer, 0)
G
guduhanyan 已提交
164 165
		
		console.log("stop timer")
G
guduhanyan 已提交
166
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
167 168
		
		console.log("destroy timer")
G
guduhanyan 已提交
169
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
170 171 172 173 174
		console.log('SUB_systemTimer_Timer_JS_API_0500 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0600
G
guduhanyan 已提交
175
     * @tc.name      Test systemTimer.createTimer triggerTime = 5000
G
guduhanyan 已提交
176 177 178 179 180 181 182 183 184 185 186 187 188
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test6',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0600 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
189
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
190 191 192
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
193
		systemTimer.startTimer(timer, 5000)
G
guduhanyan 已提交
194 195
		
		console.log("stop timer")
G
guduhanyan 已提交
196
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
197 198
		
		console.log("destroy timer")
G
guduhanyan 已提交
199
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
200 201 202 203 204
		console.log('SUB_systemTimer_Timer_JS_API_0600 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0700
G
guduhanyan 已提交
205
     * @tc.name      Test systemTimer.createTimer triggerTime = Number.MAX_VALUE/2
G
guduhanyan 已提交
206 207 208 209 210 211 212 213 214 215 216 217 218
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test7',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0700 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
219
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
220 221 222
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
223
		systemTimer.startTimer(timer, Number.MAX_VALUE/2)
G
guduhanyan 已提交
224 225
		
		console.log("stop timer")
G
guduhanyan 已提交
226
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
227 228
		
		console.log("destroy timer")
G
guduhanyan 已提交
229
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
230 231 232 233 234
		console.log('SUB_systemTimer_Timer_JS_API_0700 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0800
G
guduhanyan 已提交
235
     * @tc.name      Test systemTimer.createTimer triggerTime = Number.MAX_VALUE-1
G
guduhanyan 已提交
236 237 238 239 240 241 242 243 244 245 246 247 248
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test8',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0800 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
249
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
250 251 252
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
253
		systemTimer.startTimer(timer, Number.MAX_VALUE-1)
G
guduhanyan 已提交
254 255
		
		console.log("stop timer")
G
guduhanyan 已提交
256
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
257 258
		
		console.log("destroy timer")
G
guduhanyan 已提交
259
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
260 261 262 263 264
		console.log('SUB_systemTimer_Timer_JS_API_0800 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_0900
G
guduhanyan 已提交
265
     * @tc.name      Test systemTimer.createTimer triggerTime = Number.MAX_VALUE
G
guduhanyan 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test9',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_0900 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
279
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
280 281 282
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
283
		systemTimer.startTimer(timer, Number.MAX_VALUE)
G
guduhanyan 已提交
284 285
		
		console.log("stop timer")
G
guduhanyan 已提交
286
		ystemTimer.stopTimer(timer)
G
guduhanyan 已提交
287 288
		
		console.log("destroy timer")
G
guduhanyan 已提交
289
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
290 291 292 293 294
		console.log('SUB_systemTimer_Timer_JS_API_0900 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1000
G
guduhanyan 已提交
295
     * @tc.name      Test systemTimer.createTimer repeat = true
G
guduhanyan 已提交
296 297 298 299 300 301 302 303 304 305 306 307 308
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test10',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1000 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:true,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
309
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
310 311 312
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
313
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
314 315
		
		console.log("stop timer")
G
guduhanyan 已提交
316
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
317 318
		
		console.log("destroy timer")
G
guduhanyan 已提交
319
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
320 321 322 323 324
		console.log('SUB_systemTimer_Timer_JS_API_1000 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1100
G
guduhanyan 已提交
325
     * @tc.name      Test systemTimer.createTimer persistent = true
G
guduhanyan 已提交
326 327 328 329 330 331 332 333 334 335 336 337 338
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test11',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1100 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:true
		}
		console.log("create timer")
G
guduhanyan 已提交
339
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
340 341 342
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
343
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
344 345
		
		console.log("stop timer")
G
guduhanyan 已提交
346
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
347 348
		
		console.log("destroy timer")
G
guduhanyan 已提交
349
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
350 351 352 353 354
		console.log('SUB_systemTimer_Timer_JS_API_1100 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1200
G
guduhanyan 已提交
355
     * @tc.name      Test systemTimer.createTimer repeat,persistent = true
G
guduhanyan 已提交
356 357 358 359 360 361 362 363 364 365 366 367 368
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test12',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1200 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:true,
			persistent:true
		}
		console.log("create timer")
G
guduhanyan 已提交
369
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
370 371 372
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
373
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
374 375
		
		console.log("stop timer")
G
guduhanyan 已提交
376
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
377 378
		
		console.log("destroy timer")
G
guduhanyan 已提交
379
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
380 381 382 383 384
		console.log('SUB_systemTimer_Timer_JS_API_1200 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1300
G
guduhanyan 已提交
385
     * @tc.name      Test systemTimer.createTimer create,start,stop,destroy 1000 timers
G
guduhanyan 已提交
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test13',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1300 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		for (var index = 0; index < 1000; index++)
		{
			console.log("create timer")
G
guduhanyan 已提交
401
			let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
402 403 404
			expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)

			console.log("start timer")
G
guduhanyan 已提交
405
			systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
406 407

			console.log("stop timer")
G
guduhanyan 已提交
408
			systemTimer.stopTimer(timer)
G
guduhanyan 已提交
409 410

			console.log("destroy timer")
G
guduhanyan 已提交
411
			systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
412 413 414 415 416 417
			console.log('SUB_systemTimer_Timer_JS_API_1300 end');
		}
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1400
G
guduhanyan 已提交
418
     * @tc.name      Test systemTimer.createTimer interval = 0
G
guduhanyan 已提交
419 420 421 422 423 424 425 426 427 428 429 430 431 432
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test14',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1400 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:0,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
433
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
434 435 436
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
437
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
438 439
		
		console.log("stop timer")
G
guduhanyan 已提交
440
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
441 442
		
		console.log("destroy timer")
G
guduhanyan 已提交
443
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
444 445 446 447 448
		console.log('SUB_systemTimer_Timer_JS_API_1400 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1500
G
guduhanyan 已提交
449
     * @tc.name      Test systemTimer.createTimer interval = 5000
G
guduhanyan 已提交
450 451 452 453 454 455 456 457 458 459 460 461 462 463
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test15',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1500 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:5000,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
464
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
465 466 467
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
468
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
469 470
		
		console.log("stop timer")
G
guduhanyan 已提交
471
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
472 473
		
		console.log("destroy timer")
G
guduhanyan 已提交
474
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
475 476 477 478 479
		console.log('SUB_systemTimer_Timer_JS_API_1500 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1600
G
guduhanyan 已提交
480
     * @tc.name      Test systemTimer.createTimer interval = Number.MAX_VALUE/2
G
guduhanyan 已提交
481 482 483 484 485 486 487 488 489 490 491 492 493 494
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test16',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1600 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:Number.MAX_VALUE/2,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
495
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
496 497 498
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
499
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
500 501
		
		console.log("stop timer")
G
guduhanyan 已提交
502
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
503 504
		
		console.log("destroy timer")
G
guduhanyan 已提交
505
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
506 507 508 509 510
		console.log('SUB_systemTimer_Timer_JS_API_1600 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1700
G
guduhanyan 已提交
511
     * @tc.name      Test systemTimer.createTimer interval = Number.MAX_VALUE-1
G
guduhanyan 已提交
512 513 514 515 516 517 518 519 520 521 522 523 524 525
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test17',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1700 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:Number.MAX_VALUE-1,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
526
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
527 528 529
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
530
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
531 532
		
		console.log("stop timer")
G
guduhanyan 已提交
533
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
534 535
		
		console.log("destroy timer")
G
guduhanyan 已提交
536
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
537 538 539 540 541
		console.log('SUB_systemTimer_Timer_JS_API_1700 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1800
G
guduhanyan 已提交
542
     * @tc.name      Test systemTimer.createTimer interval = Number.MAX_VALUE
G
guduhanyan 已提交
543 544 545 546 547 548 549 550 551 552 553 554 555 556
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test18',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1800 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:Number.MAX_VALUE,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
557
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
558 559 560
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
561
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
562 563
		
		console.log("stop timer")
G
guduhanyan 已提交
564
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
565 566
		
		console.log("destroy timer")
G
guduhanyan 已提交
567
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
568 569 570 571 572
		console.log('SUB_systemTimer_Timer_JS_API_1800 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_1900
G
guduhanyan 已提交
573
     * @tc.name      Test systemTimer.createTimer WantAgent
G
guduhanyan 已提交
574 575 576 577 578 579 580 581 582 583 584 585 586 587
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test19',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_1900 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:100000,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
588
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
589 590 591
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
592
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
593 594
		
		console.log("stop timer")
G
guduhanyan 已提交
595
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
596 597
		
		console.log("destroy timer")
G
guduhanyan 已提交
598
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
599 600 601 602 603
		console.log('SUB_systemTimer_Timer_JS_API_1900 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2000
G
guduhanyan 已提交
604
     * @tc.name      Test systemTimer.createTimer Called back when the timer goes off.
G
guduhanyan 已提交
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test20',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2000 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			interval:100000,
			persistent:false,
			callback:callbackFunction
		}
		console.log("create timer")
G
guduhanyan 已提交
620
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
621 622 623
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
624
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
625 626
		
		console.log("stop timer")
G
guduhanyan 已提交
627
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
628 629
		
		console.log("destroy timer")
G
guduhanyan 已提交
630
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
631 632 633 634 635
		console.log('SUB_systemTimer_Timer_JS_API_2000 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2100
G
guduhanyan 已提交
636
     * @tc.name      Test systemTimer.createTimer start a not exist timer
G
guduhanyan 已提交
637 638 639 640 641 642 643 644 645 646 647 648 649
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test21',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2100 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
650
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
651 652 653
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start a not exist timer")
G
guduhanyan 已提交
654
		systemTimer.startTimer(timer + 1, 100000)
G
guduhanyan 已提交
655 656
		
		console.log("destroy timer")
G
guduhanyan 已提交
657
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
658 659 660 661 662
		console.log('SUB_systemTimer_Timer_JS_API_2100 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2200
G
guduhanyan 已提交
663
     * @tc.name      Test systemTimer.createTimer stop a not exist timer
G
guduhanyan 已提交
664 665 666 667 668 669 670 671 672 673 674 675 676
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test22',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2200 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
677
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
678 679 680
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
681
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
682 683
		
		console.log("stop a not exist timer")
G
guduhanyan 已提交
684
		systemTimer.stopTimer(timer + 1)
G
guduhanyan 已提交
685 686
		
		console.log("stop the current timer")
G
guduhanyan 已提交
687
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
688 689
		
		console.log("destroy timer")
G
guduhanyan 已提交
690
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
691 692 693 694 695
		console.log('SUB_systemTimer_Timer_JS_API_2200 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2300
G
guduhanyan 已提交
696
     * @tc.name      Test systemTimer.createTimer destroy a not exist timer
G
guduhanyan 已提交
697 698 699 700 701 702 703 704 705 706 707 708 709
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test23',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2300 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
710
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
711 712 713
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
714
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
715 716
		
		console.log("stop timer")
G
guduhanyan 已提交
717
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
718 719
		
		console.log("destroy a not exist timer")
G
guduhanyan 已提交
720
		systemTimer.destroyTimer(timer + 1)
G
guduhanyan 已提交
721 722
		
		console.log("destroy timer")
G
guduhanyan 已提交
723
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
724 725 726 727 728
		console.log('SUB_systemTimer_Timer_JS_API_2300 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2400
G
guduhanyan 已提交
729
     * @tc.name      Test systemTimer.createTimer stop a not started timer
G
guduhanyan 已提交
730 731 732 733 734 735 736 737 738 739 740 741 742
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test24',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2400 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
743
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
744 745 746
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("stop a not started timer")
G
guduhanyan 已提交
747
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
748 749
		
		console.log("destroy timer")
G
guduhanyan 已提交
750
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
751 752 753 754 755
		console.log('SUB_systemTimer_Timer_JS_API_2400 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2500
G
guduhanyan 已提交
756
     * @tc.name      Test systemTimer.createTimer destroy a started timer
G
guduhanyan 已提交
757 758 759 760 761 762 763 764 765 766 767 768 769
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test25',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2500 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
770
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
771 772 773
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
774
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
775 776
		
		console.log("destroy a started timer")
G
guduhanyan 已提交
777
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
778 779 780 781 782
		console.log('SUB_systemTimer_Timer_JS_API_2500 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2600
G
guduhanyan 已提交
783
     * @tc.name      Test systemTimer.createTimer repeat to start a timer
G
guduhanyan 已提交
784 785 786 787 788 789 790 791 792 793 794 795 796
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test26',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2600 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
797
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
798 799 800
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
801
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
802 803
		
		console.log("start timer again")
G
guduhanyan 已提交
804
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
805 806
		
		console.log("stop timer")
G
guduhanyan 已提交
807
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
808 809
		
		console.log("destroy timer")
G
guduhanyan 已提交
810
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
811 812 813 814 815
		console.log('SUB_systemTimer_Timer_JS_API_2600 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2700
G
guduhanyan 已提交
816
     * @tc.name      Test systemTimer.createTimer repeat to stop a timer
G
guduhanyan 已提交
817 818 819 820 821 822 823 824 825 826 827 828 829
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test27',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2700 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
830
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
831 832 833
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
834
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
835 836
		
		console.log("stop timer")
G
guduhanyan 已提交
837
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
838 839
		
		console.log("stop timer again")
G
guduhanyan 已提交
840
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
841 842
		
		console.log("destroy timer")
G
guduhanyan 已提交
843
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
844 845 846 847 848
		console.log('SUB_systemTimer_Timer_JS_API_2700 end');
	});

	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2800
G
guduhanyan 已提交
849
     * @tc.name      Test systemTimer.createTimer repeat to destroy a timer
G
guduhanyan 已提交
850 851 852 853 854 855 856 857 858 859 860 861 862
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test28',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2800 start")
        var options = {
			type:TIMER_TYPE_REALTIME,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
G
guduhanyan 已提交
863
        let timer = systemTimer.createTimer(options)
G
guduhanyan 已提交
864 865 866
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
G
guduhanyan 已提交
867
		systemTimer.startTimer(timer, 100000)
G
guduhanyan 已提交
868 869
		
		console.log("stop timer")
G
guduhanyan 已提交
870
		systemTimer.stopTimer(timer)
G
guduhanyan 已提交
871 872
		
		console.log("destroy timer")
G
guduhanyan 已提交
873
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
874 875
		
		console.log("destroy timer again")
G
guduhanyan 已提交
876
		systemTimer.destroyTimer(timer)
G
guduhanyan 已提交
877 878 879
		console.log('SUB_systemTimer_Timer_JS_API_2800 end');
	});

G
guduhanyan 已提交
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
	/**
     * @tc.number    SUB_systemTimer_Timer_JS_API_2900
     * @tc.name      Test systemTimer.createTTimer type = TIMER_TYPE_IDLE
     * @tc.desc      Test systemTimer_Timer API functionality.
     * @tc.size      : MEDIUM
     * @tc.type      : Function
     * @tc.level     : Level 0
     */
	it('systemTimer_Timer_test29',0, async () => {
		console.log("SUB_systemTimer_Timer_JS_API_2900 start")
        var options = {
			type:TIMER_TYPE_IDLE,
			repeat:false,
			persistent:false
		}
		console.log("create timer")
        let timer = systemTimer.createTimer(options)
		expect(parseInt(timer) == parseFloat(timer)).assertEqual(true)
		
		console.log("start timer")
		systemTimer.startTimer(timer, 100000)
		
		console.log("stop timer")
		systemTimer.stopTimer(timer)
		
		console.log("destroy timer")
		systemTimer.destroyTimer(timer)
		console.log('SUB_systemTimer_Timer_JS_API_2900 end');
	});

G
guduhanyan 已提交
910 911 912 913 914 915 916 917 918
	/**
     * @function     Used for callback functions
     * @tc.name      callbackFunction
     */
	function callbackFunction()
	{
		console.log("Start to call the callback function")
	}
})