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_controller.h" | 5 #include "content/shell/webkit_test_controller.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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); | 245 PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); |
246 params.should_clear_history_list = true; | 246 params.should_clear_history_list = true; |
247 main_window_->web_contents()->GetController().LoadURLWithParams(params); | 247 main_window_->web_contents()->GetController().LoadURLWithParams(params); |
248 main_window_->web_contents()->GetView()->Focus(); | 248 main_window_->web_contents()->GetView()->Focus(); |
249 } | 249 } |
250 main_window_->web_contents()->GetRenderViewHost()->SetActive(true); | 250 main_window_->web_contents()->GetRenderViewHost()->SetActive(true); |
251 main_window_->web_contents()->GetRenderViewHost()->Focus(); | 251 main_window_->web_contents()->GetRenderViewHost()->Focus(); |
252 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout)) { | 252 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout)) { |
253 watchdog_.Reset(base::Bind(&WebKitTestController::TimeoutHandler, | 253 watchdog_.Reset(base::Bind(&WebKitTestController::TimeoutHandler, |
254 base::Unretained(this))); | 254 base::Unretained(this))); |
255 MessageLoop::current()->PostDelayedTask( | 255 base::MessageLoop::current()->PostDelayedTask( |
256 FROM_HERE, | 256 FROM_HERE, |
257 watchdog_.callback(), | 257 watchdog_.callback(), |
258 base::TimeDelta::FromMilliseconds(kTestTimeoutMilliseconds + 1000)); | 258 base::TimeDelta::FromMilliseconds(kTestTimeoutMilliseconds + 1000)); |
259 } | 259 } |
260 return true; | 260 return true; |
261 } | 261 } |
262 | 262 |
263 bool WebKitTestController::ResetAfterLayoutTest() { | 263 bool WebKitTestController::ResetAfterLayoutTest() { |
264 DCHECK(CalledOnValidThread()); | 264 DCHECK(CalledOnValidThread()); |
265 printer_->PrintTextFooter(); | 265 printer_->PrintTextFooter(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 DiscardMainWindow(); | 417 DiscardMainWindow(); |
418 } | 418 } |
419 | 419 |
420 void WebKitTestController::DiscardMainWindow() { | 420 void WebKitTestController::DiscardMainWindow() { |
421 // If we're running a test, we need to close all windows and exit the message | 421 // If we're running a test, we need to close all windows and exit the message |
422 // loop. Otherwise, we're already outside of the message loop, and we just | 422 // loop. Otherwise, we're already outside of the message loop, and we just |
423 // discard the main window. | 423 // discard the main window. |
424 WebContentsObserver::Observe(NULL); | 424 WebContentsObserver::Observe(NULL); |
425 if (is_running_test_) { | 425 if (is_running_test_) { |
426 Shell::CloseAllWindows(); | 426 Shell::CloseAllWindows(); |
427 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 427 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 428 base::MessageLoop::QuitClosure()); |
428 } else if (main_window_) { | 429 } else if (main_window_) { |
429 main_window_->Close(); | 430 main_window_->Close(); |
430 } | 431 } |
431 main_window_ = NULL; | 432 main_window_ = NULL; |
432 current_pid_ = base::kNullProcessId; | 433 current_pid_ = base::kNullProcessId; |
433 } | 434 } |
434 | 435 |
435 void WebKitTestController::SendTestConfiguration() { | 436 void WebKitTestController::SendTestConfiguration() { |
436 RenderViewHost* render_view_host = | 437 RenderViewHost* render_view_host = |
437 main_window_->web_contents()->GetRenderViewHost(); | 438 main_window_->web_contents()->GetRenderViewHost(); |
(...skipping 18 matching lines...) Expand all Loading... |
456 if (did_timeout) { | 457 if (did_timeout) { |
457 printer_->AddErrorMessage( | 458 printer_->AddErrorMessage( |
458 "FAIL: Timed out waiting for notifyDone to be called"); | 459 "FAIL: Timed out waiting for notifyDone to be called"); |
459 DiscardMainWindow(); | 460 DiscardMainWindow(); |
460 return; | 461 return; |
461 } | 462 } |
462 if (!printer_->output_finished()) | 463 if (!printer_->output_finished()) |
463 printer_->PrintImageFooter(); | 464 printer_->PrintImageFooter(); |
464 RenderViewHost* render_view_host = | 465 RenderViewHost* render_view_host = |
465 main_window_->web_contents()->GetRenderViewHost(); | 466 main_window_->web_contents()->GetRenderViewHost(); |
466 MessageLoop::current()->PostTask( | 467 base::MessageLoop::current()->PostTask( |
467 FROM_HERE, | 468 FROM_HERE, |
468 base::Bind(base::IgnoreResult(&WebKitTestController::Send), | 469 base::Bind(base::IgnoreResult(&WebKitTestController::Send), |
469 base::Unretained(this), | 470 base::Unretained(this), |
470 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); | 471 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); |
471 } | 472 } |
472 | 473 |
473 void WebKitTestController::OnImageDump( | 474 void WebKitTestController::OnImageDump( |
474 const std::string& actual_pixel_hash, | 475 const std::string& actual_pixel_hash, |
475 const SkBitmap& image) { | 476 const SkBitmap& image) { |
476 SkAutoLockPixels image_lock(image); | 477 SkAutoLockPixels image_lock(image); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 current_entry_indexes)); | 602 current_entry_indexes)); |
602 } | 603 } |
603 | 604 |
604 void WebKitTestController::OnCloseRemainingWindows() { | 605 void WebKitTestController::OnCloseRemainingWindows() { |
605 DevToolsManager::GetInstance()->CloseAllClientHosts(); | 606 DevToolsManager::GetInstance()->CloseAllClientHosts(); |
606 std::vector<Shell*> open_windows(Shell::windows()); | 607 std::vector<Shell*> open_windows(Shell::windows()); |
607 for (size_t i = 0; i < open_windows.size(); ++i) { | 608 for (size_t i = 0; i < open_windows.size(); ++i) { |
608 if (open_windows[i] != main_window_) | 609 if (open_windows[i] != main_window_) |
609 open_windows[i]->Close(); | 610 open_windows[i]->Close(); |
610 } | 611 } |
611 MessageLoop::current()->RunUntilIdle(); | 612 base::MessageLoop::current()->RunUntilIdle(); |
612 } | 613 } |
613 | 614 |
614 void WebKitTestController::OnResetDone() { | 615 void WebKitTestController::OnResetDone() { |
615 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 616 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 617 base::MessageLoop::QuitClosure()); |
616 } | 618 } |
617 | 619 |
618 } // namespace content | 620 } // namespace content |
OLD | NEW |