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 "blimp/net/client_connection_manager.h" | 5 #include "blimp/net/client_connection_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "blimp/common/create_blimp_message.h" | 14 #include "blimp/common/create_blimp_message.h" |
15 #include "blimp/common/proto/blimp_message.pb.h" | 15 #include "blimp/common/proto/blimp_message.pb.h" |
16 #include "blimp/common/protocol_version.h" | 16 #include "blimp/common/version_info.h" |
17 #include "blimp/net/blimp_connection.h" | 17 #include "blimp/net/blimp_connection.h" |
18 #include "blimp/net/blimp_transport.h" | 18 #include "blimp/net/blimp_transport.h" |
19 #include "blimp/net/test_common.h" | 19 #include "blimp/net/test_common.h" |
20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 #include "net/base/test_completion_callback.h" | 22 #include "net/base/test_completion_callback.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 using testing::_; | 26 using testing::_; |
(...skipping 10 matching lines...) Expand all Loading... |
37 public: | 37 public: |
38 ClientConnectionManagerTest() | 38 ClientConnectionManagerTest() |
39 : manager_(new ClientConnectionManager(&connection_handler_)), | 39 : manager_(new ClientConnectionManager(&connection_handler_)), |
40 transport1_(new testing::StrictMock<MockTransport>), | 40 transport1_(new testing::StrictMock<MockTransport>), |
41 transport2_(new testing::StrictMock<MockTransport>), | 41 transport2_(new testing::StrictMock<MockTransport>), |
42 reader_(new MockPacketReader), | 42 reader_(new MockPacketReader), |
43 writer_(new MockPacketWriter), | 43 writer_(new MockPacketWriter), |
44 connection_(new BlimpConnection(base::WrapUnique(reader_), | 44 connection_(new BlimpConnection(base::WrapUnique(reader_), |
45 base::WrapUnique(writer_))), | 45 base::WrapUnique(writer_))), |
46 start_connection_message_( | 46 start_connection_message_( |
47 CreateStartConnectionMessage(kDummyClientToken, kProtocolVersion)) { | 47 CreateStartConnectionMessage(kDummyClientToken, |
| 48 GetProtocolVersion())) { |
48 manager_->set_client_token(kDummyClientToken); | 49 manager_->set_client_token(kDummyClientToken); |
49 } | 50 } |
50 | 51 |
51 ~ClientConnectionManagerTest() override {} | 52 ~ClientConnectionManagerTest() override {} |
52 | 53 |
53 protected: | 54 protected: |
54 base::MessageLoop message_loop_; | 55 base::MessageLoop message_loop_; |
55 testing::StrictMock<MockConnectionHandler> connection_handler_; | 56 testing::StrictMock<MockConnectionHandler> connection_handler_; |
56 std::unique_ptr<ClientConnectionManager> manager_; | 57 std::unique_ptr<ClientConnectionManager> manager_; |
57 std::unique_ptr<testing::StrictMock<MockTransport>> transport1_; | 58 std::unique_ptr<testing::StrictMock<MockTransport>> transport1_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 manager_->AddTransport(std::move(transport2_)); | 123 manager_->AddTransport(std::move(transport2_)); |
123 manager_->Connect(); | 124 manager_->Connect(); |
124 ASSERT_FALSE(connect_cb_1.is_null()); | 125 ASSERT_FALSE(connect_cb_1.is_null()); |
125 ASSERT_TRUE(connect_cb_2.is_null()); | 126 ASSERT_TRUE(connect_cb_2.is_null()); |
126 base::ResetAndReturn(&connect_cb_1).Run(net::ERR_FAILED); | 127 base::ResetAndReturn(&connect_cb_1).Run(net::ERR_FAILED); |
127 ASSERT_FALSE(connect_cb_2.is_null()); | 128 ASSERT_FALSE(connect_cb_2.is_null()); |
128 base::ResetAndReturn(&connect_cb_2).Run(net::ERR_FAILED); | 129 base::ResetAndReturn(&connect_cb_2).Run(net::ERR_FAILED); |
129 } | 130 } |
130 | 131 |
131 } // namespace blimp | 132 } // namespace blimp |
OLD | NEW |