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

Side by Side Diff: net/websockets/websocket_basic_stream_test.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 MockWrite writes[], 127 MockWrite writes[],
128 size_t writes_count) { 128 size_t writes_count) {
129 socket_data_.reset(new StrictStaticSocketDataProvider( 129 socket_data_.reset(new StrictStaticSocketDataProvider(
130 reads, reads_count, writes, writes_count, expect_all_io_to_complete_)); 130 reads, reads_count, writes, writes_count, expect_all_io_to_complete_));
131 socket_data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); 131 socket_data_->set_connect_data(MockConnect(SYNCHRONOUS, OK));
132 factory_.AddSocketDataProvider(socket_data_.get()); 132 factory_.AddSocketDataProvider(socket_data_.get());
133 133
134 std::unique_ptr<ClientSocketHandle> transport_socket( 134 std::unique_ptr<ClientSocketHandle> transport_socket(
135 new ClientSocketHandle); 135 new ClientSocketHandle);
136 scoped_refptr<MockTransportSocketParams> params; 136 scoped_refptr<MockTransportSocketParams> params;
137 transport_socket->Init( 137 transport_socket->Init("a", params, MEDIUM,
138 "a", params, MEDIUM, ClientSocketPool::RespectLimits::ENABLED, 138 ClientSocketPool::RespectLimits::ENABLED,
139 CompletionCallback(), &pool_, bound_net_log_.bound()); 139 CompletionCallback(), &pool_, net_log_.bound());
140 return transport_socket; 140 return transport_socket;
141 } 141 }
142 142
143 void SetHttpReadBuffer(const char* data, size_t size) { 143 void SetHttpReadBuffer(const char* data, size_t size) {
144 http_read_buffer_ = new GrowableIOBuffer; 144 http_read_buffer_ = new GrowableIOBuffer;
145 http_read_buffer_->SetCapacity(size); 145 http_read_buffer_->SetCapacity(size);
146 memcpy(http_read_buffer_->data(), data, size); 146 memcpy(http_read_buffer_->data(), data, size);
147 http_read_buffer_->set_offset(size); 147 http_read_buffer_->set_offset(size);
148 } 148 }
149 149
(...skipping 12 matching lines...) Expand all
162 template <size_t N> 162 template <size_t N>
163 void CreateReadOnly(MockRead (&reads)[N]) { 163 void CreateReadOnly(MockRead (&reads)[N]) {
164 CreateStream(reads, N, NULL, 0); 164 CreateStream(reads, N, NULL, 0);
165 } 165 }
166 166
167 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); } 167 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); }
168 168
169 std::unique_ptr<SocketDataProvider> socket_data_; 169 std::unique_ptr<SocketDataProvider> socket_data_;
170 MockClientSocketFactory factory_; 170 MockClientSocketFactory factory_;
171 MockTransportClientSocketPool pool_; 171 MockTransportClientSocketPool pool_;
172 BoundTestNetLog(bound_net_log_); 172 BoundTestNetLog(net_log_);
173 std::vector<std::unique_ptr<WebSocketFrame>> frames_; 173 std::vector<std::unique_ptr<WebSocketFrame>> frames_;
174 TestCompletionCallback cb_; 174 TestCompletionCallback cb_;
175 scoped_refptr<GrowableIOBuffer> http_read_buffer_; 175 scoped_refptr<GrowableIOBuffer> http_read_buffer_;
176 std::string sub_protocol_; 176 std::string sub_protocol_;
177 std::string extensions_; 177 std::string extensions_;
178 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_; 178 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_;
179 bool expect_all_io_to_complete_; 179 bool expect_all_io_to_complete_;
180 }; 180 };
181 181
182 // A test fixture for the common case of tests that only perform a single read. 182 // A test fixture for the common case of tests that only perform a single read.
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 964
965 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { 965 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) {
966 sub_protocol_ = "cyberchat"; 966 sub_protocol_ = "cyberchat";
967 CreateNullStream(); 967 CreateNullStream();
968 968
969 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); 969 EXPECT_EQ("cyberchat", stream_->GetSubProtocol());
970 } 970 }
971 971
972 } // namespace 972 } // namespace
973 } // namespace net 973 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698