Add input_panel_enabled_set case in tests 62/235262/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 3 Jun 2020 07:09:34 +0000 (16:09 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 3 Jun 2020 07:13:13 +0000 (16:13 +0900)
Change-Id: Iefa9b56ae0768b24551311d8ff4a3a8b6a686389
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/tests/Makefile.am
ism/tests/ecore_imf_tests.cpp [new file with mode: 0644]
ism/tests/ecore_imf_unittests.cpp [deleted file]

index 699ceb00102fb2f9cea35b3e757df4d5e484b709..5045b732fb4a3285c5733e2e01e305ef35bcfcc6 100644 (file)
@@ -26,7 +26,7 @@ ISF_TESTS = isf-tests
 appexecdir            = /usr/bin/
 appexec_PROGRAMS      = $(ISF_TESTS)
 
-isf_tests_SOURCES  = main.cpp ecore_imf_unittests.cpp
+isf_tests_SOURCES  = main.cpp ecore_imf_tests.cpp
 
 isf_tests_CXXFLAGS = @GMOCK_CFLAGS@ \
                      @ECORE_IMF_CFLAGS@ \
diff --git a/ism/tests/ecore_imf_tests.cpp b/ism/tests/ecore_imf_tests.cpp
new file mode 100644 (file)
index 0000000..6e13a60
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * ISF(Input Service Framework)
+ *
+ * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
+ * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jihoon Kim <jihoon48.kim@samsung.com>, Inhong Han <inhong1.han@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <gtest/gtest.h>
+#include <Ecore_IMF.h>
+#include <Ecore_Evas.h>
+#include <Evas.h>
+#include <Ecore.h>
+
+#define WIDTH 480
+#define HEIGHT 800
+
+#define WAIT_RESULT_DELAY 1.5
+
+namespace {
+
+static bool callback_called = false;
+static Ecore_IMF_Input_Panel_State input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
+
+static void STOP_LOOP();
+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);
+            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);
+        }
+        virtual void TearDown() {
+            ecore_imf_shutdown();
+            ecore_evas_shutdown();
+        }
+};
+
+class EcoreIMFContextWinTest : public testing::Test {
+    public:
+        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);
+            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);
+        }
+        virtual void TearDown() {
+            if (ee)
+                ecore_evas_free(ee);
+
+            ecore_imf_shutdown();
+            ecore_evas_shutdown();
+        }
+};
+
+static Eina_Bool _timeout_timer_cb(void *data)
+{
+    printf("timeout\n");
+    STOP_LOOP();
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static void _input_panel_state_cb (void *data, Ecore_IMF_Context *ctx, int value)
+{
+    int x, y, w, h;
+
+    input_panel_state = (Ecore_IMF_Input_Panel_State)value;
+
+    if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
+        ecore_imf_context_input_panel_geometry_get (ctx, &x, &y, &w, &h);
+        printf ("Input panel is shown. ctx : %p\n", ctx);
+        printf ("x : %d, y : %d, w : %d, h : %d\n", x, y, w, h);
+    } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
+        printf ("Input panel is hidden. ctx : %p\n", ctx);
+    } else if (value == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW) {
+        printf ("Input panel will be shown. ctx : %p\n", ctx);
+    }
+
+    callback_called = true;
+
+    STOP_LOOP();
+}
+
+static void STOP_LOOP()
+{
+    ecore_main_loop_quit();
+}
+
+static void WAIT_FOR_CALLBACK()
+{
+    ecore_main_loop_begin();
+}
+
+/**
+ * @testcase        ecore_imf_context_add_p
+ * @since           2.4
+ * @description     Positive UTC of ecore_imf_context_add().
+ */
+TEST_F(EcoreIMFContextTest, utc_ecore_imf_context_add_p)
+{
+    const char *ctx_id = ecore_imf_context_default_id_get();
+    ASSERT_NE(ctx_id, nullptr);
+
+    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
+    EXPECT_NE(ctx, nullptr);
+
+    ecore_imf_context_del(ctx);
+}
+
+/**
+ * @testcase        ecore_imf_context_add_n
+ * @since           2.4
+ * @description     Negative UTC of ecore_imf_context_add().
+ */
+TEST_F(EcoreIMFContextTest, utc_ecore_imf_context_add_n)
+{
+    Ecore_IMF_Context *ctx = ecore_imf_context_add(NULL);
+    EXPECT_EQ(ctx, nullptr);
+}
+
+TEST_F(EcoreIMFContextWinTest, 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);
+
+    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();
+
+    Ecore_IMF_Input_Panel_State input_panel_state = ecore_imf_context_input_panel_state_get(ctx);
+
+    EXPECT_EQ(callback_called, true);
+    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
+}
+
+TEST_F(EcoreIMFContextWinTest, utc_ime_disable_show)
+{
+    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);
+
+    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();
+
+    Ecore_IMF_Input_Panel_State input_panel_state = ecore_imf_context_input_panel_state_get(ctx);
+
+    EXPECT_EQ(callback_called, false);
+    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_HIDE);
+}
+
+TEST_F(EcoreIMFContextWinTest, utc_ime_show_in_canvas_no_window_show)
+{
+    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);
+
+    evas_focus_in(evas);
+
+    // 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);
+
+    ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
+
+    WAIT_FOR_CALLBACK();
+
+    Ecore_IMF_Input_Panel_State input_panel_state = ecore_imf_context_input_panel_state_get(ctx);
+
+    EXPECT_EQ(callback_called, false);
+    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_HIDE);
+}
+
+TEST_F(EcoreIMFContextWinTest, 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);
+
+    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);
+
+    ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
+
+    WAIT_FOR_CALLBACK();
+
+    EXPECT_EQ(callback_called, true);
+    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
+}
+
+} // namespace
diff --git a/ism/tests/ecore_imf_unittests.cpp b/ism/tests/ecore_imf_unittests.cpp
deleted file mode 100644 (file)
index d3b6a65..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * ISF(Input Service Framework)
- *
- * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
- * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
- *
- * Contact: Jihoon Kim <jihoon48.kim@samsung.com>, Inhong Han <inhong1.han@samsung.com>
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#include <gtest/gtest.h>
-#include <Ecore_IMF.h>
-#include <Ecore_Evas.h>
-#include <Evas.h>
-#include <Ecore.h>
-
-#define WIDTH 480
-#define HEIGHT 800
-
-namespace {
-
-static bool callback_called = false;
-static Ecore_IMF_Input_Panel_State input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-static void STOP_LOOP();
-static void WAIT_FOR_CALLBACK();
-
-class EcoreIMFContextTest : public testing::Test {
-    public:
-        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);
-        }
-        virtual void TearDown() {
-            ecore_imf_shutdown();
-            ecore_evas_shutdown();
-        }
-
-        Ecore_Timer *timer_exit = nullptr;
-};
-
-static Eina_Bool _timeout_timer_cb(void *data)
-{
-    printf("timeout\n");
-    STOP_LOOP();
-
-   return ECORE_CALLBACK_DONE;
-}
-
-static void _input_panel_state_cb (void *data, Ecore_IMF_Context *ctx, int value)
-{
-    int x, y, w, h;
-
-    input_panel_state = (Ecore_IMF_Input_Panel_State)value;
-
-    if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
-        ecore_imf_context_input_panel_geometry_get (ctx, &x, &y, &w, &h);
-        printf ("Input panel is shown. ctx : %p\n", ctx);
-        printf ("x : %d, y : %d, w : %d, h : %d\n", x, y, w, h);
-    } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
-        printf ("Input panel is hidden. ctx : %p\n", ctx);
-    } else if (value == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW) {
-        printf ("Input panel will be shown. ctx : %p\n", ctx);
-    }
-
-    callback_called = true;
-
-    STOP_LOOP();
-}
-
-static void STOP_LOOP()
-{
-    ecore_main_loop_quit();
-}
-
-static void WAIT_FOR_CALLBACK()
-{
-    ecore_main_loop_begin();
-}
-
-/**
- * @testcase        ecore_imf_context_add_p
- * @since           2.4
- * @description     Positive UTC of ecore_imf_context_add().
- */
-TEST_F(EcoreIMFContextTest, utc_ecore_imf_context_add_p)
-{
-    const char *ctx_id = ecore_imf_context_default_id_get();
-    ASSERT_NE(ctx_id, nullptr);
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    EXPECT_NE(ctx, nullptr);
-}
-
-/**
- * @testcase        ecore_imf_context_add_n
- * @since           2.4
- * @description     Negative UTC of ecore_imf_context_add().
- */
-TEST_F(EcoreIMFContextTest, utc_ecore_imf_context_add_n)
-{
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(NULL);
-    EXPECT_EQ(ctx, nullptr);
-}
-
-TEST_F(EcoreIMFContextTest, utc_ime_show_in_canvas)
-{
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    int ret = ecore_evas_init();
-    ASSERT_NE(ret, 0);
-
-    const char *ctx_id = ecore_imf_context_default_id_get();
-    ASSERT_NE(ctx_id, nullptr);
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
-    ASSERT_NE(ee, nullptr);
-
-    ecore_evas_show(ee);
-
-    Evas *evas = ecore_evas_get(ee);
-    ASSERT_NE(evas, nullptr);
-
-    evas_focus_in(evas);
-
-    ecore_imf_context_client_canvas_set(ctx, evas);
-    ecore_imf_context_focus_in(ctx);
-
-    timer_exit = ecore_timer_add(1.5, _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();
-
-    ecore_evas_free(ee);
-
-    EXPECT_EQ(callback_called, true);
-}
-
-TEST_F(EcoreIMFContextTest, utc_ime_show_in_canvas_no_window_show)
-{
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    int ret = ecore_evas_init();
-    ASSERT_NE(ret, 0);
-
-    const char *ctx_id = ecore_imf_context_default_id_get();
-    ASSERT_NE(ctx_id, nullptr);
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
-    ASSERT_NE(ee, nullptr);
-
-    Evas *evas = ecore_evas_get(ee);
-    ASSERT_NE(evas, nullptr);
-
-    evas_focus_in(evas);
-
-    // no call ecore_evas_show() intentionally for testing
-
-    timer_exit = ecore_timer_add(1.5, _timeout_timer_cb, NULL);
-
-    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);
-
-    WAIT_FOR_CALLBACK();
-
-    Ecore_IMF_Input_Panel_State input_panel_state = ecore_imf_context_input_panel_state_get(ctx);
-
-    ecore_evas_free(ee);
-
-    EXPECT_EQ(callback_called, false);
-    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_HIDE);
-}
-
-TEST_F(EcoreIMFContextTest, utc_ime_show_in_client_window)
-{
-    callback_called = false;
-    input_panel_state = ECORE_IMF_INPUT_PANEL_STATE_HIDE;
-
-    int ret = ecore_evas_init();
-    ASSERT_NE(ret, 0);
-
-    const char *ctx_id = ecore_imf_context_default_id_get();
-    ASSERT_NE(ctx_id, nullptr);
-
-    Ecore_IMF_Context *ctx = ecore_imf_context_add(ctx_id);
-    ASSERT_NE(ctx, nullptr);
-
-    Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
-    ASSERT_NE(ee, nullptr);
-
-    ecore_evas_show(ee);
-
-    Evas *evas = ecore_evas_get(ee);
-
-    timer_exit = ecore_timer_add(1.5, _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);
-
-    ecore_imf_context_input_panel_event_callback_add(ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
-
-    WAIT_FOR_CALLBACK();
-
-    ecore_evas_free(ee);
-
-    EXPECT_EQ(callback_called, true);
-    EXPECT_EQ(input_panel_state, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
-}
-
-} // namespace