OLD | NEW |
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); | 381 base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); |
382 ASSERT_TRUE(PathExists(input_file)); | 382 ASSERT_TRUE(PathExists(input_file)); |
383 | 383 |
384 scoped_ptr<InterceptingPrefFilter> intercepting_pref_filter( | 384 scoped_ptr<InterceptingPrefFilter> intercepting_pref_filter( |
385 new InterceptingPrefFilter()); | 385 new InterceptingPrefFilter()); |
386 InterceptingPrefFilter* raw_intercepting_pref_filter_ = | 386 InterceptingPrefFilter* raw_intercepting_pref_filter_ = |
387 intercepting_pref_filter.get(); | 387 intercepting_pref_filter.get(); |
388 scoped_refptr<JsonPrefStore> pref_store = | 388 scoped_refptr<JsonPrefStore> pref_store = |
389 new JsonPrefStore(input_file, | 389 new JsonPrefStore(input_file, |
390 message_loop_.message_loop_proxy().get(), | 390 message_loop_.message_loop_proxy().get(), |
391 intercepting_pref_filter.PassAs<PrefFilter>()); | 391 intercepting_pref_filter.Pass()); |
392 | 392 |
393 ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE, | 393 ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE, |
394 pref_store->ReadPrefs()); | 394 pref_store->ReadPrefs()); |
395 EXPECT_FALSE(pref_store->ReadOnly()); | 395 EXPECT_FALSE(pref_store->ReadOnly()); |
396 | 396 |
397 // The store shouldn't be considered initialized until the interceptor | 397 // The store shouldn't be considered initialized until the interceptor |
398 // returns. | 398 // returns. |
399 EXPECT_TRUE(raw_intercepting_pref_filter_->has_intercepted_prefs()); | 399 EXPECT_TRUE(raw_intercepting_pref_filter_->has_intercepted_prefs()); |
400 EXPECT_FALSE(pref_store->IsInitializationComplete()); | 400 EXPECT_FALSE(pref_store->IsInitializationComplete()); |
401 EXPECT_FALSE(pref_store->GetValue(kHomePage, NULL)); | 401 EXPECT_FALSE(pref_store->GetValue(kHomePage, NULL)); |
(...skipping 26 matching lines...) Expand all Loading... |
428 base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); | 428 base::FilePath input_file = temp_dir_.path().AppendASCII("write.json"); |
429 ASSERT_TRUE(PathExists(input_file)); | 429 ASSERT_TRUE(PathExists(input_file)); |
430 | 430 |
431 scoped_ptr<InterceptingPrefFilter> intercepting_pref_filter( | 431 scoped_ptr<InterceptingPrefFilter> intercepting_pref_filter( |
432 new InterceptingPrefFilter()); | 432 new InterceptingPrefFilter()); |
433 InterceptingPrefFilter* raw_intercepting_pref_filter_ = | 433 InterceptingPrefFilter* raw_intercepting_pref_filter_ = |
434 intercepting_pref_filter.get(); | 434 intercepting_pref_filter.get(); |
435 scoped_refptr<JsonPrefStore> pref_store = | 435 scoped_refptr<JsonPrefStore> pref_store = |
436 new JsonPrefStore(input_file, | 436 new JsonPrefStore(input_file, |
437 message_loop_.message_loop_proxy().get(), | 437 message_loop_.message_loop_proxy().get(), |
438 intercepting_pref_filter.PassAs<PrefFilter>()); | 438 intercepting_pref_filter.Pass()); |
439 | 439 |
440 MockPrefStoreObserver mock_observer; | 440 MockPrefStoreObserver mock_observer; |
441 pref_store->AddObserver(&mock_observer); | 441 pref_store->AddObserver(&mock_observer); |
442 | 442 |
443 // Ownership of the |mock_error_delegate| is handed to the |pref_store| below. | 443 // Ownership of the |mock_error_delegate| is handed to the |pref_store| below. |
444 MockReadErrorDelegate* mock_error_delegate = new MockReadErrorDelegate; | 444 MockReadErrorDelegate* mock_error_delegate = new MockReadErrorDelegate; |
445 | 445 |
446 { | 446 { |
447 pref_store->ReadPrefsAsync(mock_error_delegate); | 447 pref_store->ReadPrefsAsync(mock_error_delegate); |
448 | 448 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 // "new_windows_in_tabs": true, | 665 // "new_windows_in_tabs": true, |
666 // "max_tabs": 20 | 666 // "max_tabs": 20 |
667 // } | 667 // } |
668 // } | 668 // } |
669 | 669 |
670 RunBasicJsonPrefStoreTest( | 670 RunBasicJsonPrefStoreTest( |
671 pref_store.get(), input_file, data_dir_.AppendASCII("write.golden.json")); | 671 pref_store.get(), input_file, data_dir_.AppendASCII("write.golden.json")); |
672 } | 672 } |
673 | 673 |
674 } // namespace base | 674 } // namespace base |
OLD | NEW |