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

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

Issue 1696563002: Blimp: add support for SSL connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reland (safe_json issue fixed). Created 4 years, 9 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/net/tcp_engine_transport.cc ('k') | blimp/net/test_common.h » ('j') | 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"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 // Integration test for TCPEngineTransport and TCPClientTransport. 30 // Integration test for TCPEngineTransport and TCPClientTransport.
31 class TCPTransportTest : public testing::Test { 31 class TCPTransportTest : public testing::Test {
32 protected: 32 protected:
33 TCPTransportTest() { 33 TCPTransportTest() {
34 net::IPEndPoint local_address(net::IPAddress(127, 0, 0, 1), 0); 34 net::IPEndPoint local_address(net::IPAddress(127, 0, 0, 1), 0);
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::IPEndPoint GetLocalEndpoint() const {
39 net::IPEndPoint local_address; 39 net::IPEndPoint local_address;
40 engine_->GetLocalAddressForTesting(&local_address); 40 CHECK_EQ(net::OK, engine_->GetLocalAddressForTesting(&local_address));
41 return net::AddressList(local_address); 41 return local_address;
42 } 42 }
43 43
44 base::MessageLoopForIO message_loop_; 44 base::MessageLoopForIO message_loop_;
45 scoped_ptr<TCPEngineTransport> engine_; 45 scoped_ptr<TCPEngineTransport> engine_;
46 }; 46 };
47 47
48 TEST_F(TCPTransportTest, Connect) { 48 TEST_F(TCPTransportTest, Connect) {
49 net::TestCompletionCallback accept_callback; 49 net::TestCompletionCallback accept_callback;
50 engine_->Connect(accept_callback.callback()); 50 engine_->Connect(accept_callback.callback());
51 51
52 net::TestCompletionCallback connect_callback; 52 net::TestCompletionCallback connect_callback;
53 TCPClientTransport client(GetLocalAddressList(), nullptr); 53 TCPClientTransport client(GetLocalEndpoint(), nullptr);
54 client.Connect(connect_callback.callback()); 54 client.Connect(connect_callback.callback());
55 55
56 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); 56 EXPECT_EQ(net::OK, connect_callback.WaitForResult());
57 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 57 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
58 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 58 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
59 } 59 }
60 60
61 TEST_F(TCPTransportTest, TwoClientConnections) { 61 TEST_F(TCPTransportTest, TwoClientConnections) {
62 net::TestCompletionCallback accept_callback1; 62 net::TestCompletionCallback accept_callback1;
63 engine_->Connect(accept_callback1.callback()); 63 engine_->Connect(accept_callback1.callback());
64 64
65 net::TestCompletionCallback connect_callback1; 65 net::TestCompletionCallback connect_callback1;
66 TCPClientTransport client1(GetLocalAddressList(), nullptr); 66 TCPClientTransport client1(GetLocalEndpoint(), nullptr);
67 client1.Connect(connect_callback1.callback()); 67 client1.Connect(connect_callback1.callback());
68 68
69 net::TestCompletionCallback connect_callback2; 69 net::TestCompletionCallback connect_callback2;
70 TCPClientTransport client2(GetLocalAddressList(), nullptr); 70 TCPClientTransport client2(GetLocalEndpoint(), nullptr);
71 client2.Connect(connect_callback2.callback()); 71 client2.Connect(connect_callback2.callback());
72 72
73 EXPECT_EQ(net::OK, connect_callback1.WaitForResult()); 73 EXPECT_EQ(net::OK, connect_callback1.WaitForResult());
74 EXPECT_EQ(net::OK, accept_callback1.WaitForResult()); 74 EXPECT_EQ(net::OK, accept_callback1.WaitForResult());
75 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 75 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
76 76
77 net::TestCompletionCallback accept_callback2; 77 net::TestCompletionCallback accept_callback2;
78 engine_->Connect(accept_callback2.callback()); 78 engine_->Connect(accept_callback2.callback());
79 EXPECT_EQ(net::OK, connect_callback2.WaitForResult()); 79 EXPECT_EQ(net::OK, connect_callback2.WaitForResult());
80 EXPECT_EQ(net::OK, accept_callback2.WaitForResult()); 80 EXPECT_EQ(net::OK, accept_callback2.WaitForResult());
81 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 81 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
82 } 82 }
83 83
84 TEST_F(TCPTransportTest, ExchangeMessages) { 84 TEST_F(TCPTransportTest, ExchangeMessages) {
85 // Start the Engine transport and connect a client to it. 85 // Start the Engine transport and connect a client to it.
86 net::TestCompletionCallback accept_callback; 86 net::TestCompletionCallback accept_callback;
87 engine_->Connect(accept_callback.callback()); 87 engine_->Connect(accept_callback.callback());
88 net::TestCompletionCallback client_connect_callback; 88 net::TestCompletionCallback client_connect_callback;
89 TCPClientTransport client(GetLocalAddressList(), nullptr /* NetLog */); 89 TCPClientTransport client(GetLocalEndpoint(), nullptr /* NetLog */);
90 client.Connect(client_connect_callback.callback()); 90 client.Connect(client_connect_callback.callback());
91 EXPECT_EQ(net::OK, client_connect_callback.WaitForResult()); 91 EXPECT_EQ(net::OK, client_connect_callback.WaitForResult());
92 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 92 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
93 93
94 // Expect the engine to get two messages from the client, and the client to 94 // Expect the engine to get two messages from the client, and the client to
95 // get one from the engine. 95 // get one from the engine.
96 MockBlimpMessageProcessor engine_incoming_processor; 96 MockBlimpMessageProcessor engine_incoming_processor;
97 MockBlimpMessageProcessor client_incoming_processor; 97 MockBlimpMessageProcessor client_incoming_processor;
98 net::CompletionCallback engine_process_message_cb; 98 net::CompletionCallback engine_process_message_cb;
99 scoped_ptr<BlimpMessage> client_message1 = 99 scoped_ptr<BlimpMessage> client_message1 =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // Client sends the second message. 135 // Client sends the second message.
136 net::TestCompletionCallback client_send_callback2; 136 net::TestCompletionCallback client_send_callback2;
137 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage( 137 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage(
138 std::move(client_message2), client_send_callback2.callback()); 138 std::move(client_message2), client_send_callback2.callback());
139 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult()); 139 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult());
140 } 140 }
141 141
142 } // namespace 142 } // namespace
143 143
144 } // namespace blimp 144 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/tcp_engine_transport.cc ('k') | blimp/net/test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698