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

Side by Side Diff: base/prefs/json_pref_store_unittest.cc

Issue 12226007: base: Convert the remaining uses of MessageLoop::RunUntilIdle to RunLoop variant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win Created 7 years, 10 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
« no previous file with comments | « base/observer_list_unittest.cc ('k') | base/system_monitor/system_monitor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/prefs/json_pref_store.h" 5 #include "base/prefs/json_pref_store.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.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"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 { 200 {
201 MockPrefStoreObserver mock_observer; 201 MockPrefStoreObserver mock_observer;
202 pref_store->AddObserver(&mock_observer); 202 pref_store->AddObserver(&mock_observer);
203 203
204 MockReadErrorDelegate* mock_error_delegate = new MockReadErrorDelegate; 204 MockReadErrorDelegate* mock_error_delegate = new MockReadErrorDelegate;
205 pref_store->ReadPrefsAsync(mock_error_delegate); 205 pref_store->ReadPrefsAsync(mock_error_delegate);
206 206
207 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); 207 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1);
208 EXPECT_CALL(*mock_error_delegate, 208 EXPECT_CALL(*mock_error_delegate,
209 OnError(PersistentPrefStore::PREF_READ_ERROR_NONE)).Times(0); 209 OnError(PersistentPrefStore::PREF_READ_ERROR_NONE)).Times(0);
210 message_loop_.RunUntilIdle(); 210 RunLoop().RunUntilIdle();
211 pref_store->RemoveObserver(&mock_observer); 211 pref_store->RemoveObserver(&mock_observer);
212 212
213 ASSERT_FALSE(pref_store->ReadOnly()); 213 ASSERT_FALSE(pref_store->ReadOnly());
214 } 214 }
215 215
216 // The JSON file looks like this: 216 // The JSON file looks like this:
217 // { 217 // {
218 // "homepage": "http://www.cnn.com", 218 // "homepage": "http://www.cnn.com",
219 // "some_directory": "/usr/local/", 219 // "some_directory": "/usr/local/",
220 // "tabs": { 220 // "tabs": {
(...skipping 16 matching lines...) Expand all
237 bogus_input_file, message_loop_.message_loop_proxy()); 237 bogus_input_file, message_loop_.message_loop_proxy());
238 MockPrefStoreObserver mock_observer; 238 MockPrefStoreObserver mock_observer;
239 pref_store->AddObserver(&mock_observer); 239 pref_store->AddObserver(&mock_observer);
240 240
241 MockReadErrorDelegate *mock_error_delegate = new MockReadErrorDelegate; 241 MockReadErrorDelegate *mock_error_delegate = new MockReadErrorDelegate;
242 pref_store->ReadPrefsAsync(mock_error_delegate); 242 pref_store->ReadPrefsAsync(mock_error_delegate);
243 243
244 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); 244 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1);
245 EXPECT_CALL(*mock_error_delegate, 245 EXPECT_CALL(*mock_error_delegate,
246 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1); 246 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1);
247 message_loop_.RunUntilIdle(); 247 RunLoop().RunUntilIdle();
248 pref_store->RemoveObserver(&mock_observer); 248 pref_store->RemoveObserver(&mock_observer);
249 249
250 EXPECT_FALSE(pref_store->ReadOnly()); 250 EXPECT_FALSE(pref_store->ReadOnly());
251 } 251 }
252 252
253 TEST_F(JsonPrefStoreTest, NeedsEmptyValue) { 253 TEST_F(JsonPrefStoreTest, NeedsEmptyValue) {
254 FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); 254 FilePath pref_file = temp_dir_.path().AppendASCII("write.json");
255 255
256 ASSERT_TRUE(file_util::CopyFile( 256 ASSERT_TRUE(file_util::CopyFile(
257 data_dir_.AppendASCII("read.need_empty_value.json"), 257 data_dir_.AppendASCII("read.need_empty_value.json"),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 RunLoop().RunUntilIdle(); 292 RunLoop().RunUntilIdle();
293 293
294 // Compare to expected output. 294 // Compare to expected output.
295 FilePath golden_output_file = 295 FilePath golden_output_file =
296 data_dir_.AppendASCII("write.golden.need_empty_value.json"); 296 data_dir_.AppendASCII("write.golden.need_empty_value.json");
297 ASSERT_TRUE(file_util::PathExists(golden_output_file)); 297 ASSERT_TRUE(file_util::PathExists(golden_output_file));
298 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file)); 298 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file));
299 } 299 }
300 300
301 } // namespace base 301 } // namespace base
OLDNEW
« no previous file with comments | « base/observer_list_unittest.cc ('k') | base/system_monitor/system_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698