1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "utc_blink_ewk_base.h"
7 #define URL ("ewk_view/orientation_test.html")
9 class utc_blink_ewk_view_orientation_send : public utc_blink_ewk_base
12 utc_blink_ewk_view_orientation_send()
13 : utc_blink_ewk_base()
18 void LoadFinished(Evas_Object* webview) override {
19 g_orientation = atol(ewk_view_title_get(GetEwkWebView()));
20 EventLoopStop(utc_blink_ewk_base::Success);
23 void ConsoleMessage(Evas_Object* webview,
24 const Ewk_Console_Message* msg) override {
25 utc_blink_ewk_base::ConsoleMessage(webview, msg);
27 const char* message_text = ewk_console_message_text_get(msg);
28 long int orientation = atol(message_text);
30 switch (orientation) {
36 g_orientation = orientation;
37 EventLoopStop(utc_blink_ewk_base::Success);
40 EventLoopStop(utc_blink_ewk_base::Failure);
47 long int g_orientation;
51 * @brief Checking whether orientation is set to 90 properly.
53 TEST_F(utc_blink_ewk_view_orientation_send, TEST_90DG)
55 std::string full_path = GetResourceUrl(URL);
56 ASSERT_FALSE(full_path.empty());
57 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
58 ASSERT_EQ(Success, EventLoopStart());
60 utc_message("[utc_blink_ewk_view_orientation_send TEST_90DG] :: ewk_view_orientation_send");
61 ewk_view_orientation_send(GetEwkWebView(), 90);
63 ASSERT_EQ(Success, EventLoopStart());
64 ASSERT_EQ(g_orientation, 90);
68 * @brief Checking whether orientation is set to 180 properly.
70 TEST_F(utc_blink_ewk_view_orientation_send, TEST_180DG)
72 std::string full_path = GetResourceUrl(URL);
73 ASSERT_FALSE(full_path.empty());
74 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
75 ASSERT_EQ(Success, EventLoopStart());
77 utc_message("[utc_blink_ewk_view_orientation_send TEST_180DG] :: ewk_view_orientation_send");
78 ewk_view_orientation_send(GetEwkWebView(), 180);
80 ASSERT_EQ(Success, EventLoopStart());
81 ASSERT_EQ(g_orientation, 180);
85 * @brief Checking whether orientation is set to 0 properly.
87 TEST_F(utc_blink_ewk_view_orientation_send, TEST_0DG)
89 std::string full_path = GetResourceUrl(URL);
90 ASSERT_FALSE(full_path.empty());
91 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
92 ASSERT_EQ(Success, EventLoopStart());
94 // 0 is default value, so we need to change it before
95 // checking ewk_view_orientation_send with 0 as argument
96 if (g_orientation == 0) {
97 ewk_view_orientation_send(GetEwkWebView(), 90);
99 ASSERT_EQ(Success, EventLoopStart());
100 ASSERT_EQ(g_orientation, 90);
102 utc_message("[utc_blink_ewk_view_orientation_send TEST_0DG] :: ewk_view_orientation_send");
103 ewk_view_orientation_send(GetEwkWebView(), 0);
105 ASSERT_EQ(Success, EventLoopStart());
106 ASSERT_EQ(g_orientation, 0);
110 * @brief Checking whether orientation is set to 270 properly.
112 TEST_F(utc_blink_ewk_view_orientation_send, TEST_270DG)
114 std::string full_path = GetResourceUrl(URL);
115 ASSERT_FALSE(full_path.empty());
116 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
117 ASSERT_EQ(Success, EventLoopStart());
119 utc_message("[utc_blink_ewk_view_orientation_send TEST_270DG] :: ewk_view_orientation_send");
120 ewk_view_orientation_send(GetEwkWebView(), 270);
122 ASSERT_EQ(Success, EventLoopStart());
123 ASSERT_EQ(g_orientation, 270);
127 * @brief Checking whether orientation of -90 is transformed to -270 properly.
129 TEST_F(utc_blink_ewk_view_orientation_send, TEST_MINUS90DG)
131 std::string full_path = GetResourceUrl(URL);
132 ASSERT_FALSE(full_path.empty());
133 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
134 ASSERT_EQ(Success, EventLoopStart());
136 utc_message("[utc_blink_ewk_view_orientation_send TEST_MINUS90DG] :: ewk_view_orientation_send");
137 ewk_view_orientation_send(GetEwkWebView(), -90);
139 ASSERT_EQ(Success, EventLoopStart());
140 ASSERT_EQ(g_orientation, 270);
144 * @brief Checking that invalid orientation is not set.
146 TEST_F(utc_blink_ewk_view_orientation_send, TEST_40DG)
148 std::string full_path = GetResourceUrl(URL);
149 ASSERT_FALSE(full_path.empty());
150 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
151 ASSERT_EQ(Success, EventLoopStart());
153 utc_message("[utc_blink_ewk_view_orientation_send TEST_40DG] :: ewk_view_orientation_send");
154 ewk_view_orientation_send(GetEwkWebView(), 40);
156 ASSERT_EQ(Timeout, EventLoopStart(2.0));
161 * @brief Checking whether function works properly in case of NULL of a webview.
163 TEST_F(utc_blink_ewk_view_orientation_send, INVALID_ARGS)
165 std::string full_path = GetResourceUrl(URL);
166 ASSERT_FALSE(full_path.empty());
167 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
168 ASSERT_EQ(Success, EventLoopStart());
170 ewk_view_orientation_send(NULL, EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY);
171 EXPECT_EQ(Timeout, EventLoopStart(2.0));
173 ewk_view_orientation_send(GetEwkWebView(), 22);
174 EXPECT_EQ(Timeout, EventLoopStart(2.0));
178 * @brief Checking whether function works properly in case of no render widget
179 * host view object, that is if information about the orientation set
180 * is not lost when function is called before setting the url.
182 TEST_F(utc_blink_ewk_view_orientation_send, BEFOREURLSET)
184 std::string full_path = GetResourceUrl(URL);
185 ASSERT_FALSE(full_path.empty());
187 ewk_view_orientation_send(GetEwkWebView(), 90);
189 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), full_path.c_str()));
190 EXPECT_EQ(Success, EventLoopStart());
191 ASSERT_EQ(g_orientation, 90);