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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "blimp/common/create_blimp_message.h" | 9 #include "blimp/common/create_blimp_message.h" |
10 #include "blimp/common/proto/blimp_message.pb.h" | 10 #include "blimp/common/proto/blimp_message.pb.h" |
11 #include "blimp/common/proto/protocol_control.pb.h" | 11 #include "blimp/common/proto/protocol_control.pb.h" |
12 #include "blimp/net/blimp_connection.h" | 12 #include "blimp/net/blimp_connection.h" |
13 #include "blimp/net/tcp_client_transport.h" | 13 #include "blimp/net/tcp_client_transport.h" |
14 #include "blimp/net/tcp_engine_transport.h" | 14 #include "blimp/net/tcp_engine_transport.h" |
15 #include "blimp/net/test_common.h" | 15 #include "blimp/net/test_common.h" |
16 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
17 #include "net/base/ip_address.h" | |
17 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/test_completion_callback.h" | 20 #include "net/base/test_completion_callback.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using testing::_; | 23 using testing::_; |
23 using testing::SaveArg; | 24 using testing::SaveArg; |
24 | 25 |
25 namespace blimp { | 26 namespace blimp { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // Integration test for TCPEngineTransport and TCPClientTransport. | 30 // Integration test for TCPEngineTransport and TCPClientTransport. |
30 class TCPTransportTest : public testing::Test { | 31 class TCPTransportTest : public testing::Test { |
31 protected: | 32 protected: |
32 TCPTransportTest() { | 33 TCPTransportTest() { |
33 net::IPEndPoint local_address; | 34 net::IPEndPoint local_address; |
34 ParseAddress("127.0.0.1", 0, &local_address); | 35 ParseAddress("127.0.0.1", 0, &local_address); |
35 engine_.reset(new TCPEngineTransport(local_address, nullptr)); | 36 engine_.reset(new TCPEngineTransport(local_address, nullptr)); |
36 } | 37 } |
37 | 38 |
38 net::AddressList GetLocalAddressList() const { | 39 net::AddressList GetLocalAddressList() const { |
39 net::IPEndPoint local_address; | 40 net::IPEndPoint local_address; |
40 engine_->GetLocalAddressForTesting(&local_address); | 41 engine_->GetLocalAddressForTesting(&local_address); |
41 return net::AddressList(local_address); | 42 return net::AddressList(local_address); |
42 } | 43 } |
43 | 44 |
44 void ParseAddress(const std::string& ip_str, | 45 void ParseAddress(const std::string& ip_str, |
eroman
2016/02/25 00:20:41
I suggest deleting this function, and instead repl
martijnc
2016/02/25 19:38:54
Done.
| |
45 uint16_t port, | 46 uint16_t port, |
46 net::IPEndPoint* address) { | 47 net::IPEndPoint* address) { |
47 net::IPAddressNumber ip_number; | 48 net::IPAddress ip_address; |
48 bool rv = net::ParseIPLiteralToNumber(ip_str, &ip_number); | 49 bool rv = ip_address.AssignFromIPLiteral(ip_str); |
49 if (!rv) | 50 if (!rv) |
50 return; | 51 return; |
51 *address = net::IPEndPoint(ip_number, port); | 52 *address = net::IPEndPoint(ip_address, port); |
52 } | 53 } |
53 | 54 |
54 base::MessageLoopForIO message_loop_; | 55 base::MessageLoopForIO message_loop_; |
55 scoped_ptr<TCPEngineTransport> engine_; | 56 scoped_ptr<TCPEngineTransport> engine_; |
56 }; | 57 }; |
57 | 58 |
58 TEST_F(TCPTransportTest, Connect) { | 59 TEST_F(TCPTransportTest, Connect) { |
59 net::TestCompletionCallback accept_callback; | 60 net::TestCompletionCallback accept_callback; |
60 engine_->Connect(accept_callback.callback()); | 61 engine_->Connect(accept_callback.callback()); |
61 | 62 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 // Client sends the second message. | 146 // Client sends the second message. |
146 net::TestCompletionCallback client_send_callback2; | 147 net::TestCompletionCallback client_send_callback2; |
147 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage( | 148 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage( |
148 std::move(client_message2), client_send_callback2.callback()); | 149 std::move(client_message2), client_send_callback2.callback()); |
149 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult()); | 150 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult()); |
150 } | 151 } |
151 | 152 |
152 } // namespace | 153 } // namespace |
153 | 154 |
154 } // namespace blimp | 155 } // namespace blimp |
OLD | NEW |