[Qt][WK2] New API tests introduced in r121620 fail
authornoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 19:12:23 +0000 (19:12 +0000)
committernoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 19:12:23 +0000 (19:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90372

Reviewed by Luiz Agostini.

Updated the pixel comparison to produce more predictable results.

* UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp:
(compareImages):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121698 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp

index 07cb39a..b1ea874 100644 (file)
@@ -1,3 +1,15 @@
+2012-07-02  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
+        [Qt][WK2] New API tests introduced in r121620 fail
+        https://bugs.webkit.org/show_bug.cgi?id=90372
+
+        Reviewed by Luiz Agostini.
+
+        Updated the pixel comparison to produce more predictable results.
+
+        * UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp:
+        (compareImages):
+
 2012-07-02  Alexis Menard  <alexis.menard@openbossa.org>
 
         [Qt] Fix WebProcess crash on Mac when accessing a site with video tag.
index ae015e3..9f68881 100644 (file)
@@ -119,26 +119,19 @@ void WebView::finishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef use
     obj->m_frameLoaded = true;
 }
 
-static bool compareImages(const QImage& i1, const QImage& i2, const QPoint& p1, const QPoint& p2, int iter)
-{
-    const QPoint point((p1.x() + p2.x()) >> 1, (p1.y() + p2.y()) >> 1);
-
-    if (i1.pixel(point) != i2.pixel(point))
-        return false;
-
-    if (!iter)
-        return true;
-
-    --iter;
-    return compareImages(i1, i2, point, p1, iter) && compareImages(i1, i2, point, p2, iter)
-        && compareImages(i1, i2, point, QPoint(p1.x(), p2.y()), iter) && compareImages(i1, i2, point, QPoint(p2.x(), p1.y()), iter);
-}
-
-static bool compareImages(const QImage& i1, const QImage& i2, int iter)
+static bool compareImages(const QImage& i1, const QImage& i2, int count)
 {
     if (i1.size() != i2.size())
         return false;
-    return compareImages(i1, i2, QPoint(0, 0), QPoint(i1.size().width(), i1.size().height()), iter);
+    for (int x = 0; x < count; ++x) {
+        for (int y = 0; y < count; ++y) {
+            QPoint point(x * i1.width() / count, y * i1.height() / count);
+            if (i1.pixel(point) != i2.pixel(point))
+                return false;
+        }
+    }
+
+    return true;
 }
 
 class tst_qrawwebview : public QObject {