Changeset 153327 in webkit
- Timestamp:
- Jul 25, 2013, 9:13:30 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r153145 r153327 1 2013-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 1 76 2013-05-05 Geoffrey Garen <ggaren@apple.com> 2 77 -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
r153085 r153327 6 6 Programs/WebKit2APITests/TestContextMenu \ 7 7 Programs/WebKit2APITests/TestCookieManager \ 8 Programs/WebKit2APITests/TestDOMNode \ 8 9 Programs/WebKit2APITests/TestDownloads \ 9 10 Programs/WebKit2APITests/TestInspector \ … … 91 92 Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \ 92 93 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 \ 93 96 Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \ 94 97 Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h \ … … 119 122 Libraries_WebExtensions_libWebExtensionTest_la_CFLAGS = \ 120 123 $(global_cflags) 124 125 126 noinst_LTLIBRARIES += Libraries/WebExtensions/libWebProcessTest.la 127 Libraries_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 132 Libraries_WebExtensions_libWebProcessTest_la_LDFLAGS = \ 133 -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \ 134 $(no_undefined) \ 135 -avoid-version \ 136 -module 137 138 Libraries_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 145 Libraries_WebExtensions_libWebProcessTest_la_CXXFLAGS = \ 146 $(global_cxxflags) 147 148 Libraries_WebExtensions_libWebProcessTest_la_CFLAGS = \ 149 $(global_cflags) 121 150 122 151 … … 269 298 Programs_WebKit2APITests_TestWebKitWebViewGroup_LDFLAGS = $(webkit2_tests_ldflags) 270 299 300 Programs_WebKit2APITests_TestDOMNode_SOURCES = \ 301 Source/WebKit2/UIProcess/API/gtk/tests/TestDOMNode.cpp 302 Programs_WebKit2APITests_TestDOMNode_CPPFLAGS = $(webkit2_tests_cppflags) 303 Programs_WebKit2APITests_TestDOMNode_LDADD = $(webkit2_tests_ldadd) 304 Programs_WebKit2APITests_TestDOMNode_LDFLAGS = $(webkit2_tests_ldflags) 305 271 306 endif # ENABLE_WEBKIT2 -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp
r148887 r153327 54 54 int main(int argc, char** argv) 55 55 { 56 g_unsetenv("DBUS_SESSION_BUS_ADDRESS"); 56 57 gtk_test_init(&argc, &argv, 0); 57 58 g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.