| 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 "components/cast_channel/cast_socket.h" | 5 #include "components/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "net/socket/ssl_client_socket.h" | 34 #include "net/socket/ssl_client_socket.h" |
| 35 #include "net/socket/tcp_client_socket.h" | 35 #include "net/socket/tcp_client_socket.h" |
| 36 #include "net/ssl/ssl_info.h" | 36 #include "net/ssl/ssl_info.h" |
| 37 #include "net/test/cert_test_util.h" | 37 #include "net/test/cert_test_util.h" |
| 38 #include "net/test/test_data_directory.h" | 38 #include "net/test/test_data_directory.h" |
| 39 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
| 40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 41 | 41 |
| 42 const int64_t kDistantTimeoutMillis = 100000; // 100 seconds (never hit). | 42 const int64_t kDistantTimeoutMillis = 100000; // 100 seconds (never hit). |
| 43 | 43 |
| 44 using ::cast_channel::ChannelError; | |
| 45 using ::cast_channel::ChannelAuthType; | |
| 46 using ::cast_channel::ReadyState; | |
| 47 using ::testing::_; | 44 using ::testing::_; |
| 48 using ::testing::A; | 45 using ::testing::A; |
| 49 using ::testing::DoAll; | 46 using ::testing::DoAll; |
| 50 using ::testing::Invoke; | 47 using ::testing::Invoke; |
| 51 using ::testing::InvokeArgument; | 48 using ::testing::InvokeArgument; |
| 52 using ::testing::NotNull; | 49 using ::testing::NotNull; |
| 53 using ::testing::Return; | 50 using ::testing::Return; |
| 54 using ::testing::SaveArg; | 51 using ::testing::SaveArg; |
| 55 | 52 |
| 56 namespace cast_channel { | 53 namespace cast_channel { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 164 |
| 168 private: | 165 private: |
| 169 DISALLOW_COPY_AND_ASSIGN(CompleteHandler); | 166 DISALLOW_COPY_AND_ASSIGN(CompleteHandler); |
| 170 }; | 167 }; |
| 171 | 168 |
| 172 class TestCastSocket : public CastSocketImpl { | 169 class TestCastSocket : public CastSocketImpl { |
| 173 public: | 170 public: |
| 174 static std::unique_ptr<TestCastSocket> CreateSecure( | 171 static std::unique_ptr<TestCastSocket> CreateSecure( |
| 175 Logger* logger, | 172 Logger* logger, |
| 176 uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) { | 173 uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) { |
| 177 return std::unique_ptr<TestCastSocket>(new TestCastSocket( | 174 return std::unique_ptr<TestCastSocket>( |
| 178 CreateIPEndPointForTest(), ChannelAuthType::SSL_VERIFIED, | 175 new TestCastSocket(CreateIPEndPointForTest(), kDistantTimeoutMillis, |
| 179 kDistantTimeoutMillis, logger, device_capabilities)); | 176 logger, device_capabilities)); |
| 180 } | 177 } |
| 181 | 178 |
| 182 TestCastSocket(const net::IPEndPoint& ip_endpoint, | 179 TestCastSocket(const net::IPEndPoint& ip_endpoint, |
| 183 ChannelAuthType channel_auth, | |
| 184 int64_t timeout_ms, | 180 int64_t timeout_ms, |
| 185 Logger* logger, | 181 Logger* logger, |
| 186 uint64_t device_capabilities) | 182 uint64_t device_capabilities) |
| 187 : TestCastSocket(ip_endpoint, | 183 : TestCastSocket(ip_endpoint, |
| 188 channel_auth, | |
| 189 timeout_ms, | 184 timeout_ms, |
| 190 logger, | 185 logger, |
| 191 new net::TestNetLog(), | 186 new net::TestNetLog(), |
| 192 device_capabilities) {} | 187 device_capabilities) {} |
| 193 | 188 |
| 194 TestCastSocket(const net::IPEndPoint& ip_endpoint, | 189 TestCastSocket(const net::IPEndPoint& ip_endpoint, |
| 195 ChannelAuthType channel_auth, | |
| 196 int64_t timeout_ms, | 190 int64_t timeout_ms, |
| 197 Logger* logger, | 191 Logger* logger, |
| 198 net::TestNetLog* capturing_net_log, | 192 net::TestNetLog* capturing_net_log, |
| 199 uint64_t device_capabilities) | 193 uint64_t device_capabilities) |
| 200 : CastSocketImpl("some_extension_id", | 194 : CastSocketImpl(ip_endpoint, |
| 201 ip_endpoint, | |
| 202 channel_auth, | |
| 203 capturing_net_log, | 195 capturing_net_log, |
| 204 base::TimeDelta::FromMilliseconds(timeout_ms), | 196 base::TimeDelta::FromMilliseconds(timeout_ms), |
| 205 false, | 197 false, |
| 206 logger, | 198 logger, |
| 207 device_capabilities, | 199 device_capabilities, |
| 208 AuthContext::Create()), | 200 AuthContext::Create()), |
| 209 capturing_net_log_(capturing_net_log), | 201 capturing_net_log_(capturing_net_log), |
| 210 ip_(ip_endpoint), | 202 ip_(ip_endpoint), |
| 211 extract_cert_result_(true), | 203 extract_cert_result_(true), |
| 212 verify_challenge_result_(true), | 204 verify_challenge_result_(true), |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 socket_->transport()->SendMessage( | 762 socket_->transport()->SendMessage( |
| 771 test_message, base::Bind(&CompleteHandler::OnWriteComplete, | 763 test_message, base::Bind(&CompleteHandler::OnWriteComplete, |
| 772 base::Unretained(&handler_))); | 764 base::Unretained(&handler_))); |
| 773 RunPendingTasks(); | 765 RunPendingTasks(); |
| 774 | 766 |
| 775 EXPECT_EQ(ReadyState::OPEN, socket_->ready_state()); | 767 EXPECT_EQ(ReadyState::OPEN, socket_->ready_state()); |
| 776 EXPECT_EQ(ChannelError::NONE, socket_->error_state()); | 768 EXPECT_EQ(ChannelError::NONE, socket_->error_state()); |
| 777 } | 769 } |
| 778 | 770 |
| 779 } // namespace cast_channel | 771 } // namespace cast_channel |
| OLD | NEW |