Changeset 153327 in webkit


Ignore:
Timestamp:
Jul 25, 2013 9:13:30 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Add support for running unit tests in the web process
https://bugs.webkit.org/show_bug.cgi?id=118427

Reviewed by Gustavo Noronha Silva.

Some tests, like GObject DOM bindings API tests, run entirely in
the WebProcess, so we just need to start the test from the UI
process and wait until the test finishes running in the
WebProcess. Tests are split in two files, one containing the
actual test that runs in the WebProcess and another one to add the
tests to the glib test system that works as a
proxy. WebProcessTestRunner class starts a private DBus session
bus and starts the tests sending a message to the WebExtension
waiting until it finishes or fails. WebProcess tests are created
by defining a class derived from WebProcessTest class and
implementing the static create method and the virtual runTest
method. The macro REGISTER_TEST is used by the web process tests
to register their test cases. This patch includes the migration
of the WebKitDOMNode test, all other GObject DOM bindings tests
will be migrated in the same way in follow up patches.

  • UIProcess/API/gtk/tests/DOMNodeTest.cpp: Added.

(WebKitDOMNodeTest::create): Create a new WebKitDOMNodeTest.
(WebKitDOMNodeTest::webPageFromArgs): Get the pageID parameter
from the arguments dictionary.
(WebKitDOMNodeTest::testHierarchyNavigation):
(WebKitDOMNodeTest::testInsertion):
(WebKitDOMNodeTest::runTest): Run the given test.
(registerTests): Register test cases.

  • UIProcess/API/gtk/tests/GNUmakefile.am: Add new files to

compilation.

  • UIProcess/API/gtk/tests/TestDOMNode.cpp: Added.

(testWebKitDOMNodeHierarchyNavigation):
(testWebKitDOMNodeInsertion):
(beforeAll):
(afterAll):

  • UIProcess/API/gtk/tests/TestMain.cpp:

(main): Unset DBUS_SESSION_BUS_ADDRESS environment variable to
make sure that the GLib bus singleton is initialized by the
private DBus session bus created by the tests.

  • UIProcess/API/gtk/tests/WebProcessTest.cpp: Added.

(testsMap): Initialize and get the global map of tests.
(WebProcessTest::add): Add a new test to the map, keeping a
function to create the test.
(WebProcessTest::create): Create a test for the given name.
(methodCallCallback): Handle RunTest DBus method. It creates and
runs the given test.
(webkit_web_extension_initialize):Register the DBus service for
this WebExtension.

  • UIProcess/API/gtk/tests/WebProcessTest.h: Added.
  • UIProcess/API/gtk/tests/WebProcessTestRunner.cpp: Added.

(WebProcessTestRunner::WebProcessTestRunner): Start a private DBus
session bus and get a connection to it.
(WebProcessTestRunner::~WebProcessTestRunner): Stop the private
DBus session bus.
(WebProcessTestRunner::proxyCreatedCallback):
(WebProcessTestRunner::proxy): Create a new proxy to send messages
to the WebExtension if it doesn't exists.
(WebProcessTestRunner::onNameAppeared): Called when the DBus
service has been registered in the WebExtension and it's safe to
create a proxy.
(WebProcessTestRunner::onNameVanished): Called when the DBus
service is unregistered. This happens when the web process crash,
so we just exit here, because the g_asserts in the web process
have already registered the error message.
(WebProcessTestRunner::testFinishedCallback): Called when the
WebProcess tests has finished.
(WebProcessTestRunner::runTest): Send a message to the
WebExtension to start the given test and monitor the service.
(WebProcessTestRunner::finishTest): Save the test result and
finish the main loop.

  • UIProcess/API/gtk/tests/WebProcessTestRunner.h: Added.
Location:
trunk/Source/WebKit2
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r153145 r153327  
     12013-07-25  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add support for running unit tests in the web process
     4        https://bugs.webkit.org/show_bug.cgi?id=118427
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Some tests, like GObject DOM bindings API tests, run entirely in
     9        the WebProcess, so we just need to start the test from the UI
     10        process and wait until the test finishes running in the
     11        WebProcess. Tests are split in two files, one containing the
     12        actual test that runs in the WebProcess and another one to add the
     13        tests to the glib test system that works as a
     14        proxy. WebProcessTestRunner class starts a private DBus session
     15        bus and starts the tests sending a message to the WebExtension
     16        waiting until it finishes or fails. WebProcess tests are created
     17        by defining a class derived from WebProcessTest class and
     18        implementing the static create method and the virtual runTest
     19        method. The macro REGISTER_TEST is used by the web process tests
     20        to register their test cases. This patch includes the migration
     21        of the WebKitDOMNode test, all other GObject DOM bindings tests
     22        will be migrated in the same way in follow up patches.
     23
     24        * UIProcess/API/gtk/tests/DOMNodeTest.cpp: Added.
     25        (WebKitDOMNodeTest::create): Create a new WebKitDOMNodeTest.
     26        (WebKitDOMNodeTest::webPageFromArgs): Get the pageID parameter
     27        from the arguments dictionary.
     28        (WebKitDOMNodeTest::testHierarchyNavigation):
     29        (WebKitDOMNodeTest::testInsertion):
     30        (WebKitDOMNodeTest::runTest): Run the given test.
     31        (registerTests): Register test cases.
     32        * UIProcess/API/gtk/tests/GNUmakefile.am: Add new files to
     33        compilation.
     34        * UIProcess/API/gtk/tests/TestDOMNode.cpp: Added.
     35        (testWebKitDOMNodeHierarchyNavigation):
     36        (testWebKitDOMNodeInsertion):
     37        (beforeAll):
     38        (afterAll):
     39        * UIProcess/API/gtk/tests/TestMain.cpp:
     40        (main): Unset DBUS_SESSION_BUS_ADDRESS environment variable to
     41        make sure that the GLib bus singleton is initialized by the
     42        private DBus session bus created by the tests.
     43        * UIProcess/API/gtk/tests/WebProcessTest.cpp: Added.
     44        (testsMap): Initialize and get the global map of tests.
     45        (WebProcessTest::add): Add a new test to the map, keeping a
     46        function to create the test.
     47        (WebProcessTest::create): Create a test for the given name.
     48        (methodCallCallback): Handle RunTest DBus method. It creates and
     49        runs the given test.
     50        (webkit_web_extension_initialize):Register the DBus service for
     51        this WebExtension.
     52        * UIProcess/API/gtk/tests/WebProcessTest.h: Added.
     53        * UIProcess/API/gtk/tests/WebProcessTestRunner.cpp: Added.
     54        (WebProcessTestRunner::WebProcessTestRunner): Start a private DBus
     55        session bus and get a connection to it.
     56        (WebProcessTestRunner::~WebProcessTestRunner): Stop the private
     57        DBus session bus.
     58        (WebProcessTestRunner::proxyCreatedCallback):
     59        (WebProcessTestRunner::proxy): Create a new proxy to send messages
     60        to the WebExtension if it doesn't exists.
     61        (WebProcessTestRunner::onNameAppeared): Called when the DBus
     62        service has been registered in the WebExtension and it's safe to
     63        create a proxy.
     64        (WebProcessTestRunner::onNameVanished): Called when the DBus
     65        service is unregistered. This happens when the web process crash,
     66        so we just exit here, because the g_asserts in the web process
     67        have already registered the error message.
     68        (WebProcessTestRunner::testFinishedCallback): Called when the
     69        WebProcess tests has finished.
     70        (WebProcessTestRunner::runTest): Send a message to the
     71        WebExtension to start the given test and monitor the service.
     72        (WebProcessTestRunner::finishTest): Save the test result and
     73        finish the main loop.
     74        * UIProcess/API/gtk/tests/WebProcessTestRunner.h: Added.
     75
    1762013-05-05  Geoffrey Garen  <ggaren@apple.com>
    277
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am

    r153085 r153327  
    66        Programs/WebKit2APITests/TestContextMenu \
    77        Programs/WebKit2APITests/TestCookieManager \
     8        Programs/WebKit2APITests/TestDOMNode \
    89        Programs/WebKit2APITests/TestDownloads \
    910        Programs/WebKit2APITests/TestInspector \
     
    9192        Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \
    9293        Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h \
     94        Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.cpp \
     95        Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.h \
    9396        Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \
    9497        Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h \
     
    119122Libraries_WebExtensions_libWebExtensionTest_la_CFLAGS = \
    120123        $(global_cflags)
     124
     125
     126noinst_LTLIBRARIES += Libraries/WebExtensions/libWebProcessTest.la
     127Libraries_WebExtensions_libWebProcessTest_la_SOURCES = \
     128        Source/WebKit2/UIProcess/API/gtk/tests/DOMNodeTest.cpp \
     129        Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.cpp \
     130        Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.h
     131
     132Libraries_WebExtensions_libWebProcessTest_la_LDFLAGS = \
     133        -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \
     134        $(no_undefined) \
     135        -avoid-version \
     136        -module
     137
     138Libraries_WebExtensions_libWebProcessTest_la_CPPFLAGS = \
     139        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \
     140        -I$(top_builddir)/DerivedSources \
     141        -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \
     142        -DWEBKIT2_COMPILATION \
     143        $(webkit2_tests_cppflags)
     144
     145Libraries_WebExtensions_libWebProcessTest_la_CXXFLAGS = \
     146        $(global_cxxflags)
     147
     148Libraries_WebExtensions_libWebProcessTest_la_CFLAGS = \
     149        $(global_cflags)
    121150
    122151
     
    269298Programs_WebKit2APITests_TestWebKitWebViewGroup_LDFLAGS = $(webkit2_tests_ldflags)
    270299
     300Programs_WebKit2APITests_TestDOMNode_SOURCES = \
     301        Source/WebKit2/UIProcess/API/gtk/tests/TestDOMNode.cpp
     302Programs_WebKit2APITests_TestDOMNode_CPPFLAGS = $(webkit2_tests_cppflags)
     303Programs_WebKit2APITests_TestDOMNode_LDADD = $(webkit2_tests_ldadd)
     304Programs_WebKit2APITests_TestDOMNode_LDFLAGS = $(webkit2_tests_ldflags)
     305
    271306endif # ENABLE_WEBKIT2
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp

    r148887 r153327  
    5454int main(int argc, char** argv)
    5555{
     56    g_unsetenv("DBUS_SESSION_BUS_ADDRESS");
    5657    gtk_test_init(&argc, &argv, 0);
    5758    g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
Note: See TracChangeset for help on using the changeset viewer.