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

Side by Side Diff: net/http/transport_security_persister_unittest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/http/transport_security_persister.h" 5 #include "net/http/transport_security_persister.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 std::string serialized; 121 std::string serialized;
122 EXPECT_TRUE(persister_->SerializeData(&serialized)); 122 EXPECT_TRUE(persister_->SerializeData(&serialized));
123 123
124 // Persist the data to the file. For the test to be fast and not flaky, we 124 // Persist the data to the file. For the test to be fast and not flaky, we
125 // just do it directly rather than call persister_->StateIsDirty. (That uses 125 // just do it directly rather than call persister_->StateIsDirty. (That uses
126 // ImportantFileWriter, which has an asynchronous commit interval rather 126 // ImportantFileWriter, which has an asynchronous commit interval rather
127 // than block.) Use a different basename just for cleanliness. 127 // than block.) Use a different basename just for cleanliness.
128 base::FilePath path = 128 base::FilePath path =
129 temp_dir_.path().AppendASCII("TransportSecurityPersisterTest"); 129 temp_dir_.path().AppendASCII("TransportSecurityPersisterTest");
130 EXPECT_TRUE(file_util::WriteFile(path, serialized.c_str(), 130 EXPECT_TRUE(base::WriteFile(path, serialized.c_str(), serialized.size()));
131 serialized.size()));
132 131
133 // Read the data back. 132 // Read the data back.
134 std::string persisted; 133 std::string persisted;
135 EXPECT_TRUE(base::ReadFileToString(path, &persisted)); 134 EXPECT_TRUE(base::ReadFileToString(path, &persisted));
136 EXPECT_EQ(persisted, serialized); 135 EXPECT_EQ(persisted, serialized);
137 bool dirty; 136 bool dirty;
138 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty)); 137 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty));
139 EXPECT_FALSE(dirty); 138 EXPECT_FALSE(dirty);
140 139
141 // Check that states are the same as saved. 140 // Check that states are the same as saved.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 std::string ser; 191 std::string ser;
193 EXPECT_TRUE(persister_->SerializeData(&ser)); 192 EXPECT_TRUE(persister_->SerializeData(&ser));
194 bool dirty; 193 bool dirty;
195 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty)); 194 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty));
196 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state)); 195 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state));
197 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size()); 196 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size());
198 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag); 197 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag);
199 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), 198 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(),
200 sha1.size())); 199 sha1.size()));
201 } 200 }
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/proxy/proxy_config_service_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698