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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/test/test_file_util.h" | 15 #include "base/test/test_file_util.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/io_thread.h" | 17 #include "chrome/browser/io_thread.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/tabs/tab_strip_model.h" | 20 #include "chrome/browser/tabs/tab_strip_model.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/browser/ui/browser_navigator.h" | 23 #include "chrome/browser/ui/browser_navigator.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/logging_chrome.h" | 28 #include "chrome/common/logging_chrome.h" |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/test/base/chrome_test_suite.h" |
30 #include "chrome/test/base/test_launcher_utils.h" | 31 #include "chrome/test/base/test_launcher_utils.h" |
31 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
32 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
33 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
35 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
36 #include "content/renderer/mock_content_renderer_client.h" | 37 #include "content/renderer/mock_content_renderer_client.h" |
37 #include "content/test/test_browser_thread.h" | 38 #include "content/test/test_browser_thread.h" |
| 39 #include "content/test/test_launcher.h" |
38 #include "net/base/mock_host_resolver.h" | 40 #include "net/base/mock_host_resolver.h" |
39 #include "net/test/test_server.h" | 41 #include "net/test/test_server.h" |
40 | 42 |
41 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
42 #include "chrome/browser/chromeos/audio/audio_handler.h" | 44 #include "chrome/browser/chromeos/audio/audio_handler.h" |
43 #elif defined(OS_MACOSX) | 45 #elif defined(OS_MACOSX) |
44 #include "base/mac/scoped_nsautorelease_pool.h" | 46 #include "base/mac/scoped_nsautorelease_pool.h" |
45 #endif | 47 #endif |
46 | 48 |
47 namespace { | 49 namespace { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 ui_test_utils::WindowedNotificationObserver observer( | 272 ui_test_utils::WindowedNotificationObserver observer( |
271 content::NOTIFICATION_LOAD_STOP, | 273 content::NOTIFICATION_LOAD_STOP, |
272 content::NotificationService::AllSources()); | 274 content::NotificationService::AllSources()); |
273 browser->AddSelectedTabWithURL( | 275 browser->AddSelectedTabWithURL( |
274 GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_START_PAGE); | 276 GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_START_PAGE); |
275 observer.Wait(); | 277 observer.Wait(); |
276 | 278 |
277 browser->window()->Show(); | 279 browser->window()->Show(); |
278 } | 280 } |
279 | 281 |
| 282 #if !defined(OS_MACOSX) |
| 283 CommandLine InProcessBrowserTest::GetCommandLineForRelaunch() { |
| 284 CommandLine new_command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
| 285 CommandLine::SwitchMap switches = |
| 286 CommandLine::ForCurrentProcess()->GetSwitches(); |
| 287 switches.erase(switches::kUserDataDir); |
| 288 switches.erase(test_launcher::kSingleProcessTestsFlag); |
| 289 switches.erase(test_launcher::kSingleProcessTestsAndChromeFlag); |
| 290 switches.erase(test_launcher::kSingleProcessTestsFlag); |
| 291 new_command_line.AppendSwitch(ChromeTestSuite::kLaunchAsBrowser); |
| 292 |
| 293 FilePath user_data_dir; |
| 294 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 295 new_command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 296 |
| 297 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
| 298 iter != switches.end(); ++iter) { |
| 299 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
| 300 } |
| 301 return new_command_line; |
| 302 } |
| 303 #endif |
| 304 |
280 #if defined(OS_POSIX) | 305 #if defined(OS_POSIX) |
281 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 306 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
282 // debugging easier) and also exit with a known error code (so that the test | 307 // debugging easier) and also exit with a known error code (so that the test |
283 // framework considers this a failure -- http://crbug.com/57578). | 308 // framework considers this a failure -- http://crbug.com/57578). |
284 static void DumpStackTraceSignalHandler(int signal) { | 309 static void DumpStackTraceSignalHandler(int signal) { |
285 base::debug::StackTrace().PrintBacktrace(); | 310 base::debug::StackTrace().PrintBacktrace(); |
286 _exit(128 + signal); | 311 _exit(128 + signal); |
287 } | 312 } |
288 #endif // defined(OS_POSIX) | 313 #endif // defined(OS_POSIX) |
289 | 314 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (BrowserList::size() == 0) | 377 if (BrowserList::size() == 0) |
353 return; | 378 return; |
354 | 379 |
355 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 380 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
356 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 381 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
357 // shut down properly. | 382 // shut down properly. |
358 MessageLoopForUI::current()->PostTask(FROM_HERE, | 383 MessageLoopForUI::current()->PostTask(FROM_HERE, |
359 base::Bind(&BrowserList::AttemptExit)); | 384 base::Bind(&BrowserList::AttemptExit)); |
360 ui_test_utils::RunMessageLoop(); | 385 ui_test_utils::RunMessageLoop(); |
361 } | 386 } |
OLD | NEW |