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/engine_connection_manager.h" | 5 #include "blimp/net/engine_connection_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "blimp/common/assignment_options.h" |
16 #include "blimp/net/blimp_transport.h" | 17 #include "blimp/net/blimp_transport.h" |
17 #include "blimp/net/common.h" | 18 #include "blimp/net/common.h" |
18 #include "blimp/net/connection_error_observer.h" | 19 #include "blimp/net/connection_error_observer.h" |
19 #include "blimp/net/tcp_client_transport.h" | 20 #include "blimp/net/tcp_client_transport.h" |
20 #include "blimp/net/tcp_connection.h" | 21 #include "blimp/net/tcp_connection.h" |
21 #include "blimp/net/test_common.h" | 22 #include "blimp/net/test_common.h" |
22 #include "net/base/completion_callback.h" | 23 #include "net/base/completion_callback.h" |
23 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
24 #include "net/base/ip_address.h" | 25 #include "net/base/ip_address.h" |
25 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
(...skipping 18 matching lines...) Expand all Loading... |
44 protected: | 45 protected: |
45 testing::StrictMock<MockConnectionHandler> connection_handler_; | 46 testing::StrictMock<MockConnectionHandler> connection_handler_; |
46 std::unique_ptr<EngineConnectionManager> manager_; | 47 std::unique_ptr<EngineConnectionManager> manager_; |
47 base::MessageLoopForIO message_loop_; | 48 base::MessageLoopForIO message_loop_; |
48 }; | 49 }; |
49 | 50 |
50 TEST_F(EngineConnectionManagerTest, ConnectionSucceeds) { | 51 TEST_F(EngineConnectionManagerTest, ConnectionSucceeds) { |
51 EXPECT_CALL(connection_handler_, HandleConnectionPtr(_)).Times(1); | 52 EXPECT_CALL(connection_handler_, HandleConnectionPtr(_)).Times(1); |
52 | 53 |
53 net::IPAddress ip_addr(net::IPAddress::IPv4Localhost()); | 54 net::IPAddress ip_addr(net::IPAddress::IPv4Localhost()); |
54 net::IPEndPoint engine_endpoint(ip_addr, 0); | 55 AssignmentOptions assignment_options; |
55 | 56 assignment_options.engine_endpoint = net::IPEndPoint(ip_addr, 0); |
56 manager_->ConnectTransport(&engine_endpoint, | 57 manager_->ConnectTransport(&assignment_options, |
57 EngineConnectionManager::EngineTransportType::TCP); | 58 EngineConnectionManager::EngineTransportType::TCP); |
58 | 59 |
59 net::TestCompletionCallback connect_callback; | 60 net::TestCompletionCallback connect_callback; |
60 TCPClientTransport client(engine_endpoint, nullptr); | 61 TCPClientTransport client(assignment_options.engine_endpoint, nullptr); |
61 client.Connect(connect_callback.callback()); | 62 client.Connect(connect_callback.callback()); |
62 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); | 63 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); |
63 } | 64 } |
64 | 65 |
65 } // namespace blimp | 66 } // namespace blimp |
OLD | NEW |