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

Side by Side Diff: net/server/http_server_unittest.cc

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/server/http_server.h" 5 #include "net/server/http_server.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
30 #include "base/threading/thread_task_runner_handle.h" 30 #include "base/threading/thread_task_runner_handle.h"
31 #include "base/time/time.h" 31 #include "base/time/time.h"
32 #include "net/base/address_list.h" 32 #include "net/base/address_list.h"
33 #include "net/base/io_buffer.h" 33 #include "net/base/io_buffer.h"
34 #include "net/base/ip_endpoint.h" 34 #include "net/base/ip_endpoint.h"
35 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
36 #include "net/base/test_completion_callback.h" 36 #include "net/base/test_completion_callback.h"
37 #include "net/http/http_response_headers.h" 37 #include "net/http/http_response_headers.h"
38 #include "net/http/http_util.h" 38 #include "net/http/http_util.h"
39 #include "net/log/net_log.h" 39 #include "net/log/net_log_source.h"
40 #include "net/log/net_log_with_source.h"
40 #include "net/server/http_server_request_info.h" 41 #include "net/server/http_server_request_info.h"
41 #include "net/socket/tcp_client_socket.h" 42 #include "net/socket/tcp_client_socket.h"
42 #include "net/socket/tcp_server_socket.h" 43 #include "net/socket/tcp_server_socket.h"
43 #include "net/test/gtest_util.h" 44 #include "net/test/gtest_util.h"
44 #include "net/url_request/url_fetcher.h" 45 #include "net/url_request/url_fetcher.h"
45 #include "net/url_request/url_fetcher_delegate.h" 46 #include "net/url_request/url_fetcher_delegate.h"
46 #include "net/url_request/url_request_context.h" 47 #include "net/url_request/url_request_context.h"
47 #include "net/url_request/url_request_context_getter.h" 48 #include "net/url_request/url_request_context_getter.h"
48 #include "net/url_request/url_request_test_util.h" 49 #include "net/url_request/url_request_test_util.h"
49 #include "testing/gmock/include/gmock/gmock.h" 50 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 26 matching lines...) Expand all
76 run_loop->Run(); 77 run_loop->Run();
77 return !timed_out; 78 return !timed_out;
78 } 79 }
79 80
80 class TestHttpClient { 81 class TestHttpClient {
81 public: 82 public:
82 TestHttpClient() : connect_result_(OK) {} 83 TestHttpClient() : connect_result_(OK) {}
83 84
84 int ConnectAndWait(const IPEndPoint& address) { 85 int ConnectAndWait(const IPEndPoint& address) {
85 AddressList addresses(address); 86 AddressList addresses(address);
86 NetLog::Source source; 87 NetLogSource source;
87 socket_.reset(new TCPClientSocket(addresses, NULL, NULL, source)); 88 socket_.reset(new TCPClientSocket(addresses, NULL, NULL, source));
88 89
89 base::RunLoop run_loop; 90 base::RunLoop run_loop;
90 connect_result_ = socket_->Connect(base::Bind(&TestHttpClient::OnConnect, 91 connect_result_ = socket_->Connect(base::Bind(&TestHttpClient::OnConnect,
91 base::Unretained(this), 92 base::Unretained(this),
92 run_loop.QuitClosure())); 93 run_loop.QuitClosure()));
93 if (connect_result_ != OK && connect_result_ != ERR_IO_PENDING) 94 if (connect_result_ != OK && connect_result_ != ERR_IO_PENDING)
94 return connect_result_; 95 return connect_result_;
95 96
96 if (!RunLoopWithTimeout(&run_loop)) 97 if (!RunLoopWithTimeout(&run_loop))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 } // namespace 189 } // namespace
189 190
190 class HttpServerTest : public testing::Test, 191 class HttpServerTest : public testing::Test,
191 public HttpServer::Delegate { 192 public HttpServer::Delegate {
192 public: 193 public:
193 HttpServerTest() : quit_after_request_count_(0) {} 194 HttpServerTest() : quit_after_request_count_(0) {}
194 195
195 void SetUp() override { 196 void SetUp() override {
196 std::unique_ptr<ServerSocket> server_socket( 197 std::unique_ptr<ServerSocket> server_socket(
197 new TCPServerSocket(NULL, NetLog::Source())); 198 new TCPServerSocket(NULL, NetLogSource()));
198 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); 199 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1);
199 server_.reset(new HttpServer(std::move(server_socket), this)); 200 server_.reset(new HttpServer(std::move(server_socket), this));
200 ASSERT_THAT(server_->GetLocalAddress(&server_address_), IsOk()); 201 ASSERT_THAT(server_->GetLocalAddress(&server_address_), IsOk());
201 } 202 }
202 203
203 void OnConnect(int connection_id) override { 204 void OnConnect(int connection_id) override {
204 DCHECK(connection_map_.find(connection_id) == connection_map_.end()); 205 DCHECK(connection_map_.find(connection_id) == connection_map_.end());
205 connection_map_[connection_id] = true; 206 connection_map_[connection_id] = true;
206 } 207 }
207 208
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 ASSERT_THAT(client.ConnectAndWait(server_address_), IsOk()); 699 ASSERT_THAT(client.ConnectAndWait(server_address_), IsOk());
699 client.Send("GET / HTTP/1.1\r\n\r\n"); 700 client.Send("GET / HTTP/1.1\r\n\r\n");
700 ASSERT_FALSE(RunUntilRequestsReceived(1)); 701 ASSERT_FALSE(RunUntilRequestsReceived(1));
701 ASSERT_EQ(1ul, connection_ids_.size()); 702 ASSERT_EQ(1ul, connection_ids_.size());
702 ASSERT_EQ(0ul, requests_.size()); 703 ASSERT_EQ(0ul, requests_.size());
703 } 704 }
704 705
705 } // namespace 706 } // namespace
706 707
707 } // namespace net 708 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698