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

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

Issue 2843823002: Fix P2PSocketHostUdp to handle SetOptions() in error state (Closed)
Patch Set: dcheck 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
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_udp.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_udp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <deque> 8 #include <deque>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 274 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
275 275
276 rtc::PacketOptions options; 276 rtc::PacketOptions options;
277 std::vector<char> packet; 277 std::vector<char> packet;
278 CreateRandomPacket(&packet); 278 CreateRandomPacket(&packet);
279 socket_host_->Send(dest1_, packet, options, 0); 279 socket_host_->Send(dest1_, packet, options, 0);
280 280
281 ASSERT_EQ(sent_packets_.size(), 0U); 281 ASSERT_EQ(sent_packets_.size(), 0U);
282 } 282 }
283 283
284 // Verify that SetOption() doesn't crash after an error.
285 TEST_F(P2PSocketHostUdpTest, SetOptionAfterError) {
286 // Get the sender into the error state.
287 EXPECT_CALL(sender_,
288 Send(MatchMessage(static_cast<uint32_t>(P2PMsg_OnError::ID))))
289 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
290 socket_host_->Send(dest1_, {1, 2, 3, 4}, rtc::PacketOptions(), 0);
291 testing::Mock::VerifyAndClearExpectations(&sender_);
292
293 // Verify that SetOptions() fails, but doesn't crash.
294 EXPECT_FALSE(socket_host_->SetOption(P2P_SOCKET_OPT_RCVBUF, 2048));
295 }
296
284 // Verify that we can send data after we've received STUN request 297 // Verify that we can send data after we've received STUN request
285 // from the other side. 298 // from the other side.
286 TEST_F(P2PSocketHostUdpTest, SendAfterStunRequest) { 299 TEST_F(P2PSocketHostUdpTest, SendAfterStunRequest) {
287 // Receive packet from |dest1_|. 300 // Receive packet from |dest1_|.
288 std::vector<char> request_packet; 301 std::vector<char> request_packet;
289 CreateStunRequest(&request_packet); 302 CreateStunRequest(&request_packet);
290 303
291 EXPECT_CALL(sender_, Send(MatchPacketMessage(request_packet))) 304 EXPECT_CALL(sender_, Send(MatchPacketMessage(request_packet)))
292 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 305 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
293 socket_->ReceivePacket(dest1_, request_packet); 306 socket_->ReceivePacket(dest1_, request_packet);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 std::unique_ptr<P2PSocketHostUdp> socket_host( 580 std::unique_ptr<P2PSocketHostUdp> socket_host(
568 new P2PSocketHostUdp(&sender, 0, &throttler, fake_socket_factory)); 581 new P2PSocketHostUdp(&sender, 0, &throttler, fake_socket_factory));
569 net::IPEndPoint local_address = 582 net::IPEndPoint local_address =
570 ParseAddress(kTestLocalIpAddress, invalid_port); 583 ParseAddress(kTestLocalIpAddress, invalid_port);
571 bool rv = socket_host->Init(local_address, min_port, max_port, 584 bool rv = socket_host->Init(local_address, min_port, max_port,
572 P2PHostAndIPEndPoint()); 585 P2PHostAndIPEndPoint());
573 EXPECT_FALSE(rv); 586 EXPECT_FALSE(rv);
574 } 587 }
575 588
576 } // namespace content 589 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_udp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698