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

Side by Side Diff: net/socket/transport_client_socket_unittest.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "net/base/address_list.h" 11 #include "net/base/address_list.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/ip_address.h" 13 #include "net/base/ip_address.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/test_completion_callback.h" 15 #include "net/base/test_completion_callback.h"
16 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
17 #include "net/log/net_log.h" 17 #include "net/log/net_log.h"
18 #include "net/log/net_log_event_type.h"
18 #include "net/log/test_net_log.h" 19 #include "net/log/test_net_log.h"
19 #include "net/log/test_net_log_entry.h" 20 #include "net/log/test_net_log_entry.h"
20 #include "net/log/test_net_log_util.h" 21 #include "net/log/test_net_log_util.h"
21 #include "net/socket/client_socket_factory.h" 22 #include "net/socket/client_socket_factory.h"
22 #include "net/socket/tcp_client_socket.h" 23 #include "net/socket/tcp_client_socket.h"
23 #include "net/socket/tcp_server_socket.h" 24 #include "net/socket/tcp_server_socket.h"
24 #include "net/test/gtest_util.h" 25 #include "net/test/gtest_util.h"
25 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 #include "testing/platform_test.h" 28 #include "testing/platform_test.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 TestCompletionCallback callback; 236 TestCompletionCallback callback;
236 EXPECT_FALSE(sock_->IsConnected()); 237 EXPECT_FALSE(sock_->IsConnected());
237 238
238 int rv = sock_->Connect(callback.callback()); 239 int rv = sock_->Connect(callback.callback());
239 // Wait for |listen_sock_| to accept a connection. 240 // Wait for |listen_sock_| to accept a connection.
240 connect_loop_.Run(); 241 connect_loop_.Run();
241 242
242 TestNetLogEntry::List net_log_entries; 243 TestNetLogEntry::List net_log_entries;
243 net_log_.GetEntries(&net_log_entries); 244 net_log_.GetEntries(&net_log_entries);
244 EXPECT_TRUE( 245 EXPECT_TRUE(
245 LogContainsBeginEvent(net_log_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); 246 LogContainsBeginEvent(net_log_entries, 0, NetLogEventType::SOCKET_ALIVE));
246 EXPECT_TRUE( 247 EXPECT_TRUE(
247 LogContainsBeginEvent(net_log_entries, 1, NetLog::TYPE_TCP_CONNECT)); 248 LogContainsBeginEvent(net_log_entries, 1, NetLogEventType::TCP_CONNECT));
248 // Now wait for the client socket to accept the connection. 249 // Now wait for the client socket to accept the connection.
249 if (rv != OK) { 250 if (rv != OK) {
250 ASSERT_EQ(rv, ERR_IO_PENDING); 251 ASSERT_EQ(rv, ERR_IO_PENDING);
251 rv = callback.WaitForResult(); 252 rv = callback.WaitForResult();
252 EXPECT_EQ(rv, OK); 253 EXPECT_EQ(rv, OK);
253 } 254 }
254 255
255 EXPECT_TRUE(sock_->IsConnected()); 256 EXPECT_TRUE(sock_->IsConnected());
256 net_log_.GetEntries(&net_log_entries); 257 net_log_.GetEntries(&net_log_entries);
257 EXPECT_TRUE( 258 EXPECT_TRUE(
258 LogContainsEndEvent(net_log_entries, -1, NetLog::TYPE_TCP_CONNECT)); 259 LogContainsEndEvent(net_log_entries, -1, NetLogEventType::TCP_CONNECT));
259 260
260 sock_->Disconnect(); 261 sock_->Disconnect();
261 EXPECT_FALSE(sock_->IsConnected()); 262 EXPECT_FALSE(sock_->IsConnected());
262 } 263 }
263 264
264 TEST_P(TransportClientSocketTest, IsConnected) { 265 TEST_P(TransportClientSocketTest, IsConnected) {
265 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); 266 scoped_refptr<IOBuffer> buf(new IOBuffer(4096));
266 TestCompletionCallback callback; 267 TestCompletionCallback callback;
267 uint32_t bytes_read; 268 uint32_t bytes_read;
268 269
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 470
470 // It's possible the read is blocked because it's already read all the data. 471 // It's possible the read is blocked because it's already read all the data.
471 // Close the server socket, so there will at least be a 0-byte read. 472 // Close the server socket, so there will at least be a 0-byte read.
472 CloseServerSocket(); 473 CloseServerSocket();
473 474
474 rv = callback.WaitForResult(); 475 rv = callback.WaitForResult();
475 EXPECT_GE(rv, 0); 476 EXPECT_GE(rv, 0);
476 } 477 }
477 478
478 } // namespace net 479 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool_test_util.cc ('k') | net/socket/websocket_transport_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698