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 "app/test/data/resource.h" | 5 #include "app/test/data/resource.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/common/json_value_serializer.h" | 9 #include "chrome/common/json_value_serializer.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 EXPECT_EQ(FilePath::StringType(FILE_PATH_LITERAL("/usr/local/")), | 138 EXPECT_EQ(FilePath::StringType(FILE_PATH_LITERAL("/usr/local/")), |
139 prefs.GetFilePath(kSomeDirectory).value()); | 139 prefs.GetFilePath(kSomeDirectory).value()); |
140 prefs.SetFilePath(kSomeDirectory, some_path); | 140 prefs.SetFilePath(kSomeDirectory, some_path); |
141 EXPECT_EQ(some_path.value(), prefs.GetFilePath(kSomeDirectory).value()); | 141 EXPECT_EQ(some_path.value(), prefs.GetFilePath(kSomeDirectory).value()); |
142 | 142 |
143 // Serialize and compare to expected output. | 143 // Serialize and compare to expected output. |
144 FilePath output_file = test_dir_.AppendASCII("write.json"); | 144 FilePath output_file = test_dir_.AppendASCII("write.json"); |
145 FilePath golden_output_file = data_dir_.AppendASCII("write.golden.json"); | 145 FilePath golden_output_file = data_dir_.AppendASCII("write.golden.json"); |
146 ASSERT_TRUE(file_util::PathExists(golden_output_file)); | 146 ASSERT_TRUE(file_util::PathExists(golden_output_file)); |
147 ASSERT_TRUE(prefs.SavePersistentPrefs()); | 147 ASSERT_TRUE(prefs.SavePersistentPrefs()); |
148 EXPECT_TRUE(file_util::ContentsEqual(golden_output_file, output_file)); | 148 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); |
149 ASSERT_TRUE(file_util::Delete(output_file, false)); | 149 ASSERT_TRUE(file_util::Delete(output_file, false)); |
150 } | 150 } |
151 | 151 |
152 TEST_F(PrefServiceTest, Overlay) { | 152 TEST_F(PrefServiceTest, Overlay) { |
153 const std::string transient = | 153 const std::string transient = |
154 "{\"bool\":true, \"int\":2, \"real\":2.0, \"string\":\"transient\"," | 154 "{\"bool\":true, \"int\":2, \"real\":2.0, \"string\":\"transient\"," |
155 "\"dictionary\":{\"value\":\"transient\"}," | 155 "\"dictionary\":{\"value\":\"transient\"}," |
156 "\"list\":[\"transient\"]}"; | 156 "\"list\":[\"transient\"]}"; |
157 | 157 |
158 std::wstring persistent_string(L"persistent"); | 158 std::wstring persistent_string(L"persistent"); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 // Register the path. This doesn't set a value, so the path still shouldn't | 397 // Register the path. This doesn't set a value, so the path still shouldn't |
398 // exist. | 398 // exist. |
399 prefs.RegisterStringPref(path, std::wstring()); | 399 prefs.RegisterStringPref(path, std::wstring()); |
400 EXPECT_FALSE(prefs.HasPrefPath(path)); | 400 EXPECT_FALSE(prefs.HasPrefPath(path)); |
401 | 401 |
402 // Set a value and make sure we have a path. | 402 // Set a value and make sure we have a path. |
403 prefs.SetString(path, L"blah"); | 403 prefs.SetString(path, L"blah"); |
404 EXPECT_TRUE(prefs.HasPrefPath(path)); | 404 EXPECT_TRUE(prefs.HasPrefPath(path)); |
405 } | 405 } |
OLD | NEW |