summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_pool_unittest.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 00:13:52 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 00:13:52 +0000
commita554a82621c260c45c310deb2d12653e61221ff5 (patch)
tree7cebe573f5deb37144572c53421b6620c59765e0 /net/socket/tcp_client_socket_pool_unittest.cc
parent004a953d5432f7b752aeb1e574a0109b5ca2310a (diff)
downloadchromium_src-a554a82621c260c45c310deb2d12653e61221ff5.zip
chromium_src-a554a82621c260c45c310deb2d12653e61221ff5.tar.gz
chromium_src-a554a82621c260c45c310deb2d12653e61221ff5.tar.bz2
Revert r47395. Looks like it still crashes =/
BUG=40455,40457 Review URL: http://codereview.chromium.org/2104013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_pool_unittest.cc')
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 9fd1c8a..e6d435a 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "net/base/mock_host_resolver.h"
+#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket.h"
@@ -268,7 +269,9 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
kMaxSocketsPerGroup,
"TCPUnitTest",
host_resolver_,
- &client_socket_factory_)) {}
+ &client_socket_factory_,
+ &notifier_)) {
+ }
int StartRequest(const std::string& group_name, RequestPriority priority) {
return StartRequestUsingPool(
@@ -278,6 +281,7 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
TCPSocketParams ignored_socket_params_;
scoped_refptr<MockHostResolver> host_resolver_;
MockClientSocketFactory client_socket_factory_;
+ MockNetworkChangeNotifier notifier_;
scoped_refptr<TCPClientSocketPool> pool_;
};
@@ -654,6 +658,32 @@ TEST_F(TCPClientSocketPoolTest, FailingActiveRequestWithPendingRequests) {
EXPECT_EQ(ERR_CONNECTION_FAILED, requests_[i]->WaitForResult());
}
+TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) {
+ TestCompletionCallback callback;
+ ClientSocketHandle handle;
+ TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
+ int rv = handle.Init("a", dest, LOW, &callback, pool_, BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ EXPECT_FALSE(handle.is_initialized());
+ EXPECT_FALSE(handle.socket());
+
+ EXPECT_EQ(OK, callback.WaitForResult());
+ EXPECT_TRUE(handle.is_initialized());
+ EXPECT_TRUE(handle.socket());
+
+ handle.Reset();
+
+ // Need to run all pending to release the socket back to the pool.
+ MessageLoop::current()->RunAllPending();
+
+ // Now we should have 1 idle socket.
+ EXPECT_EQ(1, pool_->IdleSocketCount());
+
+ // After an IP address change, we should have 0 idle sockets.
+ notifier_.NotifyIPAddressChange();
+ EXPECT_EQ(0, pool_->IdleSocketCount());
+}
+
TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) {
// Case 1 tests the first socket stalling, and the backup connecting.
MockClientSocketFactory::ClientSocketType case1_types[] = {
@@ -712,7 +742,8 @@ TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) {
kMaxSocketsPerGroup,
"TCPUnitTest",
host_resolver_,
- &client_socket_factory_);
+ &client_socket_factory_,
+ NULL);
}
}