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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 class ProcessSingletonTest : public InProcessBrowserTest { | 131 class ProcessSingletonTest : public InProcessBrowserTest { |
132 public: | 132 public: |
133 ProcessSingletonTest() | 133 ProcessSingletonTest() |
134 // We use a manual reset so that all threads wake up at once when signaled | 134 // We use a manual reset so that all threads wake up at once when signaled |
135 // and thus we must manually reset it for each attempt. | 135 // and thus we must manually reset it for each attempt. |
136 : threads_waker_(true /* manual */, false /* signaled */) { | 136 : threads_waker_(true /* manual */, false /* signaled */) { |
137 EXPECT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 137 EXPECT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
138 } | 138 } |
139 | 139 |
140 void SetUp() override { | 140 void SetUp() override { |
| 141 InProcessBrowserTest::SetUp(); |
141 // Start the threads and create the starters. | 142 // Start the threads and create the starters. |
142 for (size_t i = 0; i < kNbThreads; ++i) { | 143 for (size_t i = 0; i < kNbThreads; ++i) { |
143 chrome_starter_threads_[i].reset(new base::Thread("ChromeStarter")); | 144 chrome_starter_threads_[i].reset(new base::Thread("ChromeStarter")); |
144 ASSERT_TRUE(chrome_starter_threads_[i]->Start()); | 145 ASSERT_TRUE(chrome_starter_threads_[i]->Start()); |
145 chrome_starters_[i] = new ChromeStarter( | 146 chrome_starters_[i] = new ChromeStarter( |
146 TestTimeouts::action_max_timeout(), temp_profile_dir_.path()); | 147 TestTimeouts::action_max_timeout(), temp_profile_dir_.path()); |
147 } | 148 } |
148 } | 149 } |
149 | 150 |
150 void TearDown() override { | 151 void TearDown() override { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 210 |
210 // The event that will get all threads to wake up simultaneously and try | 211 // The event that will get all threads to wake up simultaneously and try |
211 // to start a chrome process at the same time. | 212 // to start a chrome process at the same time. |
212 base::WaitableEvent threads_waker_; | 213 base::WaitableEvent threads_waker_; |
213 | 214 |
214 // We don't want to use the default profile, but can't use UITest's since we | 215 // We don't want to use the default profile, but can't use UITest's since we |
215 // don't use UITest::LaunchBrowser. | 216 // don't use UITest::LaunchBrowser. |
216 base::ScopedTempDir temp_profile_dir_; | 217 base::ScopedTempDir temp_profile_dir_; |
217 }; | 218 }; |
218 | 219 |
219 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | 220 // Disabled on all platforms after code rot due to http://crbug.com/513534. |
220 // http://crbug.com/58219 | 221 // Originally disabled on some platforms due to http://crbug.com/58219. |
221 #define MAYBE_StartupRaceCondition DISABLED_StartupRaceCondition | 222 IN_PROC_BROWSER_TEST_F(ProcessSingletonTest, DISABLED_StartupRaceCondition) { |
222 #else | |
223 #define MAYBE_StartupRaceCondition StartupRaceCondition | |
224 #endif | |
225 IN_PROC_BROWSER_TEST_F(ProcessSingletonTest, MAYBE_StartupRaceCondition) { | |
226 // We use this to stop the attempts loop on the first failure. | 223 // We use this to stop the attempts loop on the first failure. |
227 bool failed = false; | 224 bool failed = false; |
228 for (size_t attempt = 0; attempt < kNbAttempts && !failed; ++attempt) { | 225 for (size_t attempt = 0; attempt < kNbAttempts && !failed; ++attempt) { |
229 SCOPED_TRACE(testing::Message() << "Attempt: " << attempt << "."); | 226 SCOPED_TRACE(testing::Message() << "Attempt: " << attempt << "."); |
230 // We use a single event to get all threads to do the AppLaunch at the same | 227 // We use a single event to get all threads to do the AppLaunch at the same |
231 // time... | 228 // time... |
232 threads_waker_.Reset(); | 229 threads_waker_.Reset(); |
233 | 230 |
234 // Test both with and without the first-run dialog, since they exercise | 231 // Test both with and without the first-run dialog, since they exercise |
235 // different paths. | 232 // different paths. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // "There can be only one!" :-) | 309 // "There can be only one!" :-) |
313 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); | 310 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); |
314 size_t last_index = pending_starters.front(); | 311 size_t last_index = pending_starters.front(); |
315 pending_starters.clear(); | 312 pending_starters.clear(); |
316 if (chrome_starters_[last_index]->process_.IsValid()) { | 313 if (chrome_starters_[last_index]->process_.IsValid()) { |
317 KillProcessTree(chrome_starters_[last_index]->process_); | 314 KillProcessTree(chrome_starters_[last_index]->process_); |
318 chrome_starters_[last_index]->done_event_.Wait(); | 315 chrome_starters_[last_index]->done_event_.Wait(); |
319 } | 316 } |
320 } | 317 } |
321 } | 318 } |
OLD | NEW |