Mercurial > MadButterfly
comparison src/animate.c @ 1019:1a3cc22ee1bd refine_backend_if
Fix testcase of animate.c for mb_timer_man_t
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 13:52:59 +0800 |
parents | 9b5d4839c5bb |
children | f25b8ad338b4 |
comparison
equal
deleted
inserted
replaced
1018:7ccc094bdbe5 | 1019:1a3cc22ee1bd |
---|---|
375 subject_add_observer(complete, _free_completed_hdlr, progm); | 375 subject_add_observer(complete, _free_completed_hdlr, progm); |
376 } | 376 } |
377 | 377 |
378 #ifdef UNITTEST | 378 #ifdef UNITTEST |
379 | 379 |
380 #include "mb_backend_utils.h" | |
380 #include <CUnit/Basic.h> | 381 #include <CUnit/Basic.h> |
381 | 382 |
382 typedef struct _mb_dummy mb_dummy_t; | 383 typedef struct _mb_dummy mb_dummy_t; |
383 | 384 |
384 struct _mb_dummy { | 385 struct _mb_dummy { |
442 void test_animate_words(void) { | 443 void test_animate_words(void) { |
443 mb_progm_t *progm; | 444 mb_progm_t *progm; |
444 mb_word_t *word; | 445 mb_word_t *word; |
445 mb_action_t *acts[4]; | 446 mb_action_t *acts[4]; |
446 mb_timer_man_t *timer_man; | 447 mb_timer_man_t *timer_man; |
448 mb_tman_t *tman; | |
447 mb_timeval_t tv1, tv2, now, tmo_after; | 449 mb_timeval_t tv1, tv2, now, tmo_after; |
448 int logcnt = 0; | 450 int logcnt = 0; |
449 int logs[256]; | 451 int logs[256]; |
450 int r; | 452 int r; |
451 | 453 |
452 timer_man = mb_tman_new(); | 454 timer_man = mb_timer_man_new(&tman_timer_factory); |
453 CU_ASSERT(tman != NULL); | 455 CU_ASSERT(timer_man != NULL); |
456 | |
457 tman = tman_timer_man_get_tman(timer_man); | |
454 | 458 |
455 progm = mb_progm_new(3, NULL); | 459 progm = mb_progm_new(3, NULL); |
456 CU_ASSERT(progm != NULL); | 460 CU_ASSERT(progm != NULL); |
457 | 461 |
458 MB_TIMEVAL_SET(&tv1, 1, 0); | 462 MB_TIMEVAL_SET(&tv1, 1, 0); |
475 CU_ASSERT(word != NULL); | 479 CU_ASSERT(word != NULL); |
476 acts[2] = mb_dummy_new(2, &logcnt, logs, word); | 480 acts[2] = mb_dummy_new(2, &logcnt, logs, word); |
477 CU_ASSERT(acts[2] != NULL); | 481 CU_ASSERT(acts[2] != NULL); |
478 | 482 |
479 MB_TIMEVAL_SET(&now, 0, 0); | 483 MB_TIMEVAL_SET(&now, 0, 0); |
480 mb_progm_start(progm, tman, &now); | 484 mb_progm_start(progm, timer_man, &now); |
481 | 485 |
482 r = mb_tman_next_timeout(tman, &now, &tmo_after); | 486 r = mb_tman_next_timeout(tman, &now, &tmo_after); |
483 CU_ASSERT(r == 0); | 487 CU_ASSERT(r == 0); |
484 CU_ASSERT(MB_TIMEVAL_SEC(&tmo_after) == 1 && | 488 CU_ASSERT(MB_TIMEVAL_SEC(&tmo_after) == 1 && |
485 MB_TIMEVAL_USEC(&tmo_after) == 0); | 489 MB_TIMEVAL_USEC(&tmo_after) == 0); |
541 | 545 |
542 r = mb_tman_next_timeout(tman, &now, &tmo_after); | 546 r = mb_tman_next_timeout(tman, &now, &tmo_after); |
543 CU_ASSERT(r == -1); | 547 CU_ASSERT(r == -1); |
544 | 548 |
545 mb_progm_free(progm); | 549 mb_progm_free(progm); |
546 mb_tman_free(tman); | 550 mb_timer_man_free(&tman_timer_factory, timer_man); |
547 } | 551 } |
548 | 552 |
549 CU_pSuite get_animate_suite(void) { | 553 CU_pSuite get_animate_suite(void) { |
550 CU_pSuite suite; | 554 CU_pSuite suite; |
551 | 555 |