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

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

Issue 2843823002: Fix P2PSocketHostUdp to handle SetOptions() in error state (Closed)
Patch Set: dcheck Created 3 years, 7 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 177 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
178 178
179 rtc::PacketOptions options; 179 rtc::PacketOptions options;
180 std::vector<char> packet; 180 std::vector<char> packet;
181 CreateRandomPacket(&packet); 181 CreateRandomPacket(&packet);
182 socket_host_->Send(dest_.ip_address, packet, options, 0); 182 socket_host_->Send(dest_.ip_address, packet, options, 0);
183 183
184 EXPECT_EQ(0U, sent_data_.size()); 184 EXPECT_EQ(0U, sent_data_.size());
185 } 185 }
186 186
187 // Verify that SetOption() doesn't crash after an error.
188 TEST_F(P2PSocketHostTcpTest, SetOptionAfterError) {
189 // Get the sender into the error state.
190 EXPECT_CALL(sender_,
191 Send(MatchMessage(static_cast<uint32_t>(P2PMsg_OnError::ID))))
192 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
193 socket_host_->Send(dest_.ip_address, {1, 2, 3, 4}, rtc::PacketOptions(), 0);
194 testing::Mock::VerifyAndClearExpectations(&sender_);
195
196 // Verify that SetOptions() fails, but doesn't crash.
197 EXPECT_FALSE(socket_host_->SetOption(P2P_SOCKET_OPT_RCVBUF, 2048));
198 }
199
187 // Verify that we can send data after we've received STUN response 200 // Verify that we can send data after we've received STUN response
188 // from the other side. 201 // from the other side.
189 TEST_F(P2PSocketHostTcpTest, SendAfterStunRequest) { 202 TEST_F(P2PSocketHostTcpTest, SendAfterStunRequest) {
190 // Receive packet from |dest_|. 203 // Receive packet from |dest_|.
191 std::vector<char> request_packet; 204 std::vector<char> request_packet;
192 CreateStunRequest(&request_packet); 205 CreateStunRequest(&request_packet);
193 206
194 std::string received_data; 207 std::string received_data;
195 received_data.append(IntToSize(request_packet.size())); 208 received_data.append(IntToSize(request_packet.size()));
196 received_data.append(request_packet.begin(), request_packet.end()); 209 received_data.append(request_packet.begin(), request_packet.end());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 base::RunLoop().RunUntilIdle(); 409 base::RunLoop().RunUntilIdle();
397 410
398 std::string expected_data; 411 std::string expected_data;
399 expected_data.append(packet1.begin(), packet1.end()); 412 expected_data.append(packet1.begin(), packet1.end());
400 expected_data.append(packet2.begin(), packet2.end()); 413 expected_data.append(packet2.begin(), packet2.end());
401 414
402 EXPECT_EQ(expected_data, sent_data_); 415 EXPECT_EQ(expected_data, sent_data_);
403 } 416 }
404 417
405 } // namespace content 418 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp.cc ('k') | content/browser/renderer_host/p2p/socket_host_udp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698