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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 184 // Verify that asynchronous writes are handled correctly.
185 TEST_F(P2PSocketHostTcpTest, AsyncWrites) { 185 TEST_F(P2PSocketHostTcpTest, AsyncWrites) {
186 MessageLoop message_loop; 186 base::MessageLoop message_loop;
187 187
188 socket_->set_async_write(true); 188 socket_->set_async_write(true);
189 189
190 EXPECT_CALL(sender_, Send( 190 EXPECT_CALL(sender_, Send(
191 MatchMessage(static_cast<uint32>(P2PMsg_OnSendComplete::ID)))) 191 MatchMessage(static_cast<uint32>(P2PMsg_OnSendComplete::ID))))
192 .Times(2) 192 .Times(2)
193 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true))); 193 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true)));
194 194
195 std::vector<char> packet1; 195 std::vector<char> packet1;
196 CreateStunRequest(&packet1); 196 CreateStunRequest(&packet1);
197 socket_host_->Send(dest_, packet1); 197 socket_host_->Send(dest_, packet1);
198 198
199 std::vector<char> packet2; 199 std::vector<char> packet2;
200 CreateStunResponse(&packet2); 200 CreateStunResponse(&packet2);
201 socket_host_->Send(dest_, packet2); 201 socket_host_->Send(dest_, packet2);
202 202
203 message_loop.RunUntilIdle(); 203 message_loop.RunUntilIdle();
204 204
205 std::string expected_data; 205 std::string expected_data;
206 expected_data.append(IntToSize(packet1.size())); 206 expected_data.append(IntToSize(packet1.size()));
207 expected_data.append(packet1.begin(), packet1.end()); 207 expected_data.append(packet1.begin(), packet1.end());
208 expected_data.append(IntToSize(packet2.size())); 208 expected_data.append(IntToSize(packet2.size()));
209 expected_data.append(packet2.begin(), packet2.end()); 209 expected_data.append(packet2.begin(), packet2.end());
210 210
211 EXPECT_EQ(expected_data, sent_data_); 211 EXPECT_EQ(expected_data, sent_data_);
212 } 212 }
213 213
214 } // namespace content 214 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698