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

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

Issue 2236093002: Decouple Blimp transport output from BlimpConnections using MessagePort. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statistics-singleton
Patch Set: wez feedback Created 4 years, 4 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/message_port.cc ('k') | blimp/net/tcp_client_transport.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "blimp/net/blimp_connection.h" 8 #include "blimp/net/blimp_connection.h"
9 #include "blimp/net/message_port.h"
9 #include "blimp/net/ssl_client_transport.h" 10 #include "blimp/net/ssl_client_transport.h"
10 #include "net/base/address_list.h" 11 #include "net/base/address_list.h"
11 #include "net/base/ip_address.h" 12 #include "net/base/ip_address.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/socket/socket_test_util.h" 14 #include "net/socket/socket_test_util.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace blimp { 18 namespace blimp {
18 namespace { 19 namespace {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 TEST_F(SSLClientTransportTest, ConnectSyncOK) { 76 TEST_F(SSLClientTransportTest, ConnectSyncOK) {
76 net::IPEndPoint endpoint(kIPV4Address, kPort); 77 net::IPEndPoint endpoint(kIPV4Address, kPort);
77 ConfigureTransport(endpoint); 78 ConfigureTransport(endpoint);
78 for (int i = 0; i < 5; ++i) { 79 for (int i = 0; i < 5; ++i) {
79 EXPECT_CALL(*this, ConnectComplete(net::OK)); 80 EXPECT_CALL(*this, ConnectComplete(net::OK));
80 SetupTCPSyncSocketConnect(endpoint, net::OK); 81 SetupTCPSyncSocketConnect(endpoint, net::OK);
81 SetupSSLSyncSocketConnect(net::OK); 82 SetupSSLSyncSocketConnect(net::OK);
82 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete, 83 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete,
83 base::Unretained(this))); 84 base::Unretained(this)));
84 EXPECT_NE(nullptr, transport_->TakeConnection().get()); 85 EXPECT_NE(nullptr, transport_->TakeMessagePort().get());
85 base::RunLoop().RunUntilIdle(); 86 base::RunLoop().RunUntilIdle();
86 } 87 }
87 } 88 }
88 89
89 TEST_F(SSLClientTransportTest, ConnectAsyncOK) { 90 TEST_F(SSLClientTransportTest, ConnectAsyncOK) {
90 net::IPEndPoint endpoint(kIPV4Address, kPort); 91 net::IPEndPoint endpoint(kIPV4Address, kPort);
91 ConfigureTransport(endpoint); 92 ConfigureTransport(endpoint);
92 for (int i = 0; i < 5; ++i) { 93 for (int i = 0; i < 5; ++i) {
93 EXPECT_CALL(*this, ConnectComplete(net::OK)); 94 EXPECT_CALL(*this, ConnectComplete(net::OK));
94 SetupTCPAsyncSocketConnect(endpoint, net::OK); 95 SetupTCPAsyncSocketConnect(endpoint, net::OK);
95 SetupSSLAsyncSocketConnect(net::OK); 96 SetupSSLAsyncSocketConnect(net::OK);
96 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete, 97 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete,
97 base::Unretained(this))); 98 base::Unretained(this)));
98 base::RunLoop().RunUntilIdle(); 99 base::RunLoop().RunUntilIdle();
99 EXPECT_NE(nullptr, transport_->TakeConnection().get()); 100 EXPECT_NE(nullptr, transport_->TakeMessagePort().get());
100 } 101 }
101 } 102 }
102 103
103 TEST_F(SSLClientTransportTest, ConnectSyncTCPError) { 104 TEST_F(SSLClientTransportTest, ConnectSyncTCPError) {
104 net::IPEndPoint endpoint(kIPV4Address, kPort); 105 net::IPEndPoint endpoint(kIPV4Address, kPort);
105 ConfigureTransport(endpoint); 106 ConfigureTransport(endpoint);
106 EXPECT_CALL(*this, ConnectComplete(net::ERR_FAILED)); 107 EXPECT_CALL(*this, ConnectComplete(net::ERR_FAILED));
107 SetupTCPSyncSocketConnect(endpoint, net::ERR_FAILED); 108 SetupTCPSyncSocketConnect(endpoint, net::ERR_FAILED);
108 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete, 109 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete,
109 base::Unretained(this))); 110 base::Unretained(this)));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete, 149 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete,
149 base::Unretained(this))); 150 base::Unretained(this)));
150 base::RunLoop().RunUntilIdle(); 151 base::RunLoop().RunUntilIdle();
151 152
152 // Subsequent TCP+SSL connections succeed. 153 // Subsequent TCP+SSL connections succeed.
153 EXPECT_CALL(*this, ConnectComplete(net::OK)); 154 EXPECT_CALL(*this, ConnectComplete(net::OK));
154 SetupTCPSyncSocketConnect(endpoint, net::OK); 155 SetupTCPSyncSocketConnect(endpoint, net::OK);
155 SetupSSLSyncSocketConnect(net::OK); 156 SetupSSLSyncSocketConnect(net::OK);
156 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete, 157 transport_->Connect(base::Bind(&SSLClientTransportTest::ConnectComplete,
157 base::Unretained(this))); 158 base::Unretained(this)));
158 EXPECT_NE(nullptr, transport_->TakeConnection().get()); 159 EXPECT_NE(nullptr, transport_->TakeMessagePort().get());
159 base::RunLoop().RunUntilIdle(); 160 base::RunLoop().RunUntilIdle();
160 } 161 }
161 162
162 } // namespace blimp 163 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/message_port.cc ('k') | blimp/net/tcp_client_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698