Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: blimp/net/tcp_transport_unittest.cc

Issue 1718333002: Migrate blimp/* to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments eroman Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/engine/session/blimp_engine_session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(net::IPAddress(127, 0, 0, 1), 0);
34 ParseAddress("127.0.0.1", 0, &local_address);
35 engine_.reset(new TCPEngineTransport(local_address, nullptr)); 35 engine_.reset(new TCPEngineTransport(local_address, nullptr));
36 } 36 }
37 37
38 net::AddressList GetLocalAddressList() const { 38 net::AddressList GetLocalAddressList() const {
39 net::IPEndPoint local_address; 39 net::IPEndPoint local_address;
40 engine_->GetLocalAddressForTesting(&local_address); 40 engine_->GetLocalAddressForTesting(&local_address);
41 return net::AddressList(local_address); 41 return net::AddressList(local_address);
42 } 42 }
43 43
44 void ParseAddress(const std::string& ip_str,
45 uint16_t port,
46 net::IPEndPoint* address) {
47 net::IPAddressNumber ip_number;
48 bool rv = net::ParseIPLiteralToNumber(ip_str, &ip_number);
49 if (!rv)
50 return;
51 *address = net::IPEndPoint(ip_number, port);
52 }
53
54 base::MessageLoopForIO message_loop_; 44 base::MessageLoopForIO message_loop_;
55 scoped_ptr<TCPEngineTransport> engine_; 45 scoped_ptr<TCPEngineTransport> engine_;
56 }; 46 };
57 47
58 TEST_F(TCPTransportTest, Connect) { 48 TEST_F(TCPTransportTest, Connect) {
59 net::TestCompletionCallback accept_callback; 49 net::TestCompletionCallback accept_callback;
60 engine_->Connect(accept_callback.callback()); 50 engine_->Connect(accept_callback.callback());
61 51
62 net::TestCompletionCallback connect_callback; 52 net::TestCompletionCallback connect_callback;
63 TCPClientTransport client(GetLocalAddressList(), nullptr); 53 TCPClientTransport client(GetLocalAddressList(), nullptr);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Client sends the second message. 135 // Client sends the second message.
146 net::TestCompletionCallback client_send_callback2; 136 net::TestCompletionCallback client_send_callback2;
147 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage( 137 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage(
148 std::move(client_message2), client_send_callback2.callback()); 138 std::move(client_message2), client_send_callback2.callback());
149 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult()); 139 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult());
150 } 140 }
151 141
152 } // namespace 142 } // namespace
153 143
154 } // namespace blimp 144 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/session/blimp_engine_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698