Пример #1
0
void dumpWebViewAsPixelsAndCompareWithExpected(const char* /*currentTest*/, bool /*forceAllTestsToDumpPixels*/)
{
    RetainPtr<CGContextRef> context = getBitmapContextFromWebView();

#if PLATFORM(MAC)
    if (layoutTestController->testRepaint())
        repaintWebView(context.get(), layoutTestController->testRepaintSweepHorizontally());
    else 
        paintWebView(context.get());

    if (layoutTestController->dumpSelectionRect())
        drawSelectionRect(context.get(), getSelectionRect());
#endif

    // Compute the actual hash to compare to the expected image's hash.
    char actualHash[33];
    getMD5HashStringForBitmap(context.get(), actualHash);
    printf("\nActualHash: %s\n", actualHash);

    // FIXME: We should compare the actualHash to the expected hash here and
    // only set dumpImage to true if they don't match, but DRT doesn't have
    // enough information currently to find the expected checksum file.
    bool dumpImage = true;

    if (dumpImage) {
        RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(context.get()));
        printPNG(image.get());
    }

    printf("#EOF\n");
}
Пример #2
0
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();

    printPNG(data, dataLength, checksum);
}
Пример #3
0
static void dumpBitmap(CGContextRef bitmapContext, const char* checksum)
{
    RetainPtr<CGImageRef> image = adoptCF(CGBitmapContextCreateImage(bitmapContext));
    RetainPtr<CFMutableDataRef> imageData = adoptCF(CFDataCreateMutable(0, 0));
    RetainPtr<CGImageDestinationRef> imageDest = adoptCF(CGImageDestinationCreateWithData(imageData.get(), kUTTypePNG, 1, 0));
    CGImageDestinationAddImage(imageDest.get(), image.get(), 0);
    CGImageDestinationFinalize(imageDest.get());

    const unsigned char* data = CFDataGetBytePtr(imageData.get());
    const size_t dataLength = CFDataGetLength(imageData.get());

    printPNG(data, dataLength, checksum);
}