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 <stdint.h> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
| 12 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
13 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
14 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
15 #include "base/test/simple_test_clock.h" | 18 #include "base/test/simple_test_clock.h" |
16 #include "base/timer/mock_timer.h" | 19 #include "base/timer/mock_timer.h" |
17 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 20 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
18 #include "extensions/browser/api/cast_channel/cast_framer.h" | 21 #include "extensions/browser/api/cast_channel/cast_framer.h" |
19 #include "extensions/browser/api/cast_channel/cast_message_util.h" | 22 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
20 #include "extensions/browser/api/cast_channel/cast_test_util.h" | 23 #include "extensions/browser/api/cast_channel/cast_test_util.h" |
21 #include "extensions/browser/api/cast_channel/cast_transport.h" | 24 #include "extensions/browser/api/cast_channel/cast_transport.h" |
22 #include "extensions/browser/api/cast_channel/logger.h" | 25 #include "extensions/browser/api/cast_channel/logger.h" |
23 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 26 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
24 #include "net/base/address_list.h" | 27 #include "net/base/address_list.h" |
25 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
26 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
27 #include "net/log/test_net_log.h" | 30 #include "net/log/test_net_log.h" |
28 #include "net/socket/socket_test_util.h" | 31 #include "net/socket/socket_test_util.h" |
29 #include "net/socket/ssl_client_socket.h" | 32 #include "net/socket/ssl_client_socket.h" |
30 #include "net/socket/tcp_client_socket.h" | 33 #include "net/socket/tcp_client_socket.h" |
31 #include "net/ssl/ssl_info.h" | 34 #include "net/ssl/ssl_info.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
34 | 37 |
35 const int64 kDistantTimeoutMillis = 100000; // 100 seconds (never hit). | 38 const int64_t kDistantTimeoutMillis = 100000; // 100 seconds (never hit). |
36 | 39 |
37 using ::testing::_; | 40 using ::testing::_; |
38 using ::testing::A; | 41 using ::testing::A; |
39 using ::testing::DoAll; | 42 using ::testing::DoAll; |
40 using ::testing::Invoke; | 43 using ::testing::Invoke; |
41 using ::testing::InvokeArgument; | 44 using ::testing::InvokeArgument; |
42 using ::testing::NotNull; | 45 using ::testing::NotNull; |
43 using ::testing::Return; | 46 using ::testing::Return; |
44 using ::testing::SaveArg; | 47 using ::testing::SaveArg; |
45 | 48 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 MOCK_METHOD1(OnReadComplete, void(int result)); | 158 MOCK_METHOD1(OnReadComplete, void(int result)); |
156 | 159 |
157 private: | 160 private: |
158 DISALLOW_COPY_AND_ASSIGN(CompleteHandler); | 161 DISALLOW_COPY_AND_ASSIGN(CompleteHandler); |
159 }; | 162 }; |
160 | 163 |
161 class TestCastSocket : public CastSocketImpl { | 164 class TestCastSocket : public CastSocketImpl { |
162 public: | 165 public: |
163 static scoped_ptr<TestCastSocket> Create( | 166 static scoped_ptr<TestCastSocket> Create( |
164 Logger* logger, | 167 Logger* logger, |
165 uint64 device_capabilities = cast_channel::CastDeviceCapability::NONE) { | 168 uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) { |
166 return scoped_ptr<TestCastSocket>( | 169 return scoped_ptr<TestCastSocket>( |
167 new TestCastSocket(CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL, | 170 new TestCastSocket(CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL, |
168 kDistantTimeoutMillis, logger, device_capabilities)); | 171 kDistantTimeoutMillis, logger, device_capabilities)); |
169 } | 172 } |
170 | 173 |
171 static scoped_ptr<TestCastSocket> CreateSecure( | 174 static scoped_ptr<TestCastSocket> CreateSecure( |
172 Logger* logger, | 175 Logger* logger, |
173 uint64 device_capabilities = cast_channel::CastDeviceCapability::NONE) { | 176 uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) { |
174 return scoped_ptr<TestCastSocket>(new TestCastSocket( | 177 return scoped_ptr<TestCastSocket>(new TestCastSocket( |
175 CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL_VERIFIED, | 178 CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL_VERIFIED, |
176 kDistantTimeoutMillis, logger, device_capabilities)); | 179 kDistantTimeoutMillis, logger, device_capabilities)); |
177 } | 180 } |
178 | 181 |
179 explicit TestCastSocket(const net::IPEndPoint& ip_endpoint, | 182 explicit TestCastSocket(const net::IPEndPoint& ip_endpoint, |
180 ChannelAuthType channel_auth, | 183 ChannelAuthType channel_auth, |
181 int64 timeout_ms, | 184 int64_t timeout_ms, |
182 Logger* logger, | 185 Logger* logger, |
183 uint64 device_capabilities) | 186 uint64_t device_capabilities) |
184 : CastSocketImpl("some_extension_id", | 187 : CastSocketImpl("some_extension_id", |
185 ip_endpoint, | 188 ip_endpoint, |
186 channel_auth, | 189 channel_auth, |
187 &capturing_net_log_, | 190 &capturing_net_log_, |
188 base::TimeDelta::FromMilliseconds(timeout_ms), | 191 base::TimeDelta::FromMilliseconds(timeout_ms), |
189 false, | 192 false, |
190 logger, | 193 logger, |
191 device_capabilities), | 194 device_capabilities), |
192 ip_(ip_endpoint), | 195 ip_(ip_endpoint), |
193 extract_cert_result_(true), | 196 extract_cert_result_(true), |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); | 880 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); |
878 EXPECT_FALSE(socket_->audio_only()); | 881 EXPECT_FALSE(socket_->audio_only()); |
879 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); | 882 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); |
880 EXPECT_FALSE(socket_->audio_only()); | 883 EXPECT_FALSE(socket_->audio_only()); |
881 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); | 884 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); |
882 EXPECT_TRUE(socket_->audio_only()); | 885 EXPECT_TRUE(socket_->audio_only()); |
883 } | 886 } |
884 } // namespace cast_channel | 887 } // namespace cast_channel |
885 } // namespace api | 888 } // namespace api |
886 } // namespace extensions | 889 } // namespace extensions |
OLD | NEW |