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

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

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 months 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) 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 const char kSomeDirectory[] = "some_directory"; 107 const char kSomeDirectory[] = "some_directory";
108 108
109 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kSomeDirectory, &actual)); 109 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kSomeDirectory, &actual));
110 FilePath::StringType path; 110 FilePath::StringType path;
111 EXPECT_TRUE(actual->GetAsString(&path)); 111 EXPECT_TRUE(actual->GetAsString(&path));
112 EXPECT_EQ(FilePath::StringType(FILE_PATH_LITERAL("/usr/local/")), path); 112 EXPECT_EQ(FilePath::StringType(FILE_PATH_LITERAL("/usr/local/")), path);
113 FilePath some_path(FILE_PATH_LITERAL("/usr/sbin/")); 113 FilePath some_path(FILE_PATH_LITERAL("/usr/sbin/"));
114 114
115 pref_store->SetValue(kSomeDirectory, 115 pref_store->SetValue(kSomeDirectory,
116 Value::CreateStringValue(some_path.value())); 116 base::StringValue::New(some_path.value()));
117 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kSomeDirectory, &actual)); 117 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kSomeDirectory, &actual));
118 EXPECT_TRUE(actual->GetAsString(&path)); 118 EXPECT_TRUE(actual->GetAsString(&path));
119 EXPECT_EQ(some_path.value(), path); 119 EXPECT_EQ(some_path.value(), path);
120 120
121 // Test reading some other data types from sub-dictionaries. 121 // Test reading some other data types from sub-dictionaries.
122 EXPECT_EQ(PrefStore::READ_OK, 122 EXPECT_EQ(PrefStore::READ_OK,
123 pref_store->GetValue(kNewWindowsInTabs, &actual)); 123 pref_store->GetValue(kNewWindowsInTabs, &actual));
124 bool boolean = false; 124 bool boolean = false;
125 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); 125 EXPECT_TRUE(actual->GetAsBoolean(&boolean));
126 EXPECT_TRUE(boolean); 126 EXPECT_TRUE(boolean);
127 127
128 pref_store->SetValue(kNewWindowsInTabs, 128 pref_store->SetValue(kNewWindowsInTabs, base::FalseValue());
129 Value::CreateBooleanValue(false));
130 EXPECT_EQ(PrefStore::READ_OK, 129 EXPECT_EQ(PrefStore::READ_OK,
131 pref_store->GetValue(kNewWindowsInTabs, &actual)); 130 pref_store->GetValue(kNewWindowsInTabs, &actual));
132 EXPECT_TRUE(actual->GetAsBoolean(&boolean)); 131 EXPECT_TRUE(actual->GetAsBoolean(&boolean));
133 EXPECT_FALSE(boolean); 132 EXPECT_FALSE(boolean);
134 133
135 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kMaxTabs, &actual)); 134 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kMaxTabs, &actual));
136 int integer = 0; 135 int integer = 0;
137 EXPECT_TRUE(actual->GetAsInteger(&integer)); 136 EXPECT_TRUE(actual->GetAsInteger(&integer));
138 EXPECT_EQ(20, integer); 137 EXPECT_EQ(20, integer);
139 pref_store->SetValue(kMaxTabs, Value::CreateIntegerValue(10)); 138 pref_store->SetValue(kMaxTabs, base::NumberValue::New(10));
140 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kMaxTabs, &actual)); 139 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kMaxTabs, &actual));
141 EXPECT_TRUE(actual->GetAsInteger(&integer)); 140 EXPECT_TRUE(actual->GetAsInteger(&integer));
142 EXPECT_EQ(10, integer); 141 EXPECT_EQ(10, integer);
143 142
144 pref_store->SetValue(kLongIntPref, 143 pref_store->SetValue(kLongIntPref,
145 Value::CreateStringValue( 144 base::StringValue::New(
146 base::Int64ToString(214748364842LL))); 145 base::Int64ToString(214748364842LL)));
147 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kLongIntPref, &actual)); 146 EXPECT_EQ(PrefStore::READ_OK, pref_store->GetValue(kLongIntPref, &actual));
148 EXPECT_TRUE(actual->GetAsString(&string_value)); 147 EXPECT_TRUE(actual->GetAsString(&string_value));
149 int64 value; 148 int64 value;
150 base::StringToInt64(string_value, &value); 149 base::StringToInt64(string_value, &value);
151 EXPECT_EQ(214748364842LL, value); 150 EXPECT_EQ(214748364842LL, value);
152 151
153 // Serialize and compare to expected output. 152 // Serialize and compare to expected output.
154 ASSERT_TRUE(file_util::PathExists(golden_output_file)); 153 ASSERT_TRUE(file_util::PathExists(golden_output_file));
155 ASSERT_TRUE(pref_store->WritePrefs()); 154 ASSERT_TRUE(pref_store->WritePrefs());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 pref_store->ReadPrefsAsync(mock_error_delegate); 236 pref_store->ReadPrefsAsync(mock_error_delegate);
238 237
239 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); 238 EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1);
240 EXPECT_CALL(*mock_error_delegate, 239 EXPECT_CALL(*mock_error_delegate,
241 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1); 240 OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1);
242 message_loop_.RunAllPending(); 241 message_loop_.RunAllPending();
243 pref_store->RemoveObserver(&mock_observer); 242 pref_store->RemoveObserver(&mock_observer);
244 243
245 EXPECT_FALSE(pref_store->ReadOnly()); 244 EXPECT_FALSE(pref_store->ReadOnly());
246 } 245 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_set_unittest.cc ('k') | chrome/common/json_schema_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698