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 "components/prefs/json_pref_store.h" | 5 #include "components/prefs/json_pref_store.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 EXPECT_TRUE(pref_store->GetValue(kSomeDirectory, &actual)); | 234 EXPECT_TRUE(pref_store->GetValue(kSomeDirectory, &actual)); |
235 EXPECT_TRUE(actual->GetAsString(&path)); | 235 EXPECT_TRUE(actual->GetAsString(&path)); |
236 EXPECT_EQ(some_path.value(), path); | 236 EXPECT_EQ(some_path.value(), path); |
237 | 237 |
238 // Test reading some other data types from sub-dictionaries. | 238 // Test reading some other data types from sub-dictionaries. |
239 EXPECT_TRUE(pref_store->GetValue(kNewWindowsInTabs, &actual)); | 239 EXPECT_TRUE(pref_store->GetValue(kNewWindowsInTabs, &actual)); |
240 bool boolean = false; | 240 bool boolean = false; |
241 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); | 241 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); |
242 EXPECT_TRUE(boolean); | 242 EXPECT_TRUE(boolean); |
243 | 243 |
244 pref_store->SetValue(kNewWindowsInTabs, | 244 pref_store->SetValue(kNewWindowsInTabs, base::MakeUnique<Value>(false), |
245 base::MakeUnique<FundamentalValue>(false), | |
246 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 245 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
247 EXPECT_TRUE(pref_store->GetValue(kNewWindowsInTabs, &actual)); | 246 EXPECT_TRUE(pref_store->GetValue(kNewWindowsInTabs, &actual)); |
248 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); | 247 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); |
249 EXPECT_FALSE(boolean); | 248 EXPECT_FALSE(boolean); |
250 | 249 |
251 EXPECT_TRUE(pref_store->GetValue(kMaxTabs, &actual)); | 250 EXPECT_TRUE(pref_store->GetValue(kMaxTabs, &actual)); |
252 int integer = 0; | 251 int integer = 0; |
253 EXPECT_TRUE(actual->GetAsInteger(&integer)); | 252 EXPECT_TRUE(actual->GetAsInteger(&integer)); |
254 EXPECT_EQ(20, integer); | 253 EXPECT_EQ(20, integer); |
255 pref_store->SetValue(kMaxTabs, base::MakeUnique<FundamentalValue>(10), | 254 pref_store->SetValue(kMaxTabs, base::MakeUnique<Value>(10), |
256 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 255 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
257 EXPECT_TRUE(pref_store->GetValue(kMaxTabs, &actual)); | 256 EXPECT_TRUE(pref_store->GetValue(kMaxTabs, &actual)); |
258 EXPECT_TRUE(actual->GetAsInteger(&integer)); | 257 EXPECT_TRUE(actual->GetAsInteger(&integer)); |
259 EXPECT_EQ(10, integer); | 258 EXPECT_EQ(10, integer); |
260 | 259 |
261 pref_store->SetValue(kLongIntPref, base::MakeUnique<StringValue>( | 260 pref_store->SetValue(kLongIntPref, base::MakeUnique<StringValue>( |
262 base::Int64ToString(214748364842LL)), | 261 base::Int64ToString(214748364842LL)), |
263 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 262 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
264 EXPECT_TRUE(pref_store->GetValue(kLongIntPref, &actual)); | 263 EXPECT_TRUE(pref_store->GetValue(kLongIntPref, &actual)); |
265 EXPECT_TRUE(actual->GetAsString(&string_value)); | 264 EXPECT_TRUE(actual->GetAsString(&string_value)); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 file_writer->WriteNow(MakeUnique<std::string>("foo")); | 1244 file_writer->WriteNow(MakeUnique<std::string>("foo")); |
1246 } | 1245 } |
1247 RunLoop().RunUntilIdle(); | 1246 RunLoop().RunUntilIdle(); |
1248 EXPECT_FALSE(successful_write_reply_observer_.GetAndResetObservationState()); | 1247 EXPECT_FALSE(successful_write_reply_observer_.GetAndResetObservationState()); |
1249 EXPECT_TRUE(write_callback_observer_.GetAndResetPreWriteObservationState()); | 1248 EXPECT_TRUE(write_callback_observer_.GetAndResetPreWriteObservationState()); |
1250 EXPECT_EQ(CALLED_WITH_SUCCESS, | 1249 EXPECT_EQ(CALLED_WITH_SUCCESS, |
1251 write_callback_observer_.GetAndResetPostWriteObservationState()); | 1250 write_callback_observer_.GetAndResetPostWriteObservationState()); |
1252 } | 1251 } |
1253 | 1252 |
1254 } // namespace base | 1253 } // namespace base |
OLD | NEW |