Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
17 #include "content/browser/tab_contents/render_view_host_manager.h" 16 #include "content/browser/tab_contents/render_view_host_manager.h"
17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/page_transition_types.h" 20 #include "content/public/common/page_transition_types.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 using content::WebContents; 23 using content::WebContents;
24 24
25 BrowserWithTestWindowTest::BrowserWithTestWindowTest() 25 BrowserWithTestWindowTest::BrowserWithTestWindowTest()
26 : ui_thread_(BrowserThread::UI, message_loop()), 26 : ui_thread_(BrowserThread::UI, message_loop()),
27 file_thread_(BrowserThread::FILE, message_loop()), 27 file_thread_(BrowserThread::FILE, message_loop()),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { 66 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
67 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED); 67 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED);
68 params.tabstrip_index = 0; 68 params.tabstrip_index = 0;
69 params.disposition = NEW_FOREGROUND_TAB; 69 params.disposition = NEW_FOREGROUND_TAB;
70 browser::Navigate(&params); 70 browser::Navigate(&params);
71 CommitPendingLoad(&params.target_contents->web_contents()->GetController()); 71 CommitPendingLoad(&params.target_contents->web_contents()->GetController());
72 } 72 }
73 73
74 void BrowserWithTestWindowTest::CommitPendingLoad( 74 void BrowserWithTestWindowTest::CommitPendingLoad(
75 NavigationController* controller) { 75 content::NavigationController* controller) {
76 if (!controller->GetPendingEntry()) 76 if (!controller->GetPendingEntry())
77 return; // Nothing to commit. 77 return; // Nothing to commit.
78 78
79 TestRenderViewHost* old_rvh = 79 TestRenderViewHost* old_rvh =
80 TestRenderViewHostForTab(controller->GetWebContents()); 80 TestRenderViewHostForTab(controller->GetWebContents());
81 81
82 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( 82 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>(
83 controller->GetWebContents()->GetRenderManagerForTesting()-> 83 controller->GetWebContents()->GetRenderManagerForTesting()->
84 pending_render_view_host()); 84 pending_render_view_host());
85 if (pending_rvh) { 85 if (pending_rvh) {
(...skipping 22 matching lines...) Expand all
108 controller->GetPendingEntry()->GetTransitionType()); 108 controller->GetPendingEntry()->GetTransitionType());
109 } 109 }
110 110
111 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation 111 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation
112 // without making any network requests. 112 // without making any network requests.
113 if (pending_rvh) 113 if (pending_rvh)
114 old_rvh->OnSwapOutACK(); 114 old_rvh->OnSwapOutACK();
115 } 115 }
116 116
117 void BrowserWithTestWindowTest::NavigateAndCommit( 117 void BrowserWithTestWindowTest::NavigateAndCommit(
118 NavigationController* controller, 118 content::NavigationController* controller,
119 const GURL& url) { 119 const GURL& url) {
120 controller->LoadURL( 120 controller->LoadURL(
121 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); 121 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string());
122 CommitPendingLoad(controller); 122 CommitPendingLoad(controller);
123 } 123 }
124 124
125 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { 125 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) {
126 NavigateAndCommit(&browser()->GetSelectedTabContentsWrapper()-> 126 NavigateAndCommit(&browser()->GetSelectedTabContentsWrapper()->
127 web_contents()->GetController(), url); 127 web_contents()->GetController(), url);
128 } 128 }
129 129
130 void BrowserWithTestWindowTest::DestroyBrowser() { 130 void BrowserWithTestWindowTest::DestroyBrowser() {
131 if (!browser_.get()) 131 if (!browser_.get())
132 return; 132 return;
133 // Make sure we close all tabs, otherwise Browser isn't happy in its 133 // Make sure we close all tabs, otherwise Browser isn't happy in its
134 // destructor. 134 // destructor.
135 browser()->CloseAllTabs(); 135 browser()->CloseAllTabs();
136 browser_.reset(NULL); 136 browser_.reset(NULL);
137 window_.reset(NULL); 137 window_.reset(NULL);
138 } 138 }
139 139
140 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { 140 TestingProfile* BrowserWithTestWindowTest::CreateProfile() {
141 return new TestingProfile(); 141 return new TestingProfile();
142 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698