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

Unified Diff: net/socket/websocket_endpoint_lock_manager_unittest.cc

Issue 436493002: Handle multiple simultanous wss: connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/interator/iterator/ Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/socket/websocket_transport_client_socket_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/websocket_endpoint_lock_manager_unittest.cc
diff --git a/net/socket/websocket_endpoint_lock_manager_unittest.cc b/net/socket/websocket_endpoint_lock_manager_unittest.cc
index 03d4dbc8d62e6be1c8bd3a865f86ad8f8b1b97b3..cfc6cc679f5b11ee11cd7be2e793d13380dad1b4 100644
--- a/net/socket/websocket_endpoint_lock_manager_unittest.cc
+++ b/net/socket/websocket_endpoint_lock_manager_unittest.cc
@@ -196,14 +196,33 @@ TEST_F(WebSocketEndpointLockManagerTest, RememberSocketWorks) {
UnlockDummyEndpoint(1);
}
-// Calling UnlockSocket() on the same socket a second time should be harmless.
-TEST_F(WebSocketEndpointLockManagerTest, UnlockSocketTwice) {
+// UnlockEndpoint() should cause any sockets remembered for this endpoint
+// to be forgotten.
+TEST_F(WebSocketEndpointLockManagerTest, SocketAssociationForgottenOnUnlock) {
FakeWaiter waiter;
FakeStreamSocket dummy_socket;
+
EXPECT_EQ(OK, instance()->LockEndpoint(DummyEndpoint(), &waiter));
instance()->RememberSocket(&dummy_socket, DummyEndpoint());
- instance()->UnlockSocket(&dummy_socket);
- instance()->UnlockSocket(&dummy_socket);
+ instance()->UnlockEndpoint(DummyEndpoint());
+ EXPECT_TRUE(instance()->IsEmpty());
+}
+
+// When ownership of the endpoint is passed to a new waiter, the new waiter can
+// call RememberSocket() again.
+TEST_F(WebSocketEndpointLockManagerTest, NextWaiterCanCallRememberSocketAgain) {
+ FakeWaiter waiters[2];
+ FakeStreamSocket dummy_sockets[2];
+ EXPECT_EQ(OK, instance()->LockEndpoint(DummyEndpoint(), &waiters[0]));
+ EXPECT_EQ(ERR_IO_PENDING,
+ instance()->LockEndpoint(DummyEndpoint(), &waiters[1]));
+
+ instance()->RememberSocket(&dummy_sockets[0], DummyEndpoint());
+ instance()->UnlockEndpoint(DummyEndpoint());
+ EXPECT_TRUE(waiters[1].called());
+ instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint());
+
+ UnlockDummyEndpoint(1);
}
} // namespace
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/socket/websocket_transport_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698