Skip to content

Commit 112cf2d

Browse files
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
1 parent 8abb7b0 commit 112cf2d

11 files changed

+299
-37
lines changed

Tools/ChangeLog

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2011-08-18 Tony Chang <[email protected]>
2+
3+
add embedded png checksums to WebKitTestRunner
4+
https://bugs.webkit.org/show_bug.cgi?id=66494
5+
6+
Looks like WebKitTestRunner has never supported embedded checksums. This copies
7+
some code from DRT and adds it to the WebKitTestRunner.
8+
9+
Reviewed by Darin Adler.
10+
11+
* WebKitTestRunner/CyclicRedundancyCheck.cpp: Copied from Tools/DumpRenderTree
12+
* WebKitTestRunner/CyclicRedundancyCheck.h: Copied from Tools/DumpRenderTree
13+
* WebKitTestRunner/GNUmakefile.am: Add new files
14+
* WebKitTestRunner/PixelDumpSupport.cpp: Copied from Tools/DumpRenderTree
15+
* WebKitTestRunner/PixelDumpSupport.h: Copied from Tools/DumpRenderTree
16+
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Add new files
17+
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
18+
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
19+
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
20+
* WebKitTestRunner/cg/TestInvocationCG.cpp:
21+
(WTR::dumpBitmap): Refactor to use PixelDumpSupport.
22+
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
23+
* WebKitTestRunner/win/WebKitTestRunner.vcproj: Add new files
24+
125
2011-08-18 Shawn Singh <[email protected]>
226

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

Tools/DumpRenderTree/CyclicRedundancyCheck.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ unsigned computeCrc(const Vector<unsigned char>& buffer)
5656
crcTableComputed = true;
5757
}
5858

59-
unsigned crc = 0xffffffffL;
59+
unsigned crc = 0xffffffffU;
6060
for (size_t i = 0; i < buffer.size(); ++i)
61-
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffL);
62-
return crc ^ 0xffffffffL;
61+
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffU);
62+
return crc ^ 0xffffffffU;
6363
}
6464

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (C) 2010, Robert Eisele <[email protected]> All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
* * Neither the name of Google Inc. nor the names of its
15+
* contributors may be used to endorse or promote products derived from
16+
* this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
#include "config.h"
32+
#include "CyclicRedundancyCheck.h"
33+
34+
#include <wtf/Vector.h>
35+
36+
static void makeCrcTable(unsigned crcTable[256])
37+
{
38+
for (unsigned i = 0; i < 256; i++) {
39+
unsigned c = i;
40+
for (int k = 0; k < 8; k++) {
41+
if (c & 1)
42+
c = -306674912 ^ ((c >> 1) & 0x7fffffff);
43+
else
44+
c = c >> 1;
45+
}
46+
crcTable[i] = c;
47+
}
48+
}
49+
50+
unsigned computeCrc(const Vector<unsigned char>& buffer)
51+
{
52+
static unsigned crcTable[256];
53+
static bool crcTableComputed = false;
54+
if (!crcTableComputed) {
55+
makeCrcTable(crcTable);
56+
crcTableComputed = true;
57+
}
58+
59+
unsigned crc = 0xffffffffU;
60+
for (size_t i = 0; i < buffer.size(); ++i)
61+
crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffU);
62+
return crc ^ 0xffffffffU;
63+
}
64+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (C) 2011 Google Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
* * Neither the name of Google Inc. nor the names of its
15+
* contributors may be used to endorse or promote products derived from
16+
* this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
#ifndef CyclicRedundancyCheck_h
32+
#define CyclicRedundancyCheck_h
33+
34+
#include <wtf/Vector.h>
35+
36+
unsigned computeCrc(const Vector<unsigned char>&);
37+
38+
#endif

Tools/WebKitTestRunner/GNUmakefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Programs_WebKitTestRunner_SOURCES = \
1313
Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp \
1414
Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp \
1515
Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp \
16+
Tools/WebKitTestRunner/CyclicRedundancyCheck.cpp \
17+
Tools/WebKitTestRunner/CyclicRedundancyCheck.h \
18+
Tools/WebKitTestRunner/PixelDumpSupport.cpp \
19+
Tools/WebKitTestRunner/PixelDumpSupport.h \
1620
Tools/WebKitTestRunner/PlatformWebView.h \
1721
Tools/WebKitTestRunner/StringFunctions.h \
1822
Tools/WebKitTestRunner/TestController.cpp \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2009 Apple, Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14+
* its contributors may be used to endorse or promote products derived
15+
* from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#include "config.h"
30+
#include "PixelDumpSupport.h"
31+
32+
#include "CyclicRedundancyCheck.h"
33+
34+
static void appendIntToVector(unsigned number, Vector<unsigned char>& vector)
35+
{
36+
size_t offset = vector.size();
37+
vector.grow(offset + 4);
38+
vector[offset] = ((number >> 24) & 0xff);
39+
vector[offset + 1] = ((number >> 16) & 0xff);
40+
vector[offset + 2] = ((number >> 8) & 0xff);
41+
vector[offset + 3] = (number & 0xff);
42+
}
43+
44+
static void convertChecksumToPNGComment(const char* checksum, Vector<unsigned char>& bytesToAdd)
45+
{
46+
// Chunks of PNG files are <length>, <type>, <data>, <crc>.
47+
static const char textCommentPrefix[] = "\x00\x00\x00\x29tEXtchecksum\x00";
48+
static const size_t prefixLength = sizeof(textCommentPrefix) - 1; // The -1 is for the null at the end of the char[].
49+
static const size_t checksumLength = 32;
50+
51+
bytesToAdd.append(textCommentPrefix, prefixLength);
52+
bytesToAdd.append(checksum, checksumLength);
53+
54+
Vector<unsigned char> dataToCrc;
55+
dataToCrc.append(textCommentPrefix + 4, prefixLength - 4); // Don't include the chunk length in the crc.
56+
dataToCrc.append(checksum, checksumLength);
57+
unsigned crc32 = computeCrc(dataToCrc);
58+
59+
appendIntToVector(crc32, bytesToAdd);
60+
}
61+
62+
static size_t offsetAfterIHDRChunk(const unsigned char* data, const size_t dataLength)
63+
{
64+
const int pngHeaderLength = 8;
65+
const int pngIHDRChunkLength = 25; // chunk length + "IHDR" + 13 bytes of data + checksum
66+
return pngHeaderLength + pngIHDRChunkLength;
67+
}
68+
69+
void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum)
70+
{
71+
Vector<unsigned char> bytesToAdd;
72+
convertChecksumToPNGComment(checksum, bytesToAdd);
73+
74+
printf("Content-Type: %s\n", "image/png");
75+
printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength + bytesToAdd.size()));
76+
77+
size_t insertOffset = offsetAfterIHDRChunk(data, dataLength);
78+
79+
fwrite(data, 1, insertOffset, stdout);
80+
fwrite(bytesToAdd.data(), 1, bytesToAdd.size(), stdout);
81+
82+
const size_t bytesToWriteInOneChunk = 1 << 15;
83+
data += insertOffset;
84+
size_t dataRemainingToWrite = dataLength - insertOffset;
85+
while (dataRemainingToWrite) {
86+
size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
87+
size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
88+
if (bytesWritten != bytesToWriteInThisChunk)
89+
break;
90+
dataRemainingToWrite -= bytesWritten;
91+
data += bytesWritten;
92+
}
93+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2007 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14+
* its contributors may be used to endorse or promote products derived
15+
* from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#ifndef PixelDumpSupport_h
30+
#define PixelDumpSupport_h
31+
32+
void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum);
33+
34+
#endif // PixelDumpSupport_h

Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

+15-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
/* End PBXAggregateTarget section */
2222

2323
/* Begin PBXBuildFile section */
24+
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */; };
25+
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */; };
2426
6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
2527
6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
2628
6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */; };
@@ -81,6 +83,10 @@
8183
378D442213346D00006A777B /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
8284
41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
8385
4181731B138AD39D0057AAA4 /* WebCoreTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreTestSupport.h; path = WebCoreTestSupport/WebCoreTestSupport.h; sourceTree = BUILT_PRODUCTS_DIR; };
86+
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
87+
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
88+
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
89+
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; };
8490
6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
8591
6510A77811EC643800410867 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
8692
6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher100.ttf; path = fonts/WebKitWeightWatcher100.ttf; sourceTree = "<group>"; };
@@ -189,12 +195,16 @@
189195
children = (
190196
BC9192021333E4CD003011DC /* cg */,
191197
BC7933FE118F7C74005EA8E2 /* mac */,
192-
BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
198+
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */,
199+
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */,
200+
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */,
201+
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */,
193202
BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
194203
BC79342F118F7F19005EA8E2 /* TestController.h */,
195204
BC793430118F7F19005EA8E2 /* TestController.cpp */,
196205
BCD7D2F611921278006DB7EE /* TestInvocation.h */,
197206
BCD7D2F711921278006DB7EE /* TestInvocation.cpp */,
207+
BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
198208
);
199209
name = TestRunner;
200210
sourceTree = "<group>";
@@ -453,10 +463,12 @@
453463
buildActionMask = 2147483647;
454464
files = (
455465
BC793400118F7C84005EA8E2 /* main.mm in Sources */,
456-
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
466+
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
467+
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
457468
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
458-
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
469+
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
459470
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
471+
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
460472
BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
461473
);
462474
runOnlyForDeploymentPostprocessing = 0;

Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp

+4-15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "config.h"
2929
#include "TestInvocation.h"
3030

31+
#include "PixelDumpSupport.h"
3132
#include <WebKit2/WKImageCairo.h>
3233
#include <cairo/cairo.h>
3334
#include <cstdio>
@@ -66,26 +67,14 @@ static cairo_status_t writeFunction(void* closure, const unsigned char* data, un
6667
return CAIRO_STATUS_SUCCESS;
6768
}
6869

69-
static void dumpBitmap(cairo_surface_t* surface)
70+
static void dumpBitmap(cairo_surface_t* surface, const char* checksum)
7071
{
7172
Vector<unsigned char> pixelData;
7273
cairo_surface_write_to_png_stream(surface, writeFunction, &pixelData);
7374
const size_t dataLength = pixelData.size();
7475
const unsigned char* data = pixelData.data();
7576

76-
printf("Content-Type: %s\n", "image/png");
77-
printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength));
78-
79-
const size_t bytesToWriteInOneChunk = 1 << 15;
80-
size_t dataRemainingToWrite = dataLength;
81-
while (dataRemainingToWrite) {
82-
size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
83-
size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
84-
if (bytesWritten != bytesToWriteInThisChunk)
85-
break;
86-
dataRemainingToWrite -= bytesWritten;
87-
data += bytesWritten;
88-
}
77+
printPNG(data, dataLength, checksum);
8978
}
9079

9180
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage)
@@ -95,7 +84,7 @@ void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage)
9584
char actualHash[33];
9685
computeMD5HashStringForCairoSurface(surface, actualHash);
9786
if (!compareActualHashToExpectedAndDumpResults(actualHash))
98-
dumpBitmap(surface);
87+
dumpBitmap(surface, actualHash);
9988

10089
cairo_surface_destroy(surface);
10190
}

0 commit comments

Comments
 (0)