| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/run_loop.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 20 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 21 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
| 22 #include "components/search_engines/template_url_service.h" | 23 #include "components/search_engines/template_url_service.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 | 28 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 GURL osdd_url = test_server_.GetURL("/" + osdd_file_name); | 147 GURL osdd_url = test_server_.GetURL("/" + osdd_file_name); |
| 147 GURL favicon_url; | 148 GURL favicon_url; |
| 148 template_url_fetcher_->ScheduleDownload( | 149 template_url_fetcher_->ScheduleDownload( |
| 149 keyword, osdd_url, favicon_url, | 150 keyword, osdd_url, favicon_url, |
| 150 TemplateURLFetcher::URLFetcherCustomizeCallback()); | 151 TemplateURLFetcher::URLFetcherCustomizeCallback()); |
| 151 } | 152 } |
| 152 | 153 |
| 153 void TemplateURLFetcherTest::WaitForDownloadToFinish() { | 154 void TemplateURLFetcherTest::WaitForDownloadToFinish() { |
| 154 ASSERT_FALSE(waiting_for_download_); | 155 ASSERT_FALSE(waiting_for_download_); |
| 155 waiting_for_download_ = true; | 156 waiting_for_download_ = true; |
| 156 base::MessageLoop::current()->Run(); | 157 base::RunLoop().Run(); |
| 157 waiting_for_download_ = false; | 158 waiting_for_download_ = false; |
| 158 } | 159 } |
| 159 | 160 |
| 160 TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) { | 161 TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) { |
| 161 base::string16 keyword(ASCIIToUTF16("test")); | 162 base::string16 keyword(ASCIIToUTF16("test")); |
| 162 | 163 |
| 163 test_util()->ChangeModelToLoadState(); | 164 test_util()->ChangeModelToLoadState(); |
| 164 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); | 165 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 165 | 166 |
| 166 std::string osdd_file_name("simple_open_search.xml"); | 167 std::string osdd_file_name("simple_open_search.xml"); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 std::string osdd_file_name("unicode_open_search.xml"); | 268 std::string osdd_file_name("unicode_open_search.xml"); |
| 268 StartDownload(keyword, osdd_file_name, true); | 269 StartDownload(keyword, osdd_file_name, true); |
| 269 WaitForDownloadToFinish(); | 270 WaitForDownloadToFinish(); |
| 270 const TemplateURL* t_url = | 271 const TemplateURL* t_url = |
| 271 test_util()->model()->GetTemplateURLForKeyword(keyword); | 272 test_util()->model()->GetTemplateURLForKeyword(keyword); |
| 272 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), | 273 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), |
| 273 t_url->short_name()); | 274 t_url->short_name()); |
| 274 } | 275 } |
| 275 | 276 |
| 276 } // namespace | 277 } // namespace |
| OLD | NEW |