| 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" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | |
| 7 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 8 | 10 |
| 9 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 14 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 18 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 18 #include "components/search_engines/template_url.h" | 20 #include "components/search_engines/template_url.h" |
| 19 #include "components/search_engines/template_url_fetcher.h" | |
| 20 #include "components/search_engines/template_url_service.h" | 21 #include "components/search_engines/template_url_service.h" |
| 21 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "net/test/embedded_test_server/embedded_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 using base::ASCIIToUTF16; | 27 using base::ASCIIToUTF16; |
| 27 | 28 |
| 28 // Basic set-up for TemplateURLFetcher tests. | 29 // Basic set-up for TemplateURLFetcher tests. |
| 29 class TemplateURLFetcherTest : public testing::Test { | 30 class TemplateURLFetcherTest : public testing::Test { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 void TemplateURLFetcherTest::DestroyedCallback() { | 118 void TemplateURLFetcherTest::DestroyedCallback() { |
| 118 callbacks_destroyed_++; | 119 callbacks_destroyed_++; |
| 119 if (waiting_for_download_) | 120 if (waiting_for_download_) |
| 120 base::MessageLoop::current()->QuitWhenIdle(); | 121 base::MessageLoop::current()->QuitWhenIdle(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void TemplateURLFetcherTest::ConfirmAddSearchProvider( | 124 void TemplateURLFetcherTest::ConfirmAddSearchProvider( |
| 124 base::ScopedClosureRunner* callback_destruction_notifier, | 125 base::ScopedClosureRunner* callback_destruction_notifier, |
| 125 scoped_ptr<TemplateURL> template_url) { | 126 scoped_ptr<TemplateURL> template_url) { |
| 126 last_callback_template_url_ = template_url.Pass(); | 127 last_callback_template_url_ = std::move(template_url); |
| 127 add_provider_called_++; | 128 add_provider_called_++; |
| 128 } | 129 } |
| 129 | 130 |
| 130 void TemplateURLFetcherTest::StartDownload( | 131 void TemplateURLFetcherTest::StartDownload( |
| 131 const base::string16& keyword, | 132 const base::string16& keyword, |
| 132 const std::string& osdd_file_name, | 133 const std::string& osdd_file_name, |
| 133 TemplateURLFetcher::ProviderType provider_type, | 134 TemplateURLFetcher::ProviderType provider_type, |
| 134 bool check_that_file_exists) { | 135 bool check_that_file_exists) { |
| 135 if (check_that_file_exists) { | 136 if (check_that_file_exists) { |
| 136 base::FilePath osdd_full_path; | 137 base::FilePath osdd_full_path; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 339 |
| 339 std::string osdd_file_name("unicode_open_search.xml"); | 340 std::string osdd_file_name("unicode_open_search.xml"); |
| 340 StartDownload(keyword, osdd_file_name, | 341 StartDownload(keyword, osdd_file_name, |
| 341 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); | 342 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
| 342 WaitForDownloadToFinish(); | 343 WaitForDownloadToFinish(); |
| 343 const TemplateURL* t_url = | 344 const TemplateURL* t_url = |
| 344 test_util()->model()->GetTemplateURLForKeyword(keyword); | 345 test_util()->model()->GetTemplateURLForKeyword(keyword); |
| 345 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), | 346 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), |
| 346 t_url->short_name()); | 347 t_url->short_name()); |
| 347 } | 348 } |
| OLD | NEW |