Title: [208284] trunk/Tools
Revision
208284
Author
[email protected]
Date
2016-11-02 09:30:30 -0700 (Wed, 02 Nov 2016)

Log Message

[GTK] Use GTestDBus instead of dbus-launch in WebKitTestBus.cpp
https://bugs.webkit.org/show_bug.cgi?id=161481

Reviewed by Michael Catanzaro.

* TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp:
(WebKitTestBus::WebKitTestBus):
(WebKitTestBus::~WebKitTestBus):
(WebKitTestBus::run):
(WebKitTestBus::getOrCreateConnection):
(WebKitTestBus::createProxy):
* TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (208283 => 208284)


--- trunk/Tools/ChangeLog	2016-11-02 16:21:04 UTC (rev 208283)
+++ trunk/Tools/ChangeLog	2016-11-02 16:30:30 UTC (rev 208284)
@@ -1,5 +1,20 @@
 2016-11-02  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Use GTestDBus instead of dbus-launch in WebKitTestBus.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=161481
+
+        Reviewed by Michael Catanzaro.
+
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp:
+        (WebKitTestBus::WebKitTestBus):
+        (WebKitTestBus::~WebKitTestBus):
+        (WebKitTestBus::run):
+        (WebKitTestBus::getOrCreateConnection):
+        (WebKitTestBus::createProxy):
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h:
+
+2016-11-02  Carlos Garcia Campos  <[email protected]>
+
         Unreviewed. Fix /webkit2/WebKitWebContext/get-plugins in the bots after r208273.
 
         The test fails now if WEBKIT_TEST_PLUGIN_DIR contains symlinks, which is the case of the GTK+ bots.

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp (208283 => 208284)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp	2016-11-02 16:21:04 UTC (rev 208283)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp	2016-11-02 16:30:30 UTC (rev 208284)
@@ -20,53 +20,23 @@
 #include "config.h"
 #include "WebKitTestBus.h"
 
-#include <wtf/glib/GUniquePtr.h>
-#include <wtf/text/WTFString.h>
-
 WebKitTestBus::WebKitTestBus()
-    : m_pid(-1)
+    : m_bus(adoptGRef(g_test_dbus_new(G_TEST_DBUS_NONE)))
 {
 }
 
-bool WebKitTestBus::run()
+WebKitTestBus::~WebKitTestBus()
 {
-    // FIXME: Use GTestDBus when we bump glib to 2.34.
-    GUniquePtr<char> dbusLaunch(g_find_program_in_path("dbus-launch"));
-    if (!dbusLaunch) {
-        g_warning("Error starting DBUS daemon: dbus-launch not found in path");
-        return false;
-    }
-
-    GUniqueOutPtr<char> output;
-    GUniqueOutPtr<GError> error;
-    if (!g_spawn_command_line_sync(dbusLaunch.get(), &output.outPtr(), 0, 0, &error.outPtr())) {
-        g_warning("Error starting DBUS daemon: %s", error->message);
-        return false;
-    }
-
-    String outputString = String::fromUTF8(output.get());
-    Vector<String> lines;
-    outputString.split(UChar('\n'), /* allowEmptyEntries */ false, lines);
-    for (size_t i = 0; i < lines.size(); ++i) {
-        char** keyValue = g_strsplit(lines[i].utf8().data(), "=", 2);
-        g_assert_cmpuint(g_strv_length(keyValue), ==, 2);
-        if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_ADDRESS")) {
-            m_address = keyValue[1];
-            g_setenv("DBUS_SESSION_BUS_ADDRESS", keyValue[1], TRUE);
-        } else if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_PID"))
-            m_pid = g_ascii_strtoll(keyValue[1], 0, 10);
-        g_strfreev(keyValue);
-    }
-
-    return m_pid > 0;
+    g_test_dbus_down(m_bus.get());
 }
 
-WebKitTestBus::~WebKitTestBus()
+bool WebKitTestBus::run()
 {
-    g_unsetenv("DBUS_SESSION_BUS_ADDRESS");
-
-    if (m_pid != -1)
-        kill(m_pid, SIGTERM);
+    CString display = g_getenv("DISPLAY");
+    g_test_dbus_up(m_bus.get());
+    m_address = g_test_dbus_get_bus_address(m_bus.get());
+    g_setenv("DISPLAY", display.data(), FALSE);
+    return !m_address.isNull();
 }
 
 GDBusConnection* WebKitTestBus::getOrCreateConnection()
@@ -77,7 +47,8 @@
     g_assert(!m_address.isNull());
     m_connection = adoptGRef(g_dbus_connection_new_for_address_sync(m_address.data(),
         static_cast<GDBusConnectionFlags>(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
-        0, 0, 0));
+        nullptr, nullptr, nullptr));
+    g_assert(m_connection.get());
     return m_connection.get();
 }
 
@@ -88,7 +59,7 @@
 
 GDBusProxy* WebKitTestBus::createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop* mainLoop)
 {
-    unsigned watcherID = g_bus_watch_name_on_connection(getOrCreateConnection(), serviceName, G_BUS_NAME_WATCHER_FLAGS_NONE, onNameAppeared, 0, mainLoop, 0);
+    unsigned watcherID = g_bus_watch_name_on_connection(getOrCreateConnection(), serviceName, G_BUS_NAME_WATCHER_FLAGS_NONE, onNameAppeared, nullptr, mainLoop, nullptr);
     g_main_loop_run(mainLoop);
     g_bus_unwatch_name(watcherID);
 
@@ -95,12 +66,12 @@
     GDBusProxy* proxy = g_dbus_proxy_new_sync(
         connection(),
         G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
-        0, // GDBusInterfaceInfo
+        nullptr, // GDBusInterfaceInfo
         serviceName,
         objectPath,
         interfaceName,
-        0, // GCancellable
-        0);
+        nullptr, // GCancellable
+        nullptr);
     g_assert(proxy);
     return proxy;
 }

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h (208283 => 208284)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h	2016-11-02 16:21:04 UTC (rev 208283)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h	2016-11-02 16:30:30 UTC (rev 208284)
@@ -27,7 +27,7 @@
 class WebKitTestBus {
 public:
     WebKitTestBus();
-    virtual ~WebKitTestBus();
+    ~WebKitTestBus();
 
     bool run();
     GDBusProxy* createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop*);
@@ -36,7 +36,7 @@
 private:
     GDBusConnection* getOrCreateConnection();
 
-    pid_t m_pid;
+    GRefPtr<GTestDBus> m_bus;
     CString m_address;
     GRefPtr<GDBusConnection> m_connection;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to