| OLD | NEW |
| 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 "net/test/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
| 10 #include "net/test/embedded_test_server/http_request.h" | 10 #include "net/test/embedded_test_server/http_request.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 class EmbeddedTestServerTest: public testing::Test, | 43 class EmbeddedTestServerTest: public testing::Test, |
| 44 public URLFetcherDelegate { | 44 public URLFetcherDelegate { |
| 45 public: | 45 public: |
| 46 EmbeddedTestServerTest() | 46 EmbeddedTestServerTest() |
| 47 : num_responses_received_(0), | 47 : num_responses_received_(0), |
| 48 num_responses_expected_(0), | 48 num_responses_expected_(0), |
| 49 io_thread_("io_thread") { | 49 io_thread_("io_thread") { |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void SetUp() override { | 52 void SetUp() override { |
| 53 base::Thread::Options thread_options; | 53 base::Thread::Options thread_options; |
| 54 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 54 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 55 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); | 55 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); |
| 56 | 56 |
| 57 request_context_getter_ = new TestURLRequestContextGetter( | 57 request_context_getter_ = new TestURLRequestContextGetter( |
| 58 io_thread_.message_loop_proxy()); | 58 io_thread_.message_loop_proxy()); |
| 59 | 59 |
| 60 server_.reset(new EmbeddedTestServer); | 60 server_.reset(new EmbeddedTestServer); |
| 61 ASSERT_TRUE(server_->InitializeAndWaitUntilReady()); | 61 ASSERT_TRUE(server_->InitializeAndWaitUntilReady()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void TearDown() override { | 64 void TearDown() override { |
| 65 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); | 65 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // URLFetcherDelegate override. | 68 // URLFetcherDelegate override. |
| 69 void OnURLFetchComplete(const URLFetcher* source) override { | 69 void OnURLFetchComplete(const URLFetcher* source) override { |
| 70 ++num_responses_received_; | 70 ++num_responses_received_; |
| 71 if (num_responses_received_ == num_responses_expected_) | 71 if (num_responses_received_ == num_responses_expected_) |
| 72 base::MessageLoop::current()->Quit(); | 72 base::MessageLoop::current()->Quit(); |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); | 320 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); |
| 321 base::PlatformThread::Join(thread_handle); | 321 base::PlatformThread::Join(thread_handle); |
| 322 } | 322 } |
| 323 | 323 |
| 324 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, | 324 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, |
| 325 EmbeddedTestServerThreadingTest, | 325 EmbeddedTestServerThreadingTest, |
| 326 testing::Combine(testing::Bool(), testing::Bool())); | 326 testing::Combine(testing::Bool(), testing::Bool())); |
| 327 | 327 |
| 328 } // namespace test_server | 328 } // namespace test_server |
| 329 } // namespace net | 329 } // namespace net |
| OLD | NEW |