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

Side by Side Diff: jingle/notifier/base/fake_ssl_client_socket_unittest.cc

Issue 6930014: Rename ClientSocket to StreamSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/notifier/base/fake_ssl_client_socket.h" 5 #include "jingle/notifier/base/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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "net/base/capturing_net_log.h" 14 #include "net/base/capturing_net_log.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_log.h" 16 #include "net/base/net_log.h"
17 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
18 #include "net/socket/client_socket.h"
19 #include "net/socket/socket_test_util.h" 18 #include "net/socket/socket_test_util.h"
19 #include "net/socket/stream_socket.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace notifier { 23 namespace notifier {
24 24
25 namespace { 25 namespace {
26 26
27 using ::testing::Return; 27 using ::testing::Return;
28 using ::testing::ReturnRef; 28 using ::testing::ReturnRef;
29 29
30 // Used by RunUnsuccessfulHandshakeTestHelper. Represents where in 30 // Used by RunUnsuccessfulHandshakeTestHelper. Represents where in
31 // the handshake step an error should be inserted. 31 // the handshake step an error should be inserted.
32 enum HandshakeErrorLocation { 32 enum HandshakeErrorLocation {
33 CONNECT_ERROR, 33 CONNECT_ERROR,
34 SEND_CLIENT_HELLO_ERROR, 34 SEND_CLIENT_HELLO_ERROR,
35 VERIFY_SERVER_HELLO_ERROR, 35 VERIFY_SERVER_HELLO_ERROR,
36 }; 36 };
37 37
38 // Private error codes appended to the net::Error set. 38 // Private error codes appended to the net::Error set.
39 enum { 39 enum {
40 // An error representing a server hello that has been corrupted in 40 // An error representing a server hello that has been corrupted in
41 // transit. 41 // transit.
42 ERR_MALFORMED_SERVER_HELLO = -15000, 42 ERR_MALFORMED_SERVER_HELLO = -15000,
43 }; 43 };
44 44
45 // Used by PassThroughMethods test. 45 // Used by PassThroughMethods test.
46 class MockClientSocket : public net::ClientSocket { 46 class MockClientSocket : public net::StreamSocket {
47 public: 47 public:
48 virtual ~MockClientSocket() {} 48 virtual ~MockClientSocket() {}
49 49
50 MOCK_METHOD3(Read, int(net::IOBuffer*, int, net::CompletionCallback*)); 50 MOCK_METHOD3(Read, int(net::IOBuffer*, int, net::CompletionCallback*));
51 MOCK_METHOD3(Write, int(net::IOBuffer*, int, net::CompletionCallback*)); 51 MOCK_METHOD3(Write, int(net::IOBuffer*, int, net::CompletionCallback*));
52 MOCK_METHOD1(SetReceiveBufferSize, bool(int32)); 52 MOCK_METHOD1(SetReceiveBufferSize, bool(int32));
53 MOCK_METHOD1(SetSendBufferSize, bool(int32)); 53 MOCK_METHOD1(SetSendBufferSize, bool(int32));
54 MOCK_METHOD1(Connect, int(net::CompletionCallback*)); 54 MOCK_METHOD1(Connect, int(net::CompletionCallback*));
55 MOCK_METHOD0(Disconnect, void()); 55 MOCK_METHOD0(Disconnect, void());
56 MOCK_CONST_METHOD0(IsConnected, bool()); 56 MOCK_CONST_METHOD0(IsConnected, bool());
(...skipping 23 matching lines...) Expand all
80 } 80 }
81 } 81 }
82 82
83 class FakeSSLClientSocketTest : public testing::Test { 83 class FakeSSLClientSocketTest : public testing::Test {
84 protected: 84 protected:
85 FakeSSLClientSocketTest() 85 FakeSSLClientSocketTest()
86 : capturing_net_log_(net::CapturingNetLog::kUnbounded) {} 86 : capturing_net_log_(net::CapturingNetLog::kUnbounded) {}
87 87
88 virtual ~FakeSSLClientSocketTest() {} 88 virtual ~FakeSSLClientSocketTest() {}
89 89
90 net::ClientSocket* MakeClientSocket() { 90 net::StreamSocket* MakeClientSocket() {
91 return mock_client_socket_factory_.CreateTransportClientSocket( 91 return mock_client_socket_factory_.CreateTransportClientSocket(
92 net::AddressList(), &capturing_net_log_, net::NetLog::Source()); 92 net::AddressList(), &capturing_net_log_, net::NetLog::Source());
93 } 93 }
94 94
95 void SetData(const net::MockConnect& mock_connect, 95 void SetData(const net::MockConnect& mock_connect,
96 std::vector<net::MockRead>* reads, 96 std::vector<net::MockRead>* reads,
97 std::vector<net::MockWrite>* writes) { 97 std::vector<net::MockWrite>* writes) {
98 static_socket_data_provider_.reset( 98 static_socket_data_provider_.reset(
99 new net::StaticSocketDataProvider( 99 new net::StaticSocketDataProvider(
100 reads->empty() ? NULL : &*reads->begin(), reads->size(), 100 reads->empty() ? NULL : &*reads->begin(), reads->size(),
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 333
334 TEST_F(FakeSSLClientSocketTest, MalformedServerHello) { 334 TEST_F(FakeSSLClientSocketTest, MalformedServerHello) {
335 RunUnsuccessfulHandshakeTest(ERR_MALFORMED_SERVER_HELLO, 335 RunUnsuccessfulHandshakeTest(ERR_MALFORMED_SERVER_HELLO,
336 VERIFY_SERVER_HELLO_ERROR); 336 VERIFY_SERVER_HELLO_ERROR);
337 } 337 }
338 338
339 } // namespace 339 } // namespace
340 340
341 } // namespace notifier 341 } // namespace notifier
OLDNEW
« no previous file with comments | « jingle/notifier/base/fake_ssl_client_socket.cc ('k') | jingle/notifier/base/proxy_resolving_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698