ecore: Add test for timers created from idlers
authormike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 8 Jul 2011 06:38:38 +0000 (06:38 +0000)
committermike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 8 Jul 2011 06:38:38 +0000 (06:38 +0000)
Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@61145 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/ecore_test.c

index 9ac2859..c106f87 100644 (file)
@@ -7,18 +7,51 @@ const char *called = NULL;
 static const char *idler_str = "idler";
 static const char *idle_enterer_str = "idler_enterer";
 static const char *idle_exiter_str = "idler_exiter";
-static const char *timer_str = "timer";
+static const char *timer1_str = "timer 1";
+static const char *timer2_str = "timer 2";
 static const char *pipe_read_str = "pipe read";
 
 int count;
 
+Eina_Bool timer_one(void *data)
+{
+   fprintf(stderr, "timer 1\n");
+   assert(called == pipe_read_str);
+   called = timer1_str;
+
+   count++;
+   if (count == 10)
+     {
+       ecore_main_loop_quit();
+       return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
+Eina_Bool timer_two(void *data)
+{
+   fprintf(stderr, "timer 2\n");
+   assert(called == timer1_str);
+   called = timer2_str;
+
+   return EINA_TRUE;
+}
+
 Eina_Bool idle_enterer_one(void *data)
 {
    fprintf(stderr, "idle enterer!\n");
-   if (count)
-     assert(called == timer_str);
-   else
+   switch (count)
+   {
+   default:
+     assert(called == timer2_str);
+     break;
+   case 1:
+     assert(called == timer1_str);
+     break;
+   case 0:
      assert(called == NULL);
+   }
    called = idle_enterer_str;
    return EINA_TRUE;
 }
@@ -28,6 +61,8 @@ Eina_Bool idler_one(void *data)
    fprintf(stderr, "idler!\n");
    assert(called == idle_enterer_str);
    called = idler_str;
+   if (count == 0)
+     ecore_timer_add(0.0, timer_two, NULL);
    return EINA_TRUE;
 }
 
@@ -39,22 +74,6 @@ Eina_Bool idle_exiter_one(void *data)
    return EINA_TRUE;
 }
 
-Eina_Bool timer_one(void *data)
-{
-   fprintf(stderr, "timer\n");
-   assert(called == pipe_read_str);
-   called = timer_str;
-
-   count++;
-   if (count == 10)
-     {
-       ecore_main_loop_quit();
-       return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}
-
 Eina_Bool pipe_read(void *data, Ecore_Fd_Handler *fd_handler)
 {
    fprintf(stderr, "pipe read\n");