OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/disk_cache_based_quic_server_info.h" | 5 #include "net/http/disk_cache_based_quic_server_info.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/http/mock_http_cache.h" | 12 #include "net/http/mock_http_cache.h" |
13 #include "net/quic/crypto/quic_server_info.h" | 13 #include "net/quic/crypto/quic_server_info.h" |
14 #include "net/quic/quic_server_id.h" | 14 #include "net/quic/quic_server_id.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 namespace { | 18 namespace { |
19 | 19 |
20 // This is an empty transaction, needed to register the URL and the test mode. | 20 // This is an empty transaction, needed to register the URL and the test mode. |
21 const MockTransaction kHostInfoTransaction1 = { | 21 const MockTransaction kHostInfoTransaction1 = { |
22 "quicserverinfo:https://www.google.com:443", | 22 "quicserverinfo:https://www.google.com:443", "", base::Time(), |
23 "", | 23 "", LOAD_NORMAL, "", |
24 base::Time(), | 24 "", base::Time(), "", |
25 "", | 25 TEST_MODE_NORMAL, NULL, 0}; |
26 LOAD_NORMAL, | |
27 "", | |
28 "", | |
29 base::Time(), | |
30 "", | |
31 TEST_MODE_NORMAL, | |
32 NULL, | |
33 0 | |
34 }; | |
35 | 26 |
36 const MockTransaction kHostInfoTransaction2 = { | 27 const MockTransaction kHostInfoTransaction2 = { |
37 "quicserverinfo:http://www.google.com:80", | 28 "quicserverinfo:http://www.google.com:80", "", base::Time(), |
38 "", | 29 "", LOAD_NORMAL, "", |
39 base::Time(), | 30 "", base::Time(), "", |
40 "", | 31 TEST_MODE_NORMAL, NULL, 0}; |
41 LOAD_NORMAL, | |
42 "", | |
43 "", | |
44 base::Time(), | |
45 "", | |
46 TEST_MODE_NORMAL, | |
47 NULL, | |
48 0 | |
49 }; | |
50 | 32 |
51 } // namespace | 33 } // namespace |
52 | 34 |
53 // Tests that we can delete a DiskCacheBasedQuicServerInfo object in a | 35 // Tests that we can delete a DiskCacheBasedQuicServerInfo object in a |
54 // completion callback for DiskCacheBasedQuicServerInfo::WaitForDataReady. | 36 // completion callback for DiskCacheBasedQuicServerInfo::WaitForDataReady. |
55 TEST(DiskCacheBasedQuicServerInfo, DeleteInCallback) { | 37 TEST(DiskCacheBasedQuicServerInfo, DeleteInCallback) { |
56 // Use the blocking mock backend factory to force asynchronous completion | 38 // Use the blocking mock backend factory to force asynchronous completion |
57 // of quic_server_info->WaitForDataReady(), so that the callback will run. | 39 // of quic_server_info->WaitForDataReady(), so that the callback will run. |
58 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); | 40 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); |
59 MockHttpCache cache(factory); | 41 MockHttpCache cache(factory); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 EXPECT_EQ(server_config_a, state1.server_config); | 255 EXPECT_EQ(server_config_a, state1.server_config); |
274 EXPECT_EQ(source_address_token_a, state1.source_address_token); | 256 EXPECT_EQ(source_address_token_a, state1.source_address_token); |
275 EXPECT_EQ(server_config_sig_a, state1.server_config_sig); | 257 EXPECT_EQ(server_config_sig_a, state1.server_config_sig); |
276 EXPECT_EQ(1U, state1.certs.size()); | 258 EXPECT_EQ(1U, state1.certs.size()); |
277 EXPECT_EQ(cert_a, state1.certs[0]); | 259 EXPECT_EQ(cert_a, state1.certs[0]); |
278 | 260 |
279 RemoveMockTransaction(&kHostInfoTransaction1); | 261 RemoveMockTransaction(&kHostInfoTransaction1); |
280 } | 262 } |
281 | 263 |
282 } // namespace net | 264 } // namespace net |
OLD | NEW |