https://bugs.webkit.org/show_bug.cgi?id=55161
Reviewed by Darin Adler.
* Scripts/old-run-webkit-tests:
Don't print color space information when using WebKitTestRunner since
we don't need to change the screen.
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::initialize):
Add call to initializePlatformDefaults.
(WTR::InjectedBundle::done):
Return a dictionary on completion with both the text output and pixel dump override.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
Add declaration for initializePlatformDefaults.
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::LayoutTestController):
(WTR::LayoutTestController::dumpAsText):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
(WTR::LayoutTestController::shouldDumpPixels):
Make setting dumpAsText override the dump pixels preference.
* WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm: Added.
(WTR::InjectedBundle::initializePlatformDefaults):
Set platform defaults matching DumpRenderTree.
* WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp: Added.
(WTR::InjectedBundle::initializePlatformDefaults):
* WebKitTestRunner/InjectedBundle/win/InjectedBundleWin.cpp: Added.
(WTR::InjectedBundle::initializePlatformDefaults):
Add stubs for initializePlatformDefaults.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::runTest):
(WTR::TestController::runTestingServerLoop):
(WTR::TestController::run):
Parse expected pixel results out of stdin and setup the invocation with it.
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::TestInvocation):
Initialize new members.
(WTR::TestInvocation::~TestInvocation):
(WTR::TestInvocation::setIsPixelTest):
(WTR::sizeWebViewForCurrentTest):
(WTR::TestInvocation::invoke):
(WTR::TestInvocation::dump):
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.h:
Dump pixels in addition to text by calling dumpPixelsAndCompareWithExpected.
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::PlatformWebView):
Use -[NSColorSpace genericRGBColorSpace] instead of the main screen color space.
* WebKitTestRunner/mac/TestInvocationMac.mm: Added.
(WTR::createCGContextFromPlatformView):
(WTR::computeMD5HashStringForContext):
(WTR::dumpBitmap):
(WTR::forceRepaintFunction):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
Add mac specific pixel dumping support. Right now, we always pull pixels
from the window server.
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro:
* WebKitTestRunner/qt/WebKitTestRunner.pro:
* WebKitTestRunner/win/InjectedBundle.vcproj:
* WebKitTestRunner/win/WebKitTestRunner.vcproj:
Add new files.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79612
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-24 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Add basic pixel testing support to WebKitTestRunner
+ https://bugs.webkit.org/show_bug.cgi?id=55161
+
+ * Scripts/old-run-webkit-tests:
+ Don't print color space information when using WebKitTestRunner since
+ we don't need to change the screen.
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::initialize):
+ Add call to initializePlatformDefaults.
+
+ (WTR::InjectedBundle::done):
+ Return a dictionary on completion with both the text output and pixel dump override.
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+ Add declaration for initializePlatformDefaults.
+
+ * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+ (WTR::LayoutTestController::LayoutTestController):
+ (WTR::LayoutTestController::dumpAsText):
+ * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+ (WTR::LayoutTestController::shouldDumpPixels):
+ Make setting dumpAsText override the dump pixels preference.
+
+ * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm: Added.
+ (WTR::InjectedBundle::initializePlatformDefaults):
+ Set platform defaults matching DumpRenderTree.
+
+ * WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp: Added.
+ (WTR::InjectedBundle::initializePlatformDefaults):
+ * WebKitTestRunner/InjectedBundle/win/InjectedBundleWin.cpp: Added.
+ (WTR::InjectedBundle::initializePlatformDefaults):
+ Add stubs for initializePlatformDefaults.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::runTest):
+ (WTR::TestController::runTestingServerLoop):
+ (WTR::TestController::run):
+ Parse expected pixel results out of stdin and setup the invocation with it.
+
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::TestInvocation):
+ Initialize new members.
+
+ (WTR::TestInvocation::~TestInvocation):
+ (WTR::TestInvocation::setIsPixelTest):
+ (WTR::sizeWebViewForCurrentTest):
+ (WTR::TestInvocation::invoke):
+ (WTR::TestInvocation::dump):
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+ * WebKitTestRunner/TestInvocation.h:
+ Dump pixels in addition to text by calling dumpPixelsAndCompareWithExpected.
+
+ * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+ (WTR::PlatformWebView::PlatformWebView):
+ Use -[NSColorSpace genericRGBColorSpace] instead of the main screen color space.
+
+ * WebKitTestRunner/mac/TestInvocationMac.mm: Added.
+ (WTR::createCGContextFromPlatformView):
+ (WTR::computeMD5HashStringForContext):
+ (WTR::dumpBitmap):
+ (WTR::forceRepaintFunction):
+ (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+ Add mac specific pixel dumping support. Right now, we always pull pixels
+ from the window server.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro:
+ * WebKitTestRunner/qt/WebKitTestRunner.pro:
+ * WebKitTestRunner/win/InjectedBundle.vcproj:
+ * WebKitTestRunner/win/WebKitTestRunner.vcproj:
+ Add new files.
+
2011-02-24 Chang Shu <cshu@webkit.org>
Reviewed by Kenneth Rohde Christiansen.
if ($pixelTests) {
print "Enabling pixel tests with a tolerance of $tolerance%\n";
if (isDarwin()) {
- print "WARNING: Temporarily changing the main display color profile:\n";
- print "\tThe colors on your screen will change for the duration of the testing.\n";
- print "\tThis allows the pixel tests to have consistent color values across all machines.\n";
-
+ if (!$useWebKitTestRunner) {
+ print "WARNING: Temporarily changing the main display color profile:\n";
+ print "\tThe colors on your screen will change for the duration of the testing.\n";
+ print "\tThis allows the pixel tests to have consistent color values across all machines.\n";
+ }
+
if (isPerianInstalled()) {
print "WARNING: Perian's QuickTime component is installed and this may affect pixel test results!\n";
print "\tYou should avoid generating new pixel results in this environment.\n";
};
WKBundleSetClient(m_bundle, &client);
+ initializePlatformDefaults();
+
activateFonts();
WKBundleActivateMacFontAscentHack(m_bundle);
}
setTopLoadingFrame(0);
WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done"));
- WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str()));
+ WKRetainPtr<WKMutableDictionaryRef> doneMessageBody(AdoptWK, WKMutableDictionaryCreate());
+
+ WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
+ WKRetainPtr<WKStringRef> textOutput(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str()));
+ WKDictionaryAddItem(doneMessageBody.get(), textOutputKey.get(), textOutput.get());
+
+ WKRetainPtr<WKStringRef> textOnlyKey(AdoptWK, WKStringCreateWithUTF8CString("TextOnly"));
+ WKRetainPtr<WKBooleanRef> textOnly(AdoptWK, WKBooleanCreate(!m_layoutTestController->shouldDumpPixels()));
+ WKDictionaryAddItem(doneMessageBody.get(), textOnlyKey.get(), textOnly.get());
WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
void didInitializePageGroup(WKBundlePageGroupRef);
void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
+ void initializePlatformDefaults();
void resetLocalSettings();
void beginTesting();
, m_dumpEditingCallbacks(false)
, m_dumpStatusCallbacks(false)
, m_dumpTitleChanges(false)
+ , m_dumpPixels(true)
, m_waitToDump(false)
, m_testRepaint(false)
, m_testRepaintSweepHorizontally(false)
// FIXME: actually implement, once we want pixel tests
}
+void LayoutTestController::dumpAsText()
+{
+ m_whatToDump = MainFrameText;
+ m_dumpPixels = false;
+}
+
void LayoutTestController::waitUntilDone()
{
m_waitToDump = true;
void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
// The basics.
- void dumpAsText() { m_whatToDump = MainFrameText; }
+ void dumpAsText();
void dumpChildFramesAsText() { m_whatToDump = AllFramesText; }
void waitUntilDone();
void notifyDone();
bool shouldDumpMainFrameScrollPosition() const { return m_whatToDump == RenderTree; }
bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
+ bool shouldDumpPixels() const { return m_dumpPixels; }
bool waitToDump() const { return m_waitToDump; }
void waitToDumpWatchdogTimerFired();
bool m_dumpEditingCallbacks;
bool m_dumpStatusCallbacks;
bool m_dumpTitleChanges;
+ bool m_dumpPixels;
bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
bool m_testRepaint;
bool m_testRepaintSweepHorizontally;
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "InjectedBundle.h"
+
+namespace WTR {
+
+void InjectedBundle::initializePlatformDefaults()
+{
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithInteger:4], @"AppleAntiAliasingThreshold",
+ [NSNumber numberWithInteger:0], @"AppleFontSmoothing",
+ [NSNumber numberWithBool:NO], @"AppleScrollAnimationEnabled",
+ [NSNumber numberWithBool:NO], @"NSOverlayScrollersEnabled",
+ @"Always", @"AppleShowScrollBars",
+ nil];
+
+ [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
+}
+
+} // namespace WTR
../LayoutTestController.h \
../Bindings/JSWrapper.cpp \
ActivateFontsQt.cpp \
+ InjectedBundleQt.cpp \
LayoutTestControllerQt.cpp \
$$GENERATED_SOURCES_DIR/JSEventSendingController.cpp \
$$GENERATED_SOURCES_DIR/JSGCController.cpp \
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "InjectedBundle.h"
+
+namespace WTR {
+
+void InjectedBundle::initializePlatformDefaults()
+{
+}
+
+} // namespace WTR
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "InjectedBundle.h"
+
+namespace WTR {
+
+void InjectedBundle::initializePlatformDefaults()
+{
+}
+
+} // namespace WTR
return false;
}
+ std::string pathOrURL(test);
+ std::string expectedPixelHash;
+ size_t separatorPos = pathOrURL.find("'");
+ if (separatorPos != std::string::npos) {
+ pathOrURL = std::string(std::string(test), 0, separatorPos);
+ expectedPixelHash = std::string(std::string(test), separatorPos + 1);
+ }
+
m_state = RunningTest;
- m_currentInvocation.set(new TestInvocation(test));
+
+ m_currentInvocation.set(new TestInvocation(pathOrURL));
+ if (m_dumpPixels)
+ m_currentInvocation->setIsPixelTest(expectedPixelHash);
+
m_currentInvocation->invoke();
m_currentInvocation.clear();
{
char filenameBuffer[2048];
while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
- char *newLineCharacter = strchr(filenameBuffer, '\n');
+ char* newLineCharacter = strchr(filenameBuffer, '\n');
if (newLineCharacter)
*newLineCharacter = '\0';
break;
}
}
-
}
void TestController::runUntil(bool& done, TimeoutDuration timeoutDuration)
return WKURLCreateWithUTF8CString(buffer.get());
}
-TestInvocation::TestInvocation(const char* pathOrURL)
- : m_url(AdoptWK, createWKURL(pathOrURL))
- , m_pathOrURL(fastStrDup(pathOrURL))
+TestInvocation::TestInvocation(const std::string& pathOrURL)
+ : m_url(AdoptWK, createWKURL(pathOrURL.c_str()))
+ , m_pathOrURL(pathOrURL)
+ , m_dumpPixels(false)
, m_gotInitialResponse(false)
, m_gotFinalMessage(false)
+ , m_gotRepaint(false)
, m_error(false)
{
}
TestInvocation::~TestInvocation()
{
- fastFree(m_pathOrURL);
+}
+
+void TestInvocation::setIsPixelTest(const std::string& expectedPixelHash)
+{
+ m_dumpPixels = true;
+ m_expectedPixelHash = expectedPixelHash;
}
static const unsigned w3cSVGWidth = 480;
static const unsigned normalWidth = 800;
static const unsigned normalHeight = 600;
-static void sizeWebViewForCurrentTest(char* pathOrURL)
+static void sizeWebViewForCurrentTest(const char* pathOrURL)
{
bool isSVGW3CTest = strstr(pathOrURL, "svg/W3C-SVG-1.1") || strstr(pathOrURL, "svg\\W3C-SVG-1.1");
void TestInvocation::invoke()
{
- sizeWebViewForCurrentTest(m_pathOrURL);
+ sizeWebViewForCurrentTest(m_pathOrURL.c_str());
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
return;
}
- if (shouldOpenWebInspector(m_pathOrURL))
+ if (shouldOpenWebInspector(m_pathOrURL.c_str()))
WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page()));
WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get());
printf("Content-Type: text/plain\n");
printf("%s", stringToDump);
- fputs("#EOF\n", stdout);
fputs("#EOF\n", stdout);
fputs("#EOF\n", stderr);
-
- fflush(stdout);
- fflush(stderr);
}
void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
}
if (WKStringIsEqualToUTF8CString(messageName, "Done")) {
- ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
- WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody);
+ ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+ WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+
+ WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
+ WKStringRef textOutput = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, textOutputKey.get()));
+
+ WKRetainPtr<WKStringRef> textOnlyKey(AdoptWK, WKStringCreateWithUTF8CString("TextOnly"));
+ bool textOnly = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, textOnlyKey.get())));
+
+ // Dump text.
+ dump(toSTD(textOutput).c_str());
- dump(toSTD(messageBodyString).c_str());
+ // Dump pixels (if necessary).
+ if (m_dumpPixels && !textOnly)
+ dumpPixelsAndCompareWithExpected();
+ fputs("#EOF\n", stdout);
+ fflush(stdout);
+ fflush(stderr);
+
m_gotFinalMessage = true;
TestController::shared().notifyDone();
return;
#ifndef TestInvocation_h
#define TestInvocation_h
+#include <string>
#include <WebKit2/WKRetainPtr.h>
#include <wtf/Noncopyable.h>
class TestInvocation {
WTF_MAKE_NONCOPYABLE(TestInvocation);
public:
- TestInvocation(const char*);
+ TestInvocation(const std::string& pathOrURL);
~TestInvocation();
+ void setIsPixelTest(const std::string& expectedPixelHash);
+
void invoke();
void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
private:
void dump(const char*);
-
+ void dumpPixelsAndCompareWithExpected();
+
WKRetainPtr<WKURLRef> m_url;
- char* m_pathOrURL;
+ std::string m_pathOrURL;
+
+ bool m_dumpPixels;
+ std::string m_expectedPixelHash;
// Invocation state
bool m_gotInitialResponse;
bool m_gotFinalMessage;
+ bool m_gotRepaint;
bool m_error;
};
BC7934AC1190658C005EA8E2 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC7934AB1190658C005EA8E2 /* WebKit2.framework */; };
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */; };
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8C795B11D2785D004535A1 /* TestControllerMac.mm */; };
+ BC8DAD5D1315C0EC00EC96FC /* TestInvocationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8DAD5B1315C0EC00EC96FC /* TestInvocationMac.mm */; };
+ BC8DAD7B1316D91000EC96FC /* InjectedBundleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */; };
BC8FD8CA120E527F00F3E71A /* EventSendingController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8FD8C9120E527F00F3E71A /* EventSendingController.cpp */; };
BC8FD8D2120E545B00F3E71A /* JSEventSendingController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8FD8D0120E545B00F3E71A /* JSEventSendingController.cpp */; };
BC952C0D11F3B965003398B4 /* JSWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC952C0C11F3B965003398B4 /* JSWrapper.cpp */; };
BC7934DD119066EC005EA8E2 /* PlatformWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformWebView.h; sourceTree = "<group>"; };
BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformWebViewMac.mm; sourceTree = "<group>"; };
BC8C795B11D2785D004535A1 /* TestControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestControllerMac.mm; sourceTree = "<group>"; };
+ BC8DAD5B1315C0EC00EC96FC /* TestInvocationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestInvocationMac.mm; sourceTree = "<group>"; };
+ BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundleMac.mm; sourceTree = "<group>"; };
BC8FD8C8120E527F00F3E71A /* EventSendingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSendingController.h; sourceTree = "<group>"; };
BC8FD8C9120E527F00F3E71A /* EventSendingController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventSendingController.cpp; sourceTree = "<group>"; };
BC8FD8CB120E52B000F3E71A /* EventSendingController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventSendingController.idl; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
65EB859F11EC67CC0034D300 /* ActivateFonts.mm */,
+ BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */,
);
path = mac;
sourceTree = "<group>";
BC7933FF118F7C84005EA8E2 /* main.mm */,
BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
+ BC8DAD5B1315C0EC00EC96FC /* TestInvocationMac.mm */,
);
path = mac;
sourceTree = "<group>";
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
+ BC8DAD5D1315C0EC00EC96FC /* TestInvocationMac.mm in Sources */,
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
BC952F1F11F3C652003398B4 /* JSLayoutTestController.cpp in Sources */,
BC14E4DB120E02D000826C0C /* GCController.cpp in Sources */,
BC14E4EA120E03D800826C0C /* JSGCController.cpp in Sources */,
+ BC8DAD7B1316D91000EC96FC /* InjectedBundleMac.mm in Sources */,
BC8FD8CA120E527F00F3E71A /* EventSendingController.cpp in Sources */,
BC8FD8D2120E545B00F3E71A /* JSEventSendingController.cpp in Sources */,
C0CE720B1247C93300BC0EC4 /* LayoutTestControllerMac.mm in Sources */,
NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
m_window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
- [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]];
+ [m_window setColorSpace:[NSColorSpace genericRGBColorSpace]];
[[m_window contentView] addSubview:m_view];
[m_window orderBack:nil];
[m_window setAutodisplay:NO];
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "TestInvocation.h"
+
+#include "PlatformWebView.h"
+#include "TestController.h"
+#include <ImageIO/CGImageDestination.h>
+#include <LaunchServices/UTCoreTypes.h>
+#include <WebKit2/WKPage.h>
+#include <wtf/RetainPtr.h>
+
+#define COMMON_DIGEST_FOR_OPENSSL
+#include <CommonCrypto/CommonDigest.h>
+
+namespace WTR {
+
+static CGContextRef createCGContextFromPlatformView(PlatformWebView* platformWebView)
+{
+ WKView* view = platformWebView->platformView();
+ [view display];
+
+ NSSize webViewSize = [view frame].size;
+ size_t pixelsWide = static_cast<size_t>(webViewSize.width);
+ size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
+ size_t rowBytes = (4 * pixelsWide + 63) & ~63;
+ void* buffer = calloc(pixelsHigh, rowBytes);
+
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ CGContextRef context = CGBitmapContextCreate(buffer, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+ CGColorSpaceRelease(colorSpace);
+
+ CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque);
+ CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
+ CGImageRelease(image);
+
+ return context;
+}
+
+void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[33])
+{
+ ASSERT(CGBitmapContextGetBitsPerPixel(bitmapContext) == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
+ size_t pixelsHigh = CGBitmapContextGetHeight(bitmapContext);
+ size_t pixelsWide = CGBitmapContextGetWidth(bitmapContext);
+ size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
+
+ // We need to swap the bytes to ensure consistent hashes independently of endianness
+ MD5_CTX md5Context;
+ MD5_Init(&md5Context);
+ unsigned char* bitmapData = static_cast<unsigned char*>(CGBitmapContextGetData(bitmapContext));
+ if ((CGBitmapContextGetBitmapInfo(bitmapContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big) {
+ for (unsigned row = 0; row < pixelsHigh; row++) {
+ uint32_t buffer[pixelsWide];
+ for (unsigned column = 0; column < pixelsWide; column++)
+ buffer[column] = OSReadLittleInt32(bitmapData, 4 * column);
+ MD5_Update(&md5Context, buffer, 4 * pixelsWide);
+ bitmapData += bytesPerRow;
+ }
+ } else {
+ for (unsigned row = 0; row < pixelsHigh; row++) {
+ MD5_Update(&md5Context, bitmapData, 4 * pixelsWide);
+ bitmapData += bytesPerRow;
+ }
+ }
+
+ unsigned char hash[16];
+ MD5_Final(hash, &md5Context);
+
+ hashString[0] = '\0';
+ for (int i = 0; i < 16; i++)
+ snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
+}
+
+static void dumpBitmap(CGContextRef bitmapContext)
+{
+ 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());
+
+
+ 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;
+ }
+}
+
+static void forceRepaintFunction(WKErrorRef, void* context)
+{
+ *static_cast<bool*>(context) = true;
+}
+
+void TestInvocation::dumpPixelsAndCompareWithExpected()
+{
+ WKPageForceRepaint(TestController::shared().mainWebView()->page(), &m_gotRepaint, forceRepaintFunction);
+ TestController::shared().runUntil(m_gotRepaint, TestController::LongTimeout);
+
+ CGContextRef context = createCGContextFromPlatformView(TestController::shared().mainWebView());
+
+ // Compute the hash of the bitmap context pixels
+ char actualHash[33];
+ computeMD5HashStringForContext(context, actualHash);
+ fprintf(stdout, "\nActualHash: %s\n", actualHash);
+
+ // Check the computed hash against the expected one and dump image on mismatch
+ bool hashesMatch = false;
+ if (m_expectedPixelHash.length() > 0) {
+ ASSERT(m_expectedPixelHash.length() == 32);
+
+ fprintf(stdout, "\nExpectedHash: %s\n", m_expectedPixelHash.c_str());
+
+ // FIXME: Do case insensitive compare.
+ if (m_expectedPixelHash == actualHash)
+ hashesMatch = true;
+ }
+
+ if (!hashesMatch)
+ dumpBitmap(context);
+}
+
+} // namespace WTR
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "TestInvocation.h"
+
+namespace WTR {
+
+void TestInvocation::dumpPixelsAndCompareWithExpected()
+{
+}
+
+} // namespace WTR
main.cpp \
PlatformWebViewQt.cpp \
TestControllerQt.cpp \
+ TestInvocationQt.cpp \
$$BASEDIR/TestController.cpp \
$$BASEDIR/TestInvocation.cpp \
RelativePath="..\InjectedBundle\win\ActivateFonts.cpp"
>
</File>
+ <File
+ RelativePath="..\InjectedBundle\win\InjectedBundleWin.cpp"
+ >
+ </File>
<File
RelativePath="..\InjectedBundle\EventSendingController.cpp"
>
--- /dev/null
+/*
+ * Copyright (C) 2011 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "TestInvocation.h"
+
+namespace WTR {
+
+void TestInvocation::dumpPixelsAndCompareWithExpected()
+{
+}
+
+} // namespace WTR
RelativePath=".\TestControllerWin.cpp"
>
</File>
+ <File
+ RelativePath=".\TestInvocationWin.cpp"
+ >
+ </File>
</Filter>
<File
RelativePath="..\PlatformWebView.h"