| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/p2p/quic/reliablequicstream.h" | 11 #include "webrtc/p2p/quic/reliablequicstream.h" |
| 12 | 12 |
| 13 #include <memory> |
| 13 #include <string> | 14 #include <string> |
| 14 | 15 |
| 15 #include "net/base/ip_address_number.h" | 16 #include "net/base/ip_address_number.h" |
| 16 #include "net/quic/quic_connection.h" | 17 #include "net/quic/quic_connection.h" |
| 17 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 18 #include "net/quic/quic_session.h" | 19 #include "net/quic/quic_session.h" |
| 19 #include "webrtc/base/buffer.h" | 20 #include "webrtc/base/buffer.h" |
| 20 #include "webrtc/base/gunit.h" | 21 #include "webrtc/base/gunit.h" |
| 21 #include "webrtc/base/sigslot.h" | 22 #include "webrtc/base/sigslot.h" |
| 22 #include "webrtc/base/stream.h" | 23 #include "webrtc/base/stream.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 read_buffer_.append(data, length); | 175 read_buffer_.append(data, length); |
| 175 } | 176 } |
| 176 | 177 |
| 177 void OnClosed(QuicStreamId id, int err) { closed_ = true; } | 178 void OnClosed(QuicStreamId id, int err) { closed_ = true; } |
| 178 | 179 |
| 179 void OnQueuedBytesWritten(QuicStreamId id, uint64_t queued_bytes_written) { | 180 void OnQueuedBytesWritten(QuicStreamId id, uint64_t queued_bytes_written) { |
| 180 queued_bytes_written_ = queued_bytes_written; | 181 queued_bytes_written_ = queued_bytes_written; |
| 181 } | 182 } |
| 182 | 183 |
| 183 protected: | 184 protected: |
| 184 rtc::scoped_ptr<ReliableQuicStream> stream_; | 185 std::unique_ptr<ReliableQuicStream> stream_; |
| 185 rtc::scoped_ptr<MockQuicSession> session_; | 186 std::unique_ptr<MockQuicSession> session_; |
| 186 | 187 |
| 187 // Data written by the ReliableQuicStream. | 188 // Data written by the ReliableQuicStream. |
| 188 std::string write_buffer_; | 189 std::string write_buffer_; |
| 189 // Data read by the ReliableQuicStream. | 190 // Data read by the ReliableQuicStream. |
| 190 std::string read_buffer_; | 191 std::string read_buffer_; |
| 191 // Whether the ReliableQuicStream is closed. | 192 // Whether the ReliableQuicStream is closed. |
| 192 bool closed_ = false; | 193 bool closed_ = false; |
| 193 // Bytes written by OnCanWrite(). | 194 // Bytes written by OnCanWrite(). |
| 194 uint64_t queued_bytes_written_; | 195 uint64_t queued_bytes_written_; |
| 195 }; | 196 }; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 EXPECT_EQ("Hello", read_buffer_); | 250 EXPECT_EQ("Hello", read_buffer_); |
| 250 } | 251 } |
| 251 | 252 |
| 252 // Test that closing the stream results in a callback. | 253 // Test that closing the stream results in a callback. |
| 253 TEST_F(ReliableQuicStreamTest, CloseStream) { | 254 TEST_F(ReliableQuicStreamTest, CloseStream) { |
| 254 CreateReliableQuicStream(); | 255 CreateReliableQuicStream(); |
| 255 EXPECT_FALSE(closed_); | 256 EXPECT_FALSE(closed_); |
| 256 stream_->OnClose(); | 257 stream_->OnClose(); |
| 257 EXPECT_TRUE(closed_); | 258 EXPECT_TRUE(closed_); |
| 258 } | 259 } |
| OLD | NEW |