Commit db03ebea authored by mrobinson@webkit.org's avatar mrobinson@webkit.org

2010-07-12 Martin Robinson <mrobinson@igalia.com>

        Reviewed by Dirk Schulze.

        [GTK] Support pixel tests
        https://bugs.webkit.org/show_bug.cgi?id=31518

        Finish support for pixel tests on GTK+.

        * DumpRenderTree/PixelDumpSupport.cpp: Remove unecessary RetainPtr include (only
        works on CoreFoundation systems) and add missing cstdio include.
        * DumpRenderTree/cairo/PixelDumpSupportCairo.cpp: Switch to using the MD5 support found
        in JSC library. MD5.cpp and MD5.h are only available for the Windows build.
        (computeMD5HashStringForBitmapContext): The number of bytes per row should be the row stride
        of the image, not the row stride multiplied by the width. Use JSC MD5 implementation to calculate
        the MD5 hash here. According to glibc manpages, using snprintf to build a string in unsupported
        by the ANSI standard and this fails on Linux, so unroll the loop here.
        * DumpRenderTree/cairo/PixelDumpSupportCairo.h: Correct some constructor misbehavior.
        (BitmapContext::BitmapContext): There is no reason to check the value of the
        m_context member in the constructor and it certainly should not be freed. Instead
        just initialize it with the incoming value.
        * DumpRenderTree/gtk/DumpRenderTree.cpp: Fix the order of includes.
        (dump): Actually call dumpWebViewAsPixelsAndCompareWithExpected when it is time to
        dump pixels.
        * DumpRenderTree/gtk/PixelDumpSupportGtk.cpp: Added.
        (createBitmapContextFromWebView):
        * GNUmakefile.am: Add new files to the build.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5526e318
2010-07-12 Martin Robinson <mrobinson@igalia.com>
Reviewed by Dirk Schulze.
[GTK] Support pixel tests
https://bugs.webkit.org/show_bug.cgi?id=31518
Finish support for pixel tests on GTK+.
* DumpRenderTree/PixelDumpSupport.cpp: Remove unecessary RetainPtr include (only
works on CoreFoundation systems) and add missing cstdio include.
* DumpRenderTree/cairo/PixelDumpSupportCairo.cpp: Switch to using the MD5 support found
in JSC library. MD5.cpp and MD5.h are only available for the Windows build.
(computeMD5HashStringForBitmapContext): The number of bytes per row should be the row stride
of the image, not the row stride multiplied by the width. Use JSC MD5 implementation to calculate
the MD5 hash here. According to glibc manpages, using snprintf to build a string in unsupported
by the ANSI standard and this fails on Linux, so unroll the loop here.
* DumpRenderTree/cairo/PixelDumpSupportCairo.h: Correct some constructor misbehavior.
(BitmapContext::BitmapContext): There is no reason to check the value of the
m_context member in the constructor and it certainly should not be freed. Instead
just initialize it with the incoming value.
* DumpRenderTree/gtk/DumpRenderTree.cpp: Fix the order of includes.
(dump): Actually call dumpWebViewAsPixelsAndCompareWithExpected when it is time to
dump pixels.
* DumpRenderTree/gtk/PixelDumpSupportGtk.cpp: Added.
(createBitmapContextFromWebView):
* GNUmakefile.am: Add new files to the build.
2010-07-12 Adam Barth <abarth@webkit.org>
Unreviewed.
......
......@@ -30,9 +30,9 @@
#include "DumpRenderTree.h"
#include "LayoutTestController.h"
#include "PixelDumpSupport.h"
#include <cstdio>
#include <wtf/Assertions.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
#if PLATFORM(CG)
#include "PixelDumpSupportCG.h"
......
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
* (C) 2009 Brent Fulgham <bfulgham@webkit.org>
* (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -35,14 +36,10 @@
#include <algorithm>
#include <ctype.h>
#include <wtf/Assertions.h>
#include <wtf/MD5.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
#include <wtf/StringExtras.h>
#if PLATFORM(WIN)
#include "MD5.h"
#endif
using namespace std;
static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length)
......@@ -73,21 +70,20 @@ void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashStrin
size_t pixelsHigh = cairo_image_surface_get_height(surface);
size_t pixelsWide = cairo_image_surface_get_width(surface);
size_t bytesPerRow = pixelsWide * cairo_image_surface_get_stride(surface);
size_t bytesPerRow = cairo_image_surface_get_stride(surface);
MD5_CTX md5Context;
MD5_Init(&md5Context);
MD5 md5Context;
unsigned char* bitmapData = static_cast<unsigned char*>(cairo_image_surface_get_data(surface));
for (unsigned row = 0; row < pixelsHigh; row++) {
MD5_Update(&md5Context, bitmapData, 4 * pixelsWide);
md5Context.addBytes(bitmapData, 4 * pixelsWide);
bitmapData += bytesPerRow;
}
unsigned char hash[16];
MD5_Final(hash, &md5Context);
Vector<uint8_t, 16> hash;
md5Context.checksum(hash);
hashString[0] = '\0';
for (int i = 0; i < 16; i++)
snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
snprintf(hashString, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7],
hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]);
}
void dumpBitmap(BitmapContext* context)
......
......@@ -36,6 +36,8 @@
#if PLATFORM(WIN)
#include <windows.h>
#include <cairo-win32.h>
#elif PLATFORM(GTK)
#include <cairo.h>
#endif
#if PLATFORM(WIN)
......@@ -68,16 +70,12 @@ private:
BitmapContext(PlatformBitmapBuffer buffer, cairo_t* context)
: m_buffer(buffer)
, m_context(context)
{
if (m_context)
cairo_destroy(m_context);
m_context = context;
}
PlatformBitmapBuffer m_buffer;
cairo_t* m_context;
};
#endif // PixelDumpSupportCairo_h
......@@ -36,23 +36,22 @@
#include "EventSender.h"
#include "GCController.h"
#include "LayoutTestController.h"
#include "PixelDumpSupport.h"
#include "WorkQueue.h"
#include "WorkQueueItem.h"
#include <JavaScriptCore/JavaScript.h>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <getopt.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include <JavaScriptCore/JavaScript.h>
#include <wtf/Assertions.h>
#if PLATFORM(X11)
#include <fontconfig/fontconfig.h>
#endif
#include <cassert>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
......@@ -422,7 +421,7 @@ void dump()
if (dumpPixels) {
if (!gLayoutTestController->dumpAsText() && !gLayoutTestController->dumpDOMAsWebArchive() && !gLayoutTestController->dumpSourceAsWebArchive()) {
// FIXME: Add support for dumping pixels
dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash());
}
}
......
/*
* Copyright (C) 2009 Zan Dobersek <zandobersek@gmail.com>
* Copyright (C) 2010 Igalia S.L.
*
* 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 "DumpRenderTree.h"
#include "PixelDumpSupportCairo.h"
#include <webkit/webkit.h>
PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool)
{
WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
GdkPixmap* pixmap = gtk_widget_get_snapshot(GTK_WIDGET(view), 0);
gint width, height;
gdk_drawable_get_size(GDK_DRAWABLE(pixmap), &width, &height);
cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t* context = cairo_create(imageSurface);
gdk_cairo_set_source_pixmap(context, pixmap, 0, 0);
cairo_paint(context);
g_object_unref(pixmap);
return BitmapContext::createByAdoptingBitmapAndContext(0, context);
}
......@@ -33,6 +33,7 @@ Programs_GtkLauncher_LDFLAGS = \
# DumpRenderTree
dumprendertree_cppflags := \
-I$(srcdir)/WebKitTools/DumpRenderTree \
-I$(srcdir)/WebKitTools/DumpRenderTree/cairo \
-I$(srcdir)/WebKitTools/DumpRenderTree/gtk \
-I$(srcdir)/WebKit/gtk \
-I$(top_builddir)/WebKit/gtk \
......@@ -54,11 +55,14 @@ Programs_DumpRenderTree_SOURCES = \
WebKitTools/DumpRenderTree/JavaScriptThreading.h \
WebKitTools/DumpRenderTree/LayoutTestController.cpp \
WebKitTools/DumpRenderTree/LayoutTestController.h \
WebKitTools/DumpRenderTree/PixelDumpSupport.cpp \
WebKitTools/DumpRenderTree/PixelDumpSupport.h \
WebKitTools/DumpRenderTree/WorkQueue.cpp \
WebKitTools/DumpRenderTree/WorkQueue.h \
WebKitTools/DumpRenderTree/WorkQueueItem.h \
WebKitTools/DumpRenderTree/config.h \
WebKitTools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp \
WebKitTools/DumpRenderTree/cairo/PixelDumpSupportCairo.h \
WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp \
WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp \
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp \
......@@ -67,6 +71,7 @@ Programs_DumpRenderTree_SOURCES = \
WebKitTools/DumpRenderTree/gtk/EventSender.cpp \
WebKitTools/DumpRenderTree/gtk/GCControllerGtk.cpp \
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp \
WebKitTools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp \
WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp
Programs_DumpRenderTree_CXXFLAGS = \
......
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