OLD | NEW |
---|---|
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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "chrome/test/base/test_launcher_utils.h" | 29 #include "chrome/test/base/test_launcher_utils.h" |
30 #include "chrome/test/base/testing_browser_process.h" | 30 #include "chrome/test/base/testing_browser_process.h" |
31 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
32 #include "content/browser/browser_thread.h" | 32 #include "content/browser/browser_thread.h" |
33 #include "content/browser/renderer_host/render_process_host.h" | 33 #include "content/browser/renderer_host/render_process_host.h" |
34 #include "content/browser/tab_contents/tab_contents.h" | 34 #include "content/browser/tab_contents/tab_contents.h" |
35 #include "content/common/content_notification_types.h" | 35 #include "content/common/content_notification_types.h" |
36 #include "content/renderer/mock_content_renderer_client.h" | 36 #include "content/renderer/mock_content_renderer_client.h" |
37 #include "net/base/mock_host_resolver.h" | 37 #include "net/base/mock_host_resolver.h" |
38 #include "net/test/test_server.h" | 38 #include "net/test/test_server.h" |
39 #include "ui/gfx/gl/gl_switches.h" | |
40 | |
41 #if defined(VIEWS_COMPOSITOR) | |
42 #include "ui/gfx/compositor/test_compositor.h" | |
43 #include "views/widget/widget.h" | |
44 #endif | |
39 | 45 |
40 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
41 #include "chrome/browser/chromeos/audio_handler.h" | 47 #include "chrome/browser/chromeos/audio_handler.h" |
42 #endif | 48 #endif |
43 | 49 |
44 // Passed as value of kTestType. | 50 // Passed as value of kTestType. |
45 static const char kBrowserTestType[] = "browser"; | 51 static const char kBrowserTestType[] = "browser"; |
46 | 52 |
53 #if defined(VIEWS_COMPOSITOR) | |
54 static ui::Compositor* TestCreateCompositor(ui::CompositorDelegate* owner) { | |
55 return new ui::TestCompositor(owner); | |
56 } | |
57 #endif | |
58 | |
47 InProcessBrowserTest::InProcessBrowserTest() | 59 InProcessBrowserTest::InProcessBrowserTest() |
48 : browser_(NULL), | 60 : browser_(NULL), |
49 show_window_(false), | 61 show_window_(false), |
50 dom_automation_enabled_(false), | 62 dom_automation_enabled_(false), |
51 tab_closeable_state_watcher_enabled_(false) { | 63 tab_closeable_state_watcher_enabled_(false) { |
52 #if defined(OS_MACOSX) | 64 #if defined(OS_MACOSX) |
53 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. | 65 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. |
54 // Before we run the browser, we have to hack the path to the exe to match | 66 // Before we run the browser, we have to hack the path to the exe to match |
55 // what it would be if Chrome was running, because it is used to fork renderer | 67 // what it would be if Chrome was running, because it is used to fork renderer |
56 // processes, on Linux at least (failure to do so will cause a browser_test to | 68 // processes, on Linux at least (failure to do so will cause a browser_test to |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc( | 133 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc( |
122 host_resolver_.get()); | 134 host_resolver_.get()); |
123 | 135 |
124 BrowserTestBase::SetUp(); | 136 BrowserTestBase::SetUp(); |
125 } | 137 } |
126 | 138 |
127 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { | 139 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
128 // Propagate commandline settings from test_launcher_utils. | 140 // Propagate commandline settings from test_launcher_utils. |
129 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); | 141 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
130 | 142 |
143 // Use MesaGL as the GL implementation, as desktopgl/egl is not present on | |
144 // test bots yet. | |
145 EXPECT_TRUE( | |
146 test_launcher_utils::OverrideGLImplementation( | |
Paweł Hajdan Jr.
2011/10/13 20:08:13
Do you also want things to apply to content? If so
danakj
2011/10/14 15:15:13
Yes I should, thanks !
| |
147 command_line, gfx::kGLImplementationOSMesaName)); | |
148 | |
149 #if defined(VIEWS_COMPOSITOR) | |
150 // Use a mock compositor that noops draws. | |
151 views::Widget::set_compositor_factory_for_testing(&TestCreateCompositor); | |
152 #endif | |
153 | |
131 if (dom_automation_enabled_) | 154 if (dom_automation_enabled_) |
132 command_line->AppendSwitch(switches::kDomAutomationController); | 155 command_line->AppendSwitch(switches::kDomAutomationController); |
133 | 156 |
134 // This is a Browser test. | 157 // This is a Browser test. |
135 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); | 158 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); |
136 | 159 |
137 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
138 // The Windows sandbox requires that the browser and child processes are the | 161 // The Windows sandbox requires that the browser and child processes are the |
139 // same binary. So we launch browser_process.exe which loads chrome.dll | 162 // same binary. So we launch browser_process.exe which loads chrome.dll |
140 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, | 163 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 return; | 315 return; |
293 | 316 |
294 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 317 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
295 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 318 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
296 // shut down properly. | 319 // shut down properly. |
297 MessageLoopForUI::current()->PostTask( | 320 MessageLoopForUI::current()->PostTask( |
298 FROM_HERE, | 321 FROM_HERE, |
299 NewRunnableFunction(&BrowserList::AttemptExit)); | 322 NewRunnableFunction(&BrowserList::AttemptExit)); |
300 ui_test_utils::RunMessageLoop(); | 323 ui_test_utils::RunMessageLoop(); |
301 } | 324 } |
OLD | NEW |