OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 MOCK_METHOD3(OnError, | 79 MOCK_METHOD3(OnError, |
80 void(const CastSocket* socket, | 80 void(const CastSocket* socket, |
81 ChannelError error, | 81 ChannelError error, |
82 const LastErrors& last_errors)); | 82 const LastErrors& last_errors)); |
83 MOCK_METHOD2(OnMessage, void(const CastSocket* socket, | 83 MOCK_METHOD2(OnMessage, void(const CastSocket* socket, |
84 const MessageInfo& message)); | 84 const MessageInfo& message)); |
85 }; | 85 }; |
86 | 86 |
87 class MockTCPSocket : public net::TCPClientSocket { | 87 class MockTCPSocket : public net::TCPClientSocket { |
88 public: | 88 public: |
89 explicit MockTCPSocket(const net::MockConnect& connect_data) : | 89 explicit MockTCPSocket(const net::MockConnect& connect_data) |
90 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()), | 90 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()), |
91 connect_data_(connect_data), | 91 connect_data_(connect_data), |
92 do_nothing_(false) { } | 92 do_nothing_(false) {} |
93 | 93 |
94 explicit MockTCPSocket(bool do_nothing) : | 94 explicit MockTCPSocket(bool do_nothing) |
95 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()) { | 95 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) { |
96 CHECK(do_nothing); | 96 CHECK(do_nothing); |
97 do_nothing_ = do_nothing; | 97 do_nothing_ = do_nothing; |
98 } | 98 } |
99 | 99 |
100 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE { | 100 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE { |
101 if (do_nothing_) { | 101 if (do_nothing_) { |
102 // Stall the I/O event loop. | 102 // Stall the I/O event loop. |
103 return net::ERR_IO_PENDING; | 103 return net::ERR_IO_PENDING; |
104 } | 104 } |
105 | 105 |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 A<const LastErrors&>())); | 1204 A<const LastErrors&>())); |
1205 ConnectHelper(); | 1205 ConnectHelper(); |
1206 | 1206 |
1207 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state()); | 1207 EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state()); |
1208 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, | 1208 EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, |
1209 socket_->error_state()); | 1209 socket_->error_state()); |
1210 } | 1210 } |
1211 } // namespace cast_channel | 1211 } // namespace cast_channel |
1212 } // namespace core_api | 1212 } // namespace core_api |
1213 } // namespace extensions | 1213 } // namespace extensions |
OLD | NEW |