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

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

Issue 2008283004: Revert of Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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') | cc/trees/remote_channel_impl.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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
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/blimp_connection_statistics.h"
14 #include "blimp/net/tcp_client_transport.h" 13 #include "blimp/net/tcp_client_transport.h"
15 #include "blimp/net/tcp_engine_transport.h" 14 #include "blimp/net/tcp_engine_transport.h"
16 #include "blimp/net/test_common.h" 15 #include "blimp/net/test_common.h"
17 #include "net/base/address_list.h" 16 #include "net/base/address_list.h"
18 #include "net/base/ip_address.h" 17 #include "net/base/ip_address.h"
19 #include "net/base/ip_endpoint.h" 18 #include "net/base/ip_endpoint.h"
20 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
21 #include "net/base/test_completion_callback.h" 20 #include "net/base/test_completion_callback.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 using testing::_; 23 using testing::_;
25 using testing::SaveArg; 24 using testing::SaveArg;
26 25
27 namespace blimp { 26 namespace blimp {
28 27
29 namespace { 28 namespace {
30 29
31 // Integration test for TCPEngineTransport and TCPClientTransport. 30 // Integration test for TCPEngineTransport and TCPClientTransport.
32 class TCPTransportTest : public testing::Test { 31 class TCPTransportTest : public testing::Test {
33 protected: 32 protected:
34 TCPTransportTest() { 33 TCPTransportTest() {
35 net::IPEndPoint local_address(net::IPAddress(127, 0, 0, 1), 0); 34 net::IPEndPoint local_address(net::IPAddress(127, 0, 0, 1), 0);
36 engine_.reset(new TCPEngineTransport(local_address, &statistics_, nullptr)); 35 engine_.reset(new TCPEngineTransport(local_address, nullptr));
37 } 36 }
38 37
39 net::IPEndPoint GetLocalEndpoint() const { 38 net::IPEndPoint GetLocalEndpoint() const {
40 net::IPEndPoint local_address; 39 net::IPEndPoint local_address;
41 CHECK_EQ(net::OK, engine_->GetLocalAddress(&local_address)); 40 CHECK_EQ(net::OK, engine_->GetLocalAddress(&local_address));
42 return local_address; 41 return local_address;
43 } 42 }
44 43
45 base::MessageLoopForIO message_loop_; 44 base::MessageLoopForIO message_loop_;
46 BlimpConnectionStatistics statistics_;
47 std::unique_ptr<TCPEngineTransport> engine_; 45 std::unique_ptr<TCPEngineTransport> engine_;
48 }; 46 };
49 47
50 TEST_F(TCPTransportTest, Connect) { 48 TEST_F(TCPTransportTest, Connect) {
51 BlimpConnectionStatistics statistics;
52 net::TestCompletionCallback accept_callback; 49 net::TestCompletionCallback accept_callback;
53 engine_->Connect(accept_callback.callback()); 50 engine_->Connect(accept_callback.callback());
54 51
55 net::TestCompletionCallback connect_callback; 52 net::TestCompletionCallback connect_callback;
56 TCPClientTransport client(GetLocalEndpoint(), &statistics, nullptr); 53 TCPClientTransport client(GetLocalEndpoint(), nullptr);
57 client.Connect(connect_callback.callback()); 54 client.Connect(connect_callback.callback());
58 55
59 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); 56 EXPECT_EQ(net::OK, connect_callback.WaitForResult());
60 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 57 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
61 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 58 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
62 } 59 }
63 60
64 TEST_F(TCPTransportTest, TwoClientConnections) { 61 TEST_F(TCPTransportTest, TwoClientConnections) {
65 BlimpConnectionStatistics statistics;
66 net::TestCompletionCallback accept_callback1; 62 net::TestCompletionCallback accept_callback1;
67 engine_->Connect(accept_callback1.callback()); 63 engine_->Connect(accept_callback1.callback());
68 64
69 net::TestCompletionCallback connect_callback1; 65 net::TestCompletionCallback connect_callback1;
70 TCPClientTransport client1(GetLocalEndpoint(), &statistics, nullptr); 66 TCPClientTransport client1(GetLocalEndpoint(), nullptr);
71 client1.Connect(connect_callback1.callback()); 67 client1.Connect(connect_callback1.callback());
72 68
73 net::TestCompletionCallback connect_callback2; 69 net::TestCompletionCallback connect_callback2;
74 TCPClientTransport client2(GetLocalEndpoint(), &statistics, nullptr); 70 TCPClientTransport client2(GetLocalEndpoint(), nullptr);
75 client2.Connect(connect_callback2.callback()); 71 client2.Connect(connect_callback2.callback());
76 72
77 EXPECT_EQ(net::OK, connect_callback1.WaitForResult()); 73 EXPECT_EQ(net::OK, connect_callback1.WaitForResult());
78 EXPECT_EQ(net::OK, accept_callback1.WaitForResult()); 74 EXPECT_EQ(net::OK, accept_callback1.WaitForResult());
79 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 75 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
80 76
81 net::TestCompletionCallback accept_callback2; 77 net::TestCompletionCallback accept_callback2;
82 engine_->Connect(accept_callback2.callback()); 78 engine_->Connect(accept_callback2.callback());
83 EXPECT_EQ(net::OK, connect_callback2.WaitForResult()); 79 EXPECT_EQ(net::OK, connect_callback2.WaitForResult());
84 EXPECT_EQ(net::OK, accept_callback2.WaitForResult()); 80 EXPECT_EQ(net::OK, accept_callback2.WaitForResult());
85 EXPECT_TRUE(engine_->TakeConnection() != nullptr); 81 EXPECT_TRUE(engine_->TakeConnection() != nullptr);
86 } 82 }
87 83
88 TEST_F(TCPTransportTest, ExchangeMessages) { 84 TEST_F(TCPTransportTest, ExchangeMessages) {
89 BlimpConnectionStatistics statistics;
90
91 // Start the Engine transport and connect a client to it. 85 // Start the Engine transport and connect a client to it.
92 net::TestCompletionCallback accept_callback; 86 net::TestCompletionCallback accept_callback;
93 engine_->Connect(accept_callback.callback()); 87 engine_->Connect(accept_callback.callback());
94 net::TestCompletionCallback client_connect_callback; 88 net::TestCompletionCallback client_connect_callback;
95 TCPClientTransport client(GetLocalEndpoint(), &statistics, 89 TCPClientTransport client(GetLocalEndpoint(), nullptr /* NetLog */);
96 nullptr /* NetLog */);
97 client.Connect(client_connect_callback.callback()); 90 client.Connect(client_connect_callback.callback());
98 EXPECT_EQ(net::OK, client_connect_callback.WaitForResult()); 91 EXPECT_EQ(net::OK, client_connect_callback.WaitForResult());
99 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 92 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
100 93
101 // 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
102 // get one from the engine. 95 // get one from the engine.
103 MockBlimpMessageProcessor engine_incoming_processor; 96 MockBlimpMessageProcessor engine_incoming_processor;
104 MockBlimpMessageProcessor client_incoming_processor; 97 MockBlimpMessageProcessor client_incoming_processor;
105 net::CompletionCallback engine_process_message_cb; 98 net::CompletionCallback engine_process_message_cb;
106 std::unique_ptr<BlimpMessage> client_message1 = 99 std::unique_ptr<BlimpMessage> client_message1 =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Client sends the second message. 137 // Client sends the second message.
145 net::TestCompletionCallback client_send_callback2; 138 net::TestCompletionCallback client_send_callback2;
146 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage( 139 client_connnection->GetOutgoingMessageProcessor()->ProcessMessage(
147 std::move(client_message2), client_send_callback2.callback()); 140 std::move(client_message2), client_send_callback2.callback());
148 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult()); 141 EXPECT_EQ(net::OK, client_send_callback2.WaitForResult());
149 } 142 }
150 143
151 } // namespace 144 } // namespace
152 145
153 } // namespace blimp 146 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/tcp_engine_transport.cc ('k') | cc/trees/remote_channel_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698