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

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

Issue 13926013: Fix P2PSocketHostTcp to handle async write correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 <deque> 7 #include <deque>
8 8
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" 10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 CreateRandomPacket(&packet); 174 CreateRandomPacket(&packet);
175 socket_host_->Send(dest_, packet); 175 socket_host_->Send(dest_, packet);
176 176
177 std::string expected_data; 177 std::string expected_data;
178 expected_data.append(IntToSize(packet.size())); 178 expected_data.append(IntToSize(packet.size()));
179 expected_data.append(packet.begin(), packet.end()); 179 expected_data.append(packet.begin(), packet.end());
180 180
181 EXPECT_EQ(expected_data, sent_data_); 181 EXPECT_EQ(expected_data, sent_data_);
182 } 182 }
183 183
184 // Verify that asynchronous writes are handled correctly.
185 TEST_F(P2PSocketHostTcpTest, AsyncWrites) {
186 MessageLoop message_loop;
187
188 socket_->set_async_write(true);
189
190 EXPECT_CALL(sender_, Send(
191 MatchMessage(static_cast<uint32>(P2PMsg_OnSendComplete::ID))))
192 .Times(2)
193 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true)));
194
195 std::vector<char> packet1;
196 CreateStunRequest(&packet1);
197 socket_host_->Send(dest_, packet1);
198
199 std::vector<char> packet2;
200 CreateStunResponse(&packet2);
201 socket_host_->Send(dest_, packet2);
202
203 message_loop.RunUntilIdle();
204
205 std::string expected_data;
206 expected_data.append(IntToSize(packet1.size()));
207 expected_data.append(packet1.begin(), packet1.end());
208 expected_data.append(IntToSize(packet2.size()));
209 expected_data.append(packet2.begin(), packet2.end());
210
211 EXPECT_EQ(expected_data, sent_data_);
212 }
213
184 } // namespace content 214 } // 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_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698