| 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 "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
| 6 #include "content/browser/browser_url_handler.h" | 6 #include "content/browser/browser_url_handler.h" |
| 7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance.h" |
| 10 #include "content/browser/tab_contents/navigation_controller_impl.h" | 10 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| 11 #include "content/browser/tab_contents/navigation_entry_impl.h" | 11 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 12 #include "content/browser/tab_contents/render_view_host_manager.h" | 12 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 13 #include "content/browser/tab_contents/test_tab_contents.h" | 13 #include "content/browser/tab_contents/test_tab_contents.h" |
| 14 #include "content/browser/webui/empty_web_ui_factory.h" | 14 #include "content/browser/webui/empty_web_ui_factory.h" |
| 15 #include "content/common/test_url_constants.h" | 15 #include "content/common/test_url_constants.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/common/page_transition_types.h" | 20 #include "content/public/common/page_transition_types.h" |
| 21 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 22 #include "content/test/test_browser_context.h" | 22 #include "content/test/test_browser_context.h" |
| 23 #include "content/test/test_notification_tracker.h" | 23 #include "content/test/test_notification_tracker.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "googleurl/src/url_util.h" | 25 #include "googleurl/src/url_util.h" |
| 26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
| 27 | 27 |
| 28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::BrowserThreadImpl; | 29 using content::BrowserThreadImpl; |
| 30 using content::NavigationController; |
| 30 using content::NavigationEntry; | 31 using content::NavigationEntry; |
| 31 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; | 36 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; |
| 36 | 37 |
| 37 class RenderViewHostManagerTestWebUIFactory | 38 class RenderViewHostManagerTestWebUIFactory |
| 38 : public content::EmptyWebUIFactory { | 39 : public content::EmptyWebUIFactory { |
| 39 public: | 40 public: |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Tests the Navigate function. We navigate three sites consecutively and check | 288 // Tests the Navigate function. We navigate three sites consecutively and check |
| 288 // how the pending/committed RenderViewHost are modified. | 289 // how the pending/committed RenderViewHost are modified. |
| 289 TEST_F(RenderViewHostManagerTest, Navigate) { | 290 TEST_F(RenderViewHostManagerTest, Navigate) { |
| 290 TestNotificationTracker notifications; | 291 TestNotificationTracker notifications; |
| 291 | 292 |
| 292 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 293 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); |
| 293 | 294 |
| 294 TestTabContents tab_contents(browser_context(), instance); | 295 TestTabContents tab_contents(browser_context(), instance); |
| 295 notifications.ListenFor( | 296 notifications.ListenFor( |
| 296 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 297 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 297 content::Source<content::NavigationController>( | 298 content::Source<NavigationController>( |
| 298 &tab_contents.GetController())); | 299 &tab_contents.GetController())); |
| 299 | 300 |
| 300 // Create. | 301 // Create. |
| 301 RenderViewHostManager manager(&tab_contents, &tab_contents); | 302 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 302 | 303 |
| 303 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 304 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
| 304 | 305 |
| 305 RenderViewHost* host; | 306 RenderViewHost* host; |
| 306 | 307 |
| 307 // 1) The first navigation. -------------------------- | 308 // 1) The first navigation. -------------------------- |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 // has been committed. This is also a regression test for | 377 // has been committed. This is also a regression test for |
| 377 // http://crbug.com/104600. | 378 // http://crbug.com/104600. |
| 378 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { | 379 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { |
| 379 TestNotificationTracker notifications; | 380 TestNotificationTracker notifications; |
| 380 | 381 |
| 381 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 382 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); |
| 382 | 383 |
| 383 TestTabContents tab_contents(browser_context(), instance); | 384 TestTabContents tab_contents(browser_context(), instance); |
| 384 notifications.ListenFor( | 385 notifications.ListenFor( |
| 385 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 386 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 386 content::Source<content::NavigationController>( | 387 content::Source<NavigationController>( |
| 387 &tab_contents.GetController())); | 388 &tab_contents.GetController())); |
| 388 | 389 |
| 389 // Create. | 390 // Create. |
| 390 RenderViewHostManager manager(&tab_contents, &tab_contents); | 391 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 391 | 392 |
| 392 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 393 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
| 393 | 394 |
| 394 // 1) The first navigation. -------------------------- | 395 // 1) The first navigation. -------------------------- |
| 395 const GURL kUrl1("http://www.google.com/"); | 396 const GURL kUrl1("http://www.google.com/"); |
| 396 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 397 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 // current one. | 612 // current one. |
| 612 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 613 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
| 613 pending_render_view_host() == NULL); | 614 pending_render_view_host() == NULL); |
| 614 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); | 615 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); |
| 615 | 616 |
| 616 // Also we should not have a pending navigation entry. | 617 // Also we should not have a pending navigation entry. |
| 617 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); | 618 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); |
| 618 ASSERT_TRUE(entry != NULL); | 619 ASSERT_TRUE(entry != NULL); |
| 619 EXPECT_EQ(kUrl2, entry->GetURL()); | 620 EXPECT_EQ(kUrl2, entry->GetURL()); |
| 620 } | 621 } |
| OLD | NEW |