| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "blimp/common/create_blimp_message.h" |
| 9 #include "blimp/common/proto/blimp_message.pb.h" | 10 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/net/blimp_message_pump.h" | 11 #include "blimp/net/blimp_message_pump.h" |
| 11 #include "blimp/net/common.h" | 12 #include "blimp/net/common.h" |
| 12 #include "blimp/net/connection_error_observer.h" | 13 #include "blimp/net/connection_error_observer.h" |
| 13 #include "blimp/net/test_common.h" | 14 #include "blimp/net/test_common.h" |
| 14 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using testing::_; | 22 using testing::_; |
| 22 using testing::DoAll; | 23 using testing::DoAll; |
| 23 using testing::InSequence; | 24 using testing::InSequence; |
| 24 using testing::NotNull; | 25 using testing::NotNull; |
| 25 using testing::Return; | 26 using testing::Return; |
| 26 using testing::SaveArg; | 27 using testing::SaveArg; |
| 27 | 28 |
| 28 namespace blimp { | 29 namespace blimp { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 class BlimpMessagePumpTest : public testing::Test { | 32 class BlimpMessagePumpTest : public testing::Test { |
| 32 public: | 33 public: |
| 33 BlimpMessagePumpTest() | 34 BlimpMessagePumpTest() { |
| 34 : message1_(new BlimpMessage), message2_(new BlimpMessage) { | 35 TabControlMessage* tab_control; |
| 35 message1_->set_type(BlimpMessage::INPUT); | 36 message1_ = CreateBlimpMessage(&tab_control); |
| 36 message2_->set_type(BlimpMessage::TAB_CONTROL); | 37 InputMessage* input; |
| 38 message2_ = CreateBlimpMessage(&input); |
| 37 message_pump_.reset(new BlimpMessagePump(&reader_)); | 39 message_pump_.reset(new BlimpMessagePump(&reader_)); |
| 38 message_pump_->set_error_observer(&error_observer_); | 40 message_pump_->set_error_observer(&error_observer_); |
| 39 } | 41 } |
| 40 | 42 |
| 41 ~BlimpMessagePumpTest() override {} | 43 ~BlimpMessagePumpTest() override {} |
| 42 | 44 |
| 43 void NullMessageProcessor() { message_pump_->SetMessageProcessor(nullptr); } | 45 void NullMessageProcessor() { message_pump_->SetMessageProcessor(nullptr); } |
| 44 | 46 |
| 45 protected: | 47 protected: |
| 46 std::unique_ptr<BlimpMessage> message1_; | 48 std::unique_ptr<BlimpMessage> message1_; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 message_pump_->SetMessageProcessor(&receiver_); | 156 message_pump_->SetMessageProcessor(&receiver_); |
| 155 ASSERT_FALSE(read_packet_cb.is_null()); | 157 ASSERT_FALSE(read_packet_cb.is_null()); |
| 156 base::ResetAndReturn(&read_packet_cb).Run(message1_->ByteSize()); | 158 base::ResetAndReturn(&read_packet_cb).Run(message1_->ByteSize()); |
| 157 process_msg_cb.Run(net::OK); | 159 process_msg_cb.Run(net::OK); |
| 158 // Running |process_msg_cb| should NOT trigger another ReadPacket call. | 160 // Running |process_msg_cb| should NOT trigger another ReadPacket call. |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace | 163 } // namespace |
| 162 | 164 |
| 163 } // namespace blimp | 165 } // namespace blimp |
| OLD | NEW |