| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/webkit_test_runner_host.h" | 5 #include "content/shell/webkit_test_runner_host.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (state_ != IN_IMAGE_BLOCK) | 86 if (state_ != IN_IMAGE_BLOCK) |
| 87 return; | 87 return; |
| 88 if (!capture_text_only_) { | 88 if (!capture_text_only_) { |
| 89 *output_ << "#EOF\n"; | 89 *output_ << "#EOF\n"; |
| 90 output_->flush(); | 90 output_->flush(); |
| 91 } | 91 } |
| 92 state_ = AFTER_TEST; | 92 state_ = AFTER_TEST; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WebKitTestResultPrinter::AddMessage(const std::string& message) { | 95 void WebKitTestResultPrinter::AddMessage(const std::string& message) { |
| 96 AddMessageRaw(message + "\n"); |
| 97 } |
| 98 |
| 99 void WebKitTestResultPrinter::AddMessageRaw(const std::string& message) { |
| 96 if (state_ != IN_TEXT_BLOCK) | 100 if (state_ != IN_TEXT_BLOCK) |
| 97 return; | 101 return; |
| 98 *output_ << message << "\n"; | 102 *output_ << message; |
| 99 } | 103 } |
| 100 | 104 |
| 101 void WebKitTestResultPrinter::AddErrorMessage(const std::string& message) { | 105 void WebKitTestResultPrinter::AddErrorMessage(const std::string& message) { |
| 102 if (state_ != IN_TEXT_BLOCK) | 106 if (state_ != IN_TEXT_BLOCK) |
| 103 return; | 107 return; |
| 104 *output_ << message << "\n"; | 108 *output_ << message << "\n"; |
| 105 if (!capture_text_only_) | 109 if (!capture_text_only_) |
| 106 *error_ << message << "\n"; | 110 *error_ << message << "\n"; |
| 107 PrintTextFooter(); | 111 PrintTextFooter(); |
| 108 PrintImageFooter(); | 112 PrintImageFooter(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 printer_->PrintTextHeader(); | 149 printer_->PrintTextHeader(); |
| 146 content::ShellBrowserContext* browser_context = | 150 content::ShellBrowserContext* browser_context = |
| 147 static_cast<content::ShellContentBrowserClient*>( | 151 static_cast<content::ShellContentBrowserClient*>( |
| 148 content::GetContentClient()->browser())->browser_context(); | 152 content::GetContentClient()->browser())->browser_context(); |
| 149 main_window_ = content::Shell::CreateNewWindow( | 153 main_window_ = content::Shell::CreateNewWindow( |
| 150 browser_context, | 154 browser_context, |
| 151 test_url, | 155 test_url, |
| 152 NULL, | 156 NULL, |
| 153 MSG_ROUTING_NONE, | 157 MSG_ROUTING_NONE, |
| 154 NULL); | 158 NULL); |
| 159 did_set_as_main_window_ = false; |
| 155 Observe(main_window_->web_contents()); | 160 Observe(main_window_->web_contents()); |
| 156 return true; | 161 return true; |
| 157 } | 162 } |
| 158 | 163 |
| 159 bool WebKitTestController::ResetAfterLayoutTest() { | 164 bool WebKitTestController::ResetAfterLayoutTest() { |
| 160 DCHECK(CalledOnValidThread()); | 165 DCHECK(CalledOnValidThread()); |
| 161 printer_->PrintTextFooter(); | 166 printer_->PrintTextFooter(); |
| 162 printer_->PrintImageFooter(); | 167 printer_->PrintImageFooter(); |
| 163 enable_pixel_dumping_ = false; | 168 enable_pixel_dumping_ = false; |
| 164 expected_pixel_hash_.clear(); | 169 expected_pixel_hash_.clear(); |
| 165 captured_dump_ = false; | 170 captured_dump_ = false; |
| 166 dump_as_text_ = false; | 171 dump_as_text_ = false; |
| 167 dump_child_frames_ = false; | 172 dump_child_frames_ = false; |
| 168 is_printing_ = false; | 173 is_printing_ = false; |
| 169 should_stay_on_page_after_handling_before_unload_ = false; | 174 should_stay_on_page_after_handling_before_unload_ = false; |
| 170 wait_until_done_ = false; | 175 wait_until_done_ = false; |
| 176 did_set_as_main_window_ = false; |
| 171 watchdog_.Cancel(); | 177 watchdog_.Cancel(); |
| 172 if (main_window_) { | 178 if (main_window_) { |
| 173 Observe(NULL); | 179 Observe(NULL); |
| 174 main_window_ = NULL; | 180 main_window_ = NULL; |
| 175 } | 181 } |
| 176 Shell::CloseAllWindows(); | 182 Shell::CloseAllWindows(); |
| 183 Send(new ShellViewMsg_ResetAll); |
| 177 return true; | 184 return true; |
| 178 } | 185 } |
| 179 | 186 |
| 180 void WebKitTestController::RendererUnresponsive() { | 187 void WebKitTestController::RendererUnresponsive() { |
| 181 printer_->AddErrorMessage("#PROCESS UNRESPONSIVE - renderer"); | 188 printer_->AddErrorMessage("#PROCESS UNRESPONSIVE - renderer"); |
| 182 } | 189 } |
| 183 | 190 |
| 184 void WebKitTestController::NotifyDone() { | 191 void WebKitTestController::NotifyDone() { |
| 185 if (!wait_until_done_) | 192 if (!wait_until_done_) |
| 186 return; | 193 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 207 const std::string& property_name) { | 214 const std::string& property_name) { |
| 208 printer_->AddErrorMessage( | 215 printer_->AddErrorMessage( |
| 209 std::string("FAIL: NOT IMPLEMENTED: ") + | 216 std::string("FAIL: NOT IMPLEMENTED: ") + |
| 210 object_name + "." + property_name); | 217 object_name + "." + property_name); |
| 211 } | 218 } |
| 212 | 219 |
| 213 bool WebKitTestController::OnMessageReceived(const IPC::Message& message) { | 220 bool WebKitTestController::OnMessageReceived(const IPC::Message& message) { |
| 214 bool handled = true; | 221 bool handled = true; |
| 215 IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message) | 222 IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message) |
| 216 IPC_MESSAGE_HANDLER(ShellViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 223 IPC_MESSAGE_HANDLER(ShellViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 224 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) |
| 217 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) | 225 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) |
| 218 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) | 226 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) |
| 219 IPC_MESSAGE_UNHANDLED(handled = false) | 227 IPC_MESSAGE_UNHANDLED(handled = false) |
| 220 IPC_END_MESSAGE_MAP() | 228 IPC_END_MESSAGE_MAP() |
| 221 | 229 |
| 222 return handled; | 230 return handled; |
| 223 } | 231 } |
| 224 | 232 |
| 225 void WebKitTestController::PluginCrashed(const FilePath& plugin_path) { | 233 void WebKitTestController::PluginCrashed(const FilePath& plugin_path) { |
| 226 printer_->AddErrorMessage("#CRASHED - plugin"); | 234 printer_->AddErrorMessage("#CRASHED - plugin"); |
| 227 } | 235 } |
| 228 | 236 |
| 237 void WebKitTestController::RenderViewReady() { |
| 238 if (did_set_as_main_window_) |
| 239 return; |
| 240 RenderViewHost* render_view_host = |
| 241 main_window_->web_contents()->GetRenderViewHost(); |
| 242 render_view_host->Send(new ShellViewMsg_SetIsMainWindow( |
| 243 render_view_host->GetRoutingID())); |
| 244 did_set_as_main_window_ = true; |
| 245 } |
| 246 |
| 229 void WebKitTestController::RenderViewGone(base::TerminationStatus status) { | 247 void WebKitTestController::RenderViewGone(base::TerminationStatus status) { |
| 230 printer_->AddErrorMessage("#CRASHED - renderer"); | 248 printer_->AddErrorMessage("#CRASHED - renderer"); |
| 231 } | 249 } |
| 232 | 250 |
| 233 void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) { | 251 void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) { |
| 234 main_window_ = NULL; | 252 main_window_ = NULL; |
| 235 printer_->AddErrorMessage("FAIL: main window was destroyed"); | 253 printer_->AddErrorMessage("FAIL: main window was destroyed"); |
| 236 } | 254 } |
| 237 | 255 |
| 238 void WebKitTestController::CaptureDump() { | 256 void WebKitTestController::CaptureDump() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 332 |
| 315 void WebKitTestController::OnTextDump(const std::string& dump) { | 333 void WebKitTestController::OnTextDump(const std::string& dump) { |
| 316 printer_->PrintTextBlock(dump); | 334 printer_->PrintTextBlock(dump); |
| 317 printer_->PrintTextFooter(); | 335 printer_->PrintTextFooter(); |
| 318 if (dump_as_text_ || !enable_pixel_dumping_) { | 336 if (dump_as_text_ || !enable_pixel_dumping_) { |
| 319 printer_->PrintImageFooter(); | 337 printer_->PrintImageFooter(); |
| 320 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 338 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 321 } | 339 } |
| 322 } | 340 } |
| 323 | 341 |
| 342 void WebKitTestController::OnPrintMessage(const std::string& message) { |
| 343 printer_->AddMessageRaw(message); |
| 344 } |
| 345 |
| 324 // WebKitTestRunnerHost ------------------------------------------------------- | 346 // WebKitTestRunnerHost ------------------------------------------------------- |
| 325 | 347 |
| 326 WebKitTestRunnerHost::WebKitTestRunnerHost( | 348 WebKitTestRunnerHost::WebKitTestRunnerHost( |
| 327 RenderViewHost* render_view_host) | 349 RenderViewHost* render_view_host) |
| 328 : RenderViewHostObserver(render_view_host) { | 350 : RenderViewHostObserver(render_view_host) { |
| 329 } | 351 } |
| 330 | 352 |
| 331 WebKitTestRunnerHost::~WebKitTestRunnerHost() { | 353 WebKitTestRunnerHost::~WebKitTestRunnerHost() { |
| 332 } | 354 } |
| 333 | 355 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 WebKitTestController::Get()->WaitUntilDone(); | 400 WebKitTestController::Get()->WaitUntilDone(); |
| 379 } | 401 } |
| 380 | 402 |
| 381 void WebKitTestRunnerHost::OnNotImplemented( | 403 void WebKitTestRunnerHost::OnNotImplemented( |
| 382 const std::string& object_name, | 404 const std::string& object_name, |
| 383 const std::string& property_name) { | 405 const std::string& property_name) { |
| 384 WebKitTestController::Get()->NotImplemented(object_name, property_name); | 406 WebKitTestController::Get()->NotImplemented(object_name, property_name); |
| 385 } | 407 } |
| 386 | 408 |
| 387 } // namespace content | 409 } // namespace content |
| OLD | NEW |