| 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/file_util.h" | 6 #include "base/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" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Start the fetch. | 120 // Start the fetch. |
| 121 GURL osdd_url = test_server_.GetURL("/" + osdd_file_name); | 121 GURL osdd_url = test_server_.GetURL("/" + osdd_file_name); |
| 122 GURL favicon_url; | 122 GURL favicon_url; |
| 123 base::ScopedClosureRunner* callback_destruction_notifier = | 123 base::ScopedClosureRunner* callback_destruction_notifier = |
| 124 new base::ScopedClosureRunner( | 124 new base::ScopedClosureRunner( |
| 125 base::Bind(&TemplateURLFetcherTest::DestroyedCallback, | 125 base::Bind(&TemplateURLFetcherTest::DestroyedCallback, |
| 126 base::Unretained(this))); | 126 base::Unretained(this))); |
| 127 | 127 |
| 128 TemplateURLFetcherFactory::GetForProfile( | 128 TemplateURLFetcherFactory::GetForProfile( |
| 129 test_util_.profile())->ScheduleDownload( | 129 test_util_.profile())->ScheduleDownload( |
| 130 keyword, osdd_url, favicon_url, NULL, | 130 keyword, osdd_url, favicon_url, |
| 131 TemplateURLFetcher::URLFetcherCustomizeCallback(), |
| 131 base::Bind(&TemplateURLFetcherTest::ConfirmAddSearchProvider, | 132 base::Bind(&TemplateURLFetcherTest::ConfirmAddSearchProvider, |
| 132 base::Unretained(this), | 133 base::Unretained(this), |
| 133 base::Owned(callback_destruction_notifier)), | 134 base::Owned(callback_destruction_notifier)), |
| 134 provider_type); | 135 provider_type); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void TemplateURLFetcherTest::WaitForDownloadToFinish() { | 138 void TemplateURLFetcherTest::WaitForDownloadToFinish() { |
| 138 ASSERT_FALSE(waiting_for_download_); | 139 ASSERT_FALSE(waiting_for_download_); |
| 139 waiting_for_download_ = true; | 140 waiting_for_download_ = true; |
| 140 base::MessageLoop::current()->Run(); | 141 base::MessageLoop::current()->Run(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 StartDownload(keyword, osdd_file_name, | 302 StartDownload(keyword, osdd_file_name, |
| 302 TemplateURLFetcher::EXPLICIT_PROVIDER, true); | 303 TemplateURLFetcher::EXPLICIT_PROVIDER, true); |
| 303 ASSERT_EQ(0, add_provider_called_); | 304 ASSERT_EQ(0, add_provider_called_); |
| 304 ASSERT_EQ(1, callbacks_destroyed_); | 305 ASSERT_EQ(1, callbacks_destroyed_); |
| 305 | 306 |
| 306 WaitForDownloadToFinish(); | 307 WaitForDownloadToFinish(); |
| 307 ASSERT_EQ(1, add_provider_called_); | 308 ASSERT_EQ(1, add_provider_called_); |
| 308 ASSERT_EQ(2, callbacks_destroyed_); | 309 ASSERT_EQ(2, callbacks_destroyed_); |
| 309 ASSERT_TRUE(last_callback_template_url_.get()); | 310 ASSERT_TRUE(last_callback_template_url_.get()); |
| 310 } | 311 } |
| OLD | NEW |