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

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: Created 7 years, 7 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/policy/proto/chrome_device_policy.pb.h" 10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
11 #include "chrome/browser/chromeos/settings/device_settings_service.h" 11 #include "chrome/browser/chromeos/settings/device_settings_service.h"
12 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" 12 #include "chrome/browser/chromeos/settings/mock_owner_key_util.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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 Flush(); 173 Flush();
174 } 174 }
175 175
176 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { 176 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() {
177 Flush(); 177 Flush();
178 DeviceSettingsService::Get()->UnsetSessionManager(); 178 DeviceSettingsService::Get()->UnsetSessionManager();
179 DeviceSettingsService::Shutdown(); 179 DeviceSettingsService::Shutdown();
180 } 180 }
181 181
182 DeviceSettingsTestBase::DeviceSettingsTestBase() 182 DeviceSettingsTestBase::DeviceSettingsTestBase()
183 : loop_(MessageLoop::TYPE_UI), 183 : loop_(base::MessageLoop::TYPE_UI),
184 ui_thread_(content::BrowserThread::UI, &loop_), 184 ui_thread_(content::BrowserThread::UI, &loop_),
185 file_thread_(content::BrowserThread::FILE, &loop_), 185 file_thread_(content::BrowserThread::FILE, &loop_),
186 owner_key_util_(new MockOwnerKeyUtil()) {} 186 owner_key_util_(new MockOwnerKeyUtil()) {}
187 187
188 DeviceSettingsTestBase::~DeviceSettingsTestBase() { 188 DeviceSettingsTestBase::~DeviceSettingsTestBase() {
189 base::RunLoop().RunUntilIdle(); 189 base::RunLoop().RunUntilIdle();
190 } 190 }
191 191
192 void DeviceSettingsTestBase::SetUp() { 192 void DeviceSettingsTestBase::SetUp() {
193 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( 193 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(
(...skipping 13 matching lines...) Expand all
207 void DeviceSettingsTestBase::FlushDeviceSettings() { 207 void DeviceSettingsTestBase::FlushDeviceSettings() {
208 device_settings_test_helper_.Flush(); 208 device_settings_test_helper_.Flush();
209 } 209 }
210 210
211 void DeviceSettingsTestBase::ReloadDeviceSettings() { 211 void DeviceSettingsTestBase::ReloadDeviceSettings() {
212 device_settings_service_.OwnerKeySet(true); 212 device_settings_service_.OwnerKeySet(true);
213 FlushDeviceSettings(); 213 FlushDeviceSettings();
214 } 214 }
215 215
216 } // namespace chromeos 216 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698