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..0af23750114993d4b3604ac8addac51ca7500af2 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" |
@@ -286,17 +287,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 +316,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(); |
Alexey Seren
2017/05/15 08:40:48
Previously ProcessSingletonPosixTest.NotifyOtherPr
|
+ |
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 +420,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 +436,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) |