OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); | 66 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); |
67 ASSERT_TRUE(sock.Send("hi")); | 67 ASSERT_TRUE(sock.Send("hi")); |
68 std::string message; | 68 std::string message; |
69 ASSERT_EQ( | 69 ASSERT_EQ( |
70 SyncWebSocket::kOk, | 70 SyncWebSocket::kOk, |
71 sock.ReceiveNextMessage(&message, long_timeout_)); | 71 sock.ReceiveNextMessage(&message, long_timeout_)); |
72 ASSERT_STREQ("hi", message.c_str()); | 72 ASSERT_STREQ("hi", message.c_str()); |
73 } | 73 } |
74 | 74 |
75 TEST_F(SyncWebSocketImplTest, SendReceiveTimeout) { | 75 TEST_F(SyncWebSocketImplTest, SendReceiveTimeout) { |
76 SyncWebSocketImpl sock(context_getter_); | 76 SyncWebSocketImpl sock(context_getter_.get()); |
77 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); | 77 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); |
78 ASSERT_TRUE(sock.Send("hi")); | 78 ASSERT_TRUE(sock.Send("hi")); |
79 std::string message; | 79 std::string message; |
80 ASSERT_EQ( | 80 ASSERT_EQ( |
81 SyncWebSocket::kTimeout, | 81 SyncWebSocket::kTimeout, |
82 sock.ReceiveNextMessage( | 82 sock.ReceiveNextMessage( |
83 &message, base::TimeDelta())); | 83 &message, base::TimeDelta())); |
84 } | 84 } |
85 | 85 |
86 TEST_F(SyncWebSocketImplTest, SendReceiveLarge) { | 86 TEST_F(SyncWebSocketImplTest, SendReceiveLarge) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); | 156 ASSERT_TRUE(sock.Connect(server_.web_socket_url())); |
157 ASSERT_FALSE(sock.HasNextMessage()); | 157 ASSERT_FALSE(sock.HasNextMessage()); |
158 ASSERT_TRUE(sock.Send("3")); | 158 ASSERT_TRUE(sock.Send("3")); |
159 std::string message; | 159 std::string message; |
160 ASSERT_EQ( | 160 ASSERT_EQ( |
161 SyncWebSocket::kOk, | 161 SyncWebSocket::kOk, |
162 sock.ReceiveNextMessage(&message, long_timeout_)); | 162 sock.ReceiveNextMessage(&message, long_timeout_)); |
163 ASSERT_STREQ("3", message.c_str()); | 163 ASSERT_STREQ("3", message.c_str()); |
164 ASSERT_FALSE(sock.HasNextMessage()); | 164 ASSERT_FALSE(sock.HasNextMessage()); |
165 } | 165 } |
OLD | NEW |