| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/base/browser_with_test_window_test.h" | 5 #include "chrome/test/base/browser_with_test_window_test.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <ole2.h> | 8 #include <ole2.h> |
| 9 #endif // defined(OS_WIN) | 9 #endif // defined(OS_WIN) |
| 10 | 10 |
| 11 #include "chrome/browser/tabs/tab_strip_model.h" | 11 #include "chrome/browser/tabs/tab_strip_model.h" |
| 12 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/browser/tab_contents/navigation_controller.h" | 16 #include "content/browser/tab_contents/navigation_controller.h" |
| 17 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/common/page_transition_types.h" | 19 #include "content/public/common/page_transition_types.h" |
| 20 | 20 |
| 21 BrowserWithTestWindowTest::BrowserWithTestWindowTest() | 21 BrowserWithTestWindowTest::BrowserWithTestWindowTest() |
| 22 : ui_thread_(BrowserThread::UI, message_loop()), | 22 : ui_thread_(BrowserThread::UI, message_loop()), |
| 23 file_thread_(BrowserThread::FILE, message_loop()), | 23 file_thread_(BrowserThread::FILE, message_loop()), |
| 24 rph_factory_(), | 24 rph_factory_(), |
| 25 rvh_factory_(&rph_factory_) { | 25 rvh_factory_(&rph_factory_) { |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 OleInitialize(NULL); | 27 OleInitialize(NULL); |
| 28 #endif | 28 #endif |
| 29 } | 29 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 #endif | 51 #endif |
| 52 } | 52 } |
| 53 | 53 |
| 54 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( | 54 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( |
| 55 TabContents* tab_contents) { | 55 TabContents* tab_contents) { |
| 56 return static_cast<TestRenderViewHost*>( | 56 return static_cast<TestRenderViewHost*>( |
| 57 tab_contents->render_view_host()); | 57 tab_contents->render_view_host()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { | 60 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { |
| 61 browser::NavigateParams params(browser, url, PageTransition::TYPED); | 61 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); |
| 62 params.tabstrip_index = 0; | 62 params.tabstrip_index = 0; |
| 63 params.disposition = NEW_FOREGROUND_TAB; | 63 params.disposition = NEW_FOREGROUND_TAB; |
| 64 browser::Navigate(¶ms); | 64 browser::Navigate(¶ms); |
| 65 CommitPendingLoad(¶ms.target_contents->controller()); | 65 CommitPendingLoad(¶ms.target_contents->controller()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void BrowserWithTestWindowTest::CommitPendingLoad( | 68 void BrowserWithTestWindowTest::CommitPendingLoad( |
| 69 NavigationController* controller) { | 69 NavigationController* controller) { |
| 70 if (!controller->pending_entry()) | 70 if (!controller->pending_entry()) |
| 71 return; // Nothing to commit. | 71 return; // Nothing to commit. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 controller->pending_entry()->url()); | 84 controller->pending_entry()->url()); |
| 85 } else { | 85 } else { |
| 86 test_rvh->SendNavigate(mock_rph->max_page_id() + 1, | 86 test_rvh->SendNavigate(mock_rph->max_page_id() + 1, |
| 87 controller->pending_entry()->url()); | 87 controller->pending_entry()->url()); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 void BrowserWithTestWindowTest::NavigateAndCommit( | 91 void BrowserWithTestWindowTest::NavigateAndCommit( |
| 92 NavigationController* controller, | 92 NavigationController* controller, |
| 93 const GURL& url) { | 93 const GURL& url) { |
| 94 controller->LoadURL(url, GURL(), PageTransition::LINK, std::string()); | 94 controller->LoadURL( |
| 95 url, GURL(), content::PAGE_TRANSITION_LINK, std::string()); |
| 95 CommitPendingLoad(controller); | 96 CommitPendingLoad(controller); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { | 99 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { |
| 99 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url); | 100 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void BrowserWithTestWindowTest::DestroyBrowser() { | 103 void BrowserWithTestWindowTest::DestroyBrowser() { |
| 103 if (!browser_.get()) | 104 if (!browser_.get()) |
| 104 return; | 105 return; |
| 105 // Make sure we close all tabs, otherwise Browser isn't happy in its | 106 // Make sure we close all tabs, otherwise Browser isn't happy in its |
| 106 // destructor. | 107 // destructor. |
| 107 browser()->CloseAllTabs(); | 108 browser()->CloseAllTabs(); |
| 108 browser_.reset(NULL); | 109 browser_.reset(NULL); |
| 109 window_.reset(NULL); | 110 window_.reset(NULL); |
| 110 } | 111 } |
| 111 | 112 |
| 112 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { | 113 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { |
| 113 return new TestingProfile(); | 114 return new TestingProfile(); |
| 114 } | 115 } |
| OLD | NEW |