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

Side by Side Diff: jingle/glue/fake_ssl_client_socket_unittest.cc

Issue 10796085: Give MockRead and MockWrite distinct types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix compile. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "jingle/glue/fake_ssl_client_socket.h" 5 #include "jingle/glue/fake_ssl_client_socket.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MOCK_CONST_METHOD0(UsingTCPFastOpen, bool()); 65 MOCK_CONST_METHOD0(UsingTCPFastOpen, bool());
66 MOCK_CONST_METHOD0(NumBytesRead, int64()); 66 MOCK_CONST_METHOD0(NumBytesRead, int64());
67 MOCK_CONST_METHOD0(GetConnectTimeMicros, base::TimeDelta()); 67 MOCK_CONST_METHOD0(GetConnectTimeMicros, base::TimeDelta());
68 MOCK_CONST_METHOD0(WasNpnNegotiated, bool()); 68 MOCK_CONST_METHOD0(WasNpnNegotiated, bool());
69 MOCK_CONST_METHOD0(GetNegotiatedProtocol, net::NextProto()); 69 MOCK_CONST_METHOD0(GetNegotiatedProtocol, net::NextProto());
70 MOCK_METHOD1(GetSSLInfo, bool(net::SSLInfo*)); 70 MOCK_METHOD1(GetSSLInfo, bool(net::SSLInfo*));
71 }; 71 };
72 72
73 // Break up |data| into a bunch of chunked MockReads/Writes and push 73 // Break up |data| into a bunch of chunked MockReads/Writes and push
74 // them onto |ops|. 74 // them onto |ops|.
75 template <net::MockReadWriteType type>
75 void AddChunkedOps(base::StringPiece data, size_t chunk_size, net::IoMode mode, 76 void AddChunkedOps(base::StringPiece data, size_t chunk_size, net::IoMode mode,
76 std::vector<net::MockRead>* ops) { 77 std::vector<net::MockReadWrite<type> >* ops) {
77 DCHECK_GT(chunk_size, 0U); 78 DCHECK_GT(chunk_size, 0U);
78 size_t offset = 0; 79 size_t offset = 0;
79 while (offset < data.size()) { 80 while (offset < data.size()) {
80 size_t bounded_chunk_size = std::min(data.size() - offset, chunk_size); 81 size_t bounded_chunk_size = std::min(data.size() - offset, chunk_size);
81 // We take advantage of the fact that MockWrite is typedefed to 82 ops->push_back(net::MockReadWrite<type>(mode, data.data() + offset,
82 // MockRead. 83 bounded_chunk_size));
83 ops->push_back(net::MockRead(mode, data.data() + offset,
84 bounded_chunk_size));
85 offset += bounded_chunk_size; 84 offset += bounded_chunk_size;
86 } 85 }
87 } 86 }
88 87
89 class FakeSSLClientSocketTest : public testing::Test { 88 class FakeSSLClientSocketTest : public testing::Test {
90 protected: 89 protected:
91 FakeSSLClientSocketTest() {} 90 FakeSSLClientSocketTest() {}
92 91
93 virtual ~FakeSSLClientSocketTest() {} 92 virtual ~FakeSSLClientSocketTest() {}
94 93
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 338 }
340 339
341 TEST_F(FakeSSLClientSocketTest, MalformedServerHello) { 340 TEST_F(FakeSSLClientSocketTest, MalformedServerHello) {
342 RunUnsuccessfulHandshakeTest(ERR_MALFORMED_SERVER_HELLO, 341 RunUnsuccessfulHandshakeTest(ERR_MALFORMED_SERVER_HELLO,
343 VERIFY_SERVER_HELLO_ERROR); 342 VERIFY_SERVER_HELLO_ERROR);
344 } 343 }
345 344
346 } // namespace 345 } // namespace
347 346
348 } // namespace jingle_glue 347 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698