Diff
Modified: trunk/Source/WebKit2/ChangeLog (97365 => 97366)
--- trunk/Source/WebKit2/ChangeLog 2011-10-13 14:31:38 UTC (rev 97365)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-13 15:28:38 UTC (rev 97366)
@@ -1,3 +1,32 @@
+2011-10-13 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Add WebKitTestServer class to WebKit2 GTK+ unit tests library
+ https://bugs.webkit.org/show_bug.cgi?id=70010
+
+ Reviewed by Martin Robinson.
+
+ With this class tests using a soup server only need to implement
+ the soup server callback.
+
+ * UIProcess/API/gtk/tests/GNUmakefile.am: Add new files to compilation.
+ * UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp: Use WebKitTestServer.
+ (testLoadingStatus):
+ (testLoadingError):
+ (testLoadAlternateContent):
+ (testWebViewReload):
+ (testLoadProgress):
+ (beforeAll):
+ (afterAll):
+ * UIProcess/API/gtk/tests/WebKitTestServer.cpp: Added.
+ (WebKitTestServer::WebKitTestServer):
+ (WebKitTestServer::~WebKitTestServer):
+ (WebKitTestServer::run): Run the soup server and adds the given
+ soup server callback to handle requests.
+ (WebKitTestServer::getURIForPath): Returns the server absolute URI
+ for the given relative path.
+ * UIProcess/API/gtk/tests/WebKitTestServer.h: Added.
+ (WebKitTestServer::baseURI):
+
2011-10-13 Nayan Kumar K <naya...@motorola.com>
[WebKit2][gtk] Fix warnings while generating WebKit2-GTK+ documentation.
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am (97365 => 97366)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am 2011-10-13 14:31:38 UTC (rev 97365)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am 2011-10-13 15:28:38 UTC (rev 97366)
@@ -36,6 +36,8 @@
Libraries_libWebKit2APITestCore_la_SOURCES = \
Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp \
Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h \
Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \
Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h \
Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp \
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp (97365 => 97366)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-10-13 14:31:38 UTC (rev 97365)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-10-13 15:28:38 UTC (rev 97366)
@@ -21,24 +21,16 @@
#include "config.h"
#include "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
#include <gtk/gtk.h>
#include <libsoup/soup.h>
#include <wtf/text/CString.h>
-static SoupURI* kBaseURI = 0;
-static SoupServer* kSoupServer = 0;
+static WebKitTestServer* kServer;
-static CString getURIForPath(const char* path)
-{
- SoupURI* uri = soup_uri_new_with_base(kBaseURI, path);
- GOwnPtr<gchar> uriString(soup_uri_to_string(uri, FALSE));
- soup_uri_free(uri);
- return uriString.get();
-}
-
static void testLoadingStatus(LoadTrackingTest* test, gconstpointer data)
{
- webkit_web_view_load_uri(test->m_webView, getURIForPath("/redirect").data());
+ webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath("/redirect").data());
test->waitUntilLoadFinished();
Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
@@ -51,7 +43,7 @@
static void testLoadingError(LoadTrackingTest* test, gconstpointer)
{
- webkit_web_view_load_uri(test->m_webView, getURIForPath("/error").data());
+ webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath("/error").data());
test->waitUntilLoadFinished();
Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
@@ -73,7 +65,7 @@
{
webkit_web_view_load_alternate_html(test->m_webView,
"<html><body>Alternate Content</body></html>",
- 0, getURIForPath("/alternate").data());
+ 0, kServer->getURIForPath("/alternate").data());
test->waitUntilLoadFinished();
assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
}
@@ -84,7 +76,7 @@
webkit_web_view_reload(test->m_webView);
test->wait(0.25); // Wait for a quarter of a second.
- webkit_web_view_load_uri(test->m_webView, getURIForPath("/normal").data());
+ webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath("/normal").data());
test->waitUntilLoadFinished();
assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
@@ -95,7 +87,7 @@
static void testLoadProgress(LoadTrackingTest* test, gconstpointer)
{
- webkit_web_view_load_uri(test->m_webView, getURIForPath("/normal").data());
+ webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath("/normal").data());
test->waitUntilLoadFinished();
g_assert_cmpfloat(test->m_estimatedProgress, ==, 1);
}
@@ -132,13 +124,9 @@
void beforeAll()
{
- kBaseURI = soup_uri_new("http://127.0.0.1/");
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
- kSoupServer = soup_server_new(SOUP_SERVER_PORT, 0, NULL);
- soup_uri_set_port(kBaseURI, soup_server_get_port(kSoupServer));
- soup_server_run_async(kSoupServer);
- soup_server_add_handler(kSoupServer, 0, serverCallback, 0, 0);
-
LoadTrackingTest::add("WebKitWebLoaderClient", "loading-status", testLoadingStatus);
LoadTrackingTest::add("WebKitWebLoaderClient", "loading-error", testLoadingError);
LoadTrackingTest::add("WebKitWebLoaderClient", "load-alternate-content", testLoadAlternateContent);
@@ -148,4 +136,5 @@
void afterAll()
{
+ delete kServer;
}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp (0 => 97366)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp 2011-10-13 15:28:38 UTC (rev 97366)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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 "config.h"
+#include "WebKitTestServer.h"
+
+#include <wtf/gobject/GOwnPtr.h>
+
+WebKitTestServer::WebKitTestServer()
+ : m_soupServer(adoptGRef(soup_server_new(SOUP_SERVER_PORT, 0, NULL)))
+ , m_baseURI(soup_uri_new("http://127.0.0.1/"))
+{
+ soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer.get()));
+}
+
+WebKitTestServer::~WebKitTestServer()
+{
+ soup_uri_free(m_baseURI);
+}
+
+void WebKitTestServer::run(SoupServerCallback serverCallback)
+{
+ soup_server_run_async(m_soupServer.get());
+ soup_server_add_handler(m_soupServer.get(), 0, serverCallback, 0, 0);
+}
+
+CString WebKitTestServer::getURIForPath(const char* path)
+{
+ SoupURI* uri = soup_uri_new_with_base(m_baseURI, path);
+ GOwnPtr<gchar> uriString(soup_uri_to_string(uri, FALSE));
+ soup_uri_free(uri);
+ return uriString.get();
+}
+
Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h (0 => 97366)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h 2011-10-13 15:28:38 UTC (rev 97366)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitTestServer_h
+#define WebKitTestServer_h
+
+#include <libsoup/soup.h>
+#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+class WebKitTestServer {
+public:
+ WebKitTestServer();
+ virtual ~WebKitTestServer();
+
+ SoupURI* baseURI() { return m_baseURI; }
+
+ CString getURIForPath(const char* path);
+ void run(SoupServerCallback);
+
+private:
+ GRefPtr<SoupServer> m_soupServer;
+ SoupURI* m_baseURI;
+};
+
+#endif // WebKitTestServer_h