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

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 14914010: GTTF: Convert WebContentsImplBrowserTest to use EmbeddedTestServer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | « content/public/test/browser_test_base.h ('k') | content/test/content_browser_test.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/public/test/browser_test_base.h" 5 #include "content/public/test/browser_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "content/browser/renderer_host/render_process_host_impl.h" 11 #include "content/browser/renderer_host/render_process_host_impl.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/main_function_params.h" 14 #include "content/public/common/main_function_params.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h"
16 17
17 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
18 #include "base/mac/mac_util.h" 19 #include "base/mac/mac_util.h"
19 #include "base/power_monitor/power_monitor.h" 20 #include "base/power_monitor/power_monitor.h"
20 #endif 21 #endif
21 22
22 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
23 #include "base/threading/thread_restrictions.h" 24 #include "base/threading/thread_restrictions.h"
24 #include "content/public/browser/browser_main_runner.h" 25 #include "content/public/browser/browser_main_runner.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
(...skipping 24 matching lines...) Expand all
50 void RunTaskOnRendererThread(const base::Closure& task, 51 void RunTaskOnRendererThread(const base::Closure& task,
51 const base::Closure& quit_task) { 52 const base::Closure& quit_task) {
52 task.Run(); 53 task.Run();
53 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); 54 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
54 } 55 }
55 56
56 } // namespace 57 } // namespace
57 58
58 extern int BrowserMain(const MainFunctionParams&); 59 extern int BrowserMain(const MainFunctionParams&);
59 60
60 BrowserTestBase::BrowserTestBase() { 61 BrowserTestBase::BrowserTestBase()
62 : embedded_test_server_(
63 new net::test_server::EmbeddedTestServer(
64 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) {
61 #if defined(OS_MACOSX) 65 #if defined(OS_MACOSX)
62 base::mac::SetOverrideAmIBundled(true); 66 base::mac::SetOverrideAmIBundled(true);
63 base::PowerMonitor::AllocateSystemIOPorts(); 67 base::PowerMonitor::AllocateSystemIOPorts();
64 #endif 68 #endif
65 69
66 #if defined(OS_POSIX) 70 #if defined(OS_POSIX)
67 handle_sigterm_ = true; 71 handle_sigterm_ = true;
68 #endif 72 #endif
69 } 73 }
70 74
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 115 }
112 116
113 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { 117 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
114 #if defined(OS_POSIX) 118 #if defined(OS_POSIX)
115 if (handle_sigterm_) { 119 if (handle_sigterm_) {
116 g_browser_process_pid = base::GetCurrentProcId(); 120 g_browser_process_pid = base::GetCurrentProcId();
117 signal(SIGTERM, DumpStackTraceSignalHandler); 121 signal(SIGTERM, DumpStackTraceSignalHandler);
118 } 122 }
119 #endif // defined(OS_POSIX) 123 #endif // defined(OS_POSIX)
120 RunTestOnMainThreadLoop(); 124 RunTestOnMainThreadLoop();
125 embedded_test_server_.reset();
121 } 126 }
122 127
123 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) { 128 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) {
124 CHECK(!test_server_.get()); 129 CHECK(!test_server_.get());
125 test_server_.reset(new net::SpawnedTestServer( 130 test_server_.reset(new net::SpawnedTestServer(
126 net::SpawnedTestServer::TYPE_HTTP, 131 net::SpawnedTestServer::TYPE_HTTP,
127 net::SpawnedTestServer::kLocalhost, 132 net::SpawnedTestServer::kLocalhost,
128 test_server_base)); 133 test_server_base));
129 } 134 }
130 135
131 void BrowserTestBase::PostTaskToInProcessRendererAndWait( 136 void BrowserTestBase::PostTaskToInProcessRendererAndWait(
132 const base::Closure& task) { 137 const base::Closure& task) {
133 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); 138 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
134 139
135 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; 140 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
136 141
137 base::MessageLoop* renderer_loop = 142 base::MessageLoop* renderer_loop =
138 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); 143 RenderProcessHostImpl::GetInProcessRendererThreadForTesting();
139 CHECK(renderer_loop); 144 CHECK(renderer_loop);
140 145
141 renderer_loop->PostTask( 146 renderer_loop->PostTask(
142 FROM_HERE, 147 FROM_HERE,
143 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); 148 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure()));
144 runner->Run(); 149 runner->Run();
145 } 150 }
146 151
147 } // namespace content 152 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | content/test/content_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698