| OLD | NEW |
| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 class HttpServerTest : public testing::Test, | 183 class HttpServerTest : public testing::Test, |
| 184 public HttpServer::Delegate { | 184 public HttpServer::Delegate { |
| 185 public: | 185 public: |
| 186 HttpServerTest() : quit_after_request_count_(0) {} | 186 HttpServerTest() : quit_after_request_count_(0) {} |
| 187 | 187 |
| 188 void SetUp() override { | 188 void SetUp() override { |
| 189 scoped_ptr<ServerSocket> server_socket( | 189 scoped_ptr<ServerSocket> server_socket( |
| 190 new TCPServerSocket(NULL, NetLog::Source())); | 190 new TCPServerSocket(NULL, NetLog::Source())); |
| 191 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); | 191 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); |
| 192 server_.reset(new HttpServer(server_socket.Pass(), this)); | 192 server_.reset(new HttpServer(std::move(server_socket), this)); |
| 193 ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); | 193 ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void OnConnect(int connection_id) override {} | 196 void OnConnect(int connection_id) override {} |
| 197 | 197 |
| 198 void OnHttpRequest(int connection_id, | 198 void OnHttpRequest(int connection_id, |
| 199 const HttpServerRequestInfo& info) override { | 199 const HttpServerRequestInfo& info) override { |
| 200 requests_.push_back(std::make_pair(info, connection_id)); | 200 requests_.push_back(std::make_pair(info, connection_id)); |
| 201 if (requests_.size() == quit_after_request_count_) | 201 if (requests_.size() == quit_after_request_count_) |
| 202 run_loop_quit_func_.Run(); | 202 run_loop_quit_func_.Run(); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); | 649 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); |
| 650 client.Send("GET / HTTP/1.1\r\n\r\n"); | 650 client.Send("GET / HTTP/1.1\r\n\r\n"); |
| 651 ASSERT_FALSE(RunUntilRequestsReceived(1)); | 651 ASSERT_FALSE(RunUntilRequestsReceived(1)); |
| 652 ASSERT_EQ(1ul, connection_ids_.size()); | 652 ASSERT_EQ(1ul, connection_ids_.size()); |
| 653 ASSERT_EQ(0ul, requests_.size()); | 653 ASSERT_EQ(0ul, requests_.size()); |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace | 656 } // namespace |
| 657 | 657 |
| 658 } // namespace net | 658 } // namespace net |
| OLD | NEW |