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 // This test validates that the ProcessSingleton class properly makes sure | 5 // This test validates that the ProcessSingleton class properly makes sure |
6 // that there is only one main browser process. | 6 // that there is only one main browser process. |
7 // | 7 // |
8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. | 8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. |
9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still | 9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still |
10 // makes sense to test that the system services are giving the behavior we | 10 // makes sense to test that the system services are giving the behavior we |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 base::CloseProcessHandle(process_handle_); | 54 base::CloseProcessHandle(process_handle_); |
55 process_handle_ = base::kNullProcessHandle; | 55 process_handle_ = base::kNullProcessHandle; |
56 process_terminated_ = false; | 56 process_terminated_ = false; |
57 } | 57 } |
58 | 58 |
59 void StartChrome(base::WaitableEvent* start_event, bool first_run) { | 59 void StartChrome(base::WaitableEvent* start_event, bool first_run) { |
60 // TODO(mattm): maybe stuff should be refactored to use | 60 // TODO(mattm): maybe stuff should be refactored to use |
61 // UITest::LaunchBrowserHelper somehow? | 61 // UITest::LaunchBrowserHelper somehow? |
62 base::FilePath program; | 62 base::FilePath program; |
63 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &program)); | 63 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &program)); |
64 CommandLine command_line(program); | 64 base::CommandLine command_line(program); |
65 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); | 65 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); |
66 | 66 |
67 if (first_run) | 67 if (first_run) |
68 command_line.AppendSwitch(switches::kForceFirstRun); | 68 command_line.AppendSwitch(switches::kForceFirstRun); |
69 else | 69 else |
70 command_line.AppendSwitch(switches::kNoFirstRun); | 70 command_line.AppendSwitch(switches::kNoFirstRun); |
71 | 71 |
72 // Add the normal test-mode switches, except for the ones we're adding | 72 // Add the normal test-mode switches, except for the ones we're adding |
73 // ourselves. | 73 // ourselves. |
74 CommandLine standard_switches(CommandLine::NO_PROGRAM); | 74 base::CommandLine standard_switches(base::CommandLine::NO_PROGRAM); |
75 test_launcher_utils::PrepareBrowserCommandLineForTests(&standard_switches); | 75 test_launcher_utils::PrepareBrowserCommandLineForTests(&standard_switches); |
76 const CommandLine::SwitchMap& switch_map = standard_switches.GetSwitches(); | 76 const base::CommandLine::SwitchMap& switch_map = |
77 for (CommandLine::SwitchMap::const_iterator i = switch_map.begin(); | 77 standard_switches.GetSwitches(); |
| 78 for (base::CommandLine::SwitchMap::const_iterator i = switch_map.begin(); |
78 i != switch_map.end(); ++i) { | 79 i != switch_map.end(); ++i) { |
79 const std::string& switch_name = i->first; | 80 const std::string& switch_name = i->first; |
80 if (switch_name == switches::kUserDataDir || | 81 if (switch_name == switches::kUserDataDir || |
81 switch_name == switches::kForceFirstRun || | 82 switch_name == switches::kForceFirstRun || |
82 switch_name == switches::kNoFirstRun) | 83 switch_name == switches::kNoFirstRun) |
83 continue; | 84 continue; |
84 | 85 |
85 command_line.AppendSwitchNative(switch_name, i->second); | 86 command_line.AppendSwitchNative(switch_name, i->second); |
86 } | 87 } |
87 | 88 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); | 318 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); |
318 size_t last_index = pending_starters.front(); | 319 size_t last_index = pending_starters.front(); |
319 pending_starters.clear(); | 320 pending_starters.clear(); |
320 if (chrome_starters_[last_index]->process_handle_ != | 321 if (chrome_starters_[last_index]->process_handle_ != |
321 base::kNullProcessHandle) { | 322 base::kNullProcessHandle) { |
322 KillProcessTree(chrome_starters_[last_index]->process_handle_); | 323 KillProcessTree(chrome_starters_[last_index]->process_handle_); |
323 chrome_starters_[last_index]->done_event_.Wait(); | 324 chrome_starters_[last_index]->done_event_.Wait(); |
324 } | 325 } |
325 } | 326 } |
326 } | 327 } |
OLD | NEW |