Index: chrome/browser/process_singleton_linux_unittest.cc |
diff --git a/chrome/browser/process_singleton_linux_unittest.cc b/chrome/browser/process_singleton_linux_unittest.cc |
index 3bc0066fee8a99b8b11e93a3d27afe1a5bae35eb..21d51eb330c91098dec7a4c274b3ac84e7b4ad83 100644 |
--- a/chrome/browser/process_singleton_linux_unittest.cc |
+++ b/chrome/browser/process_singleton_linux_unittest.cc |
@@ -39,6 +39,37 @@ bool NotificationCallback(const CommandLine& command_line, |
class ProcessSingletonLinuxTest : public testing::Test { |
public: |
+ // A MockPocessSingleton to test protected methods of ProcessSingleton. |
+ class MockProcessSingleton : ProcessSingleton { |
+ public: |
+ virtual NotifyResult NotifyOtherProcess() OVERRIDE { |
+ ProcessSingleton::NotifyOtherProcess(); |
+ } |
+ virtual bool Create( |
+ const NotificationCallback& notification_callback) OVERRIDE { |
+ ProcessSingleton::Create(); |
+ } |
+ virtual NotifyResult NotifyOtherProcessWithTimeout( |
+ const CommandLine& command_line, |
+ int timeout_seconds, |
+ bool kill_unresponsive) OVERRIDE { |
+ ProcessSingleton::NotifyOtherProcessWithTimeout(); |
robertshield
2012/11/30 21:21:52
might not build?
gab
2012/11/30 21:35:36
Never heard of implicit parameter passing ;)?!
|
+ } |
+ virtual NotifyResult NotifyOtherProcessWithTimeoutOrCreate( |
+ const CommandLine& command_line, |
+ const NotificationCallback& notification_callback, |
+ int timeout_seconds) OVERRIDE { |
+ ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(); |
+ } |
+ virtual void OverrideCurrentPidForTesting(base::ProcessId pid) OVERRIDE { |
+ ProcessSingleton::OverrideCurrentPidForTesting(); |
+ } |
+ virtual void OverrideKillCallbackForTesting( |
+ const base::Callback<void(int)>& callback) OVERRIDE { |
+ ProcessSingleton::OverrideKillCallbackForTesting(); |
+ } |
+ }; |
+ |
ProcessSingletonLinuxTest() |
: kill_callbacks_(0), |
io_thread_(BrowserThread::IO), |
@@ -99,14 +130,15 @@ class ProcessSingletonLinuxTest : public testing::Test { |
ASSERT_TRUE(helper->Run()); |
} |
- ProcessSingleton* CreateProcessSingleton() { |
- return new ProcessSingleton(temp_dir_.path()); |
+ MockProcessSingleton* CreateProcessSingleton() { |
+ return new MockProcessSingleton(temp_dir_.path()); |
} |
ProcessSingleton::NotifyResult NotifyOtherProcess( |
bool override_kill, |
base::TimeDelta timeout) { |
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton()); |
+ scoped_ptr<MockProcessSingleton> process_singleton( |
+ CreateProcessSingleton()); |
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
command_line.AppendArg("about:blank"); |
if (override_kill) { |
@@ -124,7 +156,8 @@ class ProcessSingletonLinuxTest : public testing::Test { |
ProcessSingleton::NotifyResult NotifyOtherProcessOrCreate( |
const std::string& url, |
base::TimeDelta timeout) { |
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton()); |
+ scoped_ptr<MockProcessSingleton> process_singleton( |
+ CreateProcessSingleton()); |
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram()); |
command_line.AppendArg(url); |
return process_singleton->NotifyOtherProcessWithTimeoutOrCreate( |
@@ -197,7 +230,7 @@ class ProcessSingletonLinuxTest : public testing::Test { |
base::WaitableEvent signal_event_; |
scoped_ptr<base::Thread> worker_thread_; |
- ProcessSingleton* process_singleton_on_thread_; |
+ MockProcessSingleton* process_singleton_on_thread_; |
std::vector<CommandLine::StringVector> callback_command_lines_; |
}; |
@@ -332,7 +365,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessOrCreate_DifferingHost) { |
TEST_F(ProcessSingletonLinuxTest, CreateFailsWithExistingBrowser) { |
CreateProcessSingletonOnThread(); |
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton()); |
+ scoped_ptr<MockProcessSingleton> process_singleton(CreateProcessSingleton()); |
process_singleton->OverrideCurrentPidForTesting(base::GetCurrentProcId() + 1); |
EXPECT_FALSE(process_singleton->Create( |
base::Bind(&NotificationCallback))); |
@@ -342,7 +375,7 @@ TEST_F(ProcessSingletonLinuxTest, CreateFailsWithExistingBrowser) { |
// but with the old socket location. |
TEST_F(ProcessSingletonLinuxTest, CreateChecksCompatibilitySocket) { |
CreateProcessSingletonOnThread(); |
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton()); |
+ scoped_ptr<MockProcessSingleton> process_singleton(CreateProcessSingleton()); |
process_singleton->OverrideCurrentPidForTesting(base::GetCurrentProcId() + 1); |
// Do some surgery so as to look like the old configuration. |