Commit 4ece5911 authored by kov@webkit.org's avatar kov@webkit.org

2009-06-20 Gustavo Noronha Silva <gns@gnome.org>

        Reviewed by Jan Alonzo.

        Initial test case for loading statuses.

        * tests/testloading.c: Added.
        (load_finished_cb):
        (status_changed_cb):
        (test_loading_status):
        (main):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0a028aa2
2009-06-20 Gustavo Noronha Silva <gns@gnome.org>
Reviewed by Jan Alonzo.
Adding files for the new test case for loading statuses.
* GNUmakefile.am:
2009-06-15 Xan Lopez <xlopez@igalia.com>
Reviewed by Gustavo Noronha.
......
......@@ -526,6 +526,7 @@ webkit_tests_ldflags = \
-no-fast-install
TEST_PROGS += Programs/unittests/testhttpbackend \
Programs/unittests/testloading \
Programs/unittests/testnetworkrequest \
Programs/unittests/testwebframe \
Programs/unittests/testwebbackforwardlist \
......@@ -539,6 +540,11 @@ Programs_unittests_testhttpbackend_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testhttpbackend_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testhttpbackend_LDFLAGS = $(webkit_tests_ldflags)
Programs_unittests_testloading_SOURCES = WebKit/gtk/tests/testloading.c
Programs_unittests_testloading_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testloading_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testloading_LDFLAGS = $(webkit_tests_ldflags)
Programs_unittests_testnetworkrequest_SOURCES = WebKit/gtk/tests/testnetworkrequest.c
Programs_unittests_testnetworkrequest_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testnetworkrequest_LDADD = $(webkit_tests_ldadd)
......
2009-06-20 Gustavo Noronha Silva <gns@gnome.org>
Reviewed by Jan Alonzo.
Initial test case for loading statuses.
* tests/testloading.c: Added.
(load_finished_cb):
(status_changed_cb):
(test_loading_status):
(main):
2009-06-20 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Rubber-stamped by Jan Alonzo.
......
/*
* Copyright (C) 2009 Gustavo Noronha Silva
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
static gboolean has_been_provisional = FALSE;
static gboolean has_been_committed = FALSE;
static gboolean has_been_first_visually_non_empty_layout = FALSE;
static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, gpointer data)
{
GMainLoop* loop = (GMainLoop*)data;
g_assert(has_been_provisional);
g_assert(has_been_committed);
g_assert(has_been_first_visually_non_empty_layout);
g_main_loop_quit(loop);
}
static void status_changed_cb(GObject* object, GParamSpec* pspec, gpointer data)
{
WebKitLoadStatus status = webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(object));
switch (status) {
case WEBKIT_LOAD_PROVISIONAL:
g_assert(!has_been_provisional);
g_assert(!has_been_committed);
g_assert(!has_been_first_visually_non_empty_layout);
has_been_provisional = TRUE;
break;
case WEBKIT_LOAD_COMMITTED:
g_assert(has_been_provisional);
g_assert(!has_been_committed);
g_assert(!has_been_first_visually_non_empty_layout);
has_been_committed = TRUE;
break;
case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
g_assert(has_been_provisional);
g_assert(has_been_committed);
g_assert(!has_been_first_visually_non_empty_layout);
has_been_first_visually_non_empty_layout = TRUE;
break;
case WEBKIT_LOAD_FINISHED:
g_assert(has_been_provisional);
g_assert(has_been_committed);
g_assert(has_been_first_visually_non_empty_layout);
break;
default:
g_assert_not_reached();
}
}
static void test_loading_status()
{
WebKitWebView* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
GMainLoop* loop = g_main_loop_new(NULL, TRUE);
g_object_ref_sink(web_view);
g_assert_cmpint(webkit_web_view_get_load_status(web_view), ==, WEBKIT_LOAD_PROVISIONAL);
g_object_connect(G_OBJECT(web_view),
"signal::notify::load-status", G_CALLBACK(status_changed_cb), NULL,
"signal::load-finished", G_CALLBACK(load_finished_cb), loop,
NULL);
/* load_uri will trigger the navigation-policy-decision-requested
* signal emission;
*/
webkit_web_view_load_uri(web_view, "http://gnome.org/");
g_main_loop_run(loop);
g_object_unref(web_view);
}
int main(int argc, char** argv)
{
g_thread_init(NULL);
gtk_test_init(&argc, &argv, NULL);
g_test_bug_base("https://bugs.webkit.org/");
g_test_add_func("/webkit/loading/status", test_loading_status);
return g_test_run();
}
#else
int main(int argc, char** argv)
{
g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
return 0;
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment