OLD | NEW |
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> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" |
16 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 namespace net { | 21 namespace net { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 const char kReportUri[] = "http://www.example.test/report"; | 25 const char kReportUri[] = "http://www.example.test/report"; |
24 | 26 |
25 class TransportSecurityPersisterTest : public testing::Test { | 27 class TransportSecurityPersisterTest : public testing::Test { |
26 public: | 28 public: |
27 TransportSecurityPersisterTest() { | 29 TransportSecurityPersisterTest() { |
28 } | 30 } |
29 | 31 |
30 ~TransportSecurityPersisterTest() override { | 32 ~TransportSecurityPersisterTest() override { |
31 base::MessageLoopForIO::current()->RunUntilIdle(); | 33 EXPECT_TRUE(base::MessageLoopForIO::IsCurrent()); |
| 34 base::RunLoop().RunUntilIdle(); |
32 } | 35 } |
33 | 36 |
34 void SetUp() override { | 37 void SetUp() override { |
35 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 38 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 39 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
36 persister_.reset(new TransportSecurityPersister( | 40 persister_.reset(new TransportSecurityPersister( |
37 &state_, temp_dir_.path(), | 41 &state_, temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), false)); |
38 base::MessageLoopForIO::current()->task_runner(), false)); | |
39 } | 42 } |
40 | 43 |
41 protected: | 44 protected: |
42 base::ScopedTempDir temp_dir_; | 45 base::ScopedTempDir temp_dir_; |
43 TransportSecurityState state_; | 46 TransportSecurityState state_; |
44 std::unique_ptr<TransportSecurityPersister> persister_; | 47 std::unique_ptr<TransportSecurityPersister> persister_; |
45 }; | 48 }; |
46 | 49 |
47 TEST_F(TransportSecurityPersisterTest, SerializeData1) { | 50 TEST_F(TransportSecurityPersisterTest, SerializeData1) { |
48 std::string output; | 51 std::string output; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXPECT_EQ(1u, new_pkp_state.spki_hashes.size()); | 225 EXPECT_EQ(1u, new_pkp_state.spki_hashes.size()); |
223 EXPECT_EQ(sha256.tag, new_pkp_state.spki_hashes[0].tag); | 226 EXPECT_EQ(sha256.tag, new_pkp_state.spki_hashes[0].tag); |
224 EXPECT_EQ(0, memcmp(new_pkp_state.spki_hashes[0].data(), sha256.data(), | 227 EXPECT_EQ(0, memcmp(new_pkp_state.spki_hashes[0].data(), sha256.data(), |
225 sha256.size())); | 228 sha256.size())); |
226 EXPECT_EQ(report_uri, new_pkp_state.report_uri); | 229 EXPECT_EQ(report_uri, new_pkp_state.report_uri); |
227 } | 230 } |
228 | 231 |
229 } // namespace | 232 } // namespace |
230 | 233 |
231 } // namespace net | 234 } // namespace net |
OLD | NEW |