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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc

Issue 2841803003: Wire up rtc_packet_ids to P2PSocketHostTcp, which is required for correct BWE in WebRTC. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 "content/browser/renderer_host/p2p/socket_host_tcp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 242
243 std::string expected_data; 243 std::string expected_data;
244 expected_data.append(IntToSize(packet1.size())); 244 expected_data.append(IntToSize(packet1.size()));
245 expected_data.append(packet1.begin(), packet1.end()); 245 expected_data.append(packet1.begin(), packet1.end());
246 expected_data.append(IntToSize(packet2.size())); 246 expected_data.append(IntToSize(packet2.size()));
247 expected_data.append(packet2.begin(), packet2.end()); 247 expected_data.append(packet2.begin(), packet2.end());
248 248
249 EXPECT_EQ(expected_data, sent_data_); 249 EXPECT_EQ(expected_data, sent_data_);
250 } 250 }
251 251
252 TEST_F(P2PSocketHostTcpTest, PacketIdIsPropagated) {
253 base::MessageLoop message_loop;
254
255 socket_->set_async_write(true);
256
257 const int32_t kRtcPacketId = 1234;
258
259 EXPECT_CALL(sender_, Send(MatchSendPacketMetrics(kRtcPacketId)))
260 .Times(1)
261 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true)));
262
263 rtc::PacketOptions options;
264 options.packet_id = kRtcPacketId;
265 std::vector<char> packet1;
266 CreateStunRequest(&packet1);
267
268 socket_host_->Send(dest_.ip_address, packet1, options, 0);
269
270 base::RunLoop().RunUntilIdle();
271
272 std::string expected_data;
273 expected_data.append(IntToSize(packet1.size()));
274 expected_data.append(packet1.begin(), packet1.end());
275
276 EXPECT_EQ(expected_data, sent_data_);
277 }
278
252 TEST_F(P2PSocketHostTcpTest, SendDataWithPacketOptions) { 279 TEST_F(P2PSocketHostTcpTest, SendDataWithPacketOptions) {
253 std::vector<char> request_packet; 280 std::vector<char> request_packet;
254 CreateStunRequest(&request_packet); 281 CreateStunRequest(&request_packet);
255 282
256 std::string received_data; 283 std::string received_data;
257 received_data.append(IntToSize(request_packet.size())); 284 received_data.append(IntToSize(request_packet.size()));
258 received_data.append(request_packet.begin(), request_packet.end()); 285 received_data.append(request_packet.begin(), request_packet.end());
259 286
260 EXPECT_CALL( 287 EXPECT_CALL(
261 sender_, 288 sender_,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 base::RunLoop().RunUntilIdle(); 423 base::RunLoop().RunUntilIdle();
397 424
398 std::string expected_data; 425 std::string expected_data;
399 expected_data.append(packet1.begin(), packet1.end()); 426 expected_data.append(packet1.begin(), packet1.end());
400 expected_data.append(packet2.begin(), packet2.end()); 427 expected_data.append(packet2.begin(), packet2.end());
401 428
402 EXPECT_EQ(expected_data, sent_data_); 429 EXPECT_EQ(expected_data, sent_data_);
403 } 430 }
404 431
405 } // namespace content 432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698