diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 19:30:42 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 19:30:42 +0000 |
commit | 9be0aff3b6e0d6cb7ee6e24245ba34626c913d6b (patch) | |
tree | 751d2af19919f9d731a674d3758c227cd41433e6 /webkit/tools/test_shell/test_shell.cc | |
parent | cefd753bec867863c7902680cf4c85d28d82d0f6 (diff) | |
download | chromium_src-9be0aff3b6e0d6cb7ee6e24245ba34626c913d6b.zip chromium_src-9be0aff3b6e0d6cb7ee6e24245ba34626c913d6b.tar.gz chromium_src-9be0aff3b6e0d6cb7ee6e24245ba34626c913d6b.tar.bz2 |
* Dump text/image on notifyDone.
BUG=945322
Review URL: http://codereview.chromium.org/17459
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell.cc')
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 79 |
1 files changed, 69 insertions, 10 deletions
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index fac10d6..41bfd4ea 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -123,6 +123,7 @@ TestShell::TestShell() #if defined(OS_WIN) default_edit_wnd_proc_(0), #endif + test_params_(NULL), test_is_preparing_(false), test_is_pending_(false), is_modal_(false), @@ -183,6 +184,71 @@ static void UnitTestAssertHandler(const std::string& str) { } // static +void TestShell::Dump(TestShell* shell) { + const TestParams* params = NULL; + if ((shell == NULL) || ((params = shell->test_params()) == NULL)) + return; + + // Echo the url in the output so we know we're not getting out of sync. + printf("#URL:%s\n", params->test_url.c_str()); + + // Dump the requested representation. + WebFrame* webFrame = shell->webView()->GetMainFrame(); + if (webFrame) { + bool should_dump_as_text = + shell->layout_test_controller_->ShouldDumpAsText(); + bool dumped_anything = false; + if (params->dump_tree) { + dumped_anything = true; + // Text output: the test page can request different types of output + // which we handle here. + if (!should_dump_as_text) { + // Plain text pages should be dumped as text + std::wstring mime_type = + webFrame->GetDataSource()->GetResponseMimeType(); + should_dump_as_text = (mime_type == L"text/plain"); + } + if (should_dump_as_text) { + bool recursive = shell->layout_test_controller_-> + ShouldDumpChildFramesAsText(); + std::string data_utf8 = WideToUTF8( + webkit_glue::DumpFramesAsText(webFrame, recursive)); + if (fwrite(data_utf8.c_str(), 1, data_utf8.size(), stdout) != + data_utf8.size()) { + LOG(FATAL) << "Short write to stdout, disk full?"; + } + } else { + printf("%s", WideToUTF8( + webkit_glue::DumpRenderer(webFrame)).c_str()); + + bool recursive = shell->layout_test_controller_-> + ShouldDumpChildFrameScrollPositions(); + printf("%s", WideToUTF8( + webkit_glue::DumpFrameScrollPosition(webFrame, recursive)).c_str()); + } + + if (shell->layout_test_controller_->ShouldDumpBackForwardList()) { + std::wstring bfDump; + DumpBackForwardList(&bfDump); + printf("%s", WideToUTF8(bfDump).c_str()); + } + } + + if (params->dump_pixels && !should_dump_as_text) { + // Image output: we write the image data to the file given on the + // command line (for the dump pixels argument), and the MD5 sum to + // stdout. + dumped_anything = true; + std::string md5sum = DumpImage(webFrame, params->pixel_file_name); + printf("#MD5:%s\n", md5sum.c_str()); + } + if (dumped_anything) + printf("#EOF\n"); + fflush(stdout); + } +} + +// static std::string TestShell::DumpImage(WebFrame* web_frame, const std::wstring& file_name) { scoped_ptr<skia::BitmapPlatformDevice> device; @@ -284,19 +350,12 @@ void TestShell::SetAllowScriptsToCloseWindows() { void TestShell::ResetWebPreferences() { DCHECK(web_prefs_); - // Match the settings used by Mac DumpRenderTree, with the exception of - // fonts. + // Match the settings used by Mac DumpRenderTree. if (web_prefs_) { *web_prefs_ = WebPreferences(); -#if defined(OS_MACOSX) - web_prefs_->serif_font_family = L"Times"; -#else - // NOTE: case matters here, this must be 'times new roman', else some - // layout tests fail. - web_prefs_->serif_font_family = L"times new roman"; -#endif - web_prefs_->standard_font_family = web_prefs_->serif_font_family; + web_prefs_->standard_font_family = L"Times"; web_prefs_->fixed_font_family = L"Courier"; + web_prefs_->serif_font_family = L"Times"; web_prefs_->sans_serif_font_family = L"Helvetica"; // These two fonts are picked from the intersection of // Win XP font list and Vista font list : |