| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "chrome/browser/search/search.h" | |
| 8 #include "chrome/browser/search_engines/template_url_service.h" | 7 #include "chrome/browser/search_engines/template_url_service.h" |
| 9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 8 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 10 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 105 } |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 IN_PROC_BROWSER_TEST_F(InstantNTPURLRewriteTest, | 108 IN_PROC_BROWSER_TEST_F(InstantNTPURLRewriteTest, |
| 110 UberURLHandler_InstantExtendedNewTabPage) { | 109 UberURLHandler_InstantExtendedNewTabPage) { |
| 111 const GURL url_original("chrome://newtab"); | 110 const GURL url_original("chrome://newtab"); |
| 112 const GURL url_rewritten("http://example.com/newtab"); | 111 const GURL url_rewritten("http://example.com/newtab"); |
| 113 InstallTemplateURLWithNewTabPage(url_rewritten); | 112 InstallTemplateURLWithNewTabPage(url_rewritten); |
| 114 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", | 113 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", |
| 115 "Group1 use_cacheable_ntp:1")); | 114 "Group1 use_cacheable_ntp:1")); |
| 116 chrome::EnableInstantExtendedAPIForTesting(); | |
| 117 | 115 |
| 118 ui_test_utils::NavigateToURL(browser(), url_original); | 116 ui_test_utils::NavigateToURL(browser(), url_original); |
| 119 NavigationEntry* entry = GetLastCommittedEntry(); | 117 NavigationEntry* entry = GetLastCommittedEntry(); |
| 120 | 118 |
| 121 ASSERT_TRUE(entry != NULL); | 119 ASSERT_TRUE(entry != NULL); |
| 122 EXPECT_EQ(url_rewritten, entry->GetURL()); | 120 EXPECT_EQ(url_rewritten, entry->GetURL()); |
| 123 EXPECT_EQ(url_original, entry->GetVirtualURL()); | 121 EXPECT_EQ(url_original, entry->GetVirtualURL()); |
| 124 } | 122 } |
| 125 | 123 |
| 126 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, | |
| 127 UberURLHandler_InstantExtendedNewTabPageDisabled) { | |
| 128 // Don't do the kSingleProcess shenanigans here (see the dual test) because | |
| 129 // otherwise RenderViewImpl crashes in a paranoid fit on startup. | |
| 130 const GURL url_original("chrome://newtab"); | |
| 131 const GURL url_rewritten("http://example.com/newtab"); | |
| 132 InstallTemplateURLWithNewTabPage(url_rewritten); | |
| 133 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", | |
| 134 "Group1 use_cacheable_ntp:1")); | |
| 135 chrome::DisableInstantExtendedAPIForTesting(); | |
| 136 | |
| 137 ui_test_utils::NavigateToURL(browser(), url_original); | |
| 138 NavigationEntry* entry = GetLastCommittedEntry(); | |
| 139 | |
| 140 ASSERT_TRUE(entry != NULL); | |
| 141 EXPECT_EQ(url_original, entry->GetURL()); | |
| 142 EXPECT_EQ(url_original, entry->GetVirtualURL()); | |
| 143 } | |
| 144 | |
| 145 // Test that a basic navigation works in --site-per-process mode. This prevents | 124 // Test that a basic navigation works in --site-per-process mode. This prevents |
| 146 // regressions when that mode calls out into the ChromeContentBrowserClient, | 125 // regressions when that mode calls out into the ChromeContentBrowserClient, |
| 147 // such as http://crbug.com/164223. | 126 // such as http://crbug.com/164223. |
| 148 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, | 127 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, |
| 149 SitePerProcessNavigation) { | 128 SitePerProcessNavigation) { |
| 150 CommandLine::ForCurrentProcess()->AppendSwitch( | 129 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 151 switches::kSitePerProcess); | 130 switches::kSitePerProcess); |
| 152 ASSERT_TRUE(test_server()->Start()); | 131 ASSERT_TRUE(test_server()->Start()); |
| 153 const GURL url(test_server()->GetURL("files/title1.html")); | 132 const GURL url(test_server()->GetURL("files/title1.html")); |
| 154 | 133 |
| 155 ui_test_utils::NavigateToURL(browser(), url); | 134 ui_test_utils::NavigateToURL(browser(), url); |
| 156 NavigationEntry* entry = GetLastCommittedEntry(); | 135 NavigationEntry* entry = GetLastCommittedEntry(); |
| 157 | 136 |
| 158 ASSERT_TRUE(entry != NULL); | 137 ASSERT_TRUE(entry != NULL); |
| 159 EXPECT_EQ(url, entry->GetURL()); | 138 EXPECT_EQ(url, entry->GetURL()); |
| 160 EXPECT_EQ(url, entry->GetVirtualURL()); | 139 EXPECT_EQ(url, entry->GetVirtualURL()); |
| 161 } | 140 } |
| 162 | 141 |
| 163 } // namespace content | 142 } // namespace content |
| OLD | NEW |