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

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

Issue 37683004: GTTF: Make EmbeddedTestServer always use its own thread for IO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trybots Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 virtual void SetUp() OVERRIDE { 52 virtual 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(io_thread_.message_loop_proxy())); 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 virtual void TearDown() OVERRIDE {
65 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); 65 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete());
66 } 66 }
67 67
68 // URLFetcherDelegate override. 68 // URLFetcherDelegate override.
69 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE { 69 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE {
70 ++num_responses_received_; 70 ++num_responses_received_;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 base::Thread::Options thread_options; 266 base::Thread::Options thread_options;
267 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 267 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
268 ASSERT_TRUE(io_thread.StartWithOptions(thread_options)); 268 ASSERT_TRUE(io_thread.StartWithOptions(thread_options));
269 io_thread_runner = io_thread.message_loop_proxy(); 269 io_thread_runner = io_thread.message_loop_proxy();
270 270
271 scoped_ptr<base::MessageLoop> loop; 271 scoped_ptr<base::MessageLoop> loop;
272 if (message_loop_present_on_initialize_) 272 if (message_loop_present_on_initialize_)
273 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); 273 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
274 274
275 // Create the test server instance. 275 // Create the test server instance.
276 EmbeddedTestServer server(io_thread_runner); 276 EmbeddedTestServer server;
277 base::FilePath src_dir; 277 base::FilePath src_dir;
278 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); 278 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
279 ASSERT_TRUE(server.InitializeAndWaitUntilReady()); 279 ASSERT_TRUE(server.InitializeAndWaitUntilReady());
280 280
281 // Make a request and wait for the reply. 281 // Make a request and wait for the reply.
282 if (!loop) 282 if (!loop)
283 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); 283 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
284 284
285 scoped_ptr<URLFetcher> fetcher(URLFetcher::Create( 285 scoped_ptr<URLFetcher> fetcher(URLFetcher::Create(
286 server.GetURL("/test?q=foo"), URLFetcher::GET, this)); 286 server.GetURL("/test?q=foo"), URLFetcher::GET, this));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698