OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "chrome/browser/search/search.h" | 7 #include "chrome/browser/search/search.h" |
8 #include "chrome/browser/search_engines/template_url_service.h" | 8 #include "chrome/browser/search_engines/template_url_service.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) | 133 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) |
134 << test.url << " " << test.comment; | 134 << test.url << " " << test.comment; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { | 138 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { |
139 EnableInstantExtendedAPIForTesting(); | 139 EnableInstantExtendedAPIForTesting(); |
140 | 140 |
141 const SearchTestCase kTestCases[] = { | 141 const SearchTestCase kTestCases[] = { |
142 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, | 142 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, |
| 143 {chrome::kChromeSearchLocalNtpUrl, true, ""}, |
143 {"https://foo.com/instant?strk", true, ""}, | 144 {"https://foo.com/instant?strk", true, ""}, |
144 {"https://foo.com/instant#strk", true, ""}, | 145 {"https://foo.com/instant#strk", true, ""}, |
145 {"https://foo.com/instant?strk=0", true, ""}, | 146 {"https://foo.com/instant?strk=0", true, ""}, |
146 {"https://foo.com/url?strk", true, ""}, | 147 {"https://foo.com/url?strk", true, ""}, |
147 {"https://foo.com/alt?strk", true, ""}, | 148 {"https://foo.com/alt?strk", true, ""}, |
148 {"http://foo.com/instant", false, "Non-HTTPS"}, | 149 {"http://foo.com/instant", false, "Non-HTTPS"}, |
149 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, | 150 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, |
150 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, | 151 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, |
151 {"https://foo.com/instant", false, "No search terms replacement"}, | 152 {"https://foo.com/instant", false, "No search terms replacement"}, |
152 {"https://foo.com/?strk", false, "Non-exact path"}, | 153 {"https://foo.com/?strk", false, "Non-exact path"}, |
(...skipping 27 matching lines...) Expand all Loading... |
180 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, | 181 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, |
181 {"https://foo.com/url?strk&bar=", true, "No query terms"}, | 182 {"https://foo.com/url?strk&bar=", true, "No query terms"}, |
182 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, | 183 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, |
183 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, | 184 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, |
184 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, | 185 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
185 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, | 186 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
186 {"https://foo.com/instant", false, "No search terms replacement"}, | 187 {"https://foo.com/instant", false, "No search terms replacement"}, |
187 {"chrome://blank/", false, "Chrome scheme"}, | 188 {"chrome://blank/", false, "Chrome scheme"}, |
188 {"chrome-search//foo", false, "Chrome-search scheme"}, | 189 {"chrome-search//foo", false, "Chrome-search scheme"}, |
189 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, | 190 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, |
| 191 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
190 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, | 192 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
191 }; | 193 }; |
192 | 194 |
193 TEST_F(SearchTest, InstantNTPExtendedEnabled) { | 195 TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
194 EnableInstantExtendedAPIForTesting(); | 196 EnableInstantExtendedAPIForTesting(); |
195 AddTab(browser(), GURL("chrome://blank")); | 197 AddTab(browser(), GURL("chrome://blank")); |
196 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { | 198 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
197 const SearchTestCase& test = kInstantNTPTestCases[i]; | 199 const SearchTestCase& test = kInstantNTPTestCases[i]; |
198 NavigateAndCommitActiveTab(GURL(test.url)); | 200 NavigateAndCommitActiveTab(GURL(test.url)); |
199 const content::WebContents* contents = | 201 const content::WebContents* contents = |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(GURL("http://foo.com/instant?foo=foo#foo=foo"), | 325 EXPECT_EQ(GURL("http://foo.com/instant?foo=foo#foo=foo"), |
324 GetInstantURL(profile(), kDisableStartMargin)); | 326 GetInstantURL(profile(), kDisableStartMargin)); |
325 | 327 |
326 // With start margin. | 328 // With start margin. |
327 EXPECT_EQ(GURL("http://foo.com/instant?es_sm=10&foo=foo#foo=foo"), | 329 EXPECT_EQ(GURL("http://foo.com/instant?es_sm=10&foo=foo#foo=foo"), |
328 GetInstantURL(profile(), 10)); | 330 GetInstantURL(profile(), 10)); |
329 } | 331 } |
330 | 332 |
331 } // namespace search | 333 } // namespace search |
332 } // namespace chrome | 334 } // namespace chrome |
OLD | NEW |