Changeset 93355 in webkit


Ignore:
Timestamp:
Aug 18, 2011 3:08:28 PM (13 years ago)
Author:
tony@chromium.org
Message:

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
Location:
trunk/Tools
Files:
2 added
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r93345 r93355  
     12011-08-18  Tony Chang  <tony@chromium.org>
     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
    1252011-08-18  Shawn Singh  <shawnsingh@chromium.org>
    226
  • trunk/Tools/DumpRenderTree/CyclicRedundancyCheck.cpp

    r83461 r93355  
    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
  • trunk/Tools/WebKitTestRunner/CyclicRedundancyCheck.cpp

    r93354 r93355  
    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
  • trunk/Tools/WebKitTestRunner/CyclicRedundancyCheck.h

    r93354 r93355  
    11/*
    2  * Copyright (C) 2010, Robert Eisele <robert@xarg.org> All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929 */
    3030
    31 #include "config.h"
    32 #include "CyclicRedundancyCheck.h"
     31#ifndef CyclicRedundancyCheck_h
     32#define CyclicRedundancyCheck_h
    3333
    3434#include <wtf/Vector.h>
    3535
    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 }
     36unsigned computeCrc(const Vector<unsigned char>&);
    4937
    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 = 0xffffffffL;
    60     for (size_t i = 0; i < buffer.size(); ++i)
    61         crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffL);
    62     return crc ^ 0xffffffffL;
    63 }
    64 
     38#endif
  • trunk/Tools/WebKitTestRunner/GNUmakefile.am

    r92274 r93355  
    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 \
  • trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r89530 r93355  
    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 */; };
     
    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>"; };
     
    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 */,
     
    196205                                BCD7D2F611921278006DB7EE /* TestInvocation.h */,
    197206                                BCD7D2F711921278006DB7EE /* TestInvocation.cpp */,
     207                                BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
    198208                        );
    199209                        name = TestRunner;
     
    454464                        files = (
    455465                                BC793400118F7C84005EA8E2 /* main.mm in Sources */,
     466                                5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
     467                                5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
     468                                BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
    456469                                BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
    457                                 BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
     470                                BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
    458471                                BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
    459                                 BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
    460472                                BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
    461473                        );
  • trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp

    r89759 r93355  
    2929#include "TestInvocation.h"
    3030
     31#include "PixelDumpSupport.h"
    3132#include <WebKit2/WKImageCairo.h>
    3233#include <cairo/cairo.h>
     
    6768}
    6869
    69 static void dumpBitmap(cairo_surface_t* surface)
     70static void dumpBitmap(cairo_surface_t* surface, const char* checksum)
    7071{
    7172    Vector<unsigned char> pixelData;
     
    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
     
    9685    computeMD5HashStringForCairoSurface(surface, actualHash);
    9786    if (!compareActualHashToExpectedAndDumpResults(actualHash))
    98         dumpBitmap(surface);
     87        dumpBitmap(surface, actualHash);
    9988
    10089    cairo_surface_destroy(surface);
  • trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp

    r89426 r93355  
    2727#include "TestInvocation.h"
    2828
     29#include "PixelDumpSupport.h"
    2930#include "PlatformWebView.h"
    3031#include "TestController.h"
     
    100101}
    101102
    102 static void dumpBitmap(CGContextRef bitmapContext)
     103static void dumpBitmap(CGContextRef bitmapContext, const char* checksum)
    103104{
    104105    RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
     
    111112    const size_t dataLength = CFDataGetLength(imageData.get());
    112113
    113 
    114     fprintf(stdout, "Content-Type: %s\n", "image/png");
    115     fprintf(stdout, "Content-Length: %lu\n", static_cast<unsigned long>(dataLength));
    116    
    117     const size_t bytesToWriteInOneChunk = 1 << 15;
    118     size_t dataRemainingToWrite = dataLength;
    119     while (dataRemainingToWrite) {
    120         size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
    121         size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
    122         if (bytesWritten != bytesToWriteInThisChunk)
    123             break;
    124         dataRemainingToWrite -= bytesWritten;
    125         data += bytesWritten;
    126     }
     114    printPNG(data, dataLength, checksum);
    127115}
    128116
     
    134122    computeMD5HashStringForContext(context, actualHash);
    135123    if (!compareActualHashToExpectedAndDumpResults(actualHash))
    136         dumpBitmap(context);
     124        dumpBitmap(context, actualHash);
    137125}
    138126
  • trunk/Tools/WebKitTestRunner/win/WebKitTestRunner.vcproj

    r82477 r93355  
    472472                </Filter>
    473473                <File
     474                        RelativePath="..\CyclicRedundancyCheck.cpp"
     475                        >
     476                </File>
     477                <File
     478                        RelativePath="..\CyclicRedundancyCheck.h"
     479                        >
     480                </File>
     481                <File
     482                        RelativePath="..\PixelDumpSupport.cpp"
     483                        >
     484                </File>
     485                <File
     486                        RelativePath="..\PixelDumpSupport.h"
     487                        >
     488                </File>
     489                <File
    474490                        RelativePath="..\PlatformWebView.h"
    475491                        >
Note: See TracChangeset for help on using the changeset viewer.