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

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

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