| 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/browser/browser_url_handler.h" | 5 #include "chrome/browser/browser_url_handler.h" |
| 6 #include "chrome/test/test_notification_tracker.h" | 6 #include "chrome/test/test_notification_tracker.h" |
| 7 #include "chrome/test/testing_profile.h" | 7 #include "chrome/test/testing_profile.h" |
| 8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "content/browser/site_instance.h" | 10 #include "content/browser/site_instance.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Tests the Navigate function. We navigate three sites consecutively and check | 180 // Tests the Navigate function. We navigate three sites consecutively and check |
| 181 // how the pending/committed RenderViewHost are modified. | 181 // how the pending/committed RenderViewHost are modified. |
| 182 TEST_F(RenderViewHostManagerTest, Navigate) { | 182 TEST_F(RenderViewHostManagerTest, Navigate) { |
| 183 TestNotificationTracker notifications; | 183 TestNotificationTracker notifications; |
| 184 | 184 |
| 185 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 185 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
| 186 | 186 |
| 187 TestTabContents tab_contents(profile_.get(), instance); | 187 TestTabContents tab_contents(profile_.get(), instance); |
| 188 notifications.ListenFor(NotificationType::RENDER_VIEW_HOST_CHANGED, | 188 notifications.ListenFor(content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 189 Source<NavigationController>(&tab_contents.controller())); | 189 Source<NavigationController>(&tab_contents.controller())); |
| 190 | 190 |
| 191 // Create. | 191 // Create. |
| 192 RenderViewHostManager manager(&tab_contents, &tab_contents); | 192 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 193 | 193 |
| 194 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); | 194 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); |
| 195 | 195 |
| 196 RenderViewHost* host; | 196 RenderViewHost* host; |
| 197 | 197 |
| 198 // 1) The first navigation. -------------------------- | 198 // 1) The first navigation. -------------------------- |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // Commit. | 247 // Commit. |
| 248 manager.DidNavigateMainFrame(manager.pending_render_view_host()); | 248 manager.DidNavigateMainFrame(manager.pending_render_view_host()); |
| 249 EXPECT_TRUE(host == manager.current_host()); | 249 EXPECT_TRUE(host == manager.current_host()); |
| 250 ASSERT_TRUE(host); | 250 ASSERT_TRUE(host); |
| 251 EXPECT_TRUE(host->site_instance()->has_site()); | 251 EXPECT_TRUE(host->site_instance()->has_site()); |
| 252 // Check the pending RenderViewHost has been committed. | 252 // Check the pending RenderViewHost has been committed. |
| 253 EXPECT_FALSE(manager.pending_render_view_host()); | 253 EXPECT_FALSE(manager.pending_render_view_host()); |
| 254 | 254 |
| 255 // We should observe a notification. | 255 // We should observe a notification. |
| 256 EXPECT_TRUE(notifications.Check1AndReset( | 256 EXPECT_TRUE(notifications.Check1AndReset( |
| 257 NotificationType::RENDER_VIEW_HOST_CHANGED)); | 257 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Tests WebUI creation. | 260 // Tests WebUI creation. |
| 261 TEST_F(RenderViewHostManagerTest, WebUI) { | 261 TEST_F(RenderViewHostManagerTest, WebUI) { |
| 262 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); | 262 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); |
| 263 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 263 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
| 264 | 264 |
| 265 TestTabContents tab_contents(profile_.get(), instance); | 265 TestTabContents tab_contents(profile_.get(), instance); |
| 266 RenderViewHostManager manager(&tab_contents, &tab_contents); | 266 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 267 | 267 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 // That should have cancelled the pending RVH, and the evil RVH should be the | 359 // That should have cancelled the pending RVH, and the evil RVH should be the |
| 360 // current one. | 360 // current one. |
| 361 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); | 361 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); |
| 362 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); | 362 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); |
| 363 | 363 |
| 364 // Also we should not have a pending navigation entry. | 364 // Also we should not have a pending navigation entry. |
| 365 NavigationEntry* entry = contents()->controller().GetActiveEntry(); | 365 NavigationEntry* entry = contents()->controller().GetActiveEntry(); |
| 366 ASSERT_TRUE(entry != NULL); | 366 ASSERT_TRUE(entry != NULL); |
| 367 EXPECT_EQ(kUrl2, entry->url()); | 367 EXPECT_EQ(kUrl2, entry->url()); |
| 368 } | 368 } |
| OLD | NEW |