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 "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 Loading... | |
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 exactly like 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)); | |
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
| |
193 | |
194 std::string osdd_file_name("simple_open_search_no_name.xml"); | |
195 StartDownload(keyword, osdd_file_name, true); | |
196 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.
| |
197 | |
198 WaitForDownloadToFinish(); | |
199 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.
| |
200 | |
201 const TemplateURL* t_url = | |
202 test_util()->model()->GetTemplateURLForKeyword(keyword); | |
203 ASSERT_TRUE(t_url); | |
204 EXPECT_EQ( | |
205 ASCIIToUTF16("http://example.com/%s/other_stuff"), | |
206 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.
| |
207 EXPECT_EQ(ASCIIToUTF16("example.com"), t_url->short_name()); | |
208 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.
| |
209 } | |
210 | |
185 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { | 211 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { |
186 base::string16 keyword(ASCIIToUTF16("test")); | 212 base::string16 keyword(ASCIIToUTF16("test")); |
187 | 213 |
188 test_util()->ChangeModelToLoadState(); | 214 test_util()->ChangeModelToLoadState(); |
189 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); | 215 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
190 | 216 |
191 std::string osdd_file_name("simple_open_search.xml"); | 217 std::string osdd_file_name("simple_open_search.xml"); |
192 StartDownload(keyword, osdd_file_name, true); | 218 StartDownload(keyword, osdd_file_name, true); |
193 EXPECT_EQ(0, requests_completed()); | 219 EXPECT_EQ(0, requests_completed()); |
194 | 220 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 std::string osdd_file_name("unicode_open_search.xml"); | 295 std::string osdd_file_name("unicode_open_search.xml"); |
270 StartDownload(keyword, osdd_file_name, true); | 296 StartDownload(keyword, osdd_file_name, true); |
271 WaitForDownloadToFinish(); | 297 WaitForDownloadToFinish(); |
272 const TemplateURL* t_url = | 298 const TemplateURL* t_url = |
273 test_util()->model()->GetTemplateURLForKeyword(keyword); | 299 test_util()->model()->GetTemplateURLForKeyword(keyword); |
274 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), | 300 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), |
275 t_url->short_name()); | 301 t_url->short_name()); |
276 } | 302 } |
277 | 303 |
278 } // namespace | 304 } // namespace |
OLD | NEW |