Index: net/websockets/websocket_throttle_unittest.cc |
diff --git a/net/websockets/websocket_throttle_unittest.cc b/net/websockets/websocket_throttle_unittest.cc |
index 7eb18fa52567c8629120a5d2b5ce54ff50bf95f2..525caf03b2658953f6b022e2fefcb937eebec022 100644 |
--- a/net/websockets/websocket_throttle_unittest.cc |
+++ b/net/websockets/websocket_throttle_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "net/base/sys_addrinfo.h" |
#include "net/base/test_completion_callback.h" |
#include "net/socket_stream/socket_stream.h" |
+#include "net/url_request/url_request_unittest.h" |
#include "net/websockets/websocket_job.h" |
#include "net/websockets/websocket_throttle.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -64,6 +65,8 @@ class WebSocketThrottleTest : public PlatformTest { |
static void MockSocketStreamConnect( |
SocketStream* socket, struct addrinfo* head) { |
socket->CopyAddrInfo(head); |
+ // Initialize |proxy_info_|. |
+ socket->proxy_info_.UseDirect(); |
// In SocketStream::Connect(), it adds reference to socket, which is |
// balanced with SocketStream::Finish() that is finally called from |
// SocketStream::Close() or SocketStream::DetachDelegate(), when |
@@ -77,6 +80,7 @@ class WebSocketThrottleTest : public PlatformTest { |
}; |
TEST_F(WebSocketThrottleTest, Throttle) { |
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext); |
DummySocketStreamDelegate delegate; |
// For host1: 1.2.3.4, 1.2.3.5, 1.2.3.6 |
@@ -86,6 +90,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s1( |
new SocketStream(GURL("ws://host1/"), w1.get())); |
+ s1->set_context(context.get()); |
w1->InitSocketStream(s1.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s1, addr); |
DeleteAddrInfo(addr); |
@@ -106,6 +111,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w2(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s2( |
new SocketStream(GURL("ws://host2/"), w2.get())); |
+ s2->set_context(context.get()); |
w2->InitSocketStream(s2.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s2, addr); |
DeleteAddrInfo(addr); |
@@ -125,6 +131,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w3(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s3( |
new SocketStream(GURL("ws://host3/"), w3.get())); |
+ s3->set_context(context.get()); |
w3->InitSocketStream(s3.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s3, addr); |
DeleteAddrInfo(addr); |
@@ -144,6 +151,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w4(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s4( |
new SocketStream(GURL("ws://host4/"), w4.get())); |
+ s4->set_context(context.get()); |
w4->InitSocketStream(s4.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s4, addr); |
DeleteAddrInfo(addr); |
@@ -162,6 +170,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w5(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s5( |
new SocketStream(GURL("ws://host5/"), w5.get())); |
+ s5->set_context(context.get()); |
w5->InitSocketStream(s5.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s5, addr); |
DeleteAddrInfo(addr); |
@@ -180,6 +189,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
scoped_refptr<WebSocketJob> w6(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s6( |
new SocketStream(GURL("ws://host6/"), w6.get())); |
+ s6->set_context(context.get()); |
w6->InitSocketStream(s6.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s6, addr); |
DeleteAddrInfo(addr); |
@@ -281,6 +291,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { |
} |
TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) { |
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext); |
DummySocketStreamDelegate delegate; |
// For localhost: 127.0.0.1, 127.0.0.1 |
@@ -289,6 +300,7 @@ TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) { |
scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate)); |
scoped_refptr<SocketStream> s1( |
new SocketStream(GURL("ws://localhost/"), w1.get())); |
+ s1->set_context(context.get()); |
w1->InitSocketStream(s1.get()); |
WebSocketThrottleTest::MockSocketStreamConnect(s1, addr); |
DeleteAddrInfo(addr); |