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

Side by Side Diff: net/test/embedded_test_server/embedded_test_server_unittest.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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 "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/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 : num_responses_received_(0), 48 : num_responses_received_(0),
49 num_responses_expected_(0), 49 num_responses_expected_(0),
50 io_thread_("io_thread") { 50 io_thread_("io_thread") {
51 } 51 }
52 52
53 void SetUp() override { 53 void SetUp() override {
54 base::Thread::Options thread_options; 54 base::Thread::Options thread_options;
55 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 55 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
56 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); 56 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options));
57 57
58 request_context_getter_ = new TestURLRequestContextGetter( 58 request_context_getter_ =
59 io_thread_.message_loop_proxy()); 59 new TestURLRequestContextGetter(io_thread_.task_runner());
60 60
61 server_.reset(new EmbeddedTestServer); 61 server_.reset(new EmbeddedTestServer);
62 ASSERT_TRUE(server_->InitializeAndWaitUntilReady()); 62 ASSERT_TRUE(server_->InitializeAndWaitUntilReady());
63 } 63 }
64 64
65 void TearDown() override { 65 void TearDown() override {
66 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); 66 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete());
67 } 67 }
68 68
69 // URLFetcherDelegate override. 69 // URLFetcherDelegate override.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 : message_loop_present_on_initialize_(message_loop_present_on_initialize), 254 : message_loop_present_on_initialize_(message_loop_present_on_initialize),
255 message_loop_present_on_shutdown_(message_loop_present_on_shutdown) {} 255 message_loop_present_on_shutdown_(message_loop_present_on_shutdown) {}
256 256
257 // base::PlatformThread::Delegate: 257 // base::PlatformThread::Delegate:
258 void ThreadMain() override { 258 void ThreadMain() override {
259 scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner; 259 scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner;
260 base::Thread io_thread("io_thread"); 260 base::Thread io_thread("io_thread");
261 base::Thread::Options thread_options; 261 base::Thread::Options thread_options;
262 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 262 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
263 ASSERT_TRUE(io_thread.StartWithOptions(thread_options)); 263 ASSERT_TRUE(io_thread.StartWithOptions(thread_options));
264 io_thread_runner = io_thread.message_loop_proxy(); 264 io_thread_runner = io_thread.task_runner();
265 265
266 scoped_ptr<base::MessageLoop> loop; 266 scoped_ptr<base::MessageLoop> loop;
267 if (message_loop_present_on_initialize_) 267 if (message_loop_present_on_initialize_)
268 loop.reset(new base::MessageLoopForIO); 268 loop.reset(new base::MessageLoopForIO);
269 269
270 // Create the test server instance. 270 // Create the test server instance.
271 EmbeddedTestServer server; 271 EmbeddedTestServer server;
272 base::FilePath src_dir; 272 base::FilePath src_dir;
273 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); 273 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
274 ASSERT_TRUE(server.InitializeAndWaitUntilReady()); 274 ASSERT_TRUE(server.InitializeAndWaitUntilReady());
275 275
276 // Make a request and wait for the reply. 276 // Make a request and wait for the reply.
277 if (!loop) 277 if (!loop)
278 loop.reset(new base::MessageLoopForIO); 278 loop.reset(new base::MessageLoopForIO);
279 279
280 scoped_ptr<URLFetcher> fetcher = 280 scoped_ptr<URLFetcher> fetcher =
281 URLFetcher::Create(server.GetURL("/test?q=foo"), URLFetcher::GET, this); 281 URLFetcher::Create(server.GetURL("/test?q=foo"), URLFetcher::GET, this);
282 fetcher->SetRequestContext( 282 fetcher->SetRequestContext(
283 new TestURLRequestContextGetter(loop->message_loop_proxy())); 283 new TestURLRequestContextGetter(loop->task_runner()));
284 fetcher->Start(); 284 fetcher->Start();
285 loop->Run(); 285 loop->Run();
286 fetcher.reset(); 286 fetcher.reset();
287 287
288 // Shut down. 288 // Shut down.
289 if (message_loop_present_on_shutdown_) 289 if (message_loop_present_on_shutdown_)
290 loop.reset(); 290 loop.reset();
291 291
292 ASSERT_TRUE(server.ShutdownAndWaitUntilComplete()); 292 ASSERT_TRUE(server.ShutdownAndWaitUntilComplete());
293 } 293 }
(...skipping 21 matching lines...) Expand all
315 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); 315 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle));
316 base::PlatformThread::Join(thread_handle); 316 base::PlatformThread::Join(thread_handle);
317 } 317 }
318 318
319 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, 319 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation,
320 EmbeddedTestServerThreadingTest, 320 EmbeddedTestServerThreadingTest,
321 testing::Combine(testing::Bool(), testing::Bool())); 321 testing::Combine(testing::Bool(), testing::Bool()));
322 322
323 } // namespace test_server 323 } // namespace test_server
324 } // namespace net 324 } // namespace net
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.cc ('k') | net/test/url_request/url_request_failed_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698