diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp index 7e7eb0167..e6c843456 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp @@ -30,6 +30,7 @@ WebViewTest::WebViewTest() , m_parentWindow(0) , m_javascriptResult(0) , m_resourceDataSize(0) + , m_surface(0) { assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView)); } @@ -40,6 +41,8 @@ WebViewTest::~WebViewTest() gtk_widget_destroy(m_parentWindow); if (m_javascriptResult) webkit_javascript_result_unref(m_javascriptResult); + if (m_surface) + cairo_surface_destroy(m_surface); g_object_unref(m_webView); g_main_loop_unref(m_mainLoop); } @@ -175,6 +178,15 @@ static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* te return FALSE; } +void WebViewTest::showInWindow(GtkWindowType windowType) +{ + g_assert(!m_parentWindow); + m_parentWindow = gtk_window_new(windowType); + gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); + gtk_widget_show(GTK_WIDGET(m_webView)); + gtk_widget_show(m_parentWindow); +} + void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType) { g_assert(!m_parentWindow); @@ -198,6 +210,11 @@ void WebViewTest::resizeView(int width, int height) gtk_widget_size_allocate(GTK_WIDGET(m_webView), &allocation); } +void WebViewTest::selectAll() +{ + webkit_web_view_execute_editing_command(m_webView, "SelectAll"); +} + static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData) { size_t dataSize; @@ -406,3 +423,22 @@ bool WebViewTest::javascriptResultIsUndefined(WebKitJavascriptResult* javascript return JSValueIsUndefined(context, value); } +static void onSnapshotReady(WebKitWebView* web_view, GAsyncResult* res, WebViewTest* test) +{ + GOwnPtr<GError> error; + test->m_surface = webkit_web_view_get_snapshot_finish(web_view, res, &error.outPtr()); + g_assert(!test->m_surface || !error.get()); + if (error) + g_assert_error(error.get(), WEBKIT_SNAPSHOT_ERROR, WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE); + test->quitMainLoop(); +} + +cairo_surface_t* WebViewTest::getSnapshotAndWaitUntilReady(WebKitSnapshotRegion region, WebKitSnapshotOptions options) +{ + if (m_surface) + cairo_surface_destroy(m_surface); + m_surface = 0; + webkit_web_view_get_snapshot(m_webView, region, options, 0, reinterpret_cast<GAsyncReadyCallback>(onSnapshotReady), this); + g_main_loop_run(m_mainLoop); + return m_surface; +} |