summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/chromium/TestShell.cpp')
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.cpp111
1 files changed, 13 insertions, 98 deletions
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
index 4557803..15d6dee 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
@@ -35,8 +35,6 @@
#include "DRTDevToolsClient.h"
#include "LayoutTestController.h"
#include "WebViewHost.h"
-#include "base/string16.h"
-#include "gfx/codec/png_codec.h" // FIXME: Remove dependecy. WebCore/platform/image-encoder is better?
#include "public/WebDataSource.h"
#include "public/WebDocument.h"
#include "public/WebElement.h"
@@ -55,6 +53,7 @@
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/support/webkit_support.h"
+#include "webkit/support/webkit_support_gfx.h"
#include <algorithm>
#include <cctype>
#include <vector>
@@ -155,84 +154,8 @@ void TestShell::closeDevTools()
void TestShell::resetWebSettings(WebView& webView)
{
- // Match the settings used by Mac DumpRenderTree, with the exception of
- // fonts.
- WebSettings* settings = webView.settings();
-#if OS(MAC_OS_X)
- WebString serif = WebString::fromUTF8("Times");
- settings->setCursiveFontFamily(WebString::fromUTF8("Apple Chancery"));
- settings->setFantasyFontFamily(WebString::fromUTF8("Papyrus"));
-#else
- // NOTE: case matters here, this must be 'times new roman', else
- // some layout tests fail.
- WebString serif = WebString::fromUTF8("times new roman");
-
- // These two fonts are picked from the intersection of
- // Win XP font list and Vista font list :
- // http://www.microsoft.com/typography/fonts/winxp.htm
- // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx
- // Some of them are installed only with CJK and complex script
- // support enabled on Windows XP and are out of consideration here.
- // (although we enabled both on our buildbots.)
- // They (especially Impact for fantasy) are not typical cursive
- // and fantasy fonts, but it should not matter for layout tests
- // as long as they're available.
- settings->setCursiveFontFamily(WebString::fromUTF8("Comic Sans MS"));
- settings->setFantasyFontFamily(WebString::fromUTF8("Impact"));
-#endif
- settings->setSerifFontFamily(serif);
- settings->setStandardFontFamily(serif);
- settings->setFixedFontFamily(WebString::fromUTF8("Courier"));
- settings->setSansSerifFontFamily(WebString::fromUTF8("Helvetica"));
-
- settings->setDefaultTextEncodingName(WebString::fromUTF8("ISO-8859-1"));
- settings->setDefaultFontSize(16);
- settings->setDefaultFixedFontSize(13);
- settings->setMinimumFontSize(1);
- settings->setMinimumLogicalFontSize(9);
- settings->setJavaScriptCanOpenWindowsAutomatically(true);
- settings->setJavaScriptCanAccessClipboard(true);
- settings->setDOMPasteAllowed(true);
- settings->setDeveloperExtrasEnabled(false);
- settings->setNeedsSiteSpecificQuirks(true);
- settings->setShrinksStandaloneImagesToFit(false);
- settings->setUsesEncodingDetector(false);
- settings->setTextAreasAreResizable(false);
- settings->setJavaEnabled(false);
- settings->setAllowScriptsToCloseWindows(false);
- settings->setXSSAuditorEnabled(false);
- settings->setDownloadableBinaryFontsEnabled(true);
- settings->setLocalStorageEnabled(true);
- settings->setOfflineWebApplicationCacheEnabled(true);
- settings->setAllowFileAccessFromFileURLs(true);
- settings->setUserStyleSheetLocation(WebURL());
-
- // LayoutTests were written with Safari Mac in mind which does not allow
- // tabbing to links by default.
- webView.setTabsToLinks(false);
-
- // Allow those layout tests running as local files, i.e. under
- // LayoutTests/http/tests/local, to access http server.
- settings->setAllowUniversalAccessFromFileURLs(true);
-
- settings->setJavaScriptEnabled(true);
- settings->setPluginsEnabled(true);
- settings->setWebSecurityEnabled(true);
- settings->setEditableLinkBehaviorNeverLive();
- settings->setFontRenderingModeNormal();
- settings->setShouldPaintCustomScrollbars(true);
- settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
-
- settings->setLoadsImagesAutomatically(true);
- settings->setImagesEnabled(true);
-
-#if OS(DARWIN)
- settings->setEditingBehavior(WebSettings::EditingBehaviorMac);
-#else
- settings->setEditingBehavior(WebSettings::EditingBehaviorWin);
-#endif
- // FIXME: crbug.com/51879
- settings->setAcceleratedCompositingEnabled(false);
+ m_prefs.reset();
+ m_prefs.applyTo(&webView);
}
void TestShell::runFileTest(const TestParams& params)
@@ -244,7 +167,8 @@ void TestShell::runFileTest(const TestParams& params)
bool inspectorTestMode = testUrl.find("/inspector/") != string::npos
|| testUrl.find("\\inspector\\") != string::npos;
- m_webView->settings()->setDeveloperExtrasEnabled(inspectorTestMode);
+ m_prefs.developerExtrasEnabled = inspectorTestMode;
+ applyPreferences();
if (testUrl.find("loading/") != string::npos
|| testUrl.find("loading\\") != string::npos)
@@ -585,23 +509,15 @@ void TestShell::dumpImage(skia::PlatformCanvas* canvas) const
// to keep it. On Windows, the alpha channel is wrong since text/form control
// drawing may have erased it in a few places. So on Windows we force it to
// opaque and also don't write the alpha channel for the reference. Linux
- // doesn't have the wrong alpha like Windows, but we ignore it anyway.
-#if OS(WINDOWS)
- bool discardTransparency = true;
- device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height());
-#elif OS(MAC_OS_X)
+ // doesn't have the wrong alpha like Windows, but we match Windows.
+#if OS(MAC_OS_X)
bool discardTransparency = false;
-#elif OS(UNIX)
+#else
bool discardTransparency = true;
- if (areLayoutTestImagesOpaque())
- device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height());
+ device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height());
#endif
- // Compute MD5 sum. We should have done this before calling
- // device.makeOpaque on Windows. Because we do it after the call, there are
- // some images that are the pixel identical on windows and other platforms
- // but have different MD5 sums. At this point, rebaselining all the windows
- // tests is too much of a pain, so we just check in different baselines.
+ // Compute MD5 sum.
MD5 digester;
Vector<uint8_t, 16> digestValue;
digester.addBytes(reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels()), sourceBitmap.getSize());
@@ -619,10 +535,9 @@ void TestShell::dumpImage(skia::PlatformCanvas* canvas) const
// is really expensive.
if (md5hash.compare(m_params.pixelHash)) {
std::vector<unsigned char> png;
- gfx::PNGCodec::ColorFormat colorFormat = gfx::PNGCodec::FORMAT_BGRA;
- gfx::PNGCodec::Encode(
+ webkit_support::EncodeBGRAPNG(
reinterpret_cast<const unsigned char*>(sourceBitmap.getPixels()),
- colorFormat, sourceBitmap.width(), sourceBitmap.height(),
+ sourceBitmap.width(), sourceBitmap.height(),
static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, &png);
m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), &png[0], png.size(), m_params.pixelFileName.c_str());
@@ -649,7 +564,7 @@ WebViewHost* TestShell::createNewWindow(const WebURL& url)
WebViewHost* host = new WebViewHost(this);
WebView* view = WebView::create(host, m_drtDevToolsAgent.get());
host->setWebWidget(view);
- resetWebSettings(*view);
+ m_prefs.applyTo(view);
view->initializeMainFrame(host);
m_windowList.append(host);
host->loadURLForFrame(url, WebString());