OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/process_singleton.h" | 5 #include "chrome/browser/process_singleton.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/un.h> | 10 #include <sys/un.h> |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // TODO(james.su@gmail.com): port following tests to Windows. | 270 // TODO(james.su@gmail.com): port following tests to Windows. |
271 // Test success case of NotifyOtherProcess(). | 271 // Test success case of NotifyOtherProcess(). |
272 TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessSuccess) { | 272 TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessSuccess) { |
273 CreateProcessSingletonOnThread(); | 273 CreateProcessSingletonOnThread(); |
274 EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED, | 274 EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED, |
275 NotifyOtherProcess(true, TestTimeouts::action_timeout())); | 275 NotifyOtherProcess(true, TestTimeouts::action_timeout())); |
276 CheckNotified(); | 276 CheckNotified(); |
277 } | 277 } |
278 | 278 |
279 // Test failure case of NotifyOtherProcess(). | 279 // Test failure case of NotifyOtherProcess(). |
280 TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessFailure) { | 280 // Disabled, http://crbug.com/407065 . |
| 281 TEST_F(ProcessSingletonPosixTest, DISABLED_NotifyOtherProcessFailure) { |
281 CreateProcessSingletonOnThread(); | 282 CreateProcessSingletonOnThread(); |
282 | 283 |
283 BlockWorkerThread(); | 284 BlockWorkerThread(); |
284 EXPECT_EQ(ProcessSingleton::PROCESS_NONE, | 285 EXPECT_EQ(ProcessSingleton::PROCESS_NONE, |
285 NotifyOtherProcess(true, TestTimeouts::action_timeout())); | 286 NotifyOtherProcess(true, TestTimeouts::action_timeout())); |
286 | 287 |
287 ASSERT_EQ(1, kill_callbacks_); | 288 ASSERT_EQ(1, kill_callbacks_); |
288 UnblockWorkerThread(); | 289 UnblockWorkerThread(); |
289 } | 290 } |
290 | 291 |
(...skipping 25 matching lines...) Expand all Loading... |
316 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); | 317 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); |
317 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); | 318 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); |
318 | 319 |
319 EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED, | 320 EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED, |
320 NotifyOtherProcess(false, TestTimeouts::action_timeout())); | 321 NotifyOtherProcess(false, TestTimeouts::action_timeout())); |
321 CheckNotified(); | 322 CheckNotified(); |
322 } | 323 } |
323 | 324 |
324 // Test that we fail when lock says process is on another host and we can't | 325 // Test that we fail when lock says process is on another host and we can't |
325 // notify it over the socket. | 326 // notify it over the socket. |
326 TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessDifferingHost) { | 327 // Disabled, http://crbug.com/407065 . |
| 328 TEST_F(ProcessSingletonPosixTest, DISABLED_NotifyOtherProcessDifferingHost) { |
327 CreateProcessSingletonOnThread(); | 329 CreateProcessSingletonOnThread(); |
328 | 330 |
329 BlockWorkerThread(); | 331 BlockWorkerThread(); |
330 | 332 |
331 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); | 333 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); |
332 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); | 334 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); |
333 | 335 |
334 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, | 336 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, |
335 NotifyOtherProcess(false, TestTimeouts::action_timeout())); | 337 NotifyOtherProcess(false, TestTimeouts::action_timeout())); |
336 | 338 |
337 ASSERT_EQ(0, unlink(lock_path_.value().c_str())); | 339 ASSERT_EQ(0, unlink(lock_path_.value().c_str())); |
338 | 340 |
339 UnblockWorkerThread(); | 341 UnblockWorkerThread(); |
340 } | 342 } |
341 | 343 |
342 // Test that we fail when lock says process is on another host and we can't | 344 // Test that we fail when lock says process is on another host and we can't |
343 // notify it over the socket. | 345 // notify it over the socket. |
344 TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessOrCreate_DifferingHost) { | 346 // Disabled, http://crbug.com/407065 . |
| 347 TEST_F(ProcessSingletonPosixTest, |
| 348 DISABLED_NotifyOtherProcessOrCreate_DifferingHost) { |
345 CreateProcessSingletonOnThread(); | 349 CreateProcessSingletonOnThread(); |
346 | 350 |
347 BlockWorkerThread(); | 351 BlockWorkerThread(); |
348 | 352 |
349 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); | 353 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); |
350 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); | 354 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); |
351 | 355 |
352 std::string url("about:blank"); | 356 std::string url("about:blank"); |
353 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, | 357 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, |
354 NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout())); | 358 NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout())); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // Test that if there is an existing lock file, and it's not locked, we replace | 429 // Test that if there is an existing lock file, and it's not locked, we replace |
426 // it. | 430 // it. |
427 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { | 431 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { |
428 scoped_ptr<TestableProcessSingleton> process_singleton( | 432 scoped_ptr<TestableProcessSingleton> process_singleton( |
429 CreateProcessSingleton()); | 433 CreateProcessSingleton()); |
430 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); | 434 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); |
431 EXPECT_TRUE(process_singleton->Create()); | 435 EXPECT_TRUE(process_singleton->Create()); |
432 VerifyFiles(); | 436 VerifyFiles(); |
433 } | 437 } |
434 #endif // defined(OS_MACOSX) | 438 #endif // defined(OS_MACOSX) |
OLD | NEW |