4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation; either version 2.1 of the License, or (at your option)
11 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @file utc_webkit2_ewk_view_orientation_send_func.c
24 * @author Yuni Jeong <yhnet.jung@samsung.com>
26 * @brief Tests EWK function ewk_view_orientation_send()
29 /* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
30 #define TESTED_FUN_NAME ewk_view_orientation_send
31 #define POSITIVE_TEST_FUN_NUM 4
32 #define NEGATIVE_TEST_FUN_NUM 1
34 #include "utc_webkit2_ewk.h"
36 static Eina_Bool is_load_failed = EINA_FALSE;
37 static Ewk_Screen_Orientation g_orientation = EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY;
39 static void load_finished(void* data, Evas_Object* webview, void* event_info)
41 utc_message("[load_finished] :: \n");
42 is_load_failed = EINA_FALSE;
43 utc_webkit2_main_loop_quit();
46 static void load_error(void* data, Evas_Object* webview, void* event_info)
48 utc_message("[load_error] :: \n");
49 is_load_failed = EINA_TRUE;
50 utc_webkit2_main_loop_quit();
53 static Eina_Bool alert_callback(Evas_Object* webview ,const char* alert_text, void* user_data)
55 utc_message("[alert_callback] :: \n");
56 switch (atoi(alert_text)) {
58 g_orientation = EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY;
61 g_orientation = EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY;
64 g_orientation = EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY;
67 g_orientation = EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY;
73 utc_webkit2_main_loop_quit();
76 /* Startup and cleanup functions */
77 static void startup(void)
79 utc_webkit2_ewk_test_init();
81 evas_object_smart_callback_add(test_view.webview, "load,finished", load_finished, NULL);
82 evas_object_smart_callback_add(test_view.webview, "load,error", load_error, NULL);
84 ewk_view_javascript_alert_callback_set(test_view.webview, alert_callback, 0);
87 static void cleanup(void)
89 evas_object_smart_callback_del(test_view.webview, "load,finished", load_finished);
90 evas_object_smart_callback_del(test_view.webview, "load,error", load_error);
92 utc_webkit2_ewk_test_end();
96 * @brief Checking whether orientation is set to EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY properly.
100 char* full_path = generate_full_resource_path("/ewk_view/orientation_test.html");
104 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
108 utc_webkit2_main_loop_begin();
113 Ewk_Screen_Orientation orientation = EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY;
114 ewk_view_orientation_send(test_view.webview, orientation);
115 utc_webkit2_main_loop_begin();
116 utc_check_eq(orientation, g_orientation);
120 * @brief Checking whether orientation is set to EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY properly.
124 char* full_path = generate_full_resource_path("/ewk_view/orientation_test1.html");
128 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
132 utc_webkit2_main_loop_begin();
137 Ewk_Screen_Orientation orientation = EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY;
138 ewk_view_orientation_send(test_view.webview, orientation);
139 utc_webkit2_main_loop_begin();
140 utc_check_eq(orientation, g_orientation);
144 * @brief Checking whether orientation is set to EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY properly.
148 char* full_path = generate_full_resource_path("/ewk_view/orientation_test2.html");
152 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
156 utc_webkit2_main_loop_begin();
161 Ewk_Screen_Orientation orientation = EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY;
162 ewk_view_orientation_send(test_view.webview, orientation);
163 utc_webkit2_main_loop_begin();
164 utc_check_eq(orientation, g_orientation);
168 * @brief Checking whether orientation is set to EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY properly.
172 char* full_path = generate_full_resource_path("/ewk_view/orientation_test3.html");
176 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
180 utc_webkit2_main_loop_begin();
185 Ewk_Screen_Orientation orientation = EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY;
186 ewk_view_orientation_send(test_view.webview, orientation);
187 utc_webkit2_main_loop_begin();
188 utc_check_eq(orientation, g_orientation);
192 * @brief Checking whether function works properly in case of NULL of a webview.
196 ewk_view_orientation_send(NULL, EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY);