| 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_transport.h" | 5 #include "components/cast_channel/cast_transport.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual int SetSendBufferSize(int32_t size) { | 139 virtual int SetSendBufferSize(int32_t size) { |
| 140 NOTREACHED(); | 140 NOTREACHED(); |
| 141 return 0; | 141 return 0; |
| 142 } | 142 } |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 class CastTransportTest : public testing::Test { | 145 class CastTransportTest : public testing::Test { |
| 146 public: | 146 public: |
| 147 using ChannelError = ::cast_channel::ChannelError; | |
| 148 using ChannelAuthType = ::cast_channel::ChannelAuthType; | |
| 149 | |
| 150 CastTransportTest() : logger_(new Logger()) { | 147 CastTransportTest() : logger_(new Logger()) { |
| 151 delegate_ = new MockCastTransportDelegate; | 148 delegate_ = new MockCastTransportDelegate; |
| 152 transport_.reset(new CastTransportImpl(&mock_socket_, kChannelId, | 149 transport_.reset(new CastTransportImpl(&mock_socket_, kChannelId, |
| 153 CreateIPEndPointForTest(), | 150 CreateIPEndPointForTest(), logger_)); |
| 154 auth_type_, logger_)); | |
| 155 transport_->SetReadDelegate(base::WrapUnique(delegate_)); | 151 transport_->SetReadDelegate(base::WrapUnique(delegate_)); |
| 156 } | 152 } |
| 157 ~CastTransportTest() override {} | 153 ~CastTransportTest() override {} |
| 158 | 154 |
| 159 protected: | 155 protected: |
| 160 // Runs all pending tasks in the message loop. | 156 // Runs all pending tasks in the message loop. |
| 161 void RunPendingTasks() { | 157 void RunPendingTasks() { |
| 162 base::RunLoop run_loop; | 158 base::RunLoop run_loop; |
| 163 run_loop.RunUntilIdle(); | 159 run_loop.RunUntilIdle(); |
| 164 } | 160 } |
| 165 | 161 |
| 166 base::MessageLoop message_loop_; | 162 base::MessageLoop message_loop_; |
| 167 MockCastTransportDelegate* delegate_; | 163 MockCastTransportDelegate* delegate_; |
| 168 MockSocket mock_socket_; | 164 MockSocket mock_socket_; |
| 169 ChannelAuthType auth_type_; | |
| 170 Logger* logger_; | 165 Logger* logger_; |
| 171 std::unique_ptr<CastTransport> transport_; | 166 std::unique_ptr<CastTransport> transport_; |
| 172 }; | 167 }; |
| 173 | 168 |
| 174 // ---------------------------------------------------------------------------- | 169 // ---------------------------------------------------------------------------- |
| 175 // Asynchronous write tests | 170 // Asynchronous write tests |
| 176 TEST_F(CastTransportTest, TestFullWriteAsync) { | 171 TEST_F(CastTransportTest, TestFullWriteAsync) { |
| 177 CompletionQueue socket_cbs; | 172 CompletionQueue socket_cbs; |
| 178 CompleteHandler write_handler; | 173 CompleteHandler write_handler; |
| 179 std::string output; | 174 std::string output; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 MessageFramer::MessageHeader::header_size(), | 673 MessageFramer::MessageHeader::header_size(), |
| 679 serialized_message.size() - | 674 serialized_message.size() - |
| 680 MessageFramer::MessageHeader::header_size() - 1)), | 675 MessageFramer::MessageHeader::header_size() - 1)), |
| 681 Return(serialized_message.size() - | 676 Return(serialized_message.size() - |
| 682 MessageFramer::MessageHeader::header_size()))) | 677 MessageFramer::MessageHeader::header_size()))) |
| 683 .RetiresOnSaturation(); | 678 .RetiresOnSaturation(); |
| 684 EXPECT_CALL(*delegate_, OnError(ChannelError::INVALID_MESSAGE)); | 679 EXPECT_CALL(*delegate_, OnError(ChannelError::INVALID_MESSAGE)); |
| 685 transport_->Start(); | 680 transport_->Start(); |
| 686 } | 681 } |
| 687 } // namespace cast_channel | 682 } // namespace cast_channel |
| OLD | NEW |