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 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/render_widget_host_view.h" | 23 #include "content/public/browser/render_widget_host_view.h" |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 #include "content/public/browser/web_contents_view.h" | 25 #include "content/public/browser/web_contents_view.h" |
26 #include "content/shell/common/shell_messages.h" | 26 #include "content/shell/common/shell_messages.h" |
27 #include "content/shell/common/shell_switches.h" | 27 #include "content/shell/common/shell_switches.h" |
28 #include "content/shell/common/webkit_test_helpers.h" | 28 #include "content/shell/common/webkit_test_helpers.h" |
29 #include "content/shell/shell.h" | 29 #include "content/shell/shell.h" |
30 #include "content/shell/shell_browser_context.h" | 30 #include "content/shell/shell_browser_context.h" |
31 #include "content/shell/shell_content_browser_client.h" | 31 #include "content/shell/shell_content_browser_client.h" |
32 #include "webkit/glue/glue_serialize.h" | |
33 #include "webkit/support/webkit_support_gfx.h" | 32 #include "webkit/support/webkit_support_gfx.h" |
34 | 33 |
35 namespace content { | 34 namespace content { |
36 | 35 |
37 const int kTestTimeoutMilliseconds = 30 * 1000; | 36 const int kTestTimeoutMilliseconds = 30 * 1000; |
38 // 0x20000000ms is big enough for the purpose to avoid timeout in debugging. | 37 // 0x20000000ms is big enough for the purpose to avoid timeout in debugging. |
39 const int kCloseEnoughToInfinity = 0x20000000; | 38 const int kCloseEnoughToInfinity = 0x20000000; |
40 | 39 |
41 const int kTestWindowWidthDip = 800; | 40 const int kTestWindowWidthDip = 800; |
42 const int kTestWindowHeightDip = 600; | 41 const int kTestWindowHeightDip = 600; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 main_window_->Reload(); | 557 main_window_->Reload(); |
559 } | 558 } |
560 | 559 |
561 void WebKitTestController::OnLoadURLForFrame(const GURL& url, | 560 void WebKitTestController::OnLoadURLForFrame(const GURL& url, |
562 const std::string& frame_name) { | 561 const std::string& frame_name) { |
563 main_window_->LoadURLForFrame(url, frame_name); | 562 main_window_->LoadURLForFrame(url, frame_name); |
564 } | 563 } |
565 | 564 |
566 void WebKitTestController::OnCaptureSessionHistory() { | 565 void WebKitTestController::OnCaptureSessionHistory() { |
567 std::vector<int> routing_ids; | 566 std::vector<int> routing_ids; |
568 std::vector<std::vector<std::string> > session_histories; | 567 std::vector<std::vector<PageState> > session_histories; |
569 std::vector<unsigned> current_entry_indexes; | 568 std::vector<unsigned> current_entry_indexes; |
570 | 569 |
571 RenderViewHost* render_view_host = | 570 RenderViewHost* render_view_host = |
572 main_window_->web_contents()->GetRenderViewHost(); | 571 main_window_->web_contents()->GetRenderViewHost(); |
573 | 572 |
574 for (std::vector<Shell*>::iterator window = Shell::windows().begin(); | 573 for (std::vector<Shell*>::iterator window = Shell::windows().begin(); |
575 window != Shell::windows().end(); | 574 window != Shell::windows().end(); |
576 ++window) { | 575 ++window) { |
577 WebContents* web_contents = (*window)->web_contents(); | 576 WebContents* web_contents = (*window)->web_contents(); |
578 // Only capture the history from windows in the same process as the main | 577 // Only capture the history from windows in the same process as the main |
579 // window. During layout tests, we only use two processes when an | 578 // window. During layout tests, we only use two processes when an |
580 // devtools window is open. This should not happen during history navigation | 579 // devtools window is open. This should not happen during history navigation |
581 // tests. | 580 // tests. |
582 if (render_view_host->GetProcess() != | 581 if (render_view_host->GetProcess() != |
583 web_contents->GetRenderViewHost()->GetProcess()) { | 582 web_contents->GetRenderViewHost()->GetProcess()) { |
584 NOTREACHED(); | 583 NOTREACHED(); |
585 continue; | 584 continue; |
586 } | 585 } |
587 routing_ids.push_back(web_contents->GetRenderViewHost()->GetRoutingID()); | 586 routing_ids.push_back(web_contents->GetRenderViewHost()->GetRoutingID()); |
588 current_entry_indexes.push_back( | 587 current_entry_indexes.push_back( |
589 web_contents->GetController().GetCurrentEntryIndex()); | 588 web_contents->GetController().GetCurrentEntryIndex()); |
590 std::vector<std::string> history; | 589 std::vector<PageState> history; |
591 for (int entry = 0; entry < web_contents->GetController().GetEntryCount(); | 590 for (int entry = 0; entry < web_contents->GetController().GetEntryCount(); |
592 ++entry) { | 591 ++entry) { |
593 std::string state = web_contents->GetController().GetEntryAtIndex(entry) | 592 PageState state = web_contents->GetController().GetEntryAtIndex(entry)-> |
594 ->GetContentState(); | 593 GetPageState(); |
595 if (state.empty()) { | 594 if (!state.IsValid()) { |
596 state = webkit_glue::CreateHistoryStateForURL( | 595 state = PageState::CreateFromURL( |
597 web_contents->GetController().GetEntryAtIndex(entry)->GetURL()); | 596 web_contents->GetController().GetEntryAtIndex(entry)->GetURL()); |
598 } | 597 } |
599 history.push_back(state); | 598 history.push_back(state); |
600 } | 599 } |
601 session_histories.push_back(history); | 600 session_histories.push_back(history); |
602 } | 601 } |
603 | 602 |
604 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), | 603 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), |
605 routing_ids, | 604 routing_ids, |
606 session_histories, | 605 session_histories, |
607 current_entry_indexes)); | 606 current_entry_indexes)); |
608 } | 607 } |
609 | 608 |
610 void WebKitTestController::OnCloseRemainingWindows() { | 609 void WebKitTestController::OnCloseRemainingWindows() { |
611 DevToolsManager::GetInstance()->CloseAllClientHosts(); | 610 DevToolsManager::GetInstance()->CloseAllClientHosts(); |
612 std::vector<Shell*> open_windows(Shell::windows()); | 611 std::vector<Shell*> open_windows(Shell::windows()); |
613 for (size_t i = 0; i < open_windows.size(); ++i) { | 612 for (size_t i = 0; i < open_windows.size(); ++i) { |
614 if (open_windows[i] != main_window_) | 613 if (open_windows[i] != main_window_) |
615 open_windows[i]->Close(); | 614 open_windows[i]->Close(); |
616 } | 615 } |
617 base::MessageLoop::current()->RunUntilIdle(); | 616 base::MessageLoop::current()->RunUntilIdle(); |
618 } | 617 } |
619 | 618 |
620 void WebKitTestController::OnResetDone() { | 619 void WebKitTestController::OnResetDone() { |
621 base::MessageLoop::current()->PostTask(FROM_HERE, | 620 base::MessageLoop::current()->PostTask(FROM_HERE, |
622 base::MessageLoop::QuitClosure()); | 621 base::MessageLoop::QuitClosure()); |
623 } | 622 } |
624 | 623 |
625 } // namespace content | 624 } // namespace content |
OLD | NEW |