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