Add Unittest for ime_set_native_window_size() 92/262692/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 18 Aug 2021 04:27:00 +0000 (13:27 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 18 Aug 2021 04:27:35 +0000 (13:27 +0900)
lines......: 92.8% (1366 of 1472 lines)
functions..: 100.0% (246 of 246 functions)

Change-Id: Ibe10630963e9abd6265020050aaeecc1610d7732
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
inputmethod/src/inputmethod.cpp
tests/src/inputmethod_unittests.cpp

index 5decdce..40664a8 100644 (file)
@@ -1571,7 +1571,7 @@ EXPORT_API int ime_set_native_window_size(Ecore_Wl2_Window *window, int portrait
 {
     ime_error_e retVal = IME_ERROR_NONE;
 
-    if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
+    if (!window || portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
         LOGW("IME_ERROR_INVALID_PARAMETER");
         return IME_ERROR_INVALID_PARAMETER;
     }
index cc6a705..296cf0d 100644 (file)
@@ -18,7 +18,9 @@
 
 #include <inputmethod.h>
 #include "inputmethod_private.h"
+#include "inputmethod_internal.h"
 #include <Evas.h>
+#include <Ecore_Wl2.h>
 
 #include "cynara_mock.h"
 
@@ -1473,4 +1475,39 @@ TEST_F(InputMethodTest, utc_ime_input_device_rotary_get_direction_n)
     EXPECT_EQ(ret, IME_ERROR_INVALID_PARAMETER);
 }
 
+/**
+ * @testcase           utc_ime_set_native_size_null_window
+ * @since_tizen                6.5
+ * @description                Negative UTC of the function that updates the input panel window's size information.
+ */
+TEST_F(InputMethodTest, utc_ime_set_native_size_null_window)
+{
+    int ret = ime_set_native_window_size(NULL, 540, 400, 960, 300);
+    EXPECT_EQ(ret, IME_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_ime_set_native_window_size_zero_parameter
+ * @since_tizen                6.5
+ * @description                Negative UTC of the function that updates the input panel window's size information.
+ */
+TEST_F(InputMethodTest, utc_ime_set_native_window_size_zero_parameter)
+{
+    Ecore_Wl2_Window *win = (Ecore_Wl2_Window *)0x1;
+    int ret = ime_set_native_window_size(win, 0, 0, 0, 0);
+    EXPECT_EQ(ret, IME_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_ime_set_native_window_size_not_running
+ * @since_tizen                6.5
+ * @description                Negative UTC of the function that updates the input panel window's size information.
+ */
+TEST_F(InputMethodTest, utc_ime_set_native_window_size_not_running)
+{
+    Ecore_Wl2_Window *win = (Ecore_Wl2_Window *)0x1;
+    int ret = ime_set_native_window_size(win, 540, 400, 960, 300);
+    EXPECT_EQ(ret, IME_ERROR_NOT_RUNNING);
+}
+
 } // namespace