Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: chrome/browser/process_singleton_linux_unittest.cc

Issue 11415237: Move many ProcessSingleton methods to "protected" visibility as an upcoming refactoring of ProcessS… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: decouple from https://codereview.chromium.org/11419258/ Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..dd83e18fe9c35f6c4e74d2e7a38b8c0a034cadbe 100644
--- a/chrome/browser/process_singleton_linux_unittest.cc
+++ b/chrome/browser/process_singleton_linux_unittest.cc
@@ -39,6 +39,39 @@ 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(
+ command_line, timeout_seconds, kill_unresponsive);
+ }
+ virtual NotifyResult NotifyOtherProcessWithTimeoutOrCreate(
+ const CommandLine& command_line,
+ const NotificationCallback& notification_callback,
+ int timeout_seconds) OVERRIDE {
+ ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
+ command_line, notification_callback, timeout_seconds);
+ }
+ virtual void OverrideCurrentPidForTesting(base::ProcessId pid) OVERRIDE {
+ ProcessSingleton::OverrideCurrentPidForTesting(pid);
+ }
+ virtual void OverrideKillCallbackForTesting(
+ const base::Callback<void(int)>& callback) OVERRIDE {
+ ProcessSingleton::OverrideKillCallbackForTesting(callback);
+ }
+ };
+
ProcessSingletonLinuxTest()
: kill_callbacks_(0),
io_thread_(BrowserThread::IO),
@@ -99,14 +132,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 +158,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 +232,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 +367,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 +377,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.

Powered by Google App Engine
This is Rietveld 408576698