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

Side by Side Diff: net/base/tcp_client_socket_unittest.cc

Issue 21501: If an idle socket has received data unexpectedly, we... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Final upload before checkin. Created 11 years, 10 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
« no previous file with comments | « net/base/tcp_client_socket_libevent.cc ('k') | net/base/tcp_client_socket_win.cc » ('j') | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "net/base/address_list.h" 5 #include "net/base/address_list.h"
6 #include "net/base/host_resolver.h" 6 #include "net/base/host_resolver.h"
7 #include "net/base/listen_socket.h" 7 #include "net/base/listen_socket.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/tcp_client_socket.h" 9 #include "net/base/tcp_client_socket.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 rv = callback.WaitForResult(); 82 rv = callback.WaitForResult();
83 EXPECT_EQ(rv, net::OK); 83 EXPECT_EQ(rv, net::OK);
84 } 84 }
85 85
86 EXPECT_TRUE(sock.IsConnected()); 86 EXPECT_TRUE(sock.IsConnected());
87 87
88 sock.Disconnect(); 88 sock.Disconnect();
89 EXPECT_FALSE(sock.IsConnected()); 89 EXPECT_FALSE(sock.IsConnected());
90 } 90 }
91 91
92 // TODO(wtc): Add unit tests for IsConnectedAndIdle:
93 // - Server closes a connection.
94 // - Server sends data unexpectedly.
95
92 TEST_F(TCPClientSocketTest, Read) { 96 TEST_F(TCPClientSocketTest, Read) {
93 net::AddressList addr; 97 net::AddressList addr;
94 net::HostResolver resolver; 98 net::HostResolver resolver;
95 TestCompletionCallback callback; 99 TestCompletionCallback callback;
96 100
97 int rv = resolver.Resolve("localhost", listen_port_, &addr, &callback); 101 int rv = resolver.Resolve("localhost", listen_port_, &addr, &callback);
98 EXPECT_EQ(rv, net::ERR_IO_PENDING); 102 EXPECT_EQ(rv, net::ERR_IO_PENDING);
99 103
100 rv = callback.WaitForResult(); 104 rv = callback.WaitForResult();
101 EXPECT_EQ(rv, net::OK); 105 EXPECT_EQ(rv, net::OK);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Do a partial read and then exit. This test should not crash! 208 // Do a partial read and then exit. This test should not crash!
205 char buf[512]; 209 char buf[512];
206 rv = sock.Read(buf, sizeof(buf), &callback); 210 rv = sock.Read(buf, sizeof(buf), &callback);
207 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); 211 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
208 212
209 if (rv == net::ERR_IO_PENDING) 213 if (rv == net::ERR_IO_PENDING)
210 rv = callback.WaitForResult(); 214 rv = callback.WaitForResult();
211 215
212 EXPECT_NE(rv, 0); 216 EXPECT_NE(rv, 0);
213 } 217 }
OLDNEW
« no previous file with comments | « net/base/tcp_client_socket_libevent.cc ('k') | net/base/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698