tests: Refactor to use new fixture 59/244959/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 28 Sep 2020 08:51:13 +0000 (17:51 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 28 Sep 2020 08:51:18 +0000 (17:51 +0900)
This reverts commit d0aab84a6b4456d7302e500473ba0cc6ceb179d8.

Change-Id: I6ae1649935469bfc62a8ff25fbc5ab26122ee953

ism/tests/ecore_imf_tests.cpp

index cb05b93..14020da 100644 (file)
@@ -101,6 +101,63 @@ class EcoreIMFContextWinTest : public testing::Test {
         }
 };
 
+class EcoreIMFContextWinFocusTest : public testing::Test {
+    public:
+        const char *ctx_id = nullptr;
+        Evas *evas = nullptr;
+        Ecore_Evas *ee = nullptr;
+        Ecore_IMF_Context *ctx = nullptr;
+
+        virtual void SetUp() {
+            setenv("ECORE_IMF_MODULE", "wayland", 1);
+            setenv("WAYLAND_DISPLAY", "wayland-0", 1);
+            setenv("XDG_RUNTIME_DIR", "/run", 1);
+
+            callback_called = false;
+            int ret;
+
+            ret = ecore_evas_init();
+            ASSERT_NE(ret, 0);
+
+            ret = ecore_imf_init();
+            ASSERT_NE(ret, 0);
+
+            ctx_id = ecore_imf_context_default_id_get();
+            ASSERT_NE(ctx_id, nullptr);
+
+            ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+            ASSERT_NE(ee, nullptr);
+
+            evas = ecore_evas_get(ee);
+            ASSERT_NE(evas, nullptr);
+
+            callback_called = false;
+            input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
+
+            ctx = ecore_imf_context_add(ctx_id);
+            ASSERT_NE(ctx, nullptr);
+
+            ecore_evas_show(ee);
+
+            evas_focus_in(evas);
+
+            ecore_imf_context_client_canvas_set(ctx, evas);
+        }
+
+        virtual void TearDown() {
+            if (ee)
+                ecore_evas_free(ee);
+
+            if (ctx) {
+                ecore_imf_context_del(ctx);
+                ctx = NULL;
+            }
+
+            ecore_imf_shutdown();
+            ecore_evas_shutdown();
+        }
+};
+
 static Eina_Bool _timeout_timer_cb(void *data)
 {
     printf("timeout\n");
@@ -179,19 +236,8 @@ TEST_F(EcoreIMFContextTest, utc_ecore_imf_context_add_n)
     EXPECT_EQ(ctx, nullptr);
 }
 
-TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas)
+TEST_F(EcoreIMFContextWinFocusTest, utc_ime_show_in_canvas)
 {
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    ecore_evas_show(ee);
-
-    evas_focus_in(evas);
-
-    ecore_imf_context_client_canvas_set(ctx, evas);
     ecore_imf_context_focus_in(ctx);
 
     ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
@@ -204,19 +250,8 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas)
     EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
 }
 
-TEST_F(EcoreIMFContextWinTest, utc_ime_disable_show)
+TEST_F(EcoreIMFContextWinFocusTest, utc_ime_disable)
 {
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    ecore_evas_show(ee);
-
-    evas_focus_in(evas);
-
-    ecore_imf_context_client_canvas_set(ctx, evas);
     ecore_imf_context_input_panel_enabled_set(ctx, EINA_FALSE);
     ecore_imf_context_focus_in(ctx);
 
@@ -255,17 +290,8 @@ TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas_no_window_show)
     EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_HIDE);
 }
 
-TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_client_window)
+TEST_F(EcoreIMFContextWinFocusTest, utc_ime_show_in_client_window)
 {
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    ecore_evas_show(ee);
-
-    ecore_imf_context_client_window_set(ctx, (void *)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
     ecore_imf_context_focus_in(ctx);
 
     ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);