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

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: fix linux compile Created 8 years 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
« no previous file with comments | « chrome/browser/process_singleton.h ('k') | chrome_frame/test/net/fake_external_tab.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..06b961545591bf235fdb4dd084ec35efac586dd9 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.
« no previous file with comments | « chrome/browser/process_singleton.h ('k') | chrome_frame/test/net/fake_external_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698