void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef imageRef, WKArrayRef repaintRects) { QImage image; if (PlatformWebView::windowShapshotEnabled()) { WKPageRef page = TestController::shared().mainWebView()->page(); WKPageForceRepaint(page, this, &forceRepaintDoneCallback); TestController::shared().runUntil(m_gotRepaint, TestController::ShortTimeout); if (m_gotRepaint) image = WKImageCreateQImage(TestController::shared().mainWebView()->windowSnapshotImage().get()); else { m_error = true; m_errorMessage = "Timed out waiting for repaint\n"; m_webProcessIsUnresponsive = true; return; } } else image = WKImageCreateQImage(imageRef); if (repaintRects) { QImage mask(image.size(), image.format()); mask.fill(QColor(0, 0, 0, 0.66 * 255)); QPainter maskPainter(&mask); maskPainter.setCompositionMode(QPainter::CompositionMode_Source); size_t count = WKArrayGetSize(repaintRects); for (size_t i = 0; i < count; ++i) { WKRect wkRect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i))); QRectF rect(wkRect.origin.x, wkRect.origin.y, wkRect.size.width, wkRect.size.height); maskPainter.fillRect(rect, Qt::transparent); } QPainter painter(&image); painter.drawImage(image.rect(), mask); } QCryptographicHash hash(QCryptographicHash::Md5); for (unsigned row = 0; row < image.height(); ++row) hash.addData(reinterpret_cast<const char*>(image.constScanLine(row)), image.bytesPerLine()); QByteArray actualHash = hash.result().toHex(); ASSERT(actualHash.size() == 32); if (!compareActualHashToExpectedAndDumpResults(actualHash)) { image.setText("checksum", actualHash); dumpImage(image); } }
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef imageRef, WKArrayRef repaintRects) { //FIXME: https://bugs.webkit.org/show_bug.cgi?id=68870 UNUSED_PARAM(repaintRects); 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.bytesPerLine()); QByteArray actualHash = hash.result().toHex(); ASSERT(actualHash.size() == 32); if (!compareActualHashToExpectedAndDumpResults(actualHash)) { image.setText("checksum", actualHash); dumpImage(image); } }