Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2009-03-20 Jan Michael Alonzo <jmalonzo@gmail.com>
        Reviewed by Holger Freyther.

        Separate gtk unit tests
        https://bugs.webkit.org/show_bug.cgi?id=24039

        Build the unit tests accordingly.

        * GNUmakefile.am:


2009-03-20  Jan Michael Alonzo  <jmalonzo@gmail.com>

        Reviewed by Holger Freyther.

        Separate gtk unit tests
        https://bugs.webkit.org/show_bug.cgi?id=24039

        Split the current single-file unit test to make it more
        modularized and manageable in the future as more unit tests are
        written.

        * tests/main.c: Removed.
        * tests/testwebbackforwardlist.c: Copied from WebKit/gtk/tests/main.c.
        (main):
        * tests/testwebframe.c: Copied from WebKit/gtk/tests/main.c.
        (main):




Canonical link: https://commits.webkit.org/33921@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41864 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Jan Alonzo committed Mar 20, 2009
1 parent 032de27 commit 48477a8
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 54 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,3 +1,14 @@
2009-03-20 Jan Michael Alonzo <jmalonzo@gmail.com>

Reviewed by Holger Freyther.

Separate gtk unit tests
https://bugs.webkit.org/show_bug.cgi?id=24039

Build the unit tests accordingly.

* GNUmakefile.am:

2009-03-17 Gustavo Noronha Silva <gns@gnome.org>

Reviewed by Mark Rowe.
Expand Down
36 changes: 23 additions & 13 deletions GNUmakefile.am
Expand Up @@ -47,6 +47,8 @@ lib_LIBRARIES :=

IDL_BINDINGS :=

TEST_PROGS :=

# Global flags to CPP
global_cppflags :=

Expand Down Expand Up @@ -463,29 +465,37 @@ include JavaScriptCore/GNUmakefile.am
include WebCore/GNUmakefile.am
include WebKitTools/GNUmakefile.am

# Build unit test
noinst_PROGRAMS += Programs/UnitTests
Programs_UnitTests_CPPFLAGS = \
-I$(srcdir)/WebKit/gtk \
-I$(top_builddir)/WebKit/gtk \
$(global_cppflags) \
$(javascriptcore_cppflags)

Programs_UnitTests_SOURCES = \
WebKit/gtk/tests/main.c
# Build unit tests
noinst_PROGRAMS += $(TEST_PROGS)

Programs_UnitTests_CFLAGS = \
webkit_tests_cflags = \
-fno-strict-aliasing \
-O2 \
-I$(srcdir)/JavaScriptCore/ForwardingHeaders \
-I$(srcdir)/WebKit/gtk \
-I$(top_builddir)/WebKit/gtk \
$(global_cflags) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBSOUP_CFLAGS)

Programs_UnitTests_LDADD = \
webkit_tests_ldadd = \
libwebkit-1.0.la \
$(GTK_LIBS) \
$(GLIB_LIBS)
$(GLIB_LIBS) \
$(LIBSOUP_LIBS)

TEST_PROGS += Programs/unittests/testwebframe \
Programs/unittests/testwebbackforwardlist

# Add additional tests here
Programs_unittests_testwebframe_SOURCES = WebKit/gtk/tests/testwebframe.c
Programs_unittests_testwebframe_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebframe_LDADD = $(webkit_tests_ldadd)

Programs_unittests_testwebbackforwardlist_SOURCES = WebKit/gtk/tests/testwebbackforwardlist.c
Programs_unittests_testwebbackforwardlist_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebbackforwardlist_LDADD = $(webkit_tests_ldadd)

# Autogenerated sources
BUILT_SOURCES := \
Expand Down
17 changes: 17 additions & 0 deletions WebKit/gtk/ChangeLog
@@ -1,3 +1,20 @@
2009-03-20 Jan Michael Alonzo <jmalonzo@gmail.com>

Reviewed by Holger Freyther.

Separate gtk unit tests
https://bugs.webkit.org/show_bug.cgi?id=24039

Split the current single-file unit test to make it more
modularized and manageable in the future as more unit tests are
written.

* tests/main.c: Removed.
* tests/testwebbackforwardlist.c: Copied from WebKit/gtk/tests/main.c.
(main):
* tests/testwebframe.c: Copied from WebKit/gtk/tests/main.c.
(main):

2009-03-16 Christian Dywan <christian@twotoasts.de>

Reviewed by Adam Roben.
Expand Down
Expand Up @@ -23,19 +23,6 @@

#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)

static void test_webkit_web_frame_create_destroy(void)
{
WebKitWebView* webView;
g_test_bug("21837");

webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_assert_cmpint(G_OBJECT(webView)->ref_count, ==, 1);

// This crashed with the original version
g_object_unref(webView);
}

static void test_webkit_web_history_item_lifetime(void)
{
WebKitWebView* webView;
Expand Down Expand Up @@ -118,32 +105,6 @@ static void test_webkit_web_history_item_lifetime(void)
g_object_unref(backForwardList);
}

static void test_webkit_web_frame_lifetime(void)
{
WebKitWebView* webView;
WebKitWebFrame* webFrame;
g_test_bug("21837");

webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_assert_cmpint(G_OBJECT(webView)->ref_count, ==, 1);
webFrame = webkit_web_view_get_main_frame(webView);
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 1);

// Add dummy reference on the WebKitWebFrame to keep it alive
g_object_ref(webFrame);
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 2);

// This crashed with the original version
g_object_unref(webView);

// Make sure that the frame got deleted as well. We did this
// by adding an extra ref on the WebKitWebFrame and we should
// be the one holding the last reference.
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 1);
g_object_unref(webFrame);
}

static void test_webkit_web_back_forward_list_order(void)
{
WebKitWebView* webView;
Expand Down Expand Up @@ -311,8 +272,6 @@ int main(int argc, char** argv)
gtk_test_init(&argc, &argv, NULL);

g_test_bug_base("https://bugs.webkit.org/");
g_test_add_func("/webkit/webview/create_destroy", test_webkit_web_frame_create_destroy);
g_test_add_func("/webkit/webframe/lifetime", test_webkit_web_frame_lifetime);
g_test_add_func("/webkit/webbackforwardlist/add_item", test_webkit_web_back_forward_list_add_item);
g_test_add_func("/webkit/webbackforwardlist/list_order", test_webkit_web_back_forward_list_order);
g_test_add_func("/webkit/webhistoryitem/lifetime", test_webkit_web_history_item_lifetime);
Expand Down
83 changes: 83 additions & 0 deletions WebKit/gtk/tests/testwebframe.c
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2008 Holger Hans Peter Freyther
*
* 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 <glib.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>

#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)

static void test_webkit_web_frame_create_destroy(void)
{
WebKitWebView* webView;
g_test_bug("21837");

webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_assert_cmpint(G_OBJECT(webView)->ref_count, ==, 1);

// This crashed with the original version
g_object_unref(webView);
}

static void test_webkit_web_frame_lifetime(void)
{
WebKitWebView* webView;
WebKitWebFrame* webFrame;
g_test_bug("21837");

webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_assert_cmpint(G_OBJECT(webView)->ref_count, ==, 1);
webFrame = webkit_web_view_get_main_frame(webView);
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 1);

// Add dummy reference on the WebKitWebFrame to keep it alive
g_object_ref(webFrame);
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 2);

// This crashed with the original version
g_object_unref(webView);

// Make sure that the frame got deleted as well. We did this
// by adding an extra ref on the WebKitWebFrame and we should
// be the one holding the last reference.
g_assert_cmpint(G_OBJECT(webFrame)->ref_count, ==, 1);
g_object_unref(webFrame);
}

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/webview/create_destroy", test_webkit_web_frame_create_destroy);
g_test_add_func("/webkit/webframe/lifetime", test_webkit_web_frame_lifetime);
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

0 comments on commit 48477a8

Please sign in to comment.