| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 Value::CreateStringValue( | 145 Value::CreateStringValue( |
| 146 base::Int64ToString(214748364842LL))); | 146 base::Int64ToString(214748364842LL))); |
| 147 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kLongIntPref, &actual)); | 147 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kLongIntPref, &actual)); |
| 148 EXPECT_TRUE(actual->GetAsString(&string_value)); | 148 EXPECT_TRUE(actual->GetAsString(&string_value)); |
| 149 int64 value; | 149 int64 value; |
| 150 base::StringToInt64(string_value, &value); | 150 base::StringToInt64(string_value, &value); |
| 151 EXPECT_EQ(214748364842LL, value); | 151 EXPECT_EQ(214748364842LL, value); |
| 152 | 152 |
| 153 // Serialize and compare to expected output. | 153 // Serialize and compare to expected output. |
| 154 ASSERT_TRUE(file_util::PathExists(golden_output_file)); | 154 ASSERT_TRUE(file_util::PathExists(golden_output_file)); |
| 155 ASSERT_TRUE(pref_store->WritePrefs()); | 155 pref_store->CommitPendingWrite(); |
| 156 MessageLoop::current()->RunAllPending(); | 156 MessageLoop::current()->RunAllPending(); |
| 157 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); | 157 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); |
| 158 ASSERT_TRUE(file_util::Delete(output_file, false)); | 158 ASSERT_TRUE(file_util::Delete(output_file, false)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(JsonPrefStoreTest, Basic) { | 161 TEST_F(JsonPrefStoreTest, Basic) { |
| 162 ASSERT_TRUE(file_util::CopyFile(data_dir_.AppendASCII("read.json"), | 162 ASSERT_TRUE(file_util::CopyFile(data_dir_.AppendASCII("read.json"), |
| 163 temp_dir_.path().AppendASCII("write.json"))); | 163 temp_dir_.path().AppendASCII("write.json"))); |
| 164 | 164 |
| 165 // Test that the persistent value can be loaded. | 165 // Test that the persistent value can be loaded. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 pref_store->ReadPrefsAsync(mock_error_delegate); | 237 pref_store->ReadPrefsAsync(mock_error_delegate); |
| 238 | 238 |
| 239 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); | 239 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); |
| 240 EXPECT_CALL(*mock_error_delegate, | 240 EXPECT_CALL(*mock_error_delegate, |
| 241 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1); | 241 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1); |
| 242 message_loop_.RunAllPending(); | 242 message_loop_.RunAllPending(); |
| 243 pref_store->RemoveObserver(&mock_observer); | 243 pref_store->RemoveObserver(&mock_observer); |
| 244 | 244 |
| 245 EXPECT_FALSE(pref_store->ReadOnly()); | 245 EXPECT_FALSE(pref_store->ReadOnly()); |
| 246 } | 246 } |
| OLD | NEW |