tests: integrate timeout timer and begin main loop 58/244958/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 28 Sep 2020 08:50:55 +0000 (17:50 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 28 Sep 2020 08:51:00 +0000 (17:51 +0900)
This reverts commit ef3cc86494d9db54963892df92459a3ba3ec9230.

Change-Id: I6166c068c465e7efc9917a749355c76ce715b1aa

ism/tests/ecore_imf_tests.cpp

index 6e13a60..cb05b93 100644 (file)
@@ -34,6 +34,7 @@
 
 namespace {
 
+static Ecore_Timer *timer_exit = nullptr;
 static bool callback_called = false;
 static Ecore_IMF_Input_Panel_State input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
 
@@ -42,8 +43,6 @@ static void WAIT_FOR_CALLBACK();
 
 class EcoreIMFContextTest : public testing::Test {
     public:
-        Ecore_Timer *timer_exit = nullptr;
-
         virtual void SetUp() {
             setenv("ECORE_IMF_MODULE", "wayland", 1);
             setenv("WAYLAND_DISPLAY", "wayland-0", 1);
@@ -69,7 +68,6 @@ class EcoreIMFContextWinTest : public testing::Test {
         const char *ctx_id = nullptr;
         Evas *evas = nullptr;
         Ecore_Evas *ee = nullptr;
-        Ecore_Timer *timer_exit = nullptr;
 
         virtual void SetUp() {
             setenv("ECORE_IMF_MODULE", "wayland", 1);
@@ -106,12 +104,13 @@ class EcoreIMFContextWinTest : public testing::Test {
 static Eina_Bool _timeout_timer_cb(void *data)
 {
     printf("timeout\n");
+    timer_exit = NULL;
     STOP_LOOP();
 
    return ECORE_CALLBACK_DONE;
 }
 
-static void _input_panel_state_cb (void *data, Ecore_IMF_Context *ctx, int value)
+static void _input_panel_state_cb(void *data, Ecore_IMF_Context *ctx, int value)
 {
     int x, y, w, h;
 
@@ -129,6 +128,11 @@ static void _input_panel_state_cb (void *data, Ecore_IMF_Context *ctx, int value
 
     callback_called = true;
 
+    if (timer_exit) {
+        ecore_timer_del(timer_exit);
+        timer_exit = NULL;
+    }
+
     STOP_LOOP();
 }
 
@@ -139,6 +143,12 @@ static void STOP_LOOP()
 
 static void WAIT_FOR_CALLBACK()
 {
+    if (timer_exit) {
+        ecore_timer_del(timer_exit);
+    }
+
+    timer_exit = ecore_timer_add(WAIT_RESULT_DELAY, _timeout_timer_cb, NULL);
+
     ecore_main_loop_begin();
 }
 
@@ -184,8 +194,6 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas)
     ecore_imf_context_client_canvas_set(ctx, evas);
     ecore_imf_context_focus_in(ctx);
 
-    timer_exit = ecore_timer_add(WAIT_RESULT_DELAY, _timeout_timer_cb, NULL);
-
     ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
 
     WAIT_FOR_CALLBACK();
@@ -212,8 +220,6 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_disable_show)
     ecore_imf_context_input_panel_enabled_set(ctx, EINA_FALSE);
     ecore_imf_context_focus_in(ctx);
 
-    timer_exit = ecore_timer_add(WAIT_RESULT_DELAY, _timeout_timer_cb, NULL);
-
     ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
 
     WAIT_FOR_CALLBACK();
@@ -236,8 +242,6 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas_no_window_show)
 
     // no call ecore_evas_show() intentionally for testing
 
-    timer_exit = ecore_timer_add(WAIT_RESULT_DELAY, _timeout_timer_cb, NULL);
-
     ecore_imf_context_client_canvas_set(ctx, evas);
     ecore_imf_context_focus_in(ctx);
 
@@ -261,8 +265,6 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_client_window)
 
     ecore_evas_show(ee);
 
-    timer_exit = ecore_timer_add(WAIT_RESULT_DELAY, _timeout_timer_cb, NULL);
-
     ecore_imf_context_client_window_set(ctx, (void *)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
     ecore_imf_context_focus_in(ctx);