<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[178644] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/178644">178644</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-01-19 05:33:58 -0800 (Mon, 19 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] [WK2] TestWebKitWebView snapshot fails
https://bugs.webkit.org/show_bug.cgi?id=120404

Reviewed by Žan Doberšek.

Rework the test to make sure the snapshot is always created at the
desired size.

* Scripts/run-gtk-tests:
(TestRunner): Unskip /webkit2/WebKitWebView/snapshot.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
(testWebViewSnapshot): Use a fixed size for the document, and
disable scrollbars to make sure the visible area is always the
WebView size.
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
(WebViewTest::showInWindowAndWaitUntilMapped): Add optional width
and height parameters to create the window with a given size.
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrungtktests">trunk/Tools/Scripts/run-gtk-tests</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTesth">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (178643 => 178644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/ChangeLog        2015-01-19 13:33:58 UTC (rev 178644)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-01-19  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] [WK2] TestWebKitWebView snapshot fails
+        https://bugs.webkit.org/show_bug.cgi?id=120404
+
+        Reviewed by Žan Doberšek.
+
+        Rework the test to make sure the snapshot is always created at the
+        desired size.
+
+        * Scripts/run-gtk-tests:
+        (TestRunner): Unskip /webkit2/WebKitWebView/snapshot.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+        (testWebViewSnapshot): Use a fixed size for the document, and
+        disable scrollbars to make sure the visible area is always the
+        WebView size.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+        (WebViewTest::showInWindowAndWaitUntilMapped): Add optional width
+        and height parameters to create the window with a given size.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:
+
</ins><span class="cx"> 2015-01-18  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         iOS EWS queue name should be consistent
</span></span></pre></div>
<a id="trunkToolsScriptsrungtktests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-gtk-tests (178643 => 178644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-gtk-tests        2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/Scripts/run-gtk-tests        2015-01-19 13:33:58 UTC (rev 178644)
</span><span class="lines">@@ -64,7 +64,6 @@
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestUIClient&quot;, &quot;/webkit2/WebKitWebView/mouse-target&quot;, &quot;Test times out after r150890&quot;, 117689),
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestContextMenu&quot;, SkippedTest.ENTIRE_SUITE, &quot;Test times out after r150890&quot;, 117689),
</span><span class="cx">         SkippedTest(&quot;WebKit2APITests/TestWebKitAccessibility&quot;, &quot;/webkit2/WebKitAccessibility/atspi-basic-hierarchy&quot;, &quot;Test is flaky&quot;, 132134),
</span><del>-        SkippedTest(&quot;WebKit2Gtk/TestWebKitWebView&quot;, &quot;/webkit2/WebKitWebView/snapshot&quot;, &quot;Test fails&quot;, 120404),
</del><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestWebKitWebView&quot;, &quot;/webkit2/WebKitWebView/page-visibility&quot;, &quot;Test fails or times out&quot;, 131731),
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestCookieManager&quot;, &quot;/webkit2/WebKitCookieManager/persistent-storage&quot;, &quot;Test is flaky&quot;, 134580),
</span><span class="cx">         SkippedTest(&quot;WebKit2/TestWebKit2&quot;, &quot;WebKit2.MouseMoveAfterCrash&quot;, &quot;Test is flaky&quot;, 85066),
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (178643 => 178644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp        2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp        2015-01-19 13:33:58 UTC (rev 178644)
</span><span class="lines">@@ -546,59 +546,44 @@
</span><span class="cx"> 
</span><span class="cx"> static void testWebViewSnapshot(SnapshotWebViewTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>-    test-&gt;loadHtml(&quot;&lt;html&gt;&lt;body&gt;&lt;p&gt;Whatever&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;, 0);
</del><ins>+    test-&gt;loadHtml(&quot;&lt;html&gt;&lt;head&gt;&lt;style&gt;html { width: 200px; height: 100px; } ::-webkit-scrollbar { display: none; }&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;Whatever&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;, nullptr);
</ins><span class="cx">     test-&gt;waitUntilLoadFinished();
</span><span class="cx"> 
</span><del>-    // WebView not visible.
</del><ins>+    // WEBKIT_SNAPSHOT_REGION_VISIBLE returns a null surface when the view is not visible.
</ins><span class="cx">     cairo_surface_t* surface1 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
</span><span class="cx">     g_assert(!surface1);
</span><span class="cx"> 
</span><del>-    // Show surface, resize to 50x50, try again.
-    test-&gt;showInWindowAndWaitUntilMapped();
-    test-&gt;resizeView(50, 50);
-    surface1 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
</del><ins>+    // WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT works even if the window is not visible.
+    surface1 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE);
</ins><span class="cx">     g_assert(surface1);
</span><ins>+    g_assert_cmpuint(cairo_surface_get_type(surface1), ==, CAIRO_SURFACE_TYPE_IMAGE);
+    g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, 200);
+    g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, 100);
</ins><span class="cx"> 
</span><del>-    // obtained surface should be at the most 50x50. Store the size
-    // for comparison later.
-    int width = cairo_image_surface_get_width(surface1);
-    int height = cairo_image_surface_get_height(surface1);
-    g_assert_cmpint(width, &lt;=, 50);
-    g_assert_cmpint(height, &lt;=, 50);
-
-    // Select all text in the WebView, request a snapshot ignoring selection.
-    test-&gt;selectAll();
</del><ins>+    // Show the WebView in a popup widow of 50x50 and try again with WEBKIT_SNAPSHOT_REGION_VISIBLE.
+    test-&gt;showInWindowAndWaitUntilMapped(GTK_WINDOW_POPUP, 50, 50);
</ins><span class="cx">     surface1 = cairo_surface_reference(test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE));
</span><span class="cx">     g_assert(surface1);
</span><del>-    g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, width);
-    g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, height);
</del><ins>+    g_assert_cmpuint(cairo_surface_get_type(surface1), ==, CAIRO_SURFACE_TYPE_IMAGE);
+    g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, 50);
+    g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, 50);
</ins><span class="cx"> 
</span><del>-    // Create identical surface.
</del><ins>+    // Select all text in the WebView, request a snapshot ignoring selection.
+    test-&gt;selectAll();
</ins><span class="cx">     cairo_surface_t* surface2 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
</span><span class="cx">     g_assert(surface2);
</span><del>-
-    // Compare these two, they should be identical.
</del><span class="cx">     g_assert(Test::cairoSurfacesEqual(surface1, surface2));
</span><span class="cx"> 
</span><del>-    // Request a new snapshot, including the selection this time. The
-    // size should be the same but the result must be different to the
-    // one previously obtained.
</del><ins>+    // Request a new snapshot, including the selection this time. The size should be the same but the result
+    // must be different to the one previously obtained.
</ins><span class="cx">     surface2 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING);
</span><del>-    g_assert(surface2);
-    g_assert_cmpint(cairo_image_surface_get_width(surface2), ==, width);
-    g_assert_cmpint(cairo_image_surface_get_height(surface2), ==, height);
</del><ins>+    g_assert_cmpuint(cairo_surface_get_type(surface2), ==, CAIRO_SURFACE_TYPE_IMAGE);
+    g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, cairo_image_surface_get_width(surface2));
+    g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, cairo_image_surface_get_height(surface2));
</ins><span class="cx">     g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
</span><del>-
-    // Request a snapshot of the whole document in the WebView. The
-    // result should be different from the size obtained previously.
-    surface2 = test-&gt;getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE);
-    g_assert(surface2);
-    g_assert_cmpint(cairo_image_surface_get_width(surface2),  &gt;, width);
-    g_assert_cmpint(cairo_image_surface_get_height(surface2), &gt;, height);
-    g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
-
</del><span class="cx">     cairo_surface_destroy(surface1);
</span><span class="cx"> 
</span><ins>+    // Test that cancellation works.
</ins><span class="cx">     g_assert(test-&gt;getSnapshotAndCancel());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (178643 => 178644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-01-19 13:33:58 UTC (rev 178644)
</span><span class="lines">@@ -232,10 +232,12 @@
</span><span class="cx">     gtk_widget_show(m_parentWindow);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType)
</del><ins>+void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType, int width, int height)
</ins><span class="cx"> {
</span><span class="cx">     g_assert(!m_parentWindow);
</span><span class="cx">     m_parentWindow = gtk_window_new(windowType);
</span><ins>+    if (width &amp;&amp; height)
+        gtk_window_resize(GTK_WINDOW(m_parentWindow), width, height);
</ins><span class="cx">     gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
</span><span class="cx">     gtk_widget_show(GTK_WIDGET(m_webView));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTesth"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h (178643 => 178644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h        2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h        2015-01-19 13:33:58 UTC (rev 178644)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     void waitUntilTitleChangedTo(const char* expectedTitle);
</span><span class="cx">     void waitUntilTitleChanged();
</span><span class="cx">     void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);
</span><del>-    void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP);
</del><ins>+    void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP, int width = 0, int height = 0);
</ins><span class="cx">     void resizeView(int width, int height);
</span><span class="cx">     void selectAll();
</span><span class="cx">     const char* mainResourceData(size_t&amp; mainResourceDataSize);
</span></span></pre>
</div>
</div>

</body>
</html>