| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/timer/mock_timer.h" | 9 #include "base/timer/mock_timer.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "net/base/completion_callback.h" | 26 #include "net/base/completion_callback.h" |
| 27 #include "net/base/ip_address.h" | 27 #include "net/base/ip_address.h" |
| 28 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 29 #include "net/log/test_net_log.h" | 29 #include "net/log/test_net_log.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gmock_mutant.h" | 31 #include "testing/gmock_mutant.h" |
| 32 | 32 |
| 33 using ::cast_channel::CastMessage; | 33 using ::cast_channel::CastMessage; |
| 34 using ::cast_channel::CastSocket; | 34 using ::cast_channel::CastSocket; |
| 35 using ::cast_channel::CastTransport; | 35 using ::cast_channel::CastTransport; |
| 36 using ::cast_channel::ChannelAuthType; | |
| 37 using ::cast_channel::ChannelError; | 36 using ::cast_channel::ChannelError; |
| 38 using ::cast_channel::CreateIPEndPointForTest; | 37 using ::cast_channel::CreateIPEndPointForTest; |
| 39 using ::cast_channel::LastError; | 38 using ::cast_channel::LastError; |
| 40 using ::cast_channel::Logger; | 39 using ::cast_channel::Logger; |
| 41 using ::cast_channel::MockCastSocket; | 40 using ::cast_channel::MockCastSocket; |
| 42 using ::cast_channel::MockCastTransport; | 41 using ::cast_channel::MockCastTransport; |
| 43 using ::cast_channel::ReadyState; | 42 using ::cast_channel::ReadyState; |
| 44 using extensions::api::cast_channel::ErrorInfo; | 43 using extensions::api::cast_channel::ErrorInfo; |
| 45 using extensions::api::cast_channel::MessageInfo; | 44 using extensions::api::cast_channel::MessageInfo; |
| 46 using extensions::Extension; | 45 using extensions::Extension; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 net::IPEndPoint ip_endpoint(net::IPAddress(192, 168, 1, 1), 8009); | 96 net::IPEndPoint ip_endpoint(net::IPAddress(192, 168, 1, 1), 8009); |
| 98 mock_cast_socket_ = new MockCastSocket; | 97 mock_cast_socket_ = new MockCastSocket; |
| 99 // Transfers ownership of the socket. | 98 // Transfers ownership of the socket. |
| 100 api->SetSocketForTest(base::WrapUnique<CastSocket>(mock_cast_socket_)); | 99 api->SetSocketForTest(base::WrapUnique<CastSocket>(mock_cast_socket_)); |
| 101 ON_CALL(*mock_cast_socket_, set_id(_)) | 100 ON_CALL(*mock_cast_socket_, set_id(_)) |
| 102 .WillByDefault(SaveArg<0>(&channel_id_)); | 101 .WillByDefault(SaveArg<0>(&channel_id_)); |
| 103 ON_CALL(*mock_cast_socket_, id()) | 102 ON_CALL(*mock_cast_socket_, id()) |
| 104 .WillByDefault(ReturnPointee(&channel_id_)); | 103 .WillByDefault(ReturnPointee(&channel_id_)); |
| 105 ON_CALL(*mock_cast_socket_, ip_endpoint()) | 104 ON_CALL(*mock_cast_socket_, ip_endpoint()) |
| 106 .WillByDefault(ReturnRef(ip_endpoint_)); | 105 .WillByDefault(ReturnRef(ip_endpoint_)); |
| 107 ON_CALL(*mock_cast_socket_, channel_auth()) | |
| 108 .WillByDefault(Return(ChannelAuthType::SSL_VERIFIED)); | |
| 109 ON_CALL(*mock_cast_socket_, keep_alive()).WillByDefault(Return(false)); | 106 ON_CALL(*mock_cast_socket_, keep_alive()).WillByDefault(Return(false)); |
| 110 } | 107 } |
| 111 | 108 |
| 112 void SetUpOpenSendClose() { | 109 void SetUpOpenSendClose() { |
| 113 SetUpMockCastSocket(); | 110 SetUpMockCastSocket(); |
| 114 EXPECT_CALL(*mock_cast_socket_, error_state()) | 111 EXPECT_CALL(*mock_cast_socket_, error_state()) |
| 115 .WillRepeatedly(Return(ChannelError::NONE)); | 112 .WillRepeatedly(Return(ChannelError::NONE)); |
| 116 { | 113 { |
| 117 InSequence sequence; | 114 InSequence sequence; |
| 118 EXPECT_CALL(*mock_cast_socket_, ConnectRawPtr(_, _)) | 115 EXPECT_CALL(*mock_cast_socket_, ConnectRawPtr(_, _)) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 "\"keepAlive\": true, " | 428 "\"keepAlive\": true, " |
| 432 "\"audioOnly\": false, " | 429 "\"audioOnly\": false, " |
| 433 "\"connectInfo\": " | 430 "\"connectInfo\": " |
| 434 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " | 431 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " |
| 435 "\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, " | 432 "\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, " |
| 436 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " | 433 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " |
| 437 "\"destinationId\": \"\", \"data\": \"data\"}]", | 434 "\"destinationId\": \"\", \"data\": \"data\"}]", |
| 438 browser()); | 435 browser()); |
| 439 EXPECT_EQ(error, "message_info.destination_id is required"); | 436 EXPECT_EQ(error, "message_info.destination_id is required"); |
| 440 } | 437 } |
| OLD | NEW |