| Index: chrome/browser/process_singleton_posix_unittest.cc
|
| diff --git a/chrome/browser/process_singleton_posix_unittest.cc b/chrome/browser/process_singleton_posix_unittest.cc
|
| index 4c3922a030247d6d9f07d7a3089ecb010906a91d..9b09212498b2c0785a0f92d078c2aa9e499d63a2 100644
|
| --- a/chrome/browser/process_singleton_posix_unittest.cc
|
| +++ b/chrome/browser/process_singleton_posix_unittest.cc
|
| @@ -27,6 +27,7 @@
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/synchronization/waitable_event.h"
|
| +#include "base/test/histogram_tester.h"
|
| #include "base/test/test_timeouts.h"
|
| #include "base/test/thread_test_helper.h"
|
| #include "base/threading/thread.h"
|
| @@ -81,6 +82,7 @@ class ProcessSingletonPosixTest : public testing::Test {
|
| testing::Test::SetUp();
|
|
|
| ProcessSingleton::DisablePromptForTesting();
|
| + ProcessSingleton::SkipIsChromeProcessCheckForTesting(false);
|
| // Put the lock in a temporary directory. Doesn't need to be a
|
| // full profile to test this code.
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| @@ -286,17 +288,22 @@ TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessSuccess) {
|
|
|
| // Test failure case of NotifyOtherProcess().
|
| TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessFailure) {
|
| + base::HistogramTester histogram_tester;
|
| CreateProcessSingletonOnThread();
|
|
|
| BlockWorkerThread();
|
| EXPECT_EQ(ProcessSingleton::PROCESS_NONE, NotifyOtherProcess(true));
|
| ASSERT_EQ(1, kill_callbacks_);
|
| UnblockWorkerThread();
|
| + histogram_tester.ExpectUniqueSample(
|
| + "Chrome.ProcessSingleton.RemoteHungProcessTerminateReason",
|
| + ProcessSingleton::SOCKET_READ_FAILED, 1u);
|
| }
|
|
|
| // Test that we don't kill ourselves by accident if a lockfile with the same pid
|
| // happens to exist.
|
| TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessNoSuicide) {
|
| + base::HistogramTester histogram_tester;
|
| CreateProcessSingletonOnThread();
|
| // Replace lockfile with one containing our own pid.
|
| EXPECT_EQ(0, unlink(lock_path_.value().c_str()));
|
| @@ -310,8 +317,14 @@ TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessNoSuicide) {
|
| // Remove socket so that we will not be able to notify the existing browser.
|
| EXPECT_EQ(0, unlink(socket_path_.value().c_str()));
|
|
|
| + // Pretend we are browser process.
|
| + ProcessSingleton::SkipIsChromeProcessCheckForTesting(true);
|
| +
|
| EXPECT_EQ(ProcessSingleton::PROCESS_NONE, NotifyOtherProcess(false));
|
| // If we've gotten to this point without killing ourself, the test succeeded.
|
| + histogram_tester.ExpectUniqueSample(
|
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult",
|
| + ProcessSingleton::SAME_BROWSER_INSTANCE, 1u);
|
| }
|
|
|
| // Test that we can still notify a process on the same host even after the
|
| @@ -408,6 +421,7 @@ TEST_F(ProcessSingletonPosixTest, NotifyOtherProcessOrCreate_BadCookie) {
|
| }
|
|
|
| TEST_F(ProcessSingletonPosixTest, IgnoreSocketSymlinkWithTooLongTarget) {
|
| + base::HistogramTester histogram_tester;
|
| CreateProcessSingletonOnThread();
|
| // Change the symlink to one with a too-long target.
|
| char buf[PATH_MAX];
|
| @@ -423,6 +437,12 @@ TEST_F(ProcessSingletonPosixTest, IgnoreSocketSymlinkWithTooLongTarget) {
|
| // A new ProcessSingleton should ignore the invalid socket path target.
|
| std::string url("about:blank");
|
| EXPECT_EQ(ProcessSingleton::PROCESS_NONE, NotifyOtherProcessOrCreate(url));
|
| +
|
| + // Lock file contains PID of unit_tests process. It is non browser process so
|
| + // we treat lock file as orphaned.
|
| + histogram_tester.ExpectUniqueSample(
|
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult",
|
| + ProcessSingleton::ORPHANED_LOCK_FILE, 1u);
|
| }
|
|
|
| #if defined(OS_MACOSX)
|
|
|