summaryrefslogtreecommitdiffstats
path: root/chrome/browser/process_singleton_linux_unittest.cc
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 20:42:37 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 20:42:37 +0000
commit7707b21cb3b9e7fd46afec4fbc5bfde2719321f2 (patch)
tree1db9bfb25afb8b9e4555bb405fe3b16444141b07 /chrome/browser/process_singleton_linux_unittest.cc
parentd968e999f336ec6328dc8adefb0dd5f1d22bce2a (diff)
downloadchromium_src-7707b21cb3b9e7fd46afec4fbc5bfde2719321f2.zip
chromium_src-7707b21cb3b9e7fd46afec4fbc5bfde2719321f2.tar.gz
chromium_src-7707b21cb3b9e7fd46afec4fbc5bfde2719321f2.tar.bz2
Move many ProcessSingleton methods to "protected" visibility as an upcoming refactoring of ProcessSingleton on Windows requires that only NotifyOtherProcessOrCreate() be callable from the public interface.
This doesn't change any code logic, just moves things around. BUG=None Review URL: https://codereview.chromium.org/11415237 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/process_singleton_linux_unittest.cc')
-rw-r--r--chrome/browser/process_singleton_linux_unittest.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/chrome/browser/process_singleton_linux_unittest.cc b/chrome/browser/process_singleton_linux_unittest.cc
index 3bc0066..06b96154 100644
--- a/chrome/browser/process_singleton_linux_unittest.cc
+++ b/chrome/browser/process_singleton_linux_unittest.cc
@@ -39,6 +39,17 @@ bool NotificationCallback(const CommandLine& command_line,
class ProcessSingletonLinuxTest : public testing::Test {
public:
+ // A ProcessSingleton exposing some protected methods for testing.
+ class TestableProcessSingleton : public ProcessSingleton {
+ public:
+ explicit TestableProcessSingleton(const FilePath& user_data_dir)
+ : ProcessSingleton(user_data_dir) {}
+ using ProcessSingleton::NotifyOtherProcessWithTimeout;
+ using ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate;
+ using ProcessSingleton::OverrideCurrentPidForTesting;
+ using ProcessSingleton::OverrideKillCallbackForTesting;
+ };
+
ProcessSingletonLinuxTest()
: kill_callbacks_(0),
io_thread_(BrowserThread::IO),
@@ -99,14 +110,15 @@ class ProcessSingletonLinuxTest : public testing::Test {
ASSERT_TRUE(helper->Run());
}
- ProcessSingleton* CreateProcessSingleton() {
- return new ProcessSingleton(temp_dir_.path());
+ TestableProcessSingleton* CreateProcessSingleton() {
+ return new TestableProcessSingleton(temp_dir_.path());
}
ProcessSingleton::NotifyResult NotifyOtherProcess(
bool override_kill,
base::TimeDelta timeout) {
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
+ scoped_ptr<TestableProcessSingleton> process_singleton(
+ CreateProcessSingleton());
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram());
command_line.AppendArg("about:blank");
if (override_kill) {
@@ -124,7 +136,8 @@ class ProcessSingletonLinuxTest : public testing::Test {
ProcessSingleton::NotifyResult NotifyOtherProcessOrCreate(
const std::string& url,
base::TimeDelta timeout) {
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
+ scoped_ptr<TestableProcessSingleton> process_singleton(
+ CreateProcessSingleton());
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram());
command_line.AppendArg(url);
return process_singleton->NotifyOtherProcessWithTimeoutOrCreate(
@@ -197,7 +210,7 @@ class ProcessSingletonLinuxTest : public testing::Test {
base::WaitableEvent signal_event_;
scoped_ptr<base::Thread> worker_thread_;
- ProcessSingleton* process_singleton_on_thread_;
+ TestableProcessSingleton* process_singleton_on_thread_;
std::vector<CommandLine::StringVector> callback_command_lines_;
};
@@ -332,7 +345,8 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessOrCreate_DifferingHost) {
TEST_F(ProcessSingletonLinuxTest, CreateFailsWithExistingBrowser) {
CreateProcessSingletonOnThread();
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
+ scoped_ptr<TestableProcessSingleton> process_singleton(
+ CreateProcessSingleton());
process_singleton->OverrideCurrentPidForTesting(base::GetCurrentProcId() + 1);
EXPECT_FALSE(process_singleton->Create(
base::Bind(&NotificationCallback)));
@@ -342,7 +356,8 @@ TEST_F(ProcessSingletonLinuxTest, CreateFailsWithExistingBrowser) {
// but with the old socket location.
TEST_F(ProcessSingletonLinuxTest, CreateChecksCompatibilitySocket) {
CreateProcessSingletonOnThread();
- scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
+ scoped_ptr<TestableProcessSingleton> process_singleton(
+ CreateProcessSingleton());
process_singleton->OverrideCurrentPidForTesting(base::GetCurrentProcId() + 1);
// Do some surgery so as to look like the old configuration.