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

Side by Side Diff: content/browser/tab_contents/render_view_host_manager_unittest.cc

Issue 6901003: Revert my recent changes regarding title directionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyrights Created 9 years, 8 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/browser/browser_url_handler.h" 5 #include "chrome/browser/browser_url_handler.h"
6 #include "chrome/common/render_messages.h" 6 #include "chrome/common/render_messages.h"
7 #include "chrome/common/url_constants.h" 7 #include "chrome/common/url_constants.h"
8 #include "chrome/test/test_notification_tracker.h" 8 #include "chrome/test/test_notification_tracker.h"
9 #include "chrome/test/testing_profile.h" 9 #include "chrome/test/testing_profile.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Create. 169 // Create.
170 RenderViewHostManager manager(&tab_contents, &tab_contents); 170 RenderViewHostManager manager(&tab_contents, &tab_contents);
171 171
172 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); 172 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE);
173 173
174 RenderViewHost* host; 174 RenderViewHost* host;
175 175
176 // 1) The first navigation. -------------------------- 176 // 1) The first navigation. --------------------------
177 GURL url1("http://www.google.com/"); 177 GURL url1("http://www.google.com/");
178 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, url1, 178 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, url1,
179 GURL() /* referrer */, 179 GURL() /* referrer */, string16() /* title */,
180 base::i18n::String16WithDirection() /* title */,
181 PageTransition::TYPED); 180 PageTransition::TYPED);
182 host = manager.Navigate(entry1); 181 host = manager.Navigate(entry1);
183 182
184 // The RenderViewHost created in Init will be reused. 183 // The RenderViewHost created in Init will be reused.
185 EXPECT_TRUE(host == manager.current_host()); 184 EXPECT_TRUE(host == manager.current_host());
186 EXPECT_FALSE(manager.pending_render_view_host()); 185 EXPECT_FALSE(manager.pending_render_view_host());
187 186
188 // Commit. 187 // Commit.
189 manager.DidNavigateMainFrame(host); 188 manager.DidNavigateMainFrame(host);
190 // Commit to SiteInstance should be delayed until RenderView commit. 189 // Commit to SiteInstance should be delayed until RenderView commit.
191 EXPECT_TRUE(host == manager.current_host()); 190 EXPECT_TRUE(host == manager.current_host());
192 ASSERT_TRUE(host); 191 ASSERT_TRUE(host);
193 EXPECT_FALSE(host->site_instance()->has_site()); 192 EXPECT_FALSE(host->site_instance()->has_site());
194 host->site_instance()->SetSite(url1); 193 host->site_instance()->SetSite(url1);
195 194
196 // 2) Navigate to next site. ------------------------- 195 // 2) Navigate to next site. -------------------------
197 GURL url2("http://www.google.com/foo"); 196 GURL url2("http://www.google.com/foo");
198 NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, url2, 197 NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, url2,
199 url1 /* referrer */, 198 url1 /* referrer */, string16() /* title */,
200 base::i18n::String16WithDirection() /* title */,
201 PageTransition::LINK); 199 PageTransition::LINK);
202 host = manager.Navigate(entry2); 200 host = manager.Navigate(entry2);
203 201
204 // The RenderViewHost created in Init will be reused. 202 // The RenderViewHost created in Init will be reused.
205 EXPECT_TRUE(host == manager.current_host()); 203 EXPECT_TRUE(host == manager.current_host());
206 EXPECT_FALSE(manager.pending_render_view_host()); 204 EXPECT_FALSE(manager.pending_render_view_host());
207 205
208 // Commit. 206 // Commit.
209 manager.DidNavigateMainFrame(host); 207 manager.DidNavigateMainFrame(host);
210 EXPECT_TRUE(host == manager.current_host()); 208 EXPECT_TRUE(host == manager.current_host());
211 ASSERT_TRUE(host); 209 ASSERT_TRUE(host);
212 EXPECT_TRUE(host->site_instance()->has_site()); 210 EXPECT_TRUE(host->site_instance()->has_site());
213 211
214 // 3) Cross-site navigate to next site. -------------- 212 // 3) Cross-site navigate to next site. --------------
215 GURL url3("http://webkit.org/"); 213 GURL url3("http://webkit.org/");
216 NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, url3, 214 NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, url3,
217 url2 /* referrer */, 215 url2 /* referrer */, string16() /* title */,
218 base::i18n::String16WithDirection() /* title */,
219 PageTransition::LINK); 216 PageTransition::LINK);
220 host = manager.Navigate(entry3); 217 host = manager.Navigate(entry3);
221 218
222 // A new RenderViewHost should be created. 219 // A new RenderViewHost should be created.
223 EXPECT_TRUE(manager.pending_render_view_host()); 220 EXPECT_TRUE(manager.pending_render_view_host());
224 EXPECT_TRUE(host == manager.pending_render_view_host()); 221 EXPECT_TRUE(host == manager.pending_render_view_host());
225 222
226 notifications.Reset(); 223 notifications.Reset();
227 224
228 // Commit. 225 // Commit.
(...skipping 14 matching lines...) Expand all
243 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); 240 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current());
244 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); 241 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
245 242
246 TestTabContents tab_contents(profile_.get(), instance); 243 TestTabContents tab_contents(profile_.get(), instance);
247 RenderViewHostManager manager(&tab_contents, &tab_contents); 244 RenderViewHostManager manager(&tab_contents, &tab_contents);
248 245
249 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); 246 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE);
250 247
251 GURL url(chrome::kChromeUINewTabURL); 248 GURL url(chrome::kChromeUINewTabURL);
252 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, 249 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url,
253 GURL() /* referrer */, 250 GURL() /* referrer */, string16() /* title */,
254 base::i18n::String16WithDirection() /* title */,
255 PageTransition::TYPED); 251 PageTransition::TYPED);
256 RenderViewHost* host = manager.Navigate(entry); 252 RenderViewHost* host = manager.Navigate(entry);
257 253
258 EXPECT_TRUE(host); 254 EXPECT_TRUE(host);
259 EXPECT_TRUE(host == manager.current_host()); 255 EXPECT_TRUE(host == manager.current_host());
260 EXPECT_FALSE(manager.pending_render_view_host()); 256 EXPECT_FALSE(manager.pending_render_view_host());
261 257
262 // It's important that the site instance get set on the Web UI page as soon 258 // It's important that the site instance get set on the Web UI page as soon
263 // as the navigation starts, rather than lazily after it commits, so we don't 259 // as the navigation starts, rather than lazily after it commits, so we don't
264 // try to re-use the SiteInstance/process for non DOM-UI things that may 260 // try to re-use the SiteInstance/process for non DOM-UI things that may
(...skipping 17 matching lines...) Expand all
282 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { 278 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) {
283 BrowserThread thread(BrowserThread::UI, &message_loop_); 279 BrowserThread thread(BrowserThread::UI, &message_loop_);
284 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); 280 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
285 TestTabContents tab_contents(profile_.get(), instance); 281 TestTabContents tab_contents(profile_.get(), instance);
286 RenderViewHostManager manager(&tab_contents, &tab_contents); 282 RenderViewHostManager manager(&tab_contents, &tab_contents);
287 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); 283 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE);
288 284
289 // NTP is a Web UI page. 285 // NTP is a Web UI page.
290 GURL ntp_url(chrome::kChromeUINewTabURL); 286 GURL ntp_url(chrome::kChromeUINewTabURL);
291 NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, ntp_url, 287 NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, ntp_url,
292 GURL() /* referrer */, 288 GURL() /* referrer */, string16() /* title */,
293 base::i18n::String16WithDirection() /* title */,
294 PageTransition::TYPED); 289 PageTransition::TYPED);
295 290
296 // about: URLs are not Web UI pages. 291 // about: URLs are not Web UI pages.
297 GURL about_url(chrome::kAboutMemoryURL); 292 GURL about_url(chrome::kAboutMemoryURL);
298 // Rewrite so it looks like chrome://about/memory 293 // Rewrite so it looks like chrome://about/memory
299 bool reverse_on_redirect = false; 294 bool reverse_on_redirect = false;
300 BrowserURLHandler::RewriteURLIfNecessary( 295 BrowserURLHandler::RewriteURLIfNecessary(
301 &about_url, profile_.get(), &reverse_on_redirect); 296 &about_url, profile_.get(), &reverse_on_redirect);
302 NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url, 297 NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url,
303 GURL() /* referrer */, 298 GURL() /* referrer */, string16() /* title */,
304 base::i18n::String16WithDirection() /* title */,
305 PageTransition::TYPED); 299 PageTransition::TYPED);
306 300
307 EXPECT_TRUE(ShouldSwapProcesses(&manager, &ntp_entry, &about_entry)); 301 EXPECT_TRUE(ShouldSwapProcesses(&manager, &ntp_entry, &about_entry));
308 } 302 }
309 303
310 // Tests that we don't end up in an inconsistent state if a page does a back and 304 // Tests that we don't end up in an inconsistent state if a page does a back and
311 // then reload. http://crbug.com/51680 305 // then reload. http://crbug.com/51680
312 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { 306 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) {
313 GURL url1("http://www.google.com/"); 307 GURL url1("http://www.google.com/");
314 GURL url2("http://www.evil-site.com/"); 308 GURL url2("http://www.evil-site.com/");
(...skipping 28 matching lines...) Expand all
343 // That should have cancelled the pending RVH, and the evil RVH should be the 337 // That should have cancelled the pending RVH, and the evil RVH should be the
344 // current one. 338 // current one.
345 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); 339 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL);
346 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); 340 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host());
347 341
348 // Also we should not have a pending navigation entry. 342 // Also we should not have a pending navigation entry.
349 NavigationEntry* entry = contents()->controller().GetActiveEntry(); 343 NavigationEntry* entry = contents()->controller().GetActiveEntry();
350 ASSERT_TRUE(entry != NULL); 344 ASSERT_TRUE(entry != NULL);
351 EXPECT_EQ(url2, entry->url()); 345 EXPECT_EQ(url2, entry->url());
352 } 346 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_entry_unittest.cc ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698