Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixes. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 #include "content/public/common/url_constants.h" 26 #include "content/public/common/url_constants.h"
27 #include "net/base/escape.h" 27 #include "net/base/escape.h"
28 28
29 29
30 // Test data ------------------------------------------------------------------ 30 // Test data ------------------------------------------------------------------
31 31
32 namespace { 32 namespace {
33 33
34 struct TestItem { 34 struct TestItem {
35 GURL url; 35 GURL url;
36 std::string template_search_url;
Peter Kasting 2013/10/01 00:41:30 How many cases below will pass if we use "{google:
samarth 2013/10/02 00:18:00 Actually this override is only really needed for t
36 string16 expected_text; 37 string16 expected_text;
37 // The expected text to display when query extraction is inactive. 38 // The expected text to display when query extraction is inactive.
38 string16 expected_replace_text_inactive; 39 string16 expected_replace_text_inactive;
39 // The expected text to display when query extraction is active. 40 // The expected text to display when query extraction is active.
40 string16 expected_replace_text_active; 41 string16 expected_replace_text_active;
41 bool would_perform_search_term_replacement; 42 bool would_perform_search_term_replacement;
42 bool should_display_url; 43 bool should_display_url;
43 } test_items[] = { 44 } test_items[] = {
44 { 45 {
45 GURL("view-source:http://www.google.com"), 46 GURL("view-source:http://www.google.com"),
47 "view-source:http://www.google.com",
46 ASCIIToUTF16("view-source:www.google.com"), 48 ASCIIToUTF16("view-source:www.google.com"),
47 ASCIIToUTF16("view-source:www.google.com"), 49 ASCIIToUTF16("view-source:www.google.com"),
48 ASCIIToUTF16("view-source:www.google.com"), 50 ASCIIToUTF16("view-source:www.google.com"),
49 false, 51 false,
50 true 52 true
51 }, 53 },
52 { 54 {
53 GURL("view-source:chrome://newtab/"), 55 GURL("view-source:chrome://newtab/"),
56 "view-source:chrome://newtab/",
54 ASCIIToUTF16("view-source:chrome://newtab"), 57 ASCIIToUTF16("view-source:chrome://newtab"),
55 ASCIIToUTF16("view-source:chrome://newtab"), 58 ASCIIToUTF16("view-source:chrome://newtab"),
56 ASCIIToUTF16("view-source:chrome://newtab"), 59 ASCIIToUTF16("view-source:chrome://newtab"),
57 false, 60 false,
58 true 61 true
59 }, 62 },
60 { 63 {
61 GURL("chrome-extension://monkey/balls.html"), 64 GURL("chrome-extension://monkey/balls.html"),
65 "chrome-extension://monkey/balls.html",
62 ASCIIToUTF16("chrome-extension://monkey/balls.html"), 66 ASCIIToUTF16("chrome-extension://monkey/balls.html"),
63 ASCIIToUTF16("chrome-extension://monkey/balls.html"), 67 ASCIIToUTF16("chrome-extension://monkey/balls.html"),
64 ASCIIToUTF16("chrome-extension://monkey/balls.html"), 68 ASCIIToUTF16("chrome-extension://monkey/balls.html"),
65 false, 69 false,
66 true 70 true
67 }, 71 },
68 { 72 {
69 GURL("chrome://newtab/"), 73 GURL("chrome://newtab/"),
74 "chrome://newtab/",
70 string16(), 75 string16(),
71 string16(), 76 string16(),
72 string16(), 77 string16(),
73 false, 78 false,
74 false 79 false
75 }, 80 },
76 { 81 {
77 GURL(content::kAboutBlankURL), 82 GURL(content::kAboutBlankURL),
83 content::kAboutBlankURL,
78 ASCIIToUTF16(content::kAboutBlankURL), 84 ASCIIToUTF16(content::kAboutBlankURL),
79 ASCIIToUTF16(content::kAboutBlankURL), 85 ASCIIToUTF16(content::kAboutBlankURL),
80 ASCIIToUTF16(content::kAboutBlankURL), 86 ASCIIToUTF16(content::kAboutBlankURL),
81 false, 87 false,
82 true 88 true
83 }, 89 },
84 { 90 {
85 GURL("http://searchurl/?q=tractor+supply"), 91 GURL("http://searchurl/?q=tractor+supply"),
92 "http://searchurl/?q={searchTerms}",
86 ASCIIToUTF16("searchurl/?q=tractor+supply"), 93 ASCIIToUTF16("searchurl/?q=tractor+supply"),
87 ASCIIToUTF16("searchurl/?q=tractor+supply"), 94 ASCIIToUTF16("searchurl/?q=tractor+supply"),
88 ASCIIToUTF16("searchurl/?q=tractor+supply"), 95 ASCIIToUTF16("searchurl/?q=tractor+supply"),
89 false, 96 false,
90 true 97 true
91 }, 98 },
92 { 99 {
93 GURL("http://google.com/search?q=tractor+supply&espv=1"), 100 GURL("http://google.com/search?q=tractor+supply&espv=1"),
101 "http://google.com/search?q={searchTerms}&espv=1",
94 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"), 102 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
95 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"), 103 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
96 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"), 104 ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
97 false, 105 false,
98 true 106 true
99 }, 107 },
100 { 108 {
101 GURL("https://google.ca/search?q=tractor+supply"), 109 GURL("https://google.ca/search?q=tractor+supply"),
110 "https://google.ca/search?q={searchTerms}",
102 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"), 111 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
103 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"), 112 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
104 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"), 113 ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
105 false, 114 false,
106 true 115 true
107 }, 116 },
108 { 117 {
109 GURL("https://google.com/search?q=tractor+supply"), 118 GURL("https://google.com/search?q=tractor+supply"),
119 "https://google.com/search?q={searchTerms}",
110 ASCIIToUTF16("https://google.com/search?q=tractor+supply"), 120 ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
111 ASCIIToUTF16("https://google.com/search?q=tractor+supply"), 121 ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
112 ASCIIToUTF16("https://google.com/search?q=tractor+supply"), 122 ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
113 false, 123 false,
114 true 124 true
115 }, 125 },
116 { 126 {
117 GURL("https://google.com/search?q=tractor+supply&espv=1"), 127 GURL("https://google.com/search?q=tractor+supply&espv=1"),
128 "https://google.com/search?q={searchTerms}&espv=1",
118 ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"), 129 ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
119 ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"), 130 ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
120 ASCIIToUTF16("tractor supply"), 131 ASCIIToUTF16("tractor supply"),
121 true, 132 true,
122 true 133 true
123 }, 134 },
124 { 135 {
125 GURL("https://google.com/search?q=tractorsupply.com&espv=1"), 136 GURL("https://google.com/search?q=tractorsupply.com&espv=1"),
137 "https://google.com/search?q={searchTerms}&espv=1",
126 ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"), 138 ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
127 ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"), 139 ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
128 ASCIIToUTF16("tractorsupply.com"), 140 ASCIIToUTF16("tractorsupply.com"),
129 true, 141 true,
130 true 142 true
131 }, 143 },
132 { 144 {
133 GURL("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"), 145 GURL("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
146 "https://google.com/search?q={searchTerms}&espv=1",
134 ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"), 147 ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
135 ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"), 148 ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
136 ASCIIToUTF16("ftp://tractorsupply.ie"), 149 ASCIIToUTF16("ftp://tractorsupply.ie"),
137 true, 150 true,
138 true 151 true
139 }, 152 },
140 }; 153 };
141 154
142 } // namespace 155 } // namespace
143 156
144 157
145 // ToolbarModelTest ----------------------------------------------------------- 158 // ToolbarModelTest -----------------------------------------------------------
146 159
147 class ToolbarModelTest : public BrowserWithTestWindowTest { 160 class ToolbarModelTest : public BrowserWithTestWindowTest {
148 public: 161 public:
149 ToolbarModelTest(); 162 ToolbarModelTest();
150 virtual ~ToolbarModelTest(); 163 virtual ~ToolbarModelTest();
151 164
152 // BrowserWithTestWindowTest: 165 // BrowserWithTestWindowTest:
153 virtual void SetUp() OVERRIDE; 166 virtual void SetUp() OVERRIDE;
154 167
155 protected: 168 protected:
156 void ResetDefaultTemplateURL(); 169 void ResetDefaultTemplateURL();
157 void NavigateAndCheckText(const GURL& url, 170 void NavigateAndCheckText(const GURL& url,
171 const std::string& template_search_url,
158 const string16& expected_text, 172 const string16& expected_text,
159 const string16& expected_replace_text, 173 const string16& expected_replace_text,
160 bool would_perform_search_term_replacement, 174 bool would_perform_search_term_replacement,
161 bool should_display_url); 175 bool should_display_url);
162 176
163 private: 177 private:
164 void ResetTemplateURLForInstant(const GURL& instant_url); 178 void ResetTemplateURLForInstant(const std::string& template_search_url);
165 void NavigateAndCheckTextImpl(const GURL& url, 179 void NavigateAndCheckTextImpl(const GURL& url,
180 const std::string& template_search_url,
166 bool allow_search_term_replacement, 181 bool allow_search_term_replacement,
167 const string16 expected_text, 182 const string16 expected_text,
168 bool would_perform_search_term_replacement, 183 bool would_perform_search_term_replacement,
169 bool should_display); 184 bool should_display);
170 185
171 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest); 186 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest);
172 }; 187 };
173 188
174 ToolbarModelTest::ToolbarModelTest() { 189 ToolbarModelTest::ToolbarModelTest() {
175 } 190 }
176 191
177 ToolbarModelTest::~ToolbarModelTest() { 192 ToolbarModelTest::~ToolbarModelTest() {
178 } 193 }
179 194
180 void ToolbarModelTest::SetUp() { 195 void ToolbarModelTest::SetUp() {
181 BrowserWithTestWindowTest::SetUp(); 196 BrowserWithTestWindowTest::SetUp();
182 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 197 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
183 profile(), &TemplateURLServiceFactory::BuildInstanceFor); 198 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
184 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( 199 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
185 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); 200 profile(), &AutocompleteClassifierFactory::BuildInstanceFor);
186 UIThreadSearchTermsData::SetGoogleBaseURL("http://google.com/"); 201 UIThreadSearchTermsData::SetGoogleBaseURL("http://google.com/");
187 } 202 }
188 203
189 void ToolbarModelTest::ResetDefaultTemplateURL() { 204 void ToolbarModelTest::ResetDefaultTemplateURL() {
190 ResetTemplateURLForInstant(GURL("http://does/not/exist")); 205 ResetTemplateURLForInstant("http://does/not/exist");
191 } 206 }
192 207
193 void ToolbarModelTest::NavigateAndCheckText( 208 void ToolbarModelTest::NavigateAndCheckText(
194 const GURL& url, 209 const GURL& url,
210 const std::string& template_search_url,
195 const string16& expected_text, 211 const string16& expected_text,
196 const string16& expected_replace_text, 212 const string16& expected_replace_text,
197 bool would_perform_search_term_replacement, 213 bool would_perform_search_term_replacement,
198 bool should_display_url) { 214 bool should_display_url) {
199 NavigateAndCheckTextImpl(url, false, expected_text, 215 NavigateAndCheckTextImpl(url, template_search_url, false, expected_text,
200 would_perform_search_term_replacement, 216 would_perform_search_term_replacement,
201 should_display_url); 217 should_display_url);
202 NavigateAndCheckTextImpl(url, true, expected_replace_text, 218 NavigateAndCheckTextImpl(url, template_search_url, true,
219 expected_replace_text,
203 would_perform_search_term_replacement, 220 would_perform_search_term_replacement,
204 should_display_url); 221 should_display_url);
205 } 222 }
206 223
207 void ToolbarModelTest::ResetTemplateURLForInstant(const GURL& instant_url) { 224 void ToolbarModelTest::ResetTemplateURLForInstant(
225 const std::string& template_search_url) {
208 TemplateURLData data; 226 TemplateURLData data;
209 data.short_name = ASCIIToUTF16("Google"); 227 data.short_name = ASCIIToUTF16("Google");
210 data.SetURL("{google:baseURL}search?q={searchTerms}"); 228 data.SetURL(template_search_url);
211 data.instant_url = instant_url.spec(); 229 data.instant_url = "http://www.google.com/instant?strk=1";
212 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; 230 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}";
213 TemplateURL* search_template_url = new TemplateURL(profile(), data); 231 TemplateURL* search_template_url = new TemplateURL(profile(), data);
214 TemplateURLService* template_url_service = 232 TemplateURLService* template_url_service =
215 TemplateURLServiceFactory::GetForProfile(profile()); 233 TemplateURLServiceFactory::GetForProfile(profile());
216 template_url_service->Add(search_template_url); 234 template_url_service->Add(search_template_url);
217 template_url_service->SetDefaultSearchProvider(search_template_url); 235 template_url_service->SetDefaultSearchProvider(search_template_url);
218 ASSERT_NE(0, search_template_url->id()); 236 ASSERT_NE(0, search_template_url->id());
219 template_url_service->Load(); 237 template_url_service->Load();
220 } 238 }
221 239
222 void ToolbarModelTest::NavigateAndCheckTextImpl( 240 void ToolbarModelTest::NavigateAndCheckTextImpl(
223 const GURL& url, 241 const GURL& url,
242 const std::string& template_search_url,
224 bool allow_search_term_replacement, 243 bool allow_search_term_replacement,
225 const string16 expected_text, 244 const string16 expected_text,
226 bool would_perform_search_term_replacement, 245 bool would_perform_search_term_replacement,
227 bool should_display_url) { 246 bool should_display_url) {
228 // The URL being navigated to should be treated as the Instant URL. Else 247 // The URL being navigated to should be treated as the Instant URL. Else
229 // there will be no search term extraction. 248 // there will be no search term extraction.
230 ResetTemplateURLForInstant(url); 249 ResetTemplateURLForInstant(template_search_url);
231 250
232 // Check while loading. 251 // Check while loading.
233 content::NavigationController* controller = 252 content::NavigationController* controller =
234 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); 253 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
235 controller->LoadURL(url, content::Referrer(), content::PAGE_TRANSITION_LINK, 254 controller->LoadURL(url, content::Referrer(), content::PAGE_TRANSITION_LINK,
236 std::string()); 255 std::string());
237 ToolbarModel* toolbar_model = browser()->toolbar_model(); 256 ToolbarModel* toolbar_model = browser()->toolbar_model();
238 EXPECT_EQ(should_display_url, toolbar_model->ShouldDisplayURL()); 257 EXPECT_EQ(should_display_url, toolbar_model->ShouldDisplayURL());
239 EXPECT_EQ(expected_text, 258 EXPECT_EQ(expected_text,
240 toolbar_model->GetText(allow_search_term_replacement)); 259 toolbar_model->GetText(allow_search_term_replacement));
(...skipping 30 matching lines...) Expand all
271 290
272 // Test that we only replace URLs when query extraction and search term 291 // Test that we only replace URLs when query extraction and search term
273 // replacement are enabled. 292 // replacement are enabled.
274 TEST_F(ToolbarModelTest, ShouldDisplayURL) { 293 TEST_F(ToolbarModelTest, ShouldDisplayURL) {
275 // Before we enable instant extended, query extraction is disabled. 294 // Before we enable instant extended, query extraction is disabled.
276 EXPECT_FALSE(chrome::IsQueryExtractionEnabled()) 295 EXPECT_FALSE(chrome::IsQueryExtractionEnabled())
277 << "This test expects query extraction to be disabled."; 296 << "This test expects query extraction to be disabled.";
278 AddTab(browser(), GURL(content::kAboutBlankURL)); 297 AddTab(browser(), GURL(content::kAboutBlankURL));
279 for (size_t i = 0; i < arraysize(test_items); ++i) { 298 for (size_t i = 0; i < arraysize(test_items); ++i) {
280 const TestItem& test_item = test_items[i]; 299 const TestItem& test_item = test_items[i];
281 NavigateAndCheckText(test_item.url, test_item.expected_text, 300 NavigateAndCheckText(test_item.url, test_item.template_search_url,
301 test_item.expected_text,
282 test_item.expected_replace_text_inactive, false, 302 test_item.expected_replace_text_inactive, false,
283 test_item.should_display_url); 303 test_item.should_display_url);
284 } 304 }
285 305
286 // Once we enable it, query extraction and search term replacement are 306 chrome::EnableQueryExtractionForTesting();
287 // enabled by default.
288 chrome::EnableInstantExtendedAPIForTesting();
289 EXPECT_TRUE(chrome::IsQueryExtractionEnabled()); 307 EXPECT_TRUE(chrome::IsQueryExtractionEnabled());
290 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); 308 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
291 for (size_t i = 0; i < arraysize(test_items); ++i) { 309 for (size_t i = 0; i < arraysize(test_items); ++i) {
292 const TestItem& test_item = test_items[i]; 310 const TestItem& test_item = test_items[i];
293 NavigateAndCheckText(test_item.url, test_item.expected_text, 311 NavigateAndCheckText(test_item.url, test_item.template_search_url,
312 test_item.expected_text,
294 test_item.expected_replace_text_active, 313 test_item.expected_replace_text_active,
295 test_item.would_perform_search_term_replacement, 314 test_item.would_perform_search_term_replacement,
296 test_item.should_display_url); 315 test_item.should_display_url);
297 } 316 }
298 317
299 // Disabling search term replacement should reset to only showing URLs. 318 // Disabling search term replacement should reset to only showing URLs.
300 browser()->toolbar_model()->set_search_term_replacement_enabled(false); 319 browser()->toolbar_model()->set_search_term_replacement_enabled(false);
301 for (size_t i = 0; i < arraysize(test_items); ++i) { 320 for (size_t i = 0; i < arraysize(test_items); ++i) {
302 const TestItem& test_item = test_items[i]; 321 const TestItem& test_item = test_items[i];
303 NavigateAndCheckText(test_item.url, test_item.expected_text, 322 NavigateAndCheckText(test_item.url, test_item.template_search_url,
323 test_item.expected_text,
304 test_item.expected_replace_text_inactive, false, 324 test_item.expected_replace_text_inactive, false,
305 test_item.should_display_url); 325 test_item.should_display_url);
306 } 326 }
307 } 327 }
308 328
309 // Verify that search terms are extracted while the page is loading. 329 // Verify that search terms are extracted while the page is loading.
310 TEST_F(ToolbarModelTest, SearchTermsWhileLoading) { 330 TEST_F(ToolbarModelTest, SearchTermsWhileLoading) {
311 chrome::EnableInstantExtendedAPIForTesting(); 331 chrome::EnableQueryExtractionForTesting();
312 ResetDefaultTemplateURL(); 332 ResetDefaultTemplateURL();
313 AddTab(browser(), GURL(content::kAboutBlankURL)); 333 AddTab(browser(), GURL(content::kAboutBlankURL));
314 334
315 // While loading, we should be willing to extract search terms. 335 // While loading, we should be willing to extract search terms.
316 content::NavigationController* controller = 336 content::NavigationController* controller =
317 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); 337 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
318 controller->LoadURL(GURL("https://google.com/search?q=tractor+supply&espv=1"), 338 controller->LoadURL(GURL("https://google.com/search?q=tractor+supply&espv=1"),
319 content::Referrer(), content::PAGE_TRANSITION_LINK, 339 content::Referrer(), content::PAGE_TRANSITION_LINK,
320 std::string()); 340 std::string());
321 ToolbarModel* toolbar_model = browser()->toolbar_model(); 341 ToolbarModel* toolbar_model = browser()->toolbar_model();
322 controller->GetVisibleEntry()->GetSSL().security_style = 342 controller->GetVisibleEntry()->GetSSL().security_style =
323 content::SECURITY_STYLE_UNKNOWN; 343 content::SECURITY_STYLE_UNKNOWN;
324 EXPECT_TRUE(toolbar_model->WouldPerformSearchTermReplacement(false)); 344 EXPECT_TRUE(toolbar_model->WouldPerformSearchTermReplacement(false));
325 345
326 // When done loading, we shouldn't extract search terms if we didn't get an 346 // When done loading, we shouldn't extract search terms if we didn't get an
327 // authenticated connection. 347 // authenticated connection.
328 CommitPendingLoad(controller); 348 CommitPendingLoad(controller);
329 controller->GetVisibleEntry()->GetSSL().security_style = 349 controller->GetVisibleEntry()->GetSSL().security_style =
330 content::SECURITY_STYLE_UNKNOWN; 350 content::SECURITY_STYLE_UNKNOWN;
331 EXPECT_FALSE(toolbar_model->WouldPerformSearchTermReplacement(false)); 351 EXPECT_FALSE(toolbar_model->WouldPerformSearchTermReplacement(false));
332 } 352 }
333 353
334 // When the Google base URL is overridden on the command line, we should extract 354 // When the Google base URL is overridden on the command line, we should extract
335 // search terms from URLs that start with that base URL even when they're not 355 // search terms from URLs that start with that base URL even when they're not
336 // secure. 356 // secure.
337 TEST_F(ToolbarModelTest, GoogleBaseURL) { 357 TEST_F(ToolbarModelTest, GoogleBaseURL) {
338 chrome::EnableInstantExtendedAPIForTesting(); 358 chrome::EnableQueryExtractionForTesting();
339 AddTab(browser(), GURL(content::kAboutBlankURL)); 359 AddTab(browser(), GURL(content::kAboutBlankURL));
340 360
341 // If the Google base URL wasn't specified on the command line, then if it's 361 // If the Google base URL wasn't specified on the command line, then if it's
342 // HTTP, we should not extract search terms. 362 // HTTP, we should not extract search terms.
343 UIThreadSearchTermsData::SetGoogleBaseURL("http://www.foo.com/"); 363 UIThreadSearchTermsData::SetGoogleBaseURL("http://www.foo.com/");
344 NavigateAndCheckText( 364 NavigateAndCheckText(
345 GURL("http://www.foo.com/search?q=tractor+supply&espv=1"), 365 GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
366 "http://www.foo.com/search?q={queryTerms}&espv=1",
346 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), 367 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"),
347 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false, 368 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false,
348 true); 369 true);
349 370
350 // The same URL, when specified on the command line, should allow search term 371 // The same URL, when specified on the command line, should allow search term
351 // extraction. 372 // extraction.
352 UIThreadSearchTermsData::SetGoogleBaseURL(std::string()); 373 UIThreadSearchTermsData::SetGoogleBaseURL(std::string());
353 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, 374 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL,
354 "http://www.foo.com/"); 375 "http://www.foo.com/");
355 NavigateAndCheckText( 376 NavigateAndCheckText(
356 GURL("http://www.foo.com/search?q=tractor+supply&espv=1"), 377 GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
378 "http://www.foo.com/search?q={searchTerms}&espv=1",
357 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), 379 ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"),
358 ASCIIToUTF16("tractor supply"), true, true); 380 ASCIIToUTF16("tractor supply"), true, true);
359 } 381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698