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

Side by Side Diff: components/component_updater/component_updater_service_unittest.cc

Issue 1921973002: Convert //components/[a-e]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/component_updater/component_updater_service.h"
6
5 #include <limits> 7 #include <limits>
6 #include <string> 8 #include <string>
7 #include <vector> 9 #include <vector>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
11 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 19 #include "base/run_loop.h"
18 #include "base/test/histogram_tester.h" 20 #include "base/test/histogram_tester.h"
19 #include "base/test/sequenced_worker_pool_owner.h" 21 #include "base/test/sequenced_worker_pool_owner.h"
20 #include "base/thread_task_runner_handle.h" 22 #include "base/thread_task_runner_handle.h"
21 #include "base/values.h" 23 #include "base/values.h"
22 #include "components/component_updater/component_updater_service.h"
23 #include "components/component_updater/component_updater_service_internal.h" 24 #include "components/component_updater/component_updater_service_internal.h"
24 #include "components/update_client/test_configurator.h" 25 #include "components/update_client/test_configurator.h"
25 #include "components/update_client/test_installer.h" 26 #include "components/update_client/test_installer.h"
26 #include "components/update_client/update_client.h" 27 #include "components/update_client/update_client.h"
27
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using Configurator = update_client::Configurator; 31 using Configurator = update_client::Configurator;
32 using TestConfigurator = update_client::TestConfigurator; 32 using TestConfigurator = update_client::TestConfigurator;
33 using UpdateClient = update_client::UpdateClient; 33 using UpdateClient = update_client::UpdateClient;
34 34
35 using ::testing::_; 35 using ::testing::_;
36 using ::testing::AnyNumber; 36 using ::testing::AnyNumber;
37 using ::testing::Invoke; 37 using ::testing::Invoke;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 protected: 109 protected:
110 void RunThreads(); 110 void RunThreads();
111 111
112 private: 112 private:
113 static const int kNumWorkerThreads_ = 2; 113 static const int kNumWorkerThreads_ = 2;
114 114
115 base::MessageLoopForUI message_loop_; 115 base::MessageLoopForUI message_loop_;
116 base::RunLoop runloop_; 116 base::RunLoop runloop_;
117 base::Closure quit_closure_; 117 base::Closure quit_closure_;
118 118
119 scoped_ptr<base::SequencedWorkerPoolOwner> worker_pool_; 119 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_;
120 120
121 scoped_refptr<TestConfigurator> config_; 121 scoped_refptr<TestConfigurator> config_;
122 scoped_refptr<MockUpdateClient> update_client_; 122 scoped_refptr<MockUpdateClient> update_client_;
123 scoped_ptr<ComponentUpdateService> component_updater_; 123 std::unique_ptr<ComponentUpdateService> component_updater_;
124 124
125 DISALLOW_COPY_AND_ASSIGN(ComponentUpdaterTest); 125 DISALLOW_COPY_AND_ASSIGN(ComponentUpdaterTest);
126 }; 126 };
127 127
128 class OnDemandTester { 128 class OnDemandTester {
129 public: 129 public:
130 static bool OnDemand(ComponentUpdateService* cus, const std::string& id); 130 static bool OnDemand(ComponentUpdateService* cus, const std::string& id);
131 }; 131 };
132 132
133 MockInstaller::MockInstaller() { 133 MockInstaller::MockInstaller() {
(...skipping 12 matching lines...) Expand all
146 } 146 }
147 147
148 MockServiceObserver::~MockServiceObserver() { 148 MockServiceObserver::~MockServiceObserver() {
149 } 149 }
150 150
151 bool OnDemandTester::OnDemand(ComponentUpdateService* cus, 151 bool OnDemandTester::OnDemand(ComponentUpdateService* cus,
152 const std::string& id) { 152 const std::string& id) {
153 return cus->GetOnDemandUpdater().OnDemandUpdate(id); 153 return cus->GetOnDemandUpdater().OnDemandUpdate(id);
154 } 154 }
155 155
156 scoped_ptr<ComponentUpdateService> TestComponentUpdateServiceFactory( 156 std::unique_ptr<ComponentUpdateService> TestComponentUpdateServiceFactory(
157 const scoped_refptr<Configurator>& config) { 157 const scoped_refptr<Configurator>& config) {
158 DCHECK(config); 158 DCHECK(config);
159 return scoped_ptr<ComponentUpdateService>( 159 return base::WrapUnique(new CrxUpdateService(config, new MockUpdateClient()));
160 new CrxUpdateService(config, new MockUpdateClient()));
161 } 160 }
162 161
163 ComponentUpdaterTest::ComponentUpdaterTest() 162 ComponentUpdaterTest::ComponentUpdaterTest()
164 : worker_pool_( 163 : worker_pool_(
165 new base::SequencedWorkerPoolOwner(kNumWorkerThreads_, "test")) { 164 new base::SequencedWorkerPoolOwner(kNumWorkerThreads_, "test")) {
166 quit_closure_ = runloop_.QuitClosure(); 165 quit_closure_ = runloop_.QuitClosure();
167 166
168 auto pool = worker_pool_->pool(); 167 auto pool = worker_pool_->pool();
169 config_ = new TestConfigurator( 168 config_ = new TestConfigurator(
170 pool->GetSequencedTaskRunner(pool->GetSequenceToken()), 169 pool->GetSequencedTaskRunner(pool->GetSequenceToken()),
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 base::Bind(&ComponentUpdaterTest::ReadyCallback)); 375 base::Bind(&ComponentUpdaterTest::ReadyCallback));
377 376
378 RunThreads(); 377 RunThreads();
379 378
380 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1); 379 ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
381 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1); 380 ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
382 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1); 381 ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1);
383 } 382 }
384 383
385 } // namespace component_updater 384 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698