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

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

Issue 2319513003: //[chrome/browser/]net: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 20 matching lines...) Expand all
31 31
32 ~TransportSecurityPersisterTest() override { 32 ~TransportSecurityPersisterTest() override {
33 EXPECT_TRUE(base::MessageLoopForIO::IsCurrent()); 33 EXPECT_TRUE(base::MessageLoopForIO::IsCurrent());
34 base::RunLoop().RunUntilIdle(); 34 base::RunLoop().RunUntilIdle();
35 } 35 }
36 36
37 void SetUp() override { 37 void SetUp() override {
38 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 38 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
39 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); 39 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent());
40 persister_.reset(new TransportSecurityPersister( 40 persister_.reset(new TransportSecurityPersister(
41 &state_, temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), false)); 41 &state_, temp_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get(),
42 false));
42 } 43 }
43 44
44 protected: 45 protected:
45 base::ScopedTempDir temp_dir_; 46 base::ScopedTempDir temp_dir_;
46 TransportSecurityState state_; 47 TransportSecurityState state_;
47 std::unique_ptr<TransportSecurityPersister> persister_; 48 std::unique_ptr<TransportSecurityPersister> persister_;
48 }; 49 };
49 50
50 TEST_F(TransportSecurityPersisterTest, SerializeData1) { 51 TEST_F(TransportSecurityPersisterTest, SerializeData1) {
51 std::string output; 52 std::string output;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 137
137 std::string serialized; 138 std::string serialized;
138 EXPECT_TRUE(persister_->SerializeData(&serialized)); 139 EXPECT_TRUE(persister_->SerializeData(&serialized));
139 140
140 // Persist the data to the file. For the test to be fast and not flaky, we 141 // Persist the data to the file. For the test to be fast and not flaky, we
141 // just do it directly rather than call persister_->StateIsDirty. (That uses 142 // just do it directly rather than call persister_->StateIsDirty. (That uses
142 // ImportantFileWriter, which has an asynchronous commit interval rather 143 // ImportantFileWriter, which has an asynchronous commit interval rather
143 // than block.) Use a different basename just for cleanliness. 144 // than block.) Use a different basename just for cleanliness.
144 base::FilePath path = 145 base::FilePath path =
145 temp_dir_.path().AppendASCII("TransportSecurityPersisterTest"); 146 temp_dir_.GetPath().AppendASCII("TransportSecurityPersisterTest");
146 EXPECT_TRUE(base::WriteFile(path, serialized.c_str(), serialized.size())); 147 EXPECT_TRUE(base::WriteFile(path, serialized.c_str(), serialized.size()));
147 148
148 // Read the data back. 149 // Read the data back.
149 std::string persisted; 150 std::string persisted;
150 EXPECT_TRUE(base::ReadFileToString(path, &persisted)); 151 EXPECT_TRUE(base::ReadFileToString(path, &persisted));
151 EXPECT_EQ(persisted, serialized); 152 EXPECT_EQ(persisted, serialized);
152 bool dirty; 153 bool dirty;
153 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty)); 154 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty));
154 EXPECT_FALSE(dirty); 155 EXPECT_FALSE(dirty);
155 156
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 EXPECT_EQ(1u, new_pkp_state.spki_hashes.size()); 226 EXPECT_EQ(1u, new_pkp_state.spki_hashes.size());
226 EXPECT_EQ(sha256.tag, new_pkp_state.spki_hashes[0].tag); 227 EXPECT_EQ(sha256.tag, new_pkp_state.spki_hashes[0].tag);
227 EXPECT_EQ(0, memcmp(new_pkp_state.spki_hashes[0].data(), sha256.data(), 228 EXPECT_EQ(0, memcmp(new_pkp_state.spki_hashes[0].data(), sha256.data(),
228 sha256.size())); 229 sha256.size()));
229 EXPECT_EQ(report_uri, new_pkp_state.report_uri); 230 EXPECT_EQ(report_uri, new_pkp_state.report_uri);
230 } 231 }
231 232
232 } // namespace 233 } // namespace
233 234
234 } // namespace net 235 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/log/bounded_file_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698