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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_test_helper.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chromeos/settings/device_settings_test_helper.h" 5 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/chromeos/settings/device_settings_service.h" 10 #include "chrome/browser/chromeos/settings/device_settings_service.h"
11 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" 11 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h"
12 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" 12 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {} 17 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {}
18 18
19 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {} 19 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {}
20 20
21 void DeviceSettingsTestHelper::FlushLoops() { 21 void DeviceSettingsTestHelper::FlushLoops() {
22 // DeviceSettingsService may trigger operations that hop back and forth 22 // DeviceSettingsService may trigger operations that hop back and forth
23 // between the message loop and the blocking pool. 2 iterations are currently 23 // between the message loop and the blocking pool. 2 iterations are currently
24 // sufficient (key loading, signing). 24 // sufficient (key loading, signing).
25 for (int i = 0; i < 2; ++i) { 25 for (int i = 0; i < 2; ++i) {
26 MessageLoop::current()->RunUntilIdle(); 26 base::MessageLoop::current()->RunUntilIdle();
27 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 27 content::BrowserThread::GetBlockingPool()->FlushForTesting();
28 } 28 }
29 MessageLoop::current()->RunUntilIdle(); 29 base::MessageLoop::current()->RunUntilIdle();
30 } 30 }
31 31
32 void DeviceSettingsTestHelper::FlushStore() { 32 void DeviceSettingsTestHelper::FlushStore() {
33 std::vector<StorePolicyCallback> callbacks; 33 std::vector<StorePolicyCallback> callbacks;
34 callbacks.swap(device_policy_.store_callbacks_); 34 callbacks.swap(device_policy_.store_callbacks_);
35 for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin()); 35 for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin());
36 cb != callbacks.end(); ++cb) { 36 cb != callbacks.end(); ++cb) {
37 cb->Run(device_policy_.store_result_); 37 cb->Run(device_policy_.store_result_);
38 } 38 }
39 39
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Flush(); 179 Flush();
180 } 180 }
181 181
182 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { 182 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() {
183 Flush(); 183 Flush();
184 DeviceSettingsService::Get()->UnsetSessionManager(); 184 DeviceSettingsService::Get()->UnsetSessionManager();
185 DeviceSettingsService::Shutdown(); 185 DeviceSettingsService::Shutdown();
186 } 186 }
187 187
188 DeviceSettingsTestBase::DeviceSettingsTestBase() 188 DeviceSettingsTestBase::DeviceSettingsTestBase()
189 : loop_(MessageLoop::TYPE_UI), 189 : loop_(base::MessageLoop::TYPE_UI),
190 ui_thread_(content::BrowserThread::UI, &loop_), 190 ui_thread_(content::BrowserThread::UI, &loop_),
191 file_thread_(content::BrowserThread::FILE, &loop_), 191 file_thread_(content::BrowserThread::FILE, &loop_),
192 owner_key_util_(new MockOwnerKeyUtil()) {} 192 owner_key_util_(new MockOwnerKeyUtil()) {}
193 193
194 DeviceSettingsTestBase::~DeviceSettingsTestBase() { 194 DeviceSettingsTestBase::~DeviceSettingsTestBase() {
195 base::RunLoop().RunUntilIdle(); 195 base::RunLoop().RunUntilIdle();
196 } 196 }
197 197
198 void DeviceSettingsTestBase::SetUp() { 198 void DeviceSettingsTestBase::SetUp() {
199 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( 199 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(
(...skipping 13 matching lines...) Expand all
213 void DeviceSettingsTestBase::FlushDeviceSettings() { 213 void DeviceSettingsTestBase::FlushDeviceSettings() {
214 device_settings_test_helper_.Flush(); 214 device_settings_test_helper_.Flush();
215 } 215 }
216 216
217 void DeviceSettingsTestBase::ReloadDeviceSettings() { 217 void DeviceSettingsTestBase::ReloadDeviceSettings() {
218 device_settings_service_.OwnerKeySet(true); 218 device_settings_service_.OwnerKeySet(true);
219 FlushDeviceSettings(); 219 FlushDeviceSettings();
220 } 220 }
221 221
222 } // namespace chromeos 222 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698