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

Side by Side Diff: prefs_unittest.cc

Issue 2856070: Don't send machine and user ID to Omaha anymore. Send a/r pings instead. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Address review comments. Created 10 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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <inttypes.h> 5 #include <inttypes.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 TEST_F(PrefsTest, SetStringBadKey) { 85 TEST_F(PrefsTest, SetStringBadKey) {
86 const char kKey[] = ".no-dots"; 86 const char kKey[] = ".no-dots";
87 EXPECT_FALSE(prefs_.SetString(kKey, "some value")); 87 EXPECT_FALSE(prefs_.SetString(kKey, "some value"));
88 EXPECT_FALSE(file_util::PathExists(prefs_dir_.Append(kKey))); 88 EXPECT_FALSE(file_util::PathExists(prefs_dir_.Append(kKey)));
89 } 89 }
90 90
91 TEST_F(PrefsTest, SetStringCreateDir) { 91 TEST_F(PrefsTest, SetStringCreateDir) {
92 const char kKey[] = "a-test-key"; 92 const char kKey[] = "a-test-key";
93 const char kValue[] = "test value"; 93 const char kValue[] = "test value";
94 EXPECT_TRUE(prefs_.Init(FilePath(prefs_dir_.Append("subdir")))); 94 FilePath subdir = prefs_dir_.Append("subdir1").Append("subdir2");
95 EXPECT_TRUE(prefs_.Init(subdir));
95 EXPECT_TRUE(prefs_.SetString(kKey, kValue)); 96 EXPECT_TRUE(prefs_.SetString(kKey, kValue));
96 string value; 97 string value;
97 EXPECT_TRUE( 98 EXPECT_TRUE(file_util::ReadFileToString(subdir.Append(kKey), &value));
98 file_util::ReadFileToString(prefs_dir_.Append("subdir").Append(kKey),
99 &value));
100 EXPECT_EQ(kValue, value); 99 EXPECT_EQ(kValue, value);
101 } 100 }
102 101
103 TEST_F(PrefsTest, SetStringDirCreationFailure) { 102 TEST_F(PrefsTest, SetStringDirCreationFailure) {
104 EXPECT_TRUE(prefs_.Init(FilePath("/dev/null"))); 103 EXPECT_TRUE(prefs_.Init(FilePath("/dev/null")));
105 const char kKey[] = "test-key"; 104 const char kKey[] = "test-key";
106 EXPECT_FALSE(prefs_.SetString(kKey, "test value")); 105 EXPECT_FALSE(prefs_.SetString(kKey, "test value"));
107 } 106 }
108 107
109 TEST_F(PrefsTest, SetStringFileCreationFailure) { 108 TEST_F(PrefsTest, SetStringFileCreationFailure) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 180
182 TEST_F(PrefsTest, SetInt64Min) { 181 TEST_F(PrefsTest, SetInt64Min) {
183 const char kKey[] = "test-min-int"; 182 const char kKey[] = "test-min-int";
184 EXPECT_TRUE(prefs_.SetInt64(kKey, kint64min)); 183 EXPECT_TRUE(prefs_.SetInt64(kKey, kint64min));
185 string value; 184 string value;
186 EXPECT_TRUE(file_util::ReadFileToString(prefs_dir_.Append(kKey), &value)); 185 EXPECT_TRUE(file_util::ReadFileToString(prefs_dir_.Append(kKey), &value));
187 EXPECT_EQ(StringPrintf("%" PRIi64, kint64min), value); 186 EXPECT_EQ(StringPrintf("%" PRIi64, kint64min), value);
188 } 187 }
189 188
190 } // namespace chromeos_update_engine 189 } // namespace chromeos_update_engine
OLDNEW
« omaha_request_action.h ('K') | « prefs_mock.h ('k') | update_attempter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698