diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/chromium/TestShell.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/chromium/TestShell.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 29bd596..761f8d1 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -75,10 +75,11 @@ static const char fileTestPrefix[] = "(file test):"; static const char dataUrlPattern[] = "data:"; static const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1; -TestShell::TestShell() +TestShell::TestShell(bool testShellMode) : m_testIsPending(false) , m_testIsPreparing(false) , m_focusedWidget(0) + , m_testShellMode(testShellMode) { WebRuntimeFeatures::enableGeolocation(true); m_accessibilityController.set(new AccessibilityController(this)); @@ -87,6 +88,13 @@ TestShell::TestShell() m_plainTextController.set(new PlainTextController()); m_textInputController.set(new TextInputController(this)); m_notificationPresenter.set(new NotificationPresenter(this)); + m_printer.set(m_testShellMode ? TestEventPrinter::createTestShellPrinter() : TestEventPrinter::createDRTPrinter()); + + // 30 second is the same as the value in Mac DRT. + // If we use a value smaller than the timeout value of + // (new-)run-webkit-tests, (new-)run-webkit-tests misunderstands that a + // timed-out DRT process was crashed. + m_timeout = 30 * 1000; m_webViewHost = createWebView(); m_webView = m_webViewHost->webView(); @@ -174,6 +182,12 @@ void TestShell::resetWebSettings(WebView& webView) settings->setLoadsImagesAutomatically(true); settings->setImagesEnabled(true); + +#if OS(DARWIN) + settings->setEditingBehavior(WebSettings::EditingBehaviorMac); +#else + settings->setEditingBehavior(WebSettings::EditingBehaviorWin); +#endif } void TestShell::runFileTest(const TestParams& params) @@ -186,6 +200,7 @@ void TestShell::runFileTest(const TestParams& params) bool inspectorTestMode = testUrl.find("/inspector/") != string::npos || testUrl.find("\\inspector\\") != string::npos; m_webView->settings()->setDeveloperExtrasEnabled(inspectorTestMode); + m_printer->handleTestHeader(testUrl.c_str()); loadURL(m_params.testUrl); m_testIsPreparing = false; @@ -277,8 +292,7 @@ void TestShell::testFinished() void TestShell::testTimedOut() { - fprintf(stderr, "FAIL: Timed out waiting for notifyDone to be called\n"); - fprintf(stdout, "FAIL: Timed out waiting for notifyDone to be called\n"); + m_printer->handleTimedOut(); testFinished(); } @@ -428,7 +442,7 @@ void TestShell::dump() bool dumpedAnything = false; if (m_params.dumpTree) { dumpedAnything = true; - printf("Content-Type: text/plain\n"); + m_printer->handleTextHeader(); // Text output: the test page can request different types of output // which we handle here. if (!shouldDumpAsText) { @@ -450,7 +464,7 @@ void TestShell::dump() printf("%s", dumpAllBackForwardLists().c_str()); } if (dumpedAnything && m_params.printSeparators) - printf("#EOF\n"); + m_printer->handleTextFooter(); if (m_params.dumpPixels && !shouldDumpAsText) { // Image output: we write the image data to the file given on the @@ -491,14 +505,15 @@ void TestShell::dump() } } - string md5sum = dumpImage(m_webViewHost->canvas(), m_params.pixelHash); + dumpImage(m_webViewHost->canvas()); } - printf("#EOF\n"); // For the image. + m_printer->handleImageFooter(); + m_printer->handleTestFooter(dumpedAnything); fflush(stdout); fflush(stderr); } -string TestShell::dumpImage(skia::PlatformCanvas* canvas, const string& expectedHash) +void TestShell::dumpImage(skia::PlatformCanvas* canvas) const { skia::BitmapPlatformDevice& device = static_cast<skia::BitmapPlatformDevice&>(canvas->getTopPlatformDevice()); @@ -532,13 +547,10 @@ string TestShell::dumpImage(skia::PlatformCanvas* canvas, const string& expected MD5Digest digest; MD5Final(&digest, &ctx); string md5hash = MD5DigestToBase16(digest); - printf("\nActualHash: %s\n", md5hash.c_str()); - if (!expectedHash.empty()) - printf("\nExpectedHash: %s\n", expectedHash.c_str()); // Only encode and dump the png if the hashes don't match. Encoding the image // is really expensive. - if (md5hash.compare(expectedHash)) { + if (md5hash.compare(m_params.pixelHash)) { std::vector<unsigned char> png; gfx::PNGCodec::ColorFormat colorFormat = gfx::PNGCodec::FORMAT_BGRA; gfx::PNGCodec::Encode( @@ -546,14 +558,9 @@ string TestShell::dumpImage(skia::PlatformCanvas* canvas, const string& expected colorFormat, sourceBitmap.width(), sourceBitmap.height(), static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, &png); - printf("Content-Type: image/png\n"); - printf("Content-Length: %lu\n", png.size()); - // Write to disk. - if (fwrite(&png[0], 1, png.size(), stdout) != png.size()) - FATAL("Short write to stdout.\n"); - } - - return md5hash; + m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), &png[0], png.size(), m_params.pixelFileName.c_str()); + } else + m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), 0, 0, m_params.pixelFileName.c_str()); } void TestShell::bindJSObjectsToWindow(WebFrame* frame) @@ -565,15 +572,6 @@ void TestShell::bindJSObjectsToWindow(WebFrame* frame) m_textInputController->bindToJavascript(frame, WebString::fromUTF8("textInputController")); } -int TestShell::layoutTestTimeout() -{ - // 30 second is the same as the value in Mac DRT. - // If we use a value smaller than the timeout value of - // (new-)run-webkit-tests, (new-)run-webkit-tests misunderstands that a - // timed-out DRT process was crashed. - return 30 * 1000; -} - WebViewHost* TestShell::createWebView() { return createNewWindow(WebURL()); @@ -599,6 +597,8 @@ void TestShell::closeWindow(WebViewHost* window) return; } m_windowList.remove(i); + if (window->webWidget() == m_focusedWidget) + m_focusedWidget = 0; window->webWidget()->close(); delete window; } |