| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 test_message.set_namespace_("ns"); | 72 test_message.set_namespace_("ns"); |
| 73 test_message.set_source_id("source"); | 73 test_message.set_source_id("source"); |
| 74 test_message.set_destination_id("dest"); | 74 test_message.set_destination_id("dest"); |
| 75 test_message.set_payload_type(CastMessage::STRING); | 75 test_message.set_payload_type(CastMessage::STRING); |
| 76 test_message.set_payload_utf8("payload"); | 76 test_message.set_payload_utf8("payload"); |
| 77 return test_message; | 77 return test_message; |
| 78 } | 78 } |
| 79 | 79 |
| 80 class MockTCPSocket : public net::TCPClientSocket { | 80 class MockTCPSocket : public net::TCPClientSocket { |
| 81 public: | 81 public: |
| 82 explicit MockTCPSocket(const net::MockConnect& connect_data) : | 82 explicit MockTCPSocket(const net::MockConnect& connect_data) |
| 83 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()), | 83 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()), |
| 84 connect_data_(connect_data), | 84 connect_data_(connect_data), |
| 85 do_nothing_(false) { } | 85 do_nothing_(false) {} |
| 86 | 86 |
| 87 explicit MockTCPSocket(bool do_nothing) : | 87 explicit MockTCPSocket(bool do_nothing) |
| 88 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()) { | 88 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) { |
| 89 CHECK(do_nothing); | 89 CHECK(do_nothing); |
| 90 do_nothing_ = do_nothing; | 90 do_nothing_ = do_nothing; |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual int Connect(const net::CompletionCallback& callback) { | 93 virtual int Connect(const net::CompletionCallback& callback) { |
| 94 if (do_nothing_) { | 94 if (do_nothing_) { |
| 95 // Stall the I/O event loop. | 95 // Stall the I/O event loop. |
| 96 return net::ERR_IO_PENDING; | 96 return net::ERR_IO_PENDING; |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 false, | 189 false, |
| 190 logger, | 190 logger, |
| 191 device_capabilities), | 191 device_capabilities), |
| 192 ip_(ip_endpoint), | 192 ip_(ip_endpoint), |
| 193 connect_index_(0), | 193 connect_index_(0), |
| 194 extract_cert_result_(true), | 194 extract_cert_result_(true), |
| 195 verify_challenge_result_(true), | 195 verify_challenge_result_(true), |
| 196 verify_challenge_disallow_(false), | 196 verify_challenge_disallow_(false), |
| 197 tcp_unresponsive_(false), | 197 tcp_unresponsive_(false), |
| 198 mock_timer_(new base::MockTimer(false, false)), | 198 mock_timer_(new base::MockTimer(false, false)), |
| 199 mock_transport_(NULL) {} | 199 mock_transport_(nullptr) {} |
| 200 | 200 |
| 201 ~TestCastSocket() override {} | 201 ~TestCastSocket() override {} |
| 202 | 202 |
| 203 void SetupMockTransport() { | 203 void SetupMockTransport() { |
| 204 mock_transport_ = new MockCastTransport; | 204 mock_transport_ = new MockCastTransport; |
| 205 SetTransportForTesting(make_scoped_ptr(mock_transport_)); | 205 SetTransportForTesting(make_scoped_ptr(mock_transport_)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Socket connection helpers. | 208 // Socket connection helpers. |
| 209 void SetupTcp1Connect(net::IoMode mode, int result) { | 209 void SetupTcp1Connect(net::IoMode mode, int result) { |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 // Tests channel policy verification for device with video out capability. | 881 // Tests channel policy verification for device with video out capability. |
| 882 TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesVideoOut) { | 882 TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesVideoOut) { |
| 883 socket_ = TestCastSocket::Create( | 883 socket_ = TestCastSocket::Create( |
| 884 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); | 884 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); |
| 885 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); | 885 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); |
| 886 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); | 886 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); |
| 887 } | 887 } |
| 888 } // namespace cast_channel | 888 } // namespace cast_channel |
| 889 } // namespace core_api | 889 } // namespace core_api |
| 890 } // namespace extensions | 890 } // namespace extensions |
| OLD | NEW |