OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that | 5 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that |
6 // frame parsing itself functions correctly, as that is covered by the | 6 // frame parsing itself functions correctly, as that is covered by the |
7 // WebSocketFrameParser tests. | 7 // WebSocketFrameParser tests. |
8 | 8 |
9 #include "net/websockets/websocket_basic_stream.h" | 9 #include "net/websockets/websocket_basic_stream.h" |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 size_t reads_count, | 121 size_t reads_count, |
122 MockWrite writes[], | 122 MockWrite writes[], |
123 size_t writes_count) { | 123 size_t writes_count) { |
124 socket_data_.reset(new StrictStaticSocketDataProvider( | 124 socket_data_.reset(new StrictStaticSocketDataProvider( |
125 reads, reads_count, writes, writes_count, expect_all_io_to_complete_)); | 125 reads, reads_count, writes, writes_count, expect_all_io_to_complete_)); |
126 socket_data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); | 126 socket_data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); |
127 factory_.AddSocketDataProvider(socket_data_.get()); | 127 factory_.AddSocketDataProvider(socket_data_.get()); |
128 | 128 |
129 scoped_ptr<ClientSocketHandle> transport_socket(new ClientSocketHandle); | 129 scoped_ptr<ClientSocketHandle> transport_socket(new ClientSocketHandle); |
130 scoped_refptr<MockTransportSocketParams> params; | 130 scoped_refptr<MockTransportSocketParams> params; |
131 transport_socket->Init("a", | 131 transport_socket->Init( |
132 params, | 132 "a", params, MEDIUM, ClientSocketPool::RespectLimits::ENABLED, |
133 MEDIUM, | 133 CompletionCallback(), &pool_, bound_net_log_.bound()); |
134 CompletionCallback(), | |
135 &pool_, | |
136 bound_net_log_.bound()); | |
137 return transport_socket; | 134 return transport_socket; |
138 } | 135 } |
139 | 136 |
140 void SetHttpReadBuffer(const char* data, size_t size) { | 137 void SetHttpReadBuffer(const char* data, size_t size) { |
141 http_read_buffer_ = new GrowableIOBuffer; | 138 http_read_buffer_ = new GrowableIOBuffer; |
142 http_read_buffer_->SetCapacity(size); | 139 http_read_buffer_->SetCapacity(size); |
143 memcpy(http_read_buffer_->data(), data, size); | 140 memcpy(http_read_buffer_->data(), data, size); |
144 http_read_buffer_->set_offset(size); | 141 http_read_buffer_->set_offset(size); |
145 } | 142 } |
146 | 143 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 933 |
937 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { | 934 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { |
938 sub_protocol_ = "cyberchat"; | 935 sub_protocol_ = "cyberchat"; |
939 CreateNullStream(); | 936 CreateNullStream(); |
940 | 937 |
941 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); | 938 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); |
942 } | 939 } |
943 | 940 |
944 } // namespace | 941 } // namespace |
945 } // namespace net | 942 } // namespace net |
OLD | NEW |