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

Side by Side Diff: chrome/common/pref_service_unittest.cc

Issue 13169: Add error messages to JSONReader and friends. This required a bit of refactor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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
OLDNEW
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
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)); 158 ASSERT_TRUE(serializer.Deserialize(&transient_value, NULL));
159 } 159 }
160 prefs.transient()->Set(transient_string, transient_value); 160 prefs.transient()->Set(transient_string, transient_value);
161 161
162 Value* both_transient_value; 162 Value* both_transient_value;
163 { 163 {
164 JSONStringValueSerializer serializer(transient); 164 JSONStringValueSerializer serializer(transient);
165 ASSERT_TRUE(serializer.Deserialize(&both_transient_value)); 165 ASSERT_TRUE(serializer.Deserialize(&both_transient_value, NULL));
166 } 166 }
167 prefs.transient()->Set(L"both", both_transient_value); 167 prefs.transient()->Set(L"both", both_transient_value);
168 168
169 // Register test prefs 169 // Register test prefs
170 const wchar_t* kTypes[] = { L"neither.", L"persistent.", L"transient.", L"both ." }; 170 const wchar_t* kTypes[] =
171 { L"neither.", L"persistent.", L"transient.", L"both." };
171 for (size_t i = 0; i < arraysize(kTypes); ++i) { 172 for (size_t i = 0; i < arraysize(kTypes); ++i) {
172 wchar_t temp[1024]; 173 wchar_t temp[1024];
173 wcscpy_s(temp, kTypes[i]); 174 wcscpy_s(temp, kTypes[i]);
174 wcscat_s(temp, L"bool"); 175 wcscat_s(temp, L"bool");
175 prefs.RegisterBooleanPref(temp, false); 176 prefs.RegisterBooleanPref(temp, false);
176 177
177 wcscpy_s(temp, kTypes[i]); 178 wcscpy_s(temp, kTypes[i]);
178 wcscat_s(temp, L"int"); 179 wcscat_s(temp, L"int");
179 prefs.RegisterIntegerPref(temp, 0); 180 prefs.RegisterIntegerPref(temp, 0);
180 181
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // Register the path. This doesn't set a value, so the path still shouldn't 400 // Register the path. This doesn't set a value, so the path still shouldn't
400 // exist. 401 // exist.
401 prefs.RegisterStringPref(path, std::wstring()); 402 prefs.RegisterStringPref(path, std::wstring());
402 EXPECT_FALSE(prefs.HasPrefPath(path)); 403 EXPECT_FALSE(prefs.HasPrefPath(path));
403 404
404 // Set a value and make sure we have a path. 405 // Set a value and make sure we have a path.
405 prefs.persistent_->SetString(path, L"blah"); 406 prefs.persistent_->SetString(path, L"blah");
406 EXPECT_TRUE(prefs.HasPrefPath(path)); 407 EXPECT_TRUE(prefs.HasPrefPath(path));
407 } 408 }
408 409
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698