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/quic/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 #include "net/quic/quic_connection.h" | 6 #include "net/quic/quic_connection.h" |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "net/quic/test_tools/quic_test_utils.h" | 11 #include "net/quic/test_tools/quic_test_utils.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::hash_map; | 15 using base::hash_map; |
16 using std::set; | 16 using std::set; |
17 using testing::_; | 17 using testing::_; |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 namespace test { | 20 namespace test { |
21 namespace { | 21 namespace { |
22 | 22 |
23 class TestCryptoStream : public QuicCryptoStream { | 23 class TestCryptoStream : public QuicCryptoStream { |
24 public: | 24 public: |
25 explicit TestCryptoStream(QuicSession* session) | 25 explicit TestCryptoStream(QuicSession* session) |
26 : QuicCryptoStream(session) { | 26 : QuicCryptoStream(session) { |
27 } | 27 } |
28 | 28 |
29 void OnHandshakeMessage(const CryptoHandshakeMessage& message) { | 29 void OnHandshakeMessage(const CryptoHandshakeMessage& message) { |
30 set_handshake_complete(true); | 30 SetHandshakeComplete(QUIC_NO_ERROR); |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
34 class TestStream : public ReliableQuicStream { | 34 class TestStream : public ReliableQuicStream { |
35 public: | 35 public: |
36 TestStream(QuicStreamId id, QuicSession* session) | 36 TestStream(QuicStreamId id, QuicSession* session) |
37 : ReliableQuicStream(id, session) { | 37 : ReliableQuicStream(id, session) { |
38 } | 38 } |
39 | 39 |
40 virtual uint32 ProcessData(const char* data, uint32 data_len) { | 40 virtual uint32 ProcessData(const char* data, uint32 data_len) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 QuicGuid guid_; | 100 QuicGuid guid_; |
101 MockConnection* connection_; | 101 MockConnection* connection_; |
102 TestSession session_; | 102 TestSession session_; |
103 QuicConnectionVisitorInterface* visitor_; | 103 QuicConnectionVisitorInterface* visitor_; |
104 hash_map<QuicStreamId, ReliableQuicStream*>* streams_; | 104 hash_map<QuicStreamId, ReliableQuicStream*>* streams_; |
105 set<QuicStreamId> closed_streams_; | 105 set<QuicStreamId> closed_streams_; |
106 }; | 106 }; |
107 | 107 |
108 TEST_F(QuicSessionTest, IsHandshakeComplete) { | 108 TEST_F(QuicSessionTest, IsCryptoHandshakeComplete) { |
109 EXPECT_FALSE(session_.IsHandshakeComplete()); | 109 EXPECT_FALSE(session_.IsCryptoHandshakeComplete()); |
110 CryptoHandshakeMessage message; | 110 CryptoHandshakeMessage message; |
111 session_.crypto_stream_.OnHandshakeMessage(message); | 111 session_.crypto_stream_.OnHandshakeMessage(message); |
112 EXPECT_TRUE(session_.IsHandshakeComplete()); | 112 EXPECT_TRUE(session_.IsCryptoHandshakeComplete()); |
113 } | 113 } |
114 | 114 |
115 TEST_F(QuicSessionTest, IsClosedStreamDefault) { | 115 TEST_F(QuicSessionTest, IsClosedStreamDefault) { |
116 // Ensure that no streams are initially closed. | 116 // Ensure that no streams are initially closed. |
117 for (int i = kCryptoStreamId; i < 100; i++) { | 117 for (int i = kCryptoStreamId; i < 100; i++) { |
118 EXPECT_FALSE(session_.IsClosedStream(i)); | 118 EXPECT_FALSE(session_.IsClosedStream(i)); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) { | 122 TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) { |
(...skipping 26 matching lines...) Expand all Loading... |
149 TEST_F(QuicSessionTest, StreamIdTooLarge) { | 149 TEST_F(QuicSessionTest, StreamIdTooLarge) { |
150 scoped_ptr<ReliableQuicStream> stream3(session_.GetIncomingReliableStream(3)); | 150 scoped_ptr<ReliableQuicStream> stream3(session_.GetIncomingReliableStream(3)); |
151 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 151 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); |
152 scoped_ptr<ReliableQuicStream> stream5( | 152 scoped_ptr<ReliableQuicStream> stream5( |
153 session_.GetIncomingReliableStream(105)); | 153 session_.GetIncomingReliableStream(105)); |
154 } | 154 } |
155 | 155 |
156 } // namespace | 156 } // namespace |
157 } // namespace test | 157 } // namespace test |
158 } // namespace net | 158 } // namespace net |
OLD | NEW |