Commit 112cf2dc authored by tony@chromium.org's avatar tony@chromium.org

add embedded png checksums to WebKitTestRunner

https://bugs.webkit.org/show_bug.cgi?id=66494

Looks like WebKitTestRunner has never supported embedded checksums.  This copies
some code from DRT and adds it to the WebKitTestRunner.

Reviewed by Darin Adler.

* WebKitTestRunner/CyclicRedundancyCheck.cpp: Copied from Tools/DumpRenderTree
* WebKitTestRunner/CyclicRedundancyCheck.h: Copied from Tools/DumpRenderTree
* WebKitTestRunner/GNUmakefile.am: Add new files
* WebKitTestRunner/PixelDumpSupport.cpp: Copied from Tools/DumpRenderTree
* WebKitTestRunner/PixelDumpSupport.h: Copied from Tools/DumpRenderTree
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Add new files
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/win/WebKitTestRunner.vcproj: Add new files


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@93355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8abb7b0b
2011-08-18 Tony Chang <tony@chromium.org>
add embedded png checksums to WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=66494
Looks like WebKitTestRunner has never supported embedded checksums. This copies
some code from DRT and adds it to the WebKitTestRunner.
Reviewed by Darin Adler.
* WebKitTestRunner/CyclicRedundancyCheck.cpp: Copied from Tools/DumpRenderTree
* WebKitTestRunner/CyclicRedundancyCheck.h: Copied from Tools/DumpRenderTree
* WebKitTestRunner/GNUmakefile.am: Add new files
* WebKitTestRunner/PixelDumpSupport.cpp: Copied from Tools/DumpRenderTree
* WebKitTestRunner/PixelDumpSupport.h: Copied from Tools/DumpRenderTree
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Add new files
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/win/WebKitTestRunner.vcproj: Add new files
2011-08-18 Shawn Singh <shawnsingh@chromium.org>
https://bugs.webkit.org/show_bug.cgi?id=47240
......@@ -56,9 +56,9 @@ unsigned computeCrc(const Vector<unsigned char>& buffer)
crcTableComputed = true;
}
unsigned crc = 0xffffffffL;
unsigned crc = 0xffffffffU;
for (size_t i = 0; i < buffer.size(); ++i)
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffL);
return crc ^ 0xffffffffL;
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffU);
return crc ^ 0xffffffffU;
}
/*
* Copyright (C) 2010, Robert Eisele <robert@xarg.org> All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "CyclicRedundancyCheck.h"
#include <wtf/Vector.h>
static void makeCrcTable(unsigned crcTable[256])
{
for (unsigned i = 0; i < 256; i++) {
unsigned c = i;
for (int k = 0; k < 8; k++) {
if (c & 1)
c = -306674912 ^ ((c >> 1) & 0x7fffffff);
else
c = c >> 1;
}
crcTable[i] = c;
}
}
unsigned computeCrc(const Vector<unsigned char>& buffer)
{
static unsigned crcTable[256];
static bool crcTableComputed = false;
if (!crcTableComputed) {
makeCrcTable(crcTable);
crcTableComputed = true;
}
unsigned crc = 0xffffffffU;
for (size_t i = 0; i < buffer.size(); ++i)
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffU);
return crc ^ 0xffffffffU;
}
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CyclicRedundancyCheck_h
#define CyclicRedundancyCheck_h
#include <wtf/Vector.h>
unsigned computeCrc(const Vector<unsigned char>&);
#endif
......@@ -13,6 +13,10 @@ Programs_WebKitTestRunner_SOURCES = \
Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp \
Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp \
Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp \
Tools/WebKitTestRunner/CyclicRedundancyCheck.cpp \
Tools/WebKitTestRunner/CyclicRedundancyCheck.h \
Tools/WebKitTestRunner/PixelDumpSupport.cpp \
Tools/WebKitTestRunner/PixelDumpSupport.h \
Tools/WebKitTestRunner/PlatformWebView.h \
Tools/WebKitTestRunner/StringFunctions.h \
Tools/WebKitTestRunner/TestController.cpp \
......
/*
* Copyright (C) 2009 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PixelDumpSupport.h"
#include "CyclicRedundancyCheck.h"
static void appendIntToVector(unsigned number, Vector<unsigned char>& vector)
{
size_t offset = vector.size();
vector.grow(offset + 4);
vector[offset] = ((number >> 24) & 0xff);
vector[offset + 1] = ((number >> 16) & 0xff);
vector[offset + 2] = ((number >> 8) & 0xff);
vector[offset + 3] = (number & 0xff);
}
static void convertChecksumToPNGComment(const char* checksum, Vector<unsigned char>& bytesToAdd)
{
// Chunks of PNG files are <length>, <type>, <data>, <crc>.
static const char textCommentPrefix[] = "\x00\x00\x00\x29tEXtchecksum\x00";
static const size_t prefixLength = sizeof(textCommentPrefix) - 1; // The -1 is for the null at the end of the char[].
static const size_t checksumLength = 32;
bytesToAdd.append(textCommentPrefix, prefixLength);
bytesToAdd.append(checksum, checksumLength);
Vector<unsigned char> dataToCrc;
dataToCrc.append(textCommentPrefix + 4, prefixLength - 4); // Don't include the chunk length in the crc.
dataToCrc.append(checksum, checksumLength);
unsigned crc32 = computeCrc(dataToCrc);
appendIntToVector(crc32, bytesToAdd);
}
static size_t offsetAfterIHDRChunk(const unsigned char* data, const size_t dataLength)
{
const int pngHeaderLength = 8;
const int pngIHDRChunkLength = 25; // chunk length + "IHDR" + 13 bytes of data + checksum
return pngHeaderLength + pngIHDRChunkLength;
}
void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum)
{
Vector<unsigned char> bytesToAdd;
convertChecksumToPNGComment(checksum, bytesToAdd);
printf("Content-Type: %s\n", "image/png");
printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength + bytesToAdd.size()));
size_t insertOffset = offsetAfterIHDRChunk(data, dataLength);
fwrite(data, 1, insertOffset, stdout);
fwrite(bytesToAdd.data(), 1, bytesToAdd.size(), stdout);
const size_t bytesToWriteInOneChunk = 1 << 15;
data += insertOffset;
size_t dataRemainingToWrite = dataLength - insertOffset;
while (dataRemainingToWrite) {
size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
if (bytesWritten != bytesToWriteInThisChunk)
break;
dataRemainingToWrite -= bytesWritten;
data += bytesWritten;
}
}
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PixelDumpSupport_h
#define PixelDumpSupport_h
void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum);
#endif // PixelDumpSupport_h
......@@ -21,6 +21,8 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */; };
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */; };
6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */; };
......@@ -81,6 +83,10 @@
378D442213346D00006A777B /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
4181731B138AD39D0057AAA4 /* WebCoreTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreTestSupport.h; path = WebCoreTestSupport/WebCoreTestSupport.h; sourceTree = BUILT_PRODUCTS_DIR; };
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; };
6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
6510A77811EC643800410867 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher100.ttf; path = fonts/WebKitWeightWatcher100.ttf; sourceTree = "<group>"; };
......@@ -189,12 +195,16 @@
children = (
BC9192021333E4CD003011DC /* cg */,
BC7933FE118F7C74005EA8E2 /* mac */,
BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */,
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */,
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */,
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */,
BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
BC79342F118F7F19005EA8E2 /* TestController.h */,
BC793430118F7F19005EA8E2 /* TestController.cpp */,
BCD7D2F611921278006DB7EE /* TestInvocation.h */,
BCD7D2F711921278006DB7EE /* TestInvocation.cpp */,
BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
);
name = TestRunner;
sourceTree = "<group>";
......@@ -453,10 +463,12 @@
buildActionMask = 2147483647;
files = (
BC793400118F7C84005EA8E2 /* main.mm in Sources */,
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -28,6 +28,7 @@
#include "config.h"
#include "TestInvocation.h"
#include "PixelDumpSupport.h"
#include <WebKit2/WKImageCairo.h>
#include <cairo/cairo.h>
#include <cstdio>
......@@ -66,26 +67,14 @@ static cairo_status_t writeFunction(void* closure, const unsigned char* data, un
return CAIRO_STATUS_SUCCESS;
}
static void dumpBitmap(cairo_surface_t* surface)
static void dumpBitmap(cairo_surface_t* surface, const char* checksum)
{
Vector<unsigned char> pixelData;
cairo_surface_write_to_png_stream(surface, writeFunction, &pixelData);
const size_t dataLength = pixelData.size();
const unsigned char* data = pixelData.data();
printf("Content-Type: %s\n", "image/png");
printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength));
const size_t bytesToWriteInOneChunk = 1 << 15;
size_t dataRemainingToWrite = dataLength;
while (dataRemainingToWrite) {
size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
if (bytesWritten != bytesToWriteInThisChunk)
break;
dataRemainingToWrite -= bytesWritten;
data += bytesWritten;
}
printPNG(data, dataLength, checksum);
}
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage)
......@@ -95,7 +84,7 @@ void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage)
char actualHash[33];
computeMD5HashStringForCairoSurface(surface, actualHash);
if (!compareActualHashToExpectedAndDumpResults(actualHash))
dumpBitmap(surface);
dumpBitmap(surface, actualHash);
cairo_surface_destroy(surface);
}
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include "TestInvocation.h"
#include "PixelDumpSupport.h"
#include "PlatformWebView.h"
#include "TestController.h"
#include <ImageIO/CGImageDestination.h>
......@@ -99,7 +100,7 @@ void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[
snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
}
static void dumpBitmap(CGContextRef bitmapContext)
static void dumpBitmap(CGContextRef bitmapContext, const char* checksum)
{
RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
RetainPtr<CFMutableDataRef> imageData(AdoptCF, CFDataCreateMutable(0, 0));
......@@ -110,20 +111,7 @@ static void dumpBitmap(CGContextRef bitmapContext)
const unsigned char* data = CFDataGetBytePtr(imageData.get());
const size_t dataLength = CFDataGetLength(imageData.get());
fprintf(stdout, "Content-Type: %s\n", "image/png");
fprintf(stdout, "Content-Length: %lu\n", static_cast<unsigned long>(dataLength));
const size_t bytesToWriteInOneChunk = 1 << 15;
size_t dataRemainingToWrite = dataLength;
while (dataRemainingToWrite) {
size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
if (bytesWritten != bytesToWriteInThisChunk)
break;
dataRemainingToWrite -= bytesWritten;
data += bytesWritten;
}
printPNG(data, dataLength, checksum);
}
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image)
......@@ -133,7 +121,7 @@ void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image)
char actualHash[33];
computeMD5HashStringForContext(context, actualHash);
if (!compareActualHashToExpectedAndDumpResults(actualHash))
dumpBitmap(context);
dumpBitmap(context, actualHash);
}
} // namespace WTR
......@@ -470,6 +470,22 @@
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="..\CyclicRedundancyCheck.cpp"
>
</File>
<File
RelativePath="..\CyclicRedundancyCheck.h"
>
</File>
<File
RelativePath="..\PixelDumpSupport.cpp"
>
</File>
<File
RelativePath="..\PixelDumpSupport.h"
>
</File>
<File
RelativePath="..\PlatformWebView.h"
>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment