# HG changeset patch # User Thinker K.F. Li # Date 1219027563 -28800 # Node ID 3e3e074120a7add783edd64794b5588099ae61c3 # Parent 9ab15ebc9061d5dc25114f767decba912c6b6997 test case for observer diff -r 9ab15ebc9061 -r 3e3e074120a7 src/observer.c --- a/src/observer.c Mon Aug 18 01:59:26 2008 +0800 +++ b/src/observer.c Mon Aug 18 10:46:03 2008 +0800 @@ -112,28 +112,31 @@ static void handler(event_t *evt, void *arg) { int *cnt = (int *)arg; - CU_ASSERT(evt->type == EVT_MOUSE_OVER); + CU_ASSERT(evt->type == EVT_MOUSE_OUT); (*cnt)++; } void test_observer(void) { subject_t *subject; - observer_t *observer; + observer_t *observer[2]; event_t evt; int cnt = 0; subject = subject_new(&test_factory, NULL, 0); subject->flags |= SUBF_STOP_PROPAGATE; - observer = subject_add_observer(&test_factory, subject, - handler, &cnt); + observer[0] = subject_add_observer(&test_factory, subject, + handler, &cnt); + observer[1] = subject_add_observer(&test_factory, subject, + handler, &cnt); - evt.type = EVT_MOUSE_OVER; + evt.type = EVT_MOUSE_OUT; evt.tgt = NULL; evt.cur_tgt = NULL; subject_notify(&test_factory, subject, &evt); - CU_ASSERT(cnt == 1); + CU_ASSERT(cnt == 2); - subject_remove_observer(&test_factory, subject, observer); + subject_remove_observer(&test_factory, subject, observer[0]); + subject_remove_observer(&test_factory, subject, observer[1]); subject_free(&test_factory, subject); }