summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp36
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;
+}