| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.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/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
| 11 #include "content/browser/site_instance.h" | 11 #include "content/browser/site_instance_impl.h" |
| 12 #include "content/browser/tab_contents/interstitial_page.h" | 12 #include "content/browser/tab_contents/interstitial_page.h" |
| 13 #include "content/browser/tab_contents/navigation_entry_impl.h" | 13 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 14 #include "content/browser/tab_contents/test_tab_contents.h" | 14 #include "content/browser/tab_contents/test_tab_contents.h" |
| 15 #include "content/browser/webui/empty_web_ui_factory.h" | 15 #include "content/browser/webui/empty_web_ui_factory.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
| 18 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 21 #include "content/public/browser/web_ui_controller.h" | 21 #include "content/public/browser/web_ui_controller.h" |
| 22 #include "content/public/common/bindings_policy.h" | 22 #include "content/public/common/bindings_policy.h" |
| 23 #include "content/public/common/content_constants.h" | 23 #include "content/public/common/content_constants.h" |
| 24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 25 #include "content/test/test_browser_thread.h" | 25 #include "content/test/test_browser_thread.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 28 | 28 |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 using content::NavigationEntry; | 30 using content::NavigationEntry; |
| 31 using content::NavigationEntryImpl; | 31 using content::NavigationEntryImpl; |
| 32 using content::SiteInstance; |
| 32 using content::WebContents; | 33 using content::WebContents; |
| 33 using content::WebUIController; | 34 using content::WebUIController; |
| 34 using webkit::forms::PasswordForm; | 35 using webkit::forms::PasswordForm; |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { | 39 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { |
| 39 public: | 40 public: |
| 40 virtual WebUIController* CreateWebUIForURL(content::WebUI* web_ui, | 41 virtual WebUIController* CreateWebUIForURL(content::WebUI* web_ui, |
| 41 const GURL& url) const OVERRIDE { | 42 const GURL& url) const OVERRIDE { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 delegate_ = NULL; | 162 delegate_ = NULL; |
| 162 } | 163 } |
| 163 | 164 |
| 164 void set_delegate(Delegate* delegate) { | 165 void set_delegate(Delegate* delegate) { |
| 165 delegate_ = delegate; | 166 delegate_ = delegate; |
| 166 } | 167 } |
| 167 | 168 |
| 168 protected: | 169 protected: |
| 169 virtual RenderViewHost* CreateRenderViewHost() { | 170 virtual RenderViewHost* CreateRenderViewHost() { |
| 170 return new TestRenderViewHost( | 171 return new TestRenderViewHost( |
| 171 SiteInstance::CreateSiteInstance(tab()->GetBrowserContext()), | 172 SiteInstance::Create(tab()->GetBrowserContext()), |
| 172 this, MSG_ROUTING_NONE); | 173 this, MSG_ROUTING_NONE); |
| 173 } | 174 } |
| 174 | 175 |
| 175 virtual content::WebContentsView* CreateWebContentsView() { return NULL; } | 176 virtual content::WebContentsView* CreateWebContentsView() { return NULL; } |
| 176 | 177 |
| 177 | 178 |
| 178 virtual void CommandReceived(const std::string& command) { | 179 virtual void CommandReceived(const std::string& command) { |
| 179 command_received_count_++; | 180 command_received_count_++; |
| 180 } | 181 } |
| 181 | 182 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 InitNavigateParams(¶ms, 0, kGURL, content::PAGE_TRANSITION_TYPED); | 272 InitNavigateParams(¶ms, 0, kGURL, content::PAGE_TRANSITION_TYPED); |
| 272 content::LoadCommittedDetails details; | 273 content::LoadCommittedDetails details; |
| 273 cont.RendererDidNavigate(params, &details); | 274 cont.RendererDidNavigate(params, &details); |
| 274 // Also check title and url. | 275 // Also check title and url. |
| 275 EXPECT_EQ(ASCIIToUTF16(kUrl), contents()->GetTitle()); | 276 EXPECT_EQ(ASCIIToUTF16(kUrl), contents()->GetTitle()); |
| 276 } | 277 } |
| 277 | 278 |
| 278 // Test to ensure UpdateMaxPageID is working properly. | 279 // Test to ensure UpdateMaxPageID is working properly. |
| 279 TEST_F(TabContentsTest, UpdateMaxPageID) { | 280 TEST_F(TabContentsTest, UpdateMaxPageID) { |
| 280 SiteInstance* instance1 = contents()->GetSiteInstance(); | 281 SiteInstance* instance1 = contents()->GetSiteInstance(); |
| 281 scoped_refptr<SiteInstance> instance2(SiteInstance::CreateSiteInstance(NULL)); | 282 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); |
| 282 | 283 |
| 283 // Starts at -1. | 284 // Starts at -1. |
| 284 EXPECT_EQ(-1, contents()->GetMaxPageID()); | 285 EXPECT_EQ(-1, contents()->GetMaxPageID()); |
| 285 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1)); | 286 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1)); |
| 286 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance2)); | 287 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance2)); |
| 287 | 288 |
| 288 // Make sure max_page_id_ is monotonically increasing per SiteInstance. | 289 // Make sure max_page_id_ is monotonically increasing per SiteInstance. |
| 289 contents()->UpdateMaxPageID(3); | 290 contents()->UpdateMaxPageID(3); |
| 290 contents()->UpdateMaxPageID(1); | 291 contents()->UpdateMaxPageID(1); |
| 291 EXPECT_EQ(3, contents()->GetMaxPageID()); | 292 EXPECT_EQ(3, contents()->GetMaxPageID()); |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 | 1824 |
| 1824 // It should have a transient entry. | 1825 // It should have a transient entry. |
| 1825 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1826 EXPECT_TRUE(other_controller.GetTransientEntry()); |
| 1826 | 1827 |
| 1827 // And the interstitial should be showing. | 1828 // And the interstitial should be showing. |
| 1828 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); | 1829 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); |
| 1829 | 1830 |
| 1830 // And the interstitial should do a reload on don't proceed. | 1831 // And the interstitial should do a reload on don't proceed. |
| 1831 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); | 1832 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); |
| 1832 } | 1833 } |
| OLD | NEW |