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

Side by Side Diff: webrtc/api/quicdatatransport_unittest.cc

Issue 2166873002: Modified PeerConnection and WebRtcSession for end-to-end QuicDataChannel usage. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change the comments and minor fix. Created 4 years, 4 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
« no previous file with comments | « webrtc/api/quicdatatransport.cc ('k') | webrtc/api/test/peerconnectiontestwrapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 12 matching lines...) Expand all
23 #include "webrtc/p2p/quic/quictransportchannel.h" 23 #include "webrtc/p2p/quic/quictransportchannel.h"
24 #include "webrtc/p2p/quic/reliablequicstream.h" 24 #include "webrtc/p2p/quic/reliablequicstream.h"
25 25
26 using webrtc::DataBuffer; 26 using webrtc::DataBuffer;
27 using webrtc::DataChannelInit; 27 using webrtc::DataChannelInit;
28 using webrtc::DataChannelInterface; 28 using webrtc::DataChannelInterface;
29 using webrtc::DataChannelObserver; 29 using webrtc::DataChannelObserver;
30 using webrtc::QuicDataChannel; 30 using webrtc::QuicDataChannel;
31 using webrtc::QuicDataTransport; 31 using webrtc::QuicDataTransport;
32 using cricket::FakeTransportChannel; 32 using cricket::FakeTransportChannel;
33 using cricket::FakeTransportController;
33 using cricket::QuicTransportChannel; 34 using cricket::QuicTransportChannel;
34 using cricket::ReliableQuicStream; 35 using cricket::ReliableQuicStream;
35 36
36 namespace { 37 namespace {
37 38
38 // Timeout for asynchronous operations. 39 // Timeout for asynchronous operations.
39 static const int kTimeoutMs = 1000; // milliseconds 40 static const int kTimeoutMs = 1000; // milliseconds
41 static const char kTransportName[] = "data";
40 42
41 // FakeObserver receives messages from the data channel. 43 // FakeObserver receives messages from the data channel.
42 class FakeObserver : public DataChannelObserver { 44 class FakeObserver : public DataChannelObserver {
43 public: 45 public:
44 FakeObserver() {} 46 FakeObserver() {}
45 47
46 void OnStateChange() override {} 48 void OnStateChange() override {}
47 49
48 void OnBufferedAmountChange(uint64_t previous_amount) override {} 50 void OnBufferedAmountChange(uint64_t previous_amount) override {}
49 51
50 void OnMessage(const webrtc::DataBuffer& buffer) override { 52 void OnMessage(const webrtc::DataBuffer& buffer) override {
51 messages_.push_back(std::string(buffer.data.data<char>(), buffer.size())); 53 messages_.push_back(std::string(buffer.data.data<char>(), buffer.size()));
52 } 54 }
53 55
54 const std::vector<std::string>& messages() const { return messages_; } 56 const std::vector<std::string>& messages() const { return messages_; }
55 57
56 size_t messages_received() const { return messages_.size(); } 58 size_t messages_received() const { return messages_.size(); }
57 59
58 private: 60 private:
59 std::vector<std::string> messages_; 61 std::vector<std::string> messages_;
60 }; 62 };
61 63
62 // A peer who uses a QUIC transport channel and fake ICE transport channel to 64 // A peer who uses a QUIC transport channel and fake ICE transport channel to
63 // send or receive data. 65 // send or receive data.
64 class QuicDataTransportPeer { 66 class QuicDataTransportPeer {
65 public: 67 public:
66 QuicDataTransportPeer() 68 QuicDataTransportPeer()
67 : quic_data_transport_(rtc::Thread::Current(), 69 : fake_transport_controller_(new FakeTransportController()),
70 quic_data_transport_(rtc::Thread::Current(),
68 rtc::Thread::Current(), 71 rtc::Thread::Current(),
69 rtc::Thread::Current()), 72 rtc::Thread::Current(),
70 ice_transport_channel_(new FakeTransportChannel("data", 0)), 73 fake_transport_controller_.get()) {
71 quic_transport_channel_(ice_transport_channel_) { 74 fake_transport_controller_->use_quic();
75 quic_data_transport_.set_content_name("data");
76 quic_data_transport_.SetTransport(kTransportName);
77 ice_transport_channel_ = static_cast<FakeTransportChannel*>(
78 quic_data_transport_.quic_transport_channel()->ice_transport_channel());
72 ice_transport_channel_->SetAsync(true); 79 ice_transport_channel_->SetAsync(true);
73 } 80 }
74 81
75 void GenerateCertificateAndFingerprint() { 82 void GenerateCertificateAndFingerprint() {
76 rtc::scoped_refptr<rtc::RTCCertificate> local_cert = 83 rtc::scoped_refptr<rtc::RTCCertificate> local_cert =
77 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 84 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
78 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT))); 85 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT)));
79 quic_transport_channel_.SetLocalCertificate(local_cert); 86 quic_data_transport_.quic_transport_channel()->SetLocalCertificate(
87 local_cert);
80 local_fingerprint_.reset(CreateFingerprint(local_cert.get())); 88 local_fingerprint_.reset(CreateFingerprint(local_cert.get()));
81 } 89 }
82 90
83 // Connects |ice_transport_channel_| to that of the other peer. 91 // Connects |ice_transport_channel_| to that of the other peer.
84 void Connect(QuicDataTransportPeer* other_peer) { 92 void Connect(QuicDataTransportPeer* other_peer) {
85 ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_); 93 ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_);
86 } 94 }
87 95
88 std::unique_ptr<rtc::SSLFingerprint>& local_fingerprint() { 96 std::unique_ptr<rtc::SSLFingerprint>& local_fingerprint() {
89 return local_fingerprint_; 97 return local_fingerprint_;
90 } 98 }
91 99
92 QuicTransportChannel* quic_transport_channel() { 100 QuicTransportChannel* quic_transport_channel() {
93 return &quic_transport_channel_; 101 return quic_data_transport_.quic_transport_channel();
94 } 102 }
95 103
96 // Write a messge directly to the ReliableQuicStream. 104 // Write a messge directly to the ReliableQuicStream.
97 void WriteMessage(int data_channel_id, 105 void WriteMessage(int data_channel_id,
98 uint64_t message_id, 106 uint64_t message_id,
99 const std::string& message) { 107 const std::string& message) {
100 ReliableQuicStream* stream = quic_transport_channel_.CreateQuicStream(); 108 ReliableQuicStream* stream =
109 quic_data_transport_.quic_transport_channel()->CreateQuicStream();
101 rtc::CopyOnWriteBuffer payload; 110 rtc::CopyOnWriteBuffer payload;
102 webrtc::WriteQuicDataChannelMessageHeader(data_channel_id, message_id, 111 webrtc::WriteQuicDataChannelMessageHeader(data_channel_id, message_id,
103 &payload); 112 &payload);
104 stream->Write(payload.data<char>(), payload.size(), false); 113 stream->Write(payload.data<char>(), payload.size(), false);
105 stream->Write(message.data(), message.size(), true); 114 stream->Write(message.data(), message.size(), true);
106 } 115 }
107 116
108 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( 117 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
109 const DataChannelInit* config) { 118 const DataChannelInit* config) {
110 return quic_data_transport_.CreateDataChannel("testing", config); 119 return quic_data_transport_.CreateDataChannel("testing", config);
111 } 120 }
112 121
113 QuicDataTransport* quic_data_transport() { return &quic_data_transport_; } 122 QuicDataTransport* quic_data_transport() { return &quic_data_transport_; }
114 123
115 private: 124 private:
116 // Creates a fingerprint from a certificate. 125 // Creates a fingerprint from a certificate.
117 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) { 126 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) {
118 std::string digest_algorithm; 127 std::string digest_algorithm;
119 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm); 128 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm);
120 std::unique_ptr<rtc::SSLFingerprint> fingerprint( 129 std::unique_ptr<rtc::SSLFingerprint> fingerprint(
121 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity())); 130 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity()));
122 return fingerprint.release(); 131 return fingerprint.release();
123 } 132 }
124 133
134 std::unique_ptr<FakeTransportController> fake_transport_controller_;
125 QuicDataTransport quic_data_transport_; 135 QuicDataTransport quic_data_transport_;
126 FakeTransportChannel* ice_transport_channel_; 136 FakeTransportChannel* ice_transport_channel_;
127 QuicTransportChannel quic_transport_channel_;
128 std::unique_ptr<rtc::SSLFingerprint> local_fingerprint_; 137 std::unique_ptr<rtc::SSLFingerprint> local_fingerprint_;
129 }; 138 };
130 139
131 class QuicDataTransportTest : public testing::Test { 140 class QuicDataTransportTest : public testing::Test {
132 public: 141 public:
133 QuicDataTransportTest() {} 142 QuicDataTransportTest() {}
134 143
135 void ConnectTransportChannels() { 144 void ConnectTransportChannels() {
136 SetCryptoParameters(); 145 SetCryptoParameters();
137 peer1_.Connect(&peer2_); 146 peer1_.Connect(&peer2_);
138 ASSERT_TRUE_WAIT(peer1_.quic_transport_channel()->writable() && 147 ASSERT_TRUE_WAIT(peer1_.quic_transport_channel()->writable() &&
139 peer2_.quic_transport_channel()->writable(), 148 peer2_.quic_transport_channel()->writable(),
140 kTimeoutMs); 149 kTimeoutMs);
141 } 150 }
142 151
143 void SetTransportChannels() {
144 ASSERT_TRUE(peer1_.quic_data_transport()->SetTransportChannel(
145 peer1_.quic_transport_channel()));
146 ASSERT_TRUE(peer2_.quic_data_transport()->SetTransportChannel(
147 peer2_.quic_transport_channel()));
148 }
149
150 // Sets crypto parameters required for the QUIC handshake. 152 // Sets crypto parameters required for the QUIC handshake.
151 void SetCryptoParameters() { 153 void SetCryptoParameters() {
152 peer1_.GenerateCertificateAndFingerprint(); 154 peer1_.GenerateCertificateAndFingerprint();
153 peer2_.GenerateCertificateAndFingerprint(); 155 peer2_.GenerateCertificateAndFingerprint();
154 156
155 peer1_.quic_transport_channel()->SetSslRole(rtc::SSL_CLIENT); 157 peer1_.quic_transport_channel()->SetSslRole(rtc::SSL_CLIENT);
156 peer2_.quic_transport_channel()->SetSslRole(rtc::SSL_SERVER); 158 peer2_.quic_transport_channel()->SetSslRole(rtc::SSL_SERVER);
157 159
158 std::unique_ptr<rtc::SSLFingerprint>& peer1_fingerprint = 160 std::unique_ptr<rtc::SSLFingerprint>& peer1_fingerprint =
159 peer1_.local_fingerprint(); 161 peer1_.local_fingerprint();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Tests that the QuicDataTransport does not allow creating multiple 202 // Tests that the QuicDataTransport does not allow creating multiple
201 // QuicDataChannels with the same id. 203 // QuicDataChannels with the same id.
202 TEST_F(QuicDataTransportTest, CannotCreateDataChannelsWithSameId) { 204 TEST_F(QuicDataTransportTest, CannotCreateDataChannelsWithSameId) {
203 webrtc::DataChannelInit config; 205 webrtc::DataChannelInit config;
204 config.id = 2; 206 config.id = 2;
205 EXPECT_NE(nullptr, peer2_.CreateDataChannel(&config)); 207 EXPECT_NE(nullptr, peer2_.CreateDataChannel(&config));
206 EXPECT_EQ(nullptr, peer2_.CreateDataChannel(&config)); 208 EXPECT_EQ(nullptr, peer2_.CreateDataChannel(&config));
207 } 209 }
208 210
209 // Tests that any data channels created by the QuicDataTransport are in state 211 // Tests that any data channels created by the QuicDataTransport are in state
210 // kConnecting before the QuicTransportChannel is set, then transiton to state 212 // kConnecting before the QuicTransportChannel is set, then transition to state
211 // kOpen when the transport channel becomes writable. 213 // kOpen when the transport channel becomes writable.
212 TEST_F(QuicDataTransportTest, DataChannelsOpenWhenTransportChannelWritable) { 214 TEST_F(QuicDataTransportTest, DataChannelsOpenWhenTransportChannelWritable) {
213 webrtc::DataChannelInit config1; 215 webrtc::DataChannelInit config1;
214 config1.id = 7; 216 config1.id = 7;
215 rtc::scoped_refptr<DataChannelInterface> data_channel1 = 217 rtc::scoped_refptr<DataChannelInterface> data_channel1 =
216 peer2_.CreateDataChannel(&config1); 218 peer2_.CreateDataChannel(&config1);
217 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel1->state()); 219 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel1->state());
218 SetTransportChannels();
219 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel1->state()); 220 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel1->state());
220 webrtc::DataChannelInit config2; 221 webrtc::DataChannelInit config2;
221 config2.id = 14; 222 config2.id = 14;
222 rtc::scoped_refptr<DataChannelInterface> data_channel2 = 223 rtc::scoped_refptr<DataChannelInterface> data_channel2 =
223 peer2_.CreateDataChannel(&config2); 224 peer2_.CreateDataChannel(&config2);
224 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel2->state()); 225 EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, data_channel2->state());
225 // Existing data channels should open once the transport channel is writable. 226 // Existing data channels should open once the transport channel is writable.
226 ConnectTransportChannels(); 227 ConnectTransportChannels();
227 EXPECT_EQ_WAIT(webrtc::DataChannelInterface::kOpen, data_channel1->state(), 228 EXPECT_EQ_WAIT(webrtc::DataChannelInterface::kOpen, data_channel1->state(),
228 kTimeoutMs); 229 kTimeoutMs);
229 EXPECT_EQ_WAIT(webrtc::DataChannelInterface::kOpen, data_channel2->state(), 230 EXPECT_EQ_WAIT(webrtc::DataChannelInterface::kOpen, data_channel2->state(),
230 kTimeoutMs); 231 kTimeoutMs);
231 // Any data channels created afterwards should start in state kOpen. 232 // Any data channels created afterwards should start in state kOpen.
232 webrtc::DataChannelInit config3; 233 webrtc::DataChannelInit config3;
233 config3.id = 21; 234 config3.id = 21;
234 rtc::scoped_refptr<DataChannelInterface> data_channel3 = 235 rtc::scoped_refptr<DataChannelInterface> data_channel3 =
235 peer2_.CreateDataChannel(&config3); 236 peer2_.CreateDataChannel(&config3);
236 EXPECT_EQ(webrtc::DataChannelInterface::kOpen, data_channel3->state()); 237 EXPECT_EQ(webrtc::DataChannelInterface::kOpen, data_channel3->state());
237 } 238 }
238 239
239 // Tests that the QuicTransport dispatches messages for one QuicDataChannel. 240 // Tests that the QuicTransport dispatches messages for one QuicDataChannel.
240 TEST_F(QuicDataTransportTest, ReceiveMessagesForSingleDataChannel) { 241 TEST_F(QuicDataTransportTest, ReceiveMessagesForSingleDataChannel) {
241 ConnectTransportChannels(); 242 ConnectTransportChannels();
242 SetTransportChannels();
243 243
244 int data_channel_id = 1337; 244 int data_channel_id = 1337;
245 webrtc::DataChannelInit config; 245 webrtc::DataChannelInit config;
246 config.id = data_channel_id; 246 config.id = data_channel_id;
247 rtc::scoped_refptr<DataChannelInterface> peer2_data_channel = 247 rtc::scoped_refptr<DataChannelInterface> peer2_data_channel =
248 peer2_.CreateDataChannel(&config); 248 peer2_.CreateDataChannel(&config);
249 FakeObserver observer; 249 FakeObserver observer;
250 peer2_data_channel->RegisterObserver(&observer); 250 peer2_data_channel->RegisterObserver(&observer);
251 251
252 uint64_t message1_id = 26u; 252 uint64_t message1_id = 26u;
253 peer1_.WriteMessage(data_channel_id, message1_id, "Testing"); 253 peer1_.WriteMessage(data_channel_id, message1_id, "Testing");
254 ASSERT_EQ_WAIT(1, observer.messages_received(), kTimeoutMs); 254 ASSERT_EQ_WAIT(1, observer.messages_received(), kTimeoutMs);
255 EXPECT_EQ("Testing", observer.messages()[0]); 255 EXPECT_EQ("Testing", observer.messages()[0]);
256 256
257 uint64_t message2_id = 402u; 257 uint64_t message2_id = 402u;
258 peer1_.WriteMessage(data_channel_id, message2_id, "Hello, World!"); 258 peer1_.WriteMessage(data_channel_id, message2_id, "Hello, World!");
259 ASSERT_EQ_WAIT(2, observer.messages_received(), kTimeoutMs); 259 ASSERT_EQ_WAIT(2, observer.messages_received(), kTimeoutMs);
260 EXPECT_EQ("Hello, World!", observer.messages()[1]); 260 EXPECT_EQ("Hello, World!", observer.messages()[1]);
261 261
262 uint64_t message3_id = 100260415u; 262 uint64_t message3_id = 100260415u;
263 peer1_.WriteMessage(data_channel_id, message3_id, "Third message"); 263 peer1_.WriteMessage(data_channel_id, message3_id, "Third message");
264 ASSERT_EQ_WAIT(3, observer.messages_received(), kTimeoutMs); 264 ASSERT_EQ_WAIT(3, observer.messages_received(), kTimeoutMs);
265 EXPECT_EQ("Third message", observer.messages()[2]); 265 EXPECT_EQ("Third message", observer.messages()[2]);
266 } 266 }
267 267
268 // Tests that the QuicTransport dispatches messages to the correct data channel 268 // Tests that the QuicTransport dispatches messages to the correct data channel
269 // when multiple are in use. 269 // when multiple are in use.
270 TEST_F(QuicDataTransportTest, ReceiveMessagesForMultipleDataChannels) { 270 TEST_F(QuicDataTransportTest, ReceiveMessagesForMultipleDataChannels) {
271 ConnectTransportChannels(); 271 ConnectTransportChannels();
272 SetTransportChannels();
273 272
274 std::vector<rtc::scoped_refptr<DataChannelInterface>> data_channels; 273 std::vector<rtc::scoped_refptr<DataChannelInterface>> data_channels;
275 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) { 274 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) {
276 webrtc::DataChannelInit config; 275 webrtc::DataChannelInit config;
277 config.id = data_channel_id; 276 config.id = data_channel_id;
278 data_channels.push_back(peer2_.CreateDataChannel(&config)); 277 data_channels.push_back(peer2_.CreateDataChannel(&config));
279 } 278 }
280 279
281 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) { 280 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) {
282 uint64_t message1_id = 48023u; 281 uint64_t message1_id = 48023u;
283 FakeObserver observer; 282 FakeObserver observer;
284 DataChannelInterface* peer2_data_channel = 283 DataChannelInterface* peer2_data_channel =
285 data_channels[data_channel_id].get(); 284 data_channels[data_channel_id].get();
286 peer2_data_channel->RegisterObserver(&observer); 285 peer2_data_channel->RegisterObserver(&observer);
287 peer1_.WriteMessage(data_channel_id, message1_id, "Testing"); 286 peer1_.WriteMessage(data_channel_id, message1_id, "Testing");
288 ASSERT_EQ_WAIT(1, observer.messages_received(), kTimeoutMs); 287 ASSERT_EQ_WAIT(1, observer.messages_received(), kTimeoutMs);
289 EXPECT_EQ("Testing", observer.messages()[0]); 288 EXPECT_EQ("Testing", observer.messages()[0]);
290 289
291 uint64_t message2_id = 1372643095u; 290 uint64_t message2_id = 1372643095u;
292 peer1_.WriteMessage(data_channel_id, message2_id, "Hello, World!"); 291 peer1_.WriteMessage(data_channel_id, message2_id, "Hello, World!");
293 ASSERT_EQ_WAIT(2, observer.messages_received(), kTimeoutMs); 292 ASSERT_EQ_WAIT(2, observer.messages_received(), kTimeoutMs);
294 EXPECT_EQ("Hello, World!", observer.messages()[1]); 293 EXPECT_EQ("Hello, World!", observer.messages()[1]);
295 } 294 }
296 } 295 }
297 296
298 // Tests end-to-end that both peers can use multiple QuicDataChannels to 297 // Tests end-to-end that both peers can use multiple QuicDataChannels to
299 // send/receive messages using a QuicDataTransport. 298 // send/receive messages using a QuicDataTransport.
300 TEST_F(QuicDataTransportTest, EndToEndSendReceiveMessages) { 299 TEST_F(QuicDataTransportTest, EndToEndSendReceiveMessages) {
301 ConnectTransportChannels(); 300 ConnectTransportChannels();
302 SetTransportChannels();
303 301
304 std::vector<rtc::scoped_refptr<DataChannelInterface>> peer1_data_channels; 302 std::vector<rtc::scoped_refptr<DataChannelInterface>> peer1_data_channels;
305 std::vector<rtc::scoped_refptr<DataChannelInterface>> peer2_data_channels; 303 std::vector<rtc::scoped_refptr<DataChannelInterface>> peer2_data_channels;
306 304
307 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) { 305 for (int data_channel_id = 0; data_channel_id < 5; ++data_channel_id) {
308 webrtc::DataChannelInit config; 306 webrtc::DataChannelInit config;
309 config.id = data_channel_id; 307 config.id = data_channel_id;
310 peer1_data_channels.push_back(peer1_.CreateDataChannel(&config)); 308 peer1_data_channels.push_back(peer1_.CreateDataChannel(&config));
311 peer2_data_channels.push_back(peer2_.CreateDataChannel(&config)); 309 peer2_data_channels.push_back(peer2_.CreateDataChannel(&config));
312 } 310 }
(...skipping 19 matching lines...) Expand all
332 peer2_data_channel->Send(webrtc::DataBuffer("Peer 2 message 1")); 330 peer2_data_channel->Send(webrtc::DataBuffer("Peer 2 message 1"));
333 ASSERT_EQ_WAIT(1, observer1.messages_received(), kTimeoutMs); 331 ASSERT_EQ_WAIT(1, observer1.messages_received(), kTimeoutMs);
334 EXPECT_EQ("Peer 2 message 1", observer1.messages()[0]); 332 EXPECT_EQ("Peer 2 message 1", observer1.messages()[0]);
335 333
336 peer2_data_channel->Send(webrtc::DataBuffer("Peer 2 message 2")); 334 peer2_data_channel->Send(webrtc::DataBuffer("Peer 2 message 2"));
337 ASSERT_EQ_WAIT(2, observer1.messages_received(), kTimeoutMs); 335 ASSERT_EQ_WAIT(2, observer1.messages_received(), kTimeoutMs);
338 EXPECT_EQ("Peer 2 message 2", observer1.messages()[1]); 336 EXPECT_EQ("Peer 2 message 2", observer1.messages()[1]);
339 } 337 }
340 } 338 }
341 339
342 // Tests that SetTransportChannel returns false when setting a NULL transport 340 // Tests that SetTransport returns false when setting a transport that is not
343 // channel or a transport channel that is not equivalent to the one already set. 341 // equivalent to the one already set.
344 TEST_F(QuicDataTransportTest, SetTransportChannelReturnValue) { 342 TEST_F(QuicDataTransportTest, SetTransportReturnValue) {
345 QuicDataTransport* quic_data_transport = peer1_.quic_data_transport(); 343 QuicDataTransport* quic_data_transport = peer1_.quic_data_transport();
346 EXPECT_FALSE(quic_data_transport->SetTransportChannel(nullptr)); 344 // Ignore the same transport name.
347 QuicTransportChannel* transport_channel = peer1_.quic_transport_channel(); 345 EXPECT_TRUE(quic_data_transport->SetTransport(kTransportName));
348 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel)); 346 // Return false when setting a different transport name.
349 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel)); 347 EXPECT_FALSE(quic_data_transport->SetTransport("another transport name"));
350 QuicTransportChannel* other_transport_channel =
351 peer2_.quic_transport_channel();
352 EXPECT_FALSE(
353 quic_data_transport->SetTransportChannel(other_transport_channel));
354 } 348 }
355 349
356 } // namespace 350 } // namespace
OLDNEW
« no previous file with comments | « webrtc/api/quicdatatransport.cc ('k') | webrtc/api/test/peerconnectiontestwrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698