Changeset 52986 in webkit
- Timestamp:
- Jan 8, 2010 3:54:29 AM (14 years ago)
- Location:
- trunk/WebKit/gtk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/gtk/ChangeLog
r52890 r52986 1 2010-01-08 Gustavo Noronha Silva <gns@gnome.org> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] loading test should use SoupServer instead of actual sites 6 https://bugs.webkit.org/show_bug.cgi?id=33353 7 8 Make all the loading tests use SoupServer, instead of fetching 9 stuff from the Internet. 10 11 * tests/testloading.c: 12 (server_callback): 13 (get_uri_for_path): 14 (test_loading_status): 15 (test_loading_error): 16 (test_loading_cancelled): 17 (load_wentback_status_changed_cb): 18 (load_error_test): 19 (test_loading_goback): 20 (main): 21 1 22 2010-01-06 Joanmarie Diggs <joanmarie.diggs@gmail.com> 2 23 -
trunk/WebKit/gtk/tests/testloading.c
r52422 r52986 1 1 /* 2 * Copyright (C) 2009 Gustavo Noronha Silva2 * Copyright (C) 2009, 2010 Gustavo Noronha Silva 3 3 * Copyright (C) 2009 Igalia S.L. 4 4 * … … 20 20 21 21 #include <gtk/gtk.h> 22 #include <libsoup/soup.h> 23 #include <string.h> 22 24 #include <webkit/webkit.h> 23 25 24 26 #if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0) 27 28 /* This string has to be rather big because of the cancelled test - it 29 * looks like soup refuses to send or receive a too small chunk */ 30 #define HTML_STRING "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!</body></html>" 31 32 SoupURI* base_uri; 33 34 /* For real request testing */ 35 static void 36 server_callback(SoupServer* server, SoupMessage* msg, 37 const char* path, GHashTable* query, 38 SoupClientContext* context, gpointer data) 39 { 40 if (msg->method != SOUP_METHOD_GET) { 41 soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); 42 return; 43 } 44 45 soup_message_set_status(msg, SOUP_STATUS_OK); 46 47 if (g_str_equal(path, "/test_loading_status") || g_str_equal(path, "/test_loading_status2")) 48 soup_message_body_append(msg->response_body, SOUP_MEMORY_STATIC, HTML_STRING, strlen(HTML_STRING)); 49 else if (g_str_equal(path, "/test_load_error")) { 50 soup_message_set_status(msg, SOUP_STATUS_CANT_CONNECT); 51 } else if (g_str_equal(path, "/test_loading_cancelled")) { 52 soup_message_headers_set_encoding(msg->response_headers, SOUP_ENCODING_CHUNKED); 53 soup_message_body_append(msg->response_body, SOUP_MEMORY_STATIC, HTML_STRING, strlen(HTML_STRING)); 54 soup_server_unpause_message(server, msg); 55 return; 56 } 57 58 soup_message_body_complete(msg->response_body); 59 } 25 60 26 61 typedef struct { … … 54 89 } 55 90 91 static char* get_uri_for_path(const char* path) 92 { 93 SoupURI* uri; 94 char* uri_string; 95 96 uri = soup_uri_new_with_base(base_uri, path); 97 uri_string = soup_uri_to_string(uri, FALSE); 98 soup_uri_free (uri); 99 100 return uri_string; 101 } 102 56 103 static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, WebLoadingFixture* fixture) 57 104 { … … 99 146 static void test_loading_status(WebLoadingFixture* fixture, gconstpointer data) 100 147 { 148 char* uri_string; 149 101 150 g_assert_cmpint(webkit_web_view_get_load_status(fixture->webView), ==, WEBKIT_LOAD_PROVISIONAL); 102 151 … … 106 155 NULL); 107 156 157 uri_string = get_uri_for_path("/test_loading_status"); 158 108 159 /* load_uri will trigger the navigation-policy-decision-requested 109 160 * signal emission; 110 161 */ 111 webkit_web_view_load_uri(fixture->webView, "http://gnome.org/"); 162 webkit_web_view_load_uri(fixture->webView, uri_string); 163 g_free(uri_string); 112 164 113 165 g_main_loop_run(fixture->loop); … … 154 206 static void test_loading_error(WebLoadingFixture* fixture, gconstpointer data) 155 207 { 208 char* uri_string; 209 156 210 g_test_bug("28842"); 157 211 … … 159 213 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_error_status_changed_cb), fixture); 160 214 161 webkit_web_view_load_uri(fixture->webView, "http://snoetuhsetuhseoutoeutc.com/"); 215 uri_string = get_uri_for_path("/test_load_error"); 216 webkit_web_view_load_uri(fixture->webView, uri_string); 217 g_free(uri_string); 218 162 219 g_main_loop_run(fixture->loop); 163 220 } … … 212 269 static void test_loading_cancelled(WebLoadingFixture* fixture, gconstpointer data) 213 270 { 271 char* uri_string; 272 214 273 g_test_bug("29644"); 215 274 … … 217 276 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_cancelled_status_changed_cb), fixture); 218 277 219 webkit_web_view_load_uri(fixture->webView, "http://google.com/"); 278 uri_string = get_uri_for_path("/test_loading_cancelled"); 279 webkit_web_view_load_uri(fixture->webView, uri_string); 280 g_free(uri_string); 281 220 282 g_main_loop_run(fixture->loop); 221 283 } … … 251 313 { 252 314 WebKitLoadStatus status = webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(object)); 315 char* uri_string; 316 char* uri_string2; 317 318 uri_string = get_uri_for_path("/test_loading_status"); 319 uri_string2 = get_uri_for_path("/test_loading_status2"); 253 320 254 321 switch(status) { 255 322 case WEBKIT_LOAD_PROVISIONAL: 256 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, "http://www.debian.org/distrib/");323 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, uri_string2); 257 324 break; 258 325 case WEBKIT_LOAD_COMMITTED: 259 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, "http://www.debian.org/");326 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, uri_string); 260 327 break; 261 328 case WEBKIT_LOAD_FAILED: … … 263 330 break; 264 331 case WEBKIT_LOAD_FINISHED: 265 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, "http://www.debian.org/");332 g_assert_cmpstr(webkit_web_view_get_uri(fixture->webView), ==, uri_string); 266 333 g_main_loop_quit(fixture->loop); 267 334 break; … … 269 336 break; 270 337 } 338 339 g_free(uri_string); 340 g_free(uri_string2); 341 } 342 343 static void load_error_test(WebKitWebView* webview, WebKitWebFrame* frame, const char* uri, GError* error) 344 { 345 g_debug("Error: %s", error->message); 271 346 } 272 347 273 348 static void test_loading_goback(WebLoadingFixture* fixture, gconstpointer data) 274 349 { 350 char* uri_string; 351 275 352 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_goback_status_changed_cb), fixture); 276 353 277 webkit_web_view_load_uri(fixture->webView, "http://www.debian.org/"); 354 g_signal_connect(fixture->webView, "load-error", G_CALLBACK(load_error_test), fixture); 355 356 uri_string = get_uri_for_path("/test_loading_status"); 357 webkit_web_view_load_uri(fixture->webView, uri_string); 358 g_free(uri_string); 359 278 360 g_main_loop_run(fixture->loop); 279 361 … … 285 367 fixture->has_been_load_error = FALSE; 286 368 287 webkit_web_view_load_uri(fixture->webView, "http://debian.org/distrib/"); 288 g_main_loop_run(fixture->loop); 369 uri_string = get_uri_for_path("/test_loading_status2"); 370 webkit_web_view_load_uri(fixture->webView, uri_string); 371 g_free(uri_string); 372 373 g_main_loop_run(fixture->loop); 374 375 g_signal_handlers_disconnect_by_func(fixture->webView, load_goback_status_changed_cb, fixture); 289 376 290 377 fixture->has_been_provisional = FALSE; … … 297 384 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_wentback_status_changed_cb), fixture); 298 385 webkit_web_view_go_back(fixture->webView); 386 387 g_main_loop_run(fixture->loop); 388 389 g_signal_handlers_disconnect_by_func(fixture->webView, load_wentback_status_changed_cb, fixture); 299 390 } 300 391 301 392 int main(int argc, char** argv) 302 393 { 394 SoupServer* server; 395 303 396 g_thread_init(NULL); 304 397 gtk_test_init(&argc, &argv, NULL); 398 399 server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); 400 soup_server_run_async(server); 401 402 soup_server_add_handler(server, NULL, server_callback, NULL, NULL); 403 404 base_uri = soup_uri_new("http://127.0.0.1/"); 405 soup_uri_set_port(base_uri, soup_server_get_port(server)); 305 406 306 407 g_test_bug_base("https://bugs.webkit.org/");
Note: See TracChangeset
for help on using the changeset viewer.