| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 WaitForDownloadToFinish(); | 176 WaitForDownloadToFinish(); |
| 175 ASSERT_EQ(0, add_provider_called()); | 177 ASSERT_EQ(0, add_provider_called()); |
| 176 ASSERT_EQ(1, callbacks_destroyed()); | 178 ASSERT_EQ(1, callbacks_destroyed()); |
| 177 | 179 |
| 178 const TemplateURL* t_url = test_util()->model()->GetTemplateURLForKeyword( | 180 const TemplateURL* t_url = test_util()->model()->GetTemplateURLForKeyword( |
| 179 keyword); | 181 keyword); |
| 180 ASSERT_TRUE(t_url); | 182 ASSERT_TRUE(t_url); |
| 181 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), | 183 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), |
| 182 t_url->url_ref().DisplayURL( | 184 t_url->url_ref().DisplayURL( |
| 183 test_util()->model()->search_terms_data())); | 185 test_util()->model()->search_terms_data())); |
| 186 EXPECT_EQ(ASCIIToUTF16("Simple Search"), t_url->short_name()); |
| 184 EXPECT_TRUE(t_url->safe_for_autoreplace()); | 187 EXPECT_TRUE(t_url->safe_for_autoreplace()); |
| 185 } | 188 } |
| 186 | 189 |
| 187 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { | 190 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { |
| 188 base::string16 keyword(ASCIIToUTF16("test")); | 191 base::string16 keyword(ASCIIToUTF16("test")); |
| 189 | 192 |
| 190 test_util()->ChangeModelToLoadState(); | 193 test_util()->ChangeModelToLoadState(); |
| 191 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); | 194 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 192 | 195 |
| 193 std::string osdd_file_name("simple_open_search.xml"); | 196 std::string osdd_file_name("simple_open_search.xml"); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 StartDownload(keyword, osdd_file_name, | 319 StartDownload(keyword, osdd_file_name, |
| 317 TemplateURLFetcher::EXPLICIT_PROVIDER, true); | 320 TemplateURLFetcher::EXPLICIT_PROVIDER, true); |
| 318 ASSERT_EQ(0, add_provider_called()); | 321 ASSERT_EQ(0, add_provider_called()); |
| 319 ASSERT_EQ(1, callbacks_destroyed()); | 322 ASSERT_EQ(1, callbacks_destroyed()); |
| 320 | 323 |
| 321 WaitForDownloadToFinish(); | 324 WaitForDownloadToFinish(); |
| 322 ASSERT_EQ(1, add_provider_called()); | 325 ASSERT_EQ(1, add_provider_called()); |
| 323 ASSERT_EQ(2, callbacks_destroyed()); | 326 ASSERT_EQ(2, callbacks_destroyed()); |
| 324 ASSERT_TRUE(last_callback_template_url()); | 327 ASSERT_TRUE(last_callback_template_url()); |
| 325 } | 328 } |
| 329 |
| 330 TEST_F(TemplateURLFetcherTest, UnicodeTest) { |
| 331 base::string16 keyword(ASCIIToUTF16("test")); |
| 332 |
| 333 test_util()->ChangeModelToLoadState(); |
| 334 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 335 |
| 336 std::string osdd_file_name("unicode_open_search.xml"); |
| 337 StartDownload(keyword, osdd_file_name, |
| 338 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
| 339 WaitForDownloadToFinish(); |
| 340 const TemplateURL* t_url = |
| 341 test_util()->model()->GetTemplateURLForKeyword(keyword); |
| 342 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), |
| 343 t_url->short_name()); |
| 344 } |
| OLD | NEW |