Diff
Modified: trunk/Source/WebKit2/ChangeLog (94523 => 94524)
--- trunk/Source/WebKit2/ChangeLog 2011-09-05 10:50:51 UTC (rev 94523)
+++ trunk/Source/WebKit2/ChangeLog 2011-09-05 10:53:32 UTC (rev 94524)
@@ -1,3 +1,18 @@
+2011-09-05 Balazs Kelemen <[email protected]>
+
+ [Qt][WK2] Add pixel test support
+ https://bugs.webkit.org/show_bug.cgi?id=66283
+
+ Reviewed by Andreas Kling.
+
+ * Shared/API/c/qt/WKImageQt.cpp: Added.
+ (WKImageCreateQImage): C style (private) API to get the contents of the backing
+ store as an image.
+ * Shared/API/c/qt/WKImageQt.h: Added.
+ * Shared/qt/ShareableBitmapQt.cpp:
+ (WebKit::ShareableBitmap::createImage): Typo. Remove useless ifdef.
+ * WebKit2API.pri:
+
2011-09-05 Andras Becsi <[email protected]>
[Qt][WK2] Fix the build
Added: trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp (0 => 94524)
--- trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp (rev 0)
+++ trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp 2011-09-05 10:53:32 UTC (rev 94524)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 University of Szeged. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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 program 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 program; 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 "WKImageQt.h"
+
+#include "ShareableBitmap.h"
+#include "WKSharedAPICast.h"
+#include "WebImage.h"
+
+using namespace WebKit;
+
+QImage WKImageCreateQImage(WKImageRef imageRef)
+{
+ return toImpl(imageRef)->bitmap()->createQImage().copy();
+}
Added: trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.h (0 => 94524)
--- trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.h (rev 0)
+++ trunk/Source/WebKit2/Shared/API/c/qt/WKImageQt.h 2011-09-05 10:53:32 UTC (rev 94524)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 University of Szeged. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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 program 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 program; 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 WKImageQt_h
+#define WKImageQt_h
+
+#include <QImage>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKImage.h>
+
+WK_EXPORT QImage WKImageCreateQImage(WKImageRef image);
+
+#endif
Modified: trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp (94523 => 94524)
--- trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp 2011-09-05 10:50:51 UTC (rev 94523)
+++ trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp 2011-09-05 10:53:32 UTC (rev 94524)
@@ -42,13 +42,11 @@
m_flags & SupportsAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
}
-#if PLATFORM(QT)
PassRefPtr<Image> ShareableBitmap::createImage()
{
QPixmap* pixmap = new QPixmap(QPixmap::fromImage(createQImage()));
return BitmapImage::create(pixmap);
}
-#endif
PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext()
{
Modified: trunk/Source/WebKit2/WebKit2API.pri (94523 => 94524)
--- trunk/Source/WebKit2/WebKit2API.pri 2011-09-05 10:50:51 UTC (rev 94523)
+++ trunk/Source/WebKit2/WebKit2API.pri 2011-09-05 10:53:32 UTC (rev 94524)
@@ -19,6 +19,7 @@
$$SOURCE_DIR/WebKit2/Shared/API/c/WKURLRequest.cpp \
$$SOURCE_DIR/WebKit2/Shared/API/c/WKURLResponse.cpp \
$$SOURCE_DIR/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp \
+ $$SOURCE_DIR/WebKit2/Shared/API/c/qt/WKImageQt.cpp \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKBackForwardList.cpp \
@@ -89,6 +90,7 @@
$$SOURCE_DIR/WebKit2/Shared/API/c/WKURLRequest.h \
$$SOURCE_DIR/WebKit2/Shared/API/c/WKURLResponse.h \
$$SOURCE_DIR/WebKit2/Shared/API/c/WKUserContentURLPattern.h \
+ $$SOURCE_DIR/WebKit2/Shared/API/c/qt/WKImageQt.h \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKAPICast.h \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h \
$$SOURCE_DIR/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h \
Modified: trunk/Tools/ChangeLog (94523 => 94524)
--- trunk/Tools/ChangeLog 2011-09-05 10:50:51 UTC (rev 94523)
+++ trunk/Tools/ChangeLog 2011-09-05 10:53:32 UTC (rev 94524)
@@ -1,3 +1,16 @@
+2011-09-05 Balazs Kelemen <[email protected]>
+
+ [Qt][WK2] Add pixel test support
+ https://bugs.webkit.org/show_bug.cgi?id=66283
+
+ Reviewed by Andreas Kling.
+
+ Implemented pixel result generation by reusing the logic
+ that we have in DumpRenderTree.
+ * WebKitTestRunner/qt/TestInvocationQt.cpp:
+ (WTR::dumpImage):
+ (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+
2011-09-04 Robin Dunn <[email protected]>
[wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than GTK.
Modified: trunk/Tools/WebKitTestRunner/qt/TestInvocationQt.cpp (94523 => 94524)
--- trunk/Tools/WebKitTestRunner/qt/TestInvocationQt.cpp 2011-09-05 10:50:51 UTC (rev 94523)
+++ trunk/Tools/WebKitTestRunner/qt/TestInvocationQt.cpp 2011-09-05 10:53:32 UTC (rev 94524)
@@ -26,10 +26,52 @@
#include "config.h"
#include "TestInvocation.h"
+#include <QBuffer>
+#include <QCryptographicHash>
+#include <WebKit2/WKImageQt.h>
+#include <stdio.h>
+
namespace WTR {
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef)
+static void dumpImage(const QImage& image)
{
+ QBuffer buffer;
+ buffer.open(QBuffer::WriteOnly);
+ image.save(&buffer, "PNG");
+ buffer.close();
+ const QByteArray& data = ""
+
+ printf("Content-Type: %s\n", "image/png");
+ printf("Content-Length: %lu\n", static_cast<unsigned long>(data.length()));
+
+ const quint32 bytesToWriteInOneChunk = 1 << 15;
+ quint32 dataRemainingToWrite = data.length();
+ const char* ptr = data.data();
+ while (dataRemainingToWrite) {
+ quint32 bytesToWriteInThisChunk = qMin(dataRemainingToWrite, bytesToWriteInOneChunk);
+ quint32 bytesWritten = fwrite(ptr, 1, bytesToWriteInThisChunk, stdout);
+ if (bytesWritten != bytesToWriteInThisChunk)
+ break;
+ dataRemainingToWrite -= bytesWritten;
+ ptr += bytesWritten;
+ }
+
+ fflush(stdout);
}
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef imageRef)
+{
+ QImage image = WKImageCreateQImage(imageRef);
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ for (unsigned row = 0; row < image.height(); ++row)
+ hash.addData(reinterpret_cast<const char*>(image.constScanLine(row)), image.width() * image.bytesPerLine());
+
+ QByteArray actualHash = hash.result().toHex();
+ ASSERT(actualHash.size() == 32);
+ if (!compareActualHashToExpectedAndDumpResults(actualHash)) {
+ image.setText("checksum", actualHash);
+ dumpImage(image);
+ }
+}
+
} // namespace WTR