Index: chrome/browser/search_engines/template_url_fetcher_unittest.cc |
diff --git a/chrome/browser/search_engines/template_url_fetcher_unittest.cc b/chrome/browser/search_engines/template_url_fetcher_unittest.cc |
index 35ca95ce437b161a47f1dd6fb2f614aa6788a6bd..a9216d131236a8fbe18603f5947de771706b3344 100644 |
--- a/chrome/browser/search_engines/template_url_fetcher_unittest.cc |
+++ b/chrome/browser/search_engines/template_url_fetcher_unittest.cc |
@@ -182,6 +182,32 @@ TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) { |
EXPECT_TRUE(t_url->safe_for_autoreplace()); |
} |
+// This test is exactly like BasicAutodetectedTest except the xml file |
+// provided doesn't include a short name for the search engine. We should |
+// fall back to the hostname. |
+TEST_F(TemplateURLFetcherTest, InvalidShortName) { |
+ base::string16 keyword(ASCIIToUTF16("test")); |
+ |
+ test_util()->ChangeModelToLoadState(); |
+ ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
Peter Kasting
2017/05/26 01:38:39
Nit: I'd remove all the checks here that just dupl
Mark P
2017/05/26 21:56:26
Removed unnecessary checks. Kept this one, becaus
|
+ |
+ std::string osdd_file_name("simple_open_search_no_name.xml"); |
+ StartDownload(keyword, osdd_file_name, true); |
+ EXPECT_EQ(0, requests_completed()); |
Peter Kasting
2017/05/26 01:38:39
Nit: Or this
Mark P
2017/05/26 21:56:26
Done.
|
+ |
+ WaitForDownloadToFinish(); |
+ EXPECT_EQ(1, requests_completed()); |
Peter Kasting
2017/05/26 01:38:39
Nit: Or this
Mark P
2017/05/26 21:56:26
Done.
|
+ |
+ const TemplateURL* t_url = |
+ test_util()->model()->GetTemplateURLForKeyword(keyword); |
+ ASSERT_TRUE(t_url); |
+ EXPECT_EQ( |
+ ASCIIToUTF16("http://example.com/%s/other_stuff"), |
+ t_url->url_ref().DisplayURL(test_util()->model()->search_terms_data())); |
Peter Kasting
2017/05/26 01:38:39
Nit: Or this
Mark P
2017/05/26 21:56:26
Done.
|
+ EXPECT_EQ(ASCIIToUTF16("example.com"), t_url->short_name()); |
+ EXPECT_TRUE(t_url->safe_for_autoreplace()); |
Peter Kasting
2017/05/26 01:38:39
Nit: Or this
Mark P
2017/05/26 21:56:26
Done.
|
+} |
+ |
TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { |
base::string16 keyword(ASCIIToUTF16("test")); |