| 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 "base/callback_helpers.h" | 5 #include "base/callback_helpers.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 11 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/search_engines/template_url.h" | 14 #include "components/search_engines/template_url.h" |
| 15 #include "components/search_engines/template_url_fetcher.h" | 15 #include "components/search_engines/template_url_fetcher.h" |
| 16 #include "components/search_engines/template_url_service.h" | 16 #include "components/search_engines/template_url_service.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 using base::ASCIIToUTF16; | 22 using base::ASCIIToUTF16; |
| 23 | 23 |
| 24 // Basic set-up for TemplateURLFetcher tests. | 24 // Basic set-up for TemplateURLFetcher tests. |
| 25 class TemplateURLFetcherTest : public testing::Test { | 25 class TemplateURLFetcherTest : public testing::Test { |
| 26 public: | 26 public: |
| 27 TemplateURLFetcherTest(); | 27 TemplateURLFetcherTest(); |
| 28 | 28 |
| 29 virtual void SetUp() override { | 29 void SetUp() override { |
| 30 TestingProfile* profile = test_util_.profile(); | 30 TestingProfile* profile = test_util_.profile(); |
| 31 ASSERT_TRUE(profile->GetRequestContext()); | 31 ASSERT_TRUE(profile->GetRequestContext()); |
| 32 template_url_fetcher_.reset(new TemplateURLFetcher( | 32 template_url_fetcher_.reset(new TemplateURLFetcher( |
| 33 test_util_.model(), profile->GetRequestContext())); | 33 test_util_.model(), profile->GetRequestContext())); |
| 34 | 34 |
| 35 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 35 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void TearDown() override { | 38 void TearDown() override { |
| 39 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 39 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Called when the callback is destroyed. | 42 // Called when the callback is destroyed. |
| 43 void DestroyedCallback(); | 43 void DestroyedCallback(); |
| 44 | 44 |
| 45 // TemplateURLFetcherCallbacks implementation. (Although not derived from | 45 // TemplateURLFetcherCallbacks implementation. (Although not derived from |
| 46 // this class, this method handles those calls for the test.) | 46 // this class, this method handles those calls for the test.) |
| 47 void ConfirmAddSearchProvider( | 47 void ConfirmAddSearchProvider( |
| 48 base::ScopedClosureRunner* callback_destruction_notifier, | 48 base::ScopedClosureRunner* callback_destruction_notifier, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 StartDownload(keyword, osdd_file_name, | 309 StartDownload(keyword, osdd_file_name, |
| 310 TemplateURLFetcher::EXPLICIT_PROVIDER, true); | 310 TemplateURLFetcher::EXPLICIT_PROVIDER, true); |
| 311 ASSERT_EQ(0, add_provider_called()); | 311 ASSERT_EQ(0, add_provider_called()); |
| 312 ASSERT_EQ(1, callbacks_destroyed()); | 312 ASSERT_EQ(1, callbacks_destroyed()); |
| 313 | 313 |
| 314 WaitForDownloadToFinish(); | 314 WaitForDownloadToFinish(); |
| 315 ASSERT_EQ(1, add_provider_called()); | 315 ASSERT_EQ(1, add_provider_called()); |
| 316 ASSERT_EQ(2, callbacks_destroyed()); | 316 ASSERT_EQ(2, callbacks_destroyed()); |
| 317 ASSERT_TRUE(last_callback_template_url()); | 317 ASSERT_TRUE(last_callback_template_url()); |
| 318 } | 318 } |
| OLD | NEW |