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

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

Issue 22648006: Revert 216780 "Clean up compositor initialization/destruction." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 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
Property Changes:
Deleted: svn:mergeinfo
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 "content/browser/renderer_host/render_process_host_impl.h" 10 #include "content/browser/renderer_host/render_process_host_impl.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/main_function_params.h" 13 #include "content/public/common/main_function_params.h"
14 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
15 #include "net/test/embedded_test_server/embedded_test_server.h" 15 #include "net/test/embedded_test_server/embedded_test_server.h"
16 #include "ui/compositor/compositor_switches.h"
17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_switches.h"
19 16
20 #if defined(OS_POSIX) 17 #if defined(OS_POSIX)
21 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
22 #endif 19 #endif
23 20
24 #if defined(OS_MACOSX) 21 #if defined(OS_MACOSX)
25 #include "base/mac/mac_util.h" 22 #include "base/mac/mac_util.h"
26 #include "base/power_monitor/power_monitor_device_source.h" 23 #include "base/power_monitor/power_monitor_device_source.h"
27 #endif 24 #endif
28 25
29 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
30 #include "base/threading/thread_restrictions.h" 27 #include "base/threading/thread_restrictions.h"
31 #include "content/public/browser/browser_main_runner.h" 28 #include "content/public/browser/browser_main_runner.h"
32 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
33 #endif 30 #endif
34 31
35 #if defined(OS_CHROMEOS)
36 #include "base/chromeos/chromeos_version.h"
37 #endif
38
39 namespace content { 32 namespace content {
40 namespace { 33 namespace {
41 34
42 #if defined(OS_POSIX) 35 #if defined(OS_POSIX)
43 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make 36 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
44 // debugging easier) and also exit with a known error code (so that the test 37 // debugging easier) and also exit with a known error code (so that the test
45 // framework considers this a failure -- http://crbug.com/57578). 38 // framework considers this a failure -- http://crbug.com/57578).
46 // Note: We only want to do this in the browser process, and not forked 39 // Note: We only want to do this in the browser process, and not forked
47 // processes. That might lead to hangs because of locks inside tcmalloc or the 40 // processes. That might lead to hangs because of locks inside tcmalloc or the
48 // OS. See http://crbug.com/141302. 41 // OS. See http://crbug.com/141302.
(...skipping 15 matching lines...) Expand all
64 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); 57 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
65 } 58 }
66 59
67 } // namespace 60 } // namespace
68 61
69 extern int BrowserMain(const MainFunctionParams&); 62 extern int BrowserMain(const MainFunctionParams&);
70 63
71 BrowserTestBase::BrowserTestBase() 64 BrowserTestBase::BrowserTestBase()
72 : embedded_test_server_( 65 : embedded_test_server_(
73 new net::test_server::EmbeddedTestServer( 66 new net::test_server::EmbeddedTestServer(
74 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))), 67 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) {
75 allow_test_contexts_(true),
76 allow_osmesa_(true) {
77 #if defined(OS_MACOSX) 68 #if defined(OS_MACOSX)
78 base::mac::SetOverrideAmIBundled(true); 69 base::mac::SetOverrideAmIBundled(true);
79 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); 70 base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
80 #endif 71 #endif
81 72
82 #if defined(OS_POSIX) 73 #if defined(OS_POSIX)
83 handle_sigterm_ = true; 74 handle_sigterm_ = true;
84 #endif 75 #endif
85 } 76 }
86 77
(...skipping 13 matching lines...) Expand all
100 91
101 command_line->AppendSwitch(switches::kDomAutomationController); 92 command_line->AppendSwitch(switches::kDomAutomationController);
102 93
103 command_line->AppendSwitch(switches::kSkipGpuDataLoading); 94 command_line->AppendSwitch(switches::kSkipGpuDataLoading);
104 95
105 MainFunctionParams params(*command_line); 96 MainFunctionParams params(*command_line);
106 params.ui_task = 97 params.ui_task =
107 new base::Closure( 98 new base::Closure(
108 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); 99 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this));
109 100
110 #if defined(USE_AURA)
111 // Use test contexts for browser tests unless they override and force us to
112 // use a real context.
113 if (allow_test_contexts_)
114 command_line->AppendSwitch(switches::kTestCompositor);
115 #endif
116
117 // When using real GL contexts, we usually use OSMesa as this works on all
118 // bots. The command line can override this behaviour to use a real GPU.
119 if (command_line->HasSwitch(switches::kUseGpuInTests))
120 allow_osmesa_ = false;
121
122 // Some bots pass this flag when they want to use a real GPU.
123 if (command_line->HasSwitch("enable-gpu"))
124 allow_osmesa_ = false;
125
126 #if defined(OS_MACOSX)
127 // On Mac we always use a real GPU.
128 allow_osmesa_ = false;
129 #endif
130
131 #if defined(OS_ANDROID)
132 // On Android we always use a real GPU.
133 allow_osmesa_ = false;
134 #endif
135
136 #if defined(OS_CHROMEOS)
137 // If the test is running on the chromeos envrionment (such as
138 // device or vm bots), the compositor will use real GL contexts, and
139 // we should use real GL bindings with it.
140 if (base::chromeos::IsRunningOnChromeOS())
141 allow_osmesa_ = false;
142 #endif
143
144 if (command_line->HasSwitch(switches::kUseGL)) {
145 NOTREACHED() <<
146 "kUseGL should not be used with tests. Try kUseGpuInTests instead.";
147 }
148
149 if (allow_osmesa_) {
150 command_line->AppendSwitchASCII(
151 switches::kUseGL, gfx::kGLImplementationOSMesaName);
152 }
153
154 SetUpInProcessBrowserTestFixture(); 101 SetUpInProcessBrowserTestFixture();
155 #if defined(OS_ANDROID) 102 #if defined(OS_ANDROID)
156 BrowserMainRunner::Create()->Initialize(params); 103 BrowserMainRunner::Create()->Initialize(params);
157 // We are done running the test by now. During teardown we 104 // We are done running the test by now. During teardown we
158 // need to be able to perform IO. 105 // need to be able to perform IO.
159 base::ThreadRestrictions::SetIOAllowed(true); 106 base::ThreadRestrictions::SetIOAllowed(true);
160 BrowserThread::PostTask( 107 BrowserThread::PostTask(
161 BrowserThread::IO, FROM_HERE, 108 BrowserThread::IO, FROM_HERE,
162 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), 109 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed),
163 true)); 110 true));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); 146 RenderProcessHostImpl::GetInProcessRendererThreadForTesting();
200 CHECK(renderer_loop); 147 CHECK(renderer_loop);
201 148
202 renderer_loop->PostTask( 149 renderer_loop->PostTask(
203 FROM_HERE, 150 FROM_HERE,
204 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); 151 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure()));
205 runner->Run(); 152 runner->Run();
206 } 153 }
207 154
208 } // namespace content 155 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/public/test/browser_test_base.h ('k') | trunk/src/content/public/test/content_test_suite_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698