diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 20:33:13 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 20:33:13 +0000 |
commit | 2d94501adce21884e71b2915e5d2e290b9cb2a30 (patch) | |
tree | a8aa42cf599b63e271ff049c69465733d300f925 | |
parent | 26567568e8288f75e4db35ce85e1b8b843683880 (diff) | |
download | chromium_src-2d94501adce21884e71b2915e5d2e290b9cb2a30.zip chromium_src-2d94501adce21884e71b2915e5d2e290b9cb2a30.tar.gz chromium_src-2d94501adce21884e71b2915e5d2e290b9cb2a30.tar.bz2 |
Revert "* Dump text/image on notifyDone."
Review URL: http://codereview.chromium.org/18330
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8209 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/tools/test_shell/mac/main.mm | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | webkit/tools/test_shell/test_shell.cc | 66 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 26 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 73 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_mac.mm | 84 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | webkit/tools/test_shell/test_shell_win.cc | 73 |
7 files changed, 199 insertions, 136 deletions
diff --git a/webkit/tools/test_shell/mac/main.mm b/webkit/tools/test_shell/mac/main.mm index 91b33f3..0bb6c70 100644 --- a/webkit/tools/test_shell/mac/main.mm +++ b/webkit/tools/test_shell/mac/main.mm @@ -321,13 +321,11 @@ int main(const int argc, const char *argv[]) { continue; SetCurrentTestName(filenameBuffer); - params.test_url = filenameBuffer; - if (!TestShell::RunFileTest(params)) + if (!TestShell::RunFileTest(filenameBuffer, params)) break; } } else { - params.test_url = WideToUTF8(uri).c_str(); - TestShell::RunFileTest(params); + TestShell::RunFileTest(WideToUTF8(uri).c_str(), params); } } else { main_message_loop.Run(); diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index b26d802..41d2140 100644..100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -123,7 +123,6 @@ 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), @@ -184,71 +183,6 @@ 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; diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 699106f..79ab497 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -64,8 +64,6 @@ public: // Filename we dump pixels to (when pixel testing is enabled). std::wstring pixel_file_name; - // URL of the test. - std::string test_url; }; TestShell(); @@ -196,19 +194,14 @@ public: // window JavaScript objects so they can be accessed by layout tests. virtual void BindJSObjectsToWindow(WebFrame* frame); - // Runs a layout test. Loads a single file (specified in params.test_url) - // into the first available window, then dumps the requested text - // representation to stdout. Returns false if the test cannot be run - // because no windows are open. - static bool RunFileTest(const TestParams& params); + // Runs a layout test. Loads a single file into the first available + // window, then dumps the requested text representation to stdout. + // Returns false if the test cannot be run because no windows are open. + static bool RunFileTest(const char* filename, const TestParams& params); // Writes the back-forward list data for every open window into result. static void DumpBackForwardList(std::wstring* result); - // Dumps the output from given test as text and/or image depending on - // the flags set. - static void Dump(TestShell* shell); - // Writes the image captured from the given web frame to the given file. // The returned string is the ASCII-ized MD5 sum of the image. static std::string DumpImage(WebFrame* web_frame, @@ -251,11 +244,6 @@ public: void set_is_modal(bool value) { is_modal_ = value; } bool is_modal() const { return is_modal_; } - const TestParams* test_params() { return test_params_; } - void set_test_params(const TestParams* test_params) { - test_params_ = test_params; - } - #if defined(OS_MACOSX) // handle cleaning up a shell given the associated window static void DestroyAssociatedShell(gfx::NativeWindow handle); @@ -299,8 +287,8 @@ private: // A set of all our windows. static WindowList* window_list_; #if defined(OS_MACOSX) - typedef std::map<gfx::NativeWindow, TestShell *> WindowMap; - static base::LazyInstance<WindowMap> window_map_; + static base::LazyInstance<std::map<gfx::NativeWindow, TestShell *> > + window_map_; #endif #if defined(OS_WIN) @@ -323,8 +311,6 @@ private: scoped_refptr<TestWebViewDelegate> delegate_; - const TestParams* test_params_; - // True while a test is preparing to run bool test_is_preparing_; diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index b5d42eb..72f2f82 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -115,7 +115,6 @@ void TestShell::InitializeTestShell(bool layout_test_mode) { "/usr/share/fonts/truetype/ttf-lucida/LucidaSansRegular.ttf", "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", - "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", }; for (size_t i = 0; i < arraysize(optional_fonts); ++i) { const char* font = optional_fonts[i]; @@ -340,10 +339,6 @@ void TestShell::TestFinished() { return; test_is_pending_ = false; - GtkWidget* window = *(TestShell::windowList()->begin()); - TestShell* shell = static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), - "test-shell")); - TestShell::Dump(shell); MessageLoop::current()->Quit(); } @@ -440,7 +435,8 @@ void TestShell::ResizeSubViews() { } } -/* static */ bool TestShell::RunFileTest(const TestParams& params) { +/* static */ bool TestShell::RunFileTest(const char *filename, + const TestParams& params) { // Load the test file into the first available window. if (TestShell::windowList()->empty()) { LOG(ERROR) << "No windows open."; @@ -476,19 +472,74 @@ void TestShell::ResizeSubViews() { shell->ResizeSubViews(); - if (strstr(params.test_url.c_str(), "loading/") || - strstr(params.test_url.c_str(), "loading\\")) + if (strstr(filename, "loading/") || strstr(filename, "loading\\")) shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); shell->test_is_preparing_ = true; - shell->set_test_params(¶ms); - std::wstring wstr = UTF8ToWide(params.test_url.c_str()); + const std::wstring wstr = UTF8ToWide(filename); shell->LoadURL(wstr.c_str()); shell->test_is_preparing_ = false; shell->WaitTestFinished(); - shell->set_test_params(NULL); + + // Echo the url in the output so we know we're not getting out of sync. + printf("#URL:%s\n", filename); + + // 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); + } return true; } diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 4e6cf75..47fd8a3 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -110,11 +110,10 @@ void TestShell::PlatformCleanUp() { // static void TestShell::DestroyAssociatedShell(gfx::NativeWindow handle) { - WindowMap::iterator it = window_map_.Get().find(handle); - if (it != window_map_.Get().end()) { - delete it->second; + TestShell* shell = window_map_.Get()[handle]; + if (shell) window_map_.Get().erase(handle); - } + delete shell; } // static @@ -514,10 +513,6 @@ void TestShell::TestFinished() { return; // reached when running under test_shell_tests test_is_pending_ = false; - NSWindow* window = *(TestShell::windowList()->begin()); - WindowMap::iterator it = window_map_.Get().find(window); - if (it != window_map_.Get().end()) - TestShell::Dump(it->second); MessageLoop::current()->Quit(); } @@ -637,7 +632,6 @@ bool TestShell::CreateNewWindow(const std::wstring& startingURL, // static void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { TestShell::RemoveWindowFromList(windowHandle); - TestShell::DestroyAssociatedShell(windowHandle); [windowHandle close]; } @@ -673,13 +667,14 @@ void TestShell::ResizeSubViews() { for (WindowList::iterator iter = TestShell::windowList()->begin(); iter != TestShell::windowList()->end(); iter++) { NSWindow* window = *iter; - WindowMap::iterator it = window_map_.Get().find(window); - if (it != window_map_.Get().end()) - webkit_glue::DumpBackForwardList(it->second->webView(), NULL, result); + TestShell* shell = window_map_.Get()[window]; + if (shell) + webkit_glue::DumpBackForwardList(shell->webView(), NULL, result); } } -/* static */ bool TestShell::RunFileTest(const TestParams& params) { +/* static */ bool TestShell::RunFileTest(const char* filename, + const TestParams& params) { // Load the test file into the first available window. if (TestShell::windowList()->empty()) { LOG(ERROR) << "No windows open."; @@ -714,18 +709,71 @@ void TestShell::ResizeSubViews() { [shell->m_mainWnd orderOut:nil]; shell->ResizeSubViews(); - if (strstr(params.test_url.c_str(), "loading/")) + if (strstr(filename, "loading/")) shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); shell->test_is_preparing_ = true; - shell->set_test_params(¶ms); - std::wstring wstr = UTF8ToWide(params.test_url.c_str()); - shell->LoadURL(wstr.c_str()); + shell->LoadURL(UTF8ToWide(filename).c_str()); shell->test_is_preparing_ = false; shell->WaitTestFinished(); - shell->set_test_params(NULL); + + // Echo the url in the output so we know we're not getting out of sync. + printf("#URL:%s\n", filename); + + // 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::string mime_type = + WideToUTF8(webFrame->GetDataSource()->GetResponseMimeType()); + should_dump_as_text = (mime_type == "text/plain"); + } + if (should_dump_as_text) { + bool recursive = shell->layout_test_controller_-> + ShouldDumpChildFramesAsText(); + printf("%s", WideToUTF8( + webkit_glue::DumpFramesAsText(webFrame, recursive)). + c_str()); + } 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); + } return true; } diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 19199e0..b2f9830 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -370,13 +370,12 @@ int main(int argc, char* argv[]) { if (!*filenameBuffer) continue; - params.test_url = filenameBuffer; - if (!TestShell::RunFileTest(params)) + + if (!TestShell::RunFileTest(filenameBuffer, params)) break; } } else { - params.test_url = WideToUTF8(uri).c_str(); - TestShell::RunFileTest(params); + TestShell::RunFileTest(WideToUTF8(uri).c_str(), params); } shell->CallJSGC(); diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 72ad7f2..1dec4db 100755..100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -204,8 +204,8 @@ void TestShell::DumpBackForwardList(std::wstring* result) { } } -bool TestShell::RunFileTest(const TestParams& params) { - SetCurrentTestName(params.test_url.c_str()); +bool TestShell::RunFileTest(const char *filename, const TestParams& params) { + SetCurrentTestName(filename); // Load the test file into the first available window. if (TestShell::windowList()->empty()) { @@ -241,19 +241,71 @@ bool TestShell::RunFileTest(const TestParams& params) { SWP_NOSIZE | SWP_NOZORDER); shell->ResizeSubViews(); - if (strstr(params.test_url.c_str(), "loading/") || - strstr(params.test_url.c_str(), "loading\\")) + if (strstr(filename, "loading/") || strstr(filename, "loading\\")) shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); shell->test_is_preparing_ = true; - shell->set_test_params(¶ms); - std::wstring wstr = UTF8ToWide(params.test_url.c_str()); + + std::wstring wstr = UTF8ToWide(filename); shell->LoadURL(wstr.c_str()); shell->test_is_preparing_ = false; shell->WaitTestFinished(); - shell->set_test_params(NULL); + // Echo the url in the output so we know we're not getting out of sync. + printf("#URL:%s\n", filename); + + // 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)); + fwrite(data_utf8.c_str(), 1, data_utf8.size(), stdout); + } 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); + } return true; } @@ -364,15 +416,10 @@ void TestShell::TestFinished() { if (!test_is_pending_) return; // reached when running under test_shell_tests - test_is_pending_ = false; - HWND hwnd = *(TestShell::windowList()->begin()); - TestShell* shell = - static_cast<TestShell*>(win_util::GetWindowUserData(hwnd)); - TestShell::Dump(shell); - UINT_PTR timer_id = reinterpret_cast<UINT_PTR>(this); KillTimer(mainWnd(), timer_id); + test_is_pending_ = false; MessageLoop::current()->Quit(); } |