OLD | NEW |
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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 void SingleDesktopTestObserver::OnBrowserAdded(Browser* browser) { | 105 void SingleDesktopTestObserver::OnBrowserAdded(Browser* browser) { |
106 CHECK(CalledOnValidThread()); | 106 CHECK(CalledOnValidThread()); |
107 CHECK_EQ(browser->host_desktop_type(), allowed_desktop_); | 107 CHECK_EQ(browser->host_desktop_type(), allowed_desktop_); |
108 } | 108 } |
109 | 109 |
110 } // namespace | 110 } // namespace |
111 | 111 |
112 InProcessBrowserTest::InProcessBrowserTest() | 112 InProcessBrowserTest::InProcessBrowserTest() |
113 : browser_(NULL), | 113 : browser_(NULL), |
114 exit_when_last_browser_closes_(true), | 114 exit_when_last_browser_closes_(true), |
| 115 open_about_blank_on_browser_launch_(true), |
115 multi_desktop_test_(false) | 116 multi_desktop_test_(false) |
116 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
117 , autorelease_pool_(NULL) | 118 , autorelease_pool_(NULL) |
118 #endif // OS_MACOSX | 119 #endif // OS_MACOSX |
119 { | 120 { |
120 #if defined(OS_MACOSX) | 121 #if defined(OS_MACOSX) |
121 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. | 122 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. |
122 // Before we run the browser, we have to hack the path to the exe to match | 123 // Before we run the browser, we have to hack the path to the exe to match |
123 // what it would be if Chrome was running, because it is used to fork renderer | 124 // what it would be if Chrome was running, because it is used to fork renderer |
124 // processes, on Linux at least (failure to do so will cause a browser_test to | 125 // processes, on Linux at least (failure to do so will cause a browser_test to |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 subprocess_path = | 242 subprocess_path = |
242 subprocess_path.Append(chrome::kHelperProcessExecutablePath); | 243 subprocess_path.Append(chrome::kHelperProcessExecutablePath); |
243 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, | 244 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
244 subprocess_path); | 245 subprocess_path); |
245 #endif | 246 #endif |
246 | 247 |
247 // TODO(pkotwicz): Investigate if we can remove this switch. | 248 // TODO(pkotwicz): Investigate if we can remove this switch. |
248 if (exit_when_last_browser_closes_) | 249 if (exit_when_last_browser_closes_) |
249 command_line->AppendSwitch(switches::kDisableZeroBrowsersOpenForTests); | 250 command_line->AppendSwitch(switches::kDisableZeroBrowsersOpenForTests); |
250 | 251 |
251 if (command_line->GetArgs().empty()) | 252 if (open_about_blank_on_browser_launch_ && command_line->GetArgs().empty()) |
252 command_line->AppendArg(url::kAboutBlankURL); | 253 command_line->AppendArg(url::kAboutBlankURL); |
253 } | 254 } |
254 | 255 |
255 bool InProcessBrowserTest::CreateUserDataDirectory() { | 256 bool InProcessBrowserTest::CreateUserDataDirectory() { |
256 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 257 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
257 base::FilePath user_data_dir = | 258 base::FilePath user_data_dir = |
258 command_line->GetSwitchValuePath(switches::kUserDataDir); | 259 command_line->GetSwitchValuePath(switches::kUserDataDir); |
259 if (user_data_dir.empty()) { | 260 if (user_data_dir.empty()) { |
260 if (temp_user_data_dir_.CreateUniqueTempDir() && | 261 if (temp_user_data_dir_.CreateUniqueTempDir() && |
261 temp_user_data_dir_.IsValid()) { | 262 temp_user_data_dir_.IsValid()) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // On the Mac, this eventually reaches | 473 // On the Mac, this eventually reaches |
473 // -[BrowserWindowController windowWillClose:], which will post a deferred | 474 // -[BrowserWindowController windowWillClose:], which will post a deferred |
474 // -autorelease on itself to ultimately destroy the Browser object. The line | 475 // -autorelease on itself to ultimately destroy the Browser object. The line |
475 // below is necessary to pump these pending messages to ensure all Browsers | 476 // below is necessary to pump these pending messages to ensure all Browsers |
476 // get deleted. | 477 // get deleted. |
477 content::RunAllPendingInMessageLoop(); | 478 content::RunAllPendingInMessageLoop(); |
478 delete autorelease_pool_; | 479 delete autorelease_pool_; |
479 autorelease_pool_ = NULL; | 480 autorelease_pool_ = NULL; |
480 #endif | 481 #endif |
481 } | 482 } |
OLD | NEW |