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 <string> |
| 6 |
5 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
6 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 11 #include "base/path_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 13 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
12 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
13 #include "components/search_engines/template_url.h" | 15 #include "components/search_engines/template_url.h" |
14 #include "components/search_engines/template_url_fetcher.h" | 16 #include "components/search_engines/template_url_fetcher.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 StartDownload(keyword, osdd_file_name, | 318 StartDownload(keyword, osdd_file_name, |
317 TemplateURLFetcher::EXPLICIT_PROVIDER, true); | 319 TemplateURLFetcher::EXPLICIT_PROVIDER, true); |
318 ASSERT_EQ(0, add_provider_called()); | 320 ASSERT_EQ(0, add_provider_called()); |
319 ASSERT_EQ(1, callbacks_destroyed()); | 321 ASSERT_EQ(1, callbacks_destroyed()); |
320 | 322 |
321 WaitForDownloadToFinish(); | 323 WaitForDownloadToFinish(); |
322 ASSERT_EQ(1, add_provider_called()); | 324 ASSERT_EQ(1, add_provider_called()); |
323 ASSERT_EQ(2, callbacks_destroyed()); | 325 ASSERT_EQ(2, callbacks_destroyed()); |
324 ASSERT_TRUE(last_callback_template_url()); | 326 ASSERT_TRUE(last_callback_template_url()); |
325 } | 327 } |
| 328 |
| 329 TEST_F(TemplateURLFetcherTest, PunycodeTest) { |
| 330 base::string16 keyword(base::UTF8ToUTF16("яндекс.рф")); |
| 331 |
| 332 test_util()->ChangeModelToLoadState(); |
| 333 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 334 |
| 335 std::string osdd_file_name("punycode_open_search.xml"); |
| 336 StartDownload(keyword, osdd_file_name, |
| 337 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
| 338 WaitForDownloadToFinish(); |
| 339 const TemplateURL* t_url = |
| 340 test_util()->model()->GetTemplateURLForKeyword(keyword); |
| 341 EXPECT_EQ(base::UTF8ToUTF16("яндекс.рф"), t_url->short_name()); |
| 342 } |
| 343 |
| 344 TEST_F(TemplateURLFetcherTest, UnicodeTest) { |
| 345 base::string16 keyword(base::UTF8ToUTF16("яндекс.рф")); |
| 346 |
| 347 test_util()->ChangeModelToLoadState(); |
| 348 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 349 |
| 350 std::string osdd_file_name("unicode_open_search.xml"); |
| 351 StartDownload(keyword, osdd_file_name, |
| 352 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
| 353 WaitForDownloadToFinish(); |
| 354 const TemplateURL* t_url = |
| 355 test_util()->model()->GetTemplateURLForKeyword(keyword); |
| 356 EXPECT_EQ(base::UTF8ToUTF16("яндекс.рф"), t_url->short_name()); |
| 357 } |
OLD | NEW |