| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "chrome/common/chrome_paths.h" | 7 #include "chrome/common/chrome_paths.h" |
| 8 #include "chrome/common/json_value_serializer.h" | 8 #include "chrome/common/json_value_serializer.h" |
| 9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
| 10 #include "chrome/common/notification_types.h" | 10 #include "chrome/common/notification_types.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 PrefService prefs; | 149 PrefService prefs; |
| 150 | 150 |
| 151 std::wstring persistent_file = data_dir_; | 151 std::wstring persistent_file = data_dir_; |
| 152 file_util::AppendToPath(&persistent_file, L"overlay.json"); | 152 file_util::AppendToPath(&persistent_file, L"overlay.json"); |
| 153 EXPECT_TRUE(prefs.LoadPersistentPrefs(persistent_file)); | 153 EXPECT_TRUE(prefs.LoadPersistentPrefs(persistent_file)); |
| 154 | 154 |
| 155 Value* transient_value; | 155 Value* transient_value; |
| 156 { | 156 { |
| 157 JSONStringValueSerializer serializer(transient); | 157 JSONStringValueSerializer serializer(transient); |
| 158 ASSERT_TRUE(serializer.Deserialize(&transient_value, NULL)); | 158 transient_value = serializer.Deserialize(NULL); |
| 159 ASSERT_TRUE(transient_value); |
| 159 } | 160 } |
| 160 prefs.transient()->Set(transient_string, transient_value); | 161 prefs.transient()->Set(transient_string, transient_value); |
| 161 | 162 |
| 162 Value* both_transient_value; | 163 Value* both_transient_value; |
| 163 { | 164 { |
| 164 JSONStringValueSerializer serializer(transient); | 165 JSONStringValueSerializer serializer(transient); |
| 165 ASSERT_TRUE(serializer.Deserialize(&both_transient_value, NULL)); | 166 both_transient_value = serializer.Deserialize(NULL); |
| 167 ASSERT_TRUE(both_transient_value); |
| 166 } | 168 } |
| 167 prefs.transient()->Set(L"both", both_transient_value); | 169 prefs.transient()->Set(L"both", both_transient_value); |
| 168 | 170 |
| 169 // Register test prefs | 171 // Register test prefs |
| 170 static const std::wstring kTypes[] = | 172 static const std::wstring kTypes[] = |
| 171 { L"neither.", L"persistent.", L"transient.", L"both." }; | 173 { L"neither.", L"persistent.", L"transient.", L"both." }; |
| 172 for (size_t i = 0; i < arraysize(kTypes); ++i) { | 174 for (size_t i = 0; i < arraysize(kTypes); ++i) { |
| 173 prefs.RegisterBooleanPref((kTypes[i] + L"bool").c_str(), false); | 175 prefs.RegisterBooleanPref((kTypes[i] + L"bool").c_str(), false); |
| 174 prefs.RegisterIntegerPref((kTypes[i] + L"int").c_str(), 0); | 176 prefs.RegisterIntegerPref((kTypes[i] + L"int").c_str(), 0); |
| 175 prefs.RegisterRealPref((kTypes[i] + L"real").c_str(), 0.0); | 177 prefs.RegisterRealPref((kTypes[i] + L"real").c_str(), 0.0); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // Register the path. This doesn't set a value, so the path still shouldn't | 384 // Register the path. This doesn't set a value, so the path still shouldn't |
| 383 // exist. | 385 // exist. |
| 384 prefs.RegisterStringPref(path, std::wstring()); | 386 prefs.RegisterStringPref(path, std::wstring()); |
| 385 EXPECT_FALSE(prefs.HasPrefPath(path)); | 387 EXPECT_FALSE(prefs.HasPrefPath(path)); |
| 386 | 388 |
| 387 // Set a value and make sure we have a path. | 389 // Set a value and make sure we have a path. |
| 388 prefs.persistent_->SetString(path, L"blah"); | 390 prefs.persistent_->SetString(path, L"blah"); |
| 389 EXPECT_TRUE(prefs.HasPrefPath(path)); | 391 EXPECT_TRUE(prefs.HasPrefPath(path)); |
| 390 } | 392 } |
| 391 | 393 |
| OLD | NEW |