Fixes utc_blink_ewk_view_orientation_send_func unittest
authorArnaud Renevier <a.renevier@samsung.com>
Tue, 24 Nov 2015 00:37:19 +0000 (16:37 -0800)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
In order to fix utc_blink_ewk_view_orientation_send, we need to use the
new screen orientation API instead of window orientation.

Also, an orientation of -90 is transformed into a 270 orientation
by ewk. So, we need to take that into account

In addition, in order to make the test more thorough, we add a test to
check that an invalid orientation value isn't propagated.

Lastly, we remove the files orientation_test1.html,
orientation_test2.html and orientation_test3.html which were unused.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=6980

Reviewed by: a1.gomes, djmix.kim

Change-Id: Iae76f08151a753272877d9839c3660842f0b161b
Signed-off-by: Arnaud Renevier <a.renevier@samsung.com>
tizen_src/ewk/unittest/resources/ewk_view/orientation_test.html
tizen_src/ewk/unittest/resources/ewk_view/orientation_test1.html [deleted file]
tizen_src/ewk/unittest/resources/ewk_view/orientation_test2.html [deleted file]
tizen_src/ewk/unittest/resources/ewk_view/orientation_test3.html [deleted file]
tizen_src/ewk/unittest/utc_blink_ewk_view_orientation_send_func.cpp

index 8e07700..52807e5 100755 (executable)
@@ -2,14 +2,14 @@
     <head>
         <title>Orientation Test</title>
         <script type="text/javascript">
-            function onLoad() { 
-              window.addEventListener("orientationchange", updateOrientation);
-              document.title=window.orientation;
-            } 
+            function onLoad() {
+              screen.orientation.addEventListener("change", updateOrientation);
+              document.title=screen.orientation.angle;
+            }
 
             function updateOrientation()
             {
-              console.log(window.orientation);
+              console.log(screen.orientation.angle);
             }
         </script>
     </head>
diff --git a/tizen_src/ewk/unittest/resources/ewk_view/orientation_test1.html b/tizen_src/ewk/unittest/resources/ewk_view/orientation_test1.html
deleted file mode 100755 (executable)
index 28fda0e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<html>
-    <head>
-        <title>Orientation Test</title>
-        <script type="text/javascript">
-            window.onload=orientationchange;
-            function orientationchange()
-            {
-               alert("-90");
-            }
-        </script>
-    </head>
-    <body>
-    <h1>Orientation Test Page</h1>
-    </body>
-</html>
diff --git a/tizen_src/ewk/unittest/resources/ewk_view/orientation_test2.html b/tizen_src/ewk/unittest/resources/ewk_view/orientation_test2.html
deleted file mode 100755 (executable)
index 940c8ea..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<html>
-    <head>
-        <title>Orientation Test</title>
-        <script type="text/javascript">
-            window.onload=orientationchange;
-            function orientationchange()
-            {
-               alert("0");
-            }
-        </script>
-    </head>
-    <body>
-    <h1>Orientation Test Page</h1>
-    </body>
-</html>
diff --git a/tizen_src/ewk/unittest/resources/ewk_view/orientation_test3.html b/tizen_src/ewk/unittest/resources/ewk_view/orientation_test3.html
deleted file mode 100755 (executable)
index 28cd702..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<html>
-    <head>
-        <title>Orientation Test</title>
-        <script type="text/javascript">
-            window.onload=orientationchange;
-            function orientationchange()
-            {
-               alert("180");
-            }
-        </script>
-    </head>
-    <body>
-    <h1>Orientation Test Page</h1>
-    </body>
-</html>
index e22dbcb..d50863f 100755 (executable)
@@ -34,11 +34,15 @@ protected:
     case 0:
     case 90:
     case 180:
+    case 270:
       g_orientation = orientation;
+      EventLoopStop(utc_blink_ewk_base::Success);
+      break;
+    default:
+      EventLoopStop(utc_blink_ewk_base::Failure);
       break;
     }
 
-    EventLoopStop(utc_blink_ewk_base::Success);
   }
 
 protected:
@@ -105,7 +109,24 @@ TEST_F(utc_blink_ewk_view_orientation_send, TEST_0DG)
 }
 
 /**
- * @brief Checking whether orientation is set to -90 properly.
+ * @brief Checking whether orientation is set to 270 properly.
+ */
+TEST_F(utc_blink_ewk_view_orientation_send, TEST_270DG)
+{
+  std::string full_path = GetResourceUrl(URL);
+  ASSERT_FALSE(full_path.empty());
+  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
+  ASSERT_EQ(Success, EventLoopStart());
+
+  utc_message("[utc_blink_ewk_view_orientation_send TEST_270DG] :: ewk_view_orientation_send");
+  ewk_view_orientation_send(GetEwkWebView(), 270);
+
+  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(g_orientation, 270);
+}
+
+/**
+ * @brief Checking whether orientation of -90 is transformed to -270 properly.
  */
 TEST_F(utc_blink_ewk_view_orientation_send, TEST_MINUS90DG)
 {
@@ -118,10 +139,27 @@ TEST_F(utc_blink_ewk_view_orientation_send, TEST_MINUS90DG)
   ewk_view_orientation_send(GetEwkWebView(), -90);
 
   ASSERT_EQ(Success, EventLoopStart());
-  ASSERT_EQ(g_orientation, -90);
+  ASSERT_EQ(g_orientation, 270);
 }
 
 /**
+ * @brief Checking that invalid orientation is not set.
+ */
+TEST_F(utc_blink_ewk_view_orientation_send, TEST_40DG)
+{
+  std::string full_path = GetResourceUrl(URL);
+  ASSERT_FALSE(full_path.empty());
+  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
+  ASSERT_EQ(Success, EventLoopStart());
+
+  utc_message("[utc_blink_ewk_view_orientation_send TEST_40DG] :: ewk_view_orientation_send");
+  ewk_view_orientation_send(GetEwkWebView(), 40);
+
+  ASSERT_EQ(Timeout, EventLoopStart(2.0));
+}
+
+
+/**
  * @brief Checking whether function works properly in case of NULL of a webview.
  */
 TEST_F(utc_blink_ewk_view_orientation_send, INVALID_ARGS)
@@ -153,4 +191,4 @@ TEST_F(utc_blink_ewk_view_orientation_send, BEFOREURLSET)
   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
   EXPECT_EQ(Success, EventLoopStart());
   ASSERT_EQ(g_orientation, 90);
-}
\ No newline at end of file
+}