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

Side by Side Diff: chrome/browser/search_engines/template_url_fetcher_unittest.cc

Issue 2902043004: Omnibox - Open Search - Handle Lack of Short Name Smartly (Closed)
Patch Set: pkasting comments Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/test/data/simple_open_search_no_name.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/search_engines/template_url_fetcher.h" 5 #include "components/search_engines/template_url_fetcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const TemplateURL* t_url = test_util()->model()->GetTemplateURLForKeyword( 175 const TemplateURL* t_url = test_util()->model()->GetTemplateURLForKeyword(
176 keyword); 176 keyword);
177 ASSERT_TRUE(t_url); 177 ASSERT_TRUE(t_url);
178 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 178 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
179 t_url->url_ref().DisplayURL( 179 t_url->url_ref().DisplayURL(
180 test_util()->model()->search_terms_data())); 180 test_util()->model()->search_terms_data()));
181 EXPECT_EQ(ASCIIToUTF16("Simple Search"), t_url->short_name()); 181 EXPECT_EQ(ASCIIToUTF16("Simple Search"), t_url->short_name());
182 EXPECT_TRUE(t_url->safe_for_autoreplace()); 182 EXPECT_TRUE(t_url->safe_for_autoreplace());
183 } 183 }
184 184
185 // This test is similar to the BasicAutodetectedTest except the xml file
186 // provided doesn't include a short name for the search engine. We should
187 // fall back to the hostname.
188 TEST_F(TemplateURLFetcherTest, InvalidShortName) {
189 base::string16 keyword(ASCIIToUTF16("test"));
190
191 test_util()->ChangeModelToLoadState();
192 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword));
193
194 std::string osdd_file_name("simple_open_search_no_name.xml");
195 StartDownload(keyword, osdd_file_name, true);
196 WaitForDownloadToFinish();
197
198 const TemplateURL* t_url =
199 test_util()->model()->GetTemplateURLForKeyword(keyword);
200 ASSERT_TRUE(t_url);
201 EXPECT_EQ(ASCIIToUTF16("example.com"), t_url->short_name());
202 }
203
185 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { 204 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
186 base::string16 keyword(ASCIIToUTF16("test")); 205 base::string16 keyword(ASCIIToUTF16("test"));
187 206
188 test_util()->ChangeModelToLoadState(); 207 test_util()->ChangeModelToLoadState();
189 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); 208 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword));
190 209
191 std::string osdd_file_name("simple_open_search.xml"); 210 std::string osdd_file_name("simple_open_search.xml");
192 StartDownload(keyword, osdd_file_name, true); 211 StartDownload(keyword, osdd_file_name, true);
193 EXPECT_EQ(0, requests_completed()); 212 EXPECT_EQ(0, requests_completed());
194 213
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 std::string osdd_file_name("unicode_open_search.xml"); 288 std::string osdd_file_name("unicode_open_search.xml");
270 StartDownload(keyword, osdd_file_name, true); 289 StartDownload(keyword, osdd_file_name, true);
271 WaitForDownloadToFinish(); 290 WaitForDownloadToFinish();
272 const TemplateURL* t_url = 291 const TemplateURL* t_url =
273 test_util()->model()->GetTemplateURLForKeyword(keyword); 292 test_util()->model()->GetTemplateURLForKeyword(keyword);
274 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), 293 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"),
275 t_url->short_name()); 294 t_url->short_name());
276 } 295 }
277 296
278 } // namespace 297 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/simple_open_search_no_name.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698