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 "chrome/browser/ui/toolbar/toolbar_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 should_display); | 171 should_display); |
172 NavigateAndCheckTextImpl(url, true, expected_replace_text, would_replace, | 172 NavigateAndCheckTextImpl(url, true, expected_replace_text, would_replace, |
173 should_display); | 173 should_display); |
174 } | 174 } |
175 | 175 |
176 void NavigateAndCheckQueries(const std::vector<const char*>& queries, | 176 void NavigateAndCheckQueries(const std::vector<const char*>& queries, |
177 bool would_replace) { | 177 bool would_replace) { |
178 const std::string kInstantExtendedPrefix( | 178 const std::string kInstantExtendedPrefix( |
179 "https://google.com/search?espv=1&q="); | 179 "https://google.com/search?espv=1&q="); |
180 | 180 |
181 chrome::search::EnableQueryExtractionForTesting(); | 181 chrome::search::EnableInstantExtendedAPIForTesting(); |
182 | 182 |
183 ResetDefaultTemplateURL(); | 183 ResetDefaultTemplateURL(); |
184 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 184 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
185 for (size_t i = 0; i < queries.size(); ++i) { | 185 for (size_t i = 0; i < queries.size(); ++i) { |
186 std::string url_string = kInstantExtendedPrefix + | 186 std::string url_string = kInstantExtendedPrefix + |
187 net::EscapeQueryParamValue(queries[i], true); | 187 net::EscapeQueryParamValue(queries[i], true); |
188 NavigateAndCheckTextImpl(GURL(url_string), true, | 188 NavigateAndCheckTextImpl(GURL(url_string), true, |
189 ASCIIToUTF16(would_replace ? | 189 ASCIIToUTF16(would_replace ? |
190 std::string(queries[i]) : | 190 std::string(queries[i]) : |
191 url_string), | 191 url_string), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 NavigateAndCheckText(test_item.url, | 240 NavigateAndCheckText(test_item.url, |
241 test_item.expected_text, | 241 test_item.expected_text, |
242 test_item.expected_replace_text_inactive, | 242 test_item.expected_replace_text_inactive, |
243 false, | 243 false, |
244 test_item.should_display); | 244 test_item.should_display); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 // Test that we replace URLs when the query extraction API is enabled. | 248 // Test that we replace URLs when the query extraction API is enabled. |
249 TEST_F(ToolbarModelTest, ShouldDisplayURLQueryExtractionEnabled) { | 249 TEST_F(ToolbarModelTest, ShouldDisplayURLQueryExtractionEnabled) { |
250 chrome::search::EnableQueryExtractionForTesting(); | 250 chrome::search::EnableInstantExtendedAPIForTesting(); |
251 | 251 |
252 ResetDefaultTemplateURL(); | 252 ResetDefaultTemplateURL(); |
253 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 253 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
254 for (size_t i = 0; i < arraysize(test_items); ++i) { | 254 for (size_t i = 0; i < arraysize(test_items); ++i) { |
255 const TestItem& test_item = test_items[i]; | 255 const TestItem& test_item = test_items[i]; |
256 NavigateAndCheckText(test_item.url, | 256 NavigateAndCheckText(test_item.url, |
257 test_item.expected_text, | 257 test_item.expected_text, |
258 test_item.expected_replace_text_active, | 258 test_item.expected_replace_text_active, |
259 test_item.would_replace, | 259 test_item.would_replace, |
260 test_item.should_display); | 260 test_item.should_display); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 "9/11", | 298 "9/11", |
299 "<nomatch/>", | 299 "<nomatch/>", |
300 "ac/dc", | 300 "ac/dc", |
301 "ps/2", | 301 "ps/2", |
302 }; | 302 }; |
303 | 303 |
304 NavigateAndCheckQueries( | 304 NavigateAndCheckQueries( |
305 std::vector<const char*>(&kQueries[0], | 305 std::vector<const char*>(&kQueries[0], |
306 &kQueries[arraysize(kQueries)]), true); | 306 &kQueries[arraysize(kQueries)]), true); |
307 } | 307 } |
OLD | NEW |