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

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

Issue 1084533002: Rename NetLogLogger and CapturingNetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename NetLogLogger and CapturingNetLog(removed compiler error for chromeOS) Created 5 years, 8 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
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <string.h> // for memcpy() and memset(). 11 #include <string.h> // for memcpy() and memset().
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/big_endian.h" 16 #include "base/big_endian.h"
17 #include "base/port.h" 17 #include "base/port.h"
18 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
19 #include "net/log/capturing_net_log.h" 19 #include "net/log/test_net_log.h"
20 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace net { 23 namespace net {
24 namespace { 24 namespace {
25 25
26 #define WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(name, value) \ 26 #define WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(name, value) \
27 const char k##name[] = value; \ 27 const char k##name[] = value; \
28 const size_t k##name##Size = arraysize(k##name) - 1; 28 const size_t k##name##Size = arraysize(k##name) - 1;
29 29
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 WebSocketMaskingKey GenerateNulMaskingKey() { return kNulMaskingKey; } 68 WebSocketMaskingKey GenerateNulMaskingKey() { return kNulMaskingKey; }
69 69
70 // A masking key generation function which generates a fixed masking key with no 70 // A masking key generation function which generates a fixed masking key with no
71 // nul characters. 71 // nul characters.
72 WebSocketMaskingKey GenerateNonNulMaskingKey() { return kNonNulMaskingKey; } 72 WebSocketMaskingKey GenerateNonNulMaskingKey() { return kNonNulMaskingKey; }
73 73
74 // Base class for WebSocketBasicStream test fixtures. 74 // Base class for WebSocketBasicStream test fixtures.
75 class WebSocketBasicStreamTest : public ::testing::Test { 75 class WebSocketBasicStreamTest : public ::testing::Test {
76 protected: 76 protected:
77 scoped_ptr<WebSocketBasicStream> stream_; 77 scoped_ptr<WebSocketBasicStream> stream_;
78 CapturingNetLog net_log_; 78 TestNetLog net_log_;
79 }; 79 };
80 80
81 // A subclass of StaticSocketDataProvider modified to require that all data 81 // A subclass of StaticSocketDataProvider modified to require that all data
82 // expected to be read or written actually is. 82 // expected to be read or written actually is.
83 class StrictStaticSocketDataProvider : public StaticSocketDataProvider { 83 class StrictStaticSocketDataProvider : public StaticSocketDataProvider {
84 public: 84 public:
85 StrictStaticSocketDataProvider(MockRead* reads, 85 StrictStaticSocketDataProvider(MockRead* reads,
86 size_t reads_count, 86 size_t reads_count,
87 MockWrite* writes, 87 MockWrite* writes,
88 size_t writes_count, 88 size_t writes_count,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 template <size_t N> 157 template <size_t N>
158 void CreateReadOnly(MockRead (&reads)[N]) { 158 void CreateReadOnly(MockRead (&reads)[N]) {
159 CreateStream(reads, N, NULL, 0); 159 CreateStream(reads, N, NULL, 0);
160 } 160 }
161 161
162 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); } 162 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); }
163 163
164 scoped_ptr<SocketDataProvider> socket_data_; 164 scoped_ptr<SocketDataProvider> socket_data_;
165 MockClientSocketFactory factory_; 165 MockClientSocketFactory factory_;
166 MockTransportClientSocketPool pool_; 166 MockTransportClientSocketPool pool_;
167 CapturingBoundNetLog(bound_net_log_); 167 BoundTestNetLog(bound_net_log_);
168 ScopedVector<WebSocketFrame> frames_; 168 ScopedVector<WebSocketFrame> frames_;
169 TestCompletionCallback cb_; 169 TestCompletionCallback cb_;
170 scoped_refptr<GrowableIOBuffer> http_read_buffer_; 170 scoped_refptr<GrowableIOBuffer> http_read_buffer_;
171 std::string sub_protocol_; 171 std::string sub_protocol_;
172 std::string extensions_; 172 std::string extensions_;
173 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_; 173 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_;
174 bool expect_all_io_to_complete_; 174 bool expect_all_io_to_complete_;
175 }; 175 };
176 176
177 // A test fixture for the common case of tests that only perform a single read. 177 // A test fixture for the common case of tests that only perform a single read.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { 935 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) {
936 sub_protocol_ = "cyberchat"; 936 sub_protocol_ = "cyberchat";
937 CreateNullStream(); 937 CreateNullStream();
938 938
939 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); 939 EXPECT_EQ("cyberchat", stream_->GetSubProtocol());
940 } 940 }
941 941
942 } // namespace 942 } // namespace
943 } // namespace net 943 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698