Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: components/update_client/crx_downloader_unittest.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "components/update_client/crx_downloader.h" 14 #include "components/update_client/crx_downloader.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/url_request/test_url_request_interceptor.h" 16 #include "net/url_request/test_url_request_interceptor.h"
17 #include "net/url_request/url_request_test_util.h" 17 #include "net/url_request/url_request_test_util.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using base::ContentsEqual; 20 using base::ContentsEqual;
21 21
22 namespace update_client { 22 namespace update_client {
23 23
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 : callback_(base::Bind(&CrxDownloaderTest::DownloadComplete, 89 : callback_(base::Bind(&CrxDownloaderTest::DownloadComplete,
90 base::Unretained(this), 90 base::Unretained(this),
91 kExpectedContext)), 91 kExpectedContext)),
92 progress_callback_(base::Bind(&CrxDownloaderTest::DownloadProgress, 92 progress_callback_(base::Bind(&CrxDownloaderTest::DownloadProgress,
93 base::Unretained(this), 93 base::Unretained(this),
94 kExpectedContext)), 94 kExpectedContext)),
95 crx_context_(0), 95 crx_context_(0),
96 num_download_complete_calls_(0), 96 num_download_complete_calls_(0),
97 num_progress_calls_(0), 97 num_progress_calls_(0),
98 context_(new net::TestURLRequestContextGetter( 98 context_(new net::TestURLRequestContextGetter(
99 base::MessageLoopProxy::current())) { 99 base::ThreadTaskRunnerHandle::Get())) {
100 } 100 }
101 101
102 CrxDownloaderTest::~CrxDownloaderTest() { 102 CrxDownloaderTest::~CrxDownloaderTest() {
103 context_ = NULL; 103 context_ = NULL;
104 104
105 // The GetInterceptor requires the message loop to run to destruct correctly. 105 // The GetInterceptor requires the message loop to run to destruct correctly.
106 get_interceptor_.reset(); 106 get_interceptor_.reset();
107 RunThreadsUntilIdle(); 107 RunThreadsUntilIdle();
108 } 108 }
109 109
110 void CrxDownloaderTest::SetUp() { 110 void CrxDownloaderTest::SetUp() {
111 num_download_complete_calls_ = 0; 111 num_download_complete_calls_ = 0;
112 download_complete_result_ = CrxDownloader::Result(); 112 download_complete_result_ = CrxDownloader::Result();
113 num_progress_calls_ = 0; 113 num_progress_calls_ = 0;
114 download_progress_result_ = CrxDownloader::Result(); 114 download_progress_result_ = CrxDownloader::Result();
115 115
116 // Do not use the background downloader in these tests. 116 // Do not use the background downloader in these tests.
117 crx_downloader_.reset(CrxDownloader::Create(false, context_.get(), 117 crx_downloader_.reset(
118 base::MessageLoopProxy::current(), 118 CrxDownloader::Create(false, context_.get(),
119 NULL).release()); 119 base::ThreadTaskRunnerHandle::Get(),
120 NULL).release());
120 crx_downloader_->set_progress_callback(progress_callback_); 121 crx_downloader_->set_progress_callback(progress_callback_);
121 122
122 get_interceptor_.reset(new GetInterceptor(base::MessageLoopProxy::current(), 123 get_interceptor_.reset(
123 base::MessageLoopProxy::current())); 124 new GetInterceptor(base::ThreadTaskRunnerHandle::Get(),
125 base::ThreadTaskRunnerHandle::Get()));
124 } 126 }
125 127
126 void CrxDownloaderTest::TearDown() { 128 void CrxDownloaderTest::TearDown() {
127 crx_downloader_.reset(); 129 crx_downloader_.reset();
128 } 130 }
129 131
130 void CrxDownloaderTest::Quit() { 132 void CrxDownloaderTest::Quit() {
131 if (!quit_closure_.is_null()) 133 if (!quit_closure_.is_null())
132 quit_closure_.Run(); 134 quit_closure_.Run();
133 } 135 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 375
374 EXPECT_EQ(0, get_interceptor_->GetHitCount()); 376 EXPECT_EQ(0, get_interceptor_->GetHitCount());
375 377
376 EXPECT_EQ(1, num_download_complete_calls_); 378 EXPECT_EQ(1, num_download_complete_calls_);
377 EXPECT_EQ(kExpectedContext, crx_context_); 379 EXPECT_EQ(kExpectedContext, crx_context_);
378 EXPECT_NE(0, download_complete_result_.error); 380 EXPECT_NE(0, download_complete_result_.error);
379 EXPECT_TRUE(download_complete_result_.response.empty()); 381 EXPECT_TRUE(download_complete_result_.response.empty());
380 } 382 }
381 383
382 } // namespace update_client 384 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/background_downloader_win.cc ('k') | components/update_client/ping_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698