summaryrefslogtreecommitdiffstats
path: root/google_apis/gcm
diff options
context:
space:
mode:
authorfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-11 21:02:15 +0000
committerfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-11 21:02:15 +0000
commitfdeaf9736e096505ba21b2a2948d410cedd09770 (patch)
treee20b96595cffa2a7a93b578fe1c116c302e4cbef /google_apis/gcm
parent96c015c7a682576bdc54892d662e2a29c484be8d (diff)
downloadchromium_src-fdeaf9736e096505ba21b2a2948d410cedd09770.zip
chromium_src-fdeaf9736e096505ba21b2a2948d410cedd09770.tar.gz
chromium_src-fdeaf9736e096505ba21b2a2948d410cedd09770.tar.bz2
Removing the mock-keychain related bool from GCMStore constructor
Removing the first parameter of GCMStore constructor. Adding BuildGCMStore and SetUpForTesting to GCMInternalsBuilder. Moving GCMInternalsBuilder to its own files in gcm/engine/ BUG=343360 Review URL: https://codereview.chromium.org/232113004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gcm')
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.cc5
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.h3
-rw-r--r--google_apis/gcm/engine/gcm_store_impl_unittest.cc13
-rw-r--r--google_apis/gcm/engine/mcs_client_unittest.cc21
-rw-r--r--google_apis/gcm/gcm_client_impl.cc2
-rw-r--r--google_apis/gcm/gcm_client_impl_unittest.cc13
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc3
7 files changed, 35 insertions, 25 deletions
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index 2738c43..5393fd1 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -698,16 +698,11 @@ bool GCMStoreImpl::Backend::LoadGServicesSettings(
}
GCMStoreImpl::GCMStoreImpl(
- bool use_mock_keychain,
const base::FilePath& path,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
: backend_(new Backend(path, base::MessageLoopProxy::current())),
blocking_task_runner_(blocking_task_runner),
weak_ptr_factory_(this) {
-// On OSX, prevent the Keychain permissions popup during unit tests.
-#if defined(OS_MACOSX)
- OSCrypt::UseMockKeychain(use_mock_keychain);
-#endif
}
GCMStoreImpl::~GCMStoreImpl() {}
diff --git a/google_apis/gcm/engine/gcm_store_impl.h b/google_apis/gcm/engine/gcm_store_impl.h
index ebf6c57..e46c503 100644
--- a/google_apis/gcm/engine/gcm_store_impl.h
+++ b/google_apis/gcm/engine/gcm_store_impl.h
@@ -23,8 +23,7 @@ namespace gcm {
// all callbacks to the thread on which the GCMStoreImpl is created.
class GCM_EXPORT GCMStoreImpl : public GCMStore {
public:
- GCMStoreImpl(bool use_mock_keychain,
- const base::FilePath& path,
+ GCMStoreImpl(const base::FilePath& path,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
virtual ~GCMStoreImpl();
diff --git a/google_apis/gcm/engine/gcm_store_impl_unittest.cc b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
index a4010e2..a587bc1198 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -8,12 +8,14 @@
#include <vector>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
@@ -43,6 +45,8 @@ class GCMStoreImplTest : public testing::Test {
GCMStoreImplTest();
virtual ~GCMStoreImplTest();
+ virtual void SetUp() OVERRIDE;
+
scoped_ptr<GCMStore> BuildGCMStore();
std::string GetNextPersistentId();
@@ -70,9 +74,16 @@ GCMStoreImplTest::GCMStoreImplTest()
GCMStoreImplTest::~GCMStoreImplTest() {}
+void GCMStoreImplTest::SetUp() {
+ testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
+}
+
scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
return scoped_ptr<GCMStore>(new GCMStoreImpl(
- true,
temp_directory_.path(),
message_loop_.message_loop_proxy()));
}
diff --git a/google_apis/gcm/engine/mcs_client_unittest.cc b/google_apis/gcm/engine/mcs_client_unittest.cc
index 5983ddd..b3e2f0d 100644
--- a/google_apis/gcm/engine/mcs_client_unittest.cc
+++ b/google_apis/gcm/engine/mcs_client_unittest.cc
@@ -4,12 +4,13 @@
#include "google_apis/gcm/engine/mcs_client.h"
+#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
-#include "components/os_crypt/os_crypt.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
#include "google_apis/gcm/engine/fake_connection_handler.h"
@@ -84,6 +85,8 @@ class MCSClientTest : public testing::Test {
MCSClientTest();
virtual ~MCSClientTest();
+ virtual void SetUp() OVERRIDE;
+
void BuildMCSClient();
void InitializeClient();
void StoreCredentials();
@@ -144,20 +147,22 @@ MCSClientTest::MCSClientTest()
EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
run_loop_.reset(new base::RunLoop());
- // On OSX, prevent the Keychain permissions popup during unit tests.
-#if defined(OS_MACOSX)
- OSCrypt::UseMockKeychain(true);
-#endif
-
// Advance the clock to a non-zero time.
clock_.Advance(base::TimeDelta::FromSeconds(1));
}
MCSClientTest::~MCSClientTest() {}
+void MCSClientTest::SetUp() {
+ testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
+}
+
void MCSClientTest::BuildMCSClient() {
- gcm_store_.reset(new GCMStoreImpl(true,
- temp_directory_.path(),
+ gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
message_loop_.message_loop_proxy()));
mcs_client_.reset(new TestMCSClient(&clock_,
&connection_factory_,
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index d7d87e0..80c58d8 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -186,7 +186,7 @@ void GCMClientImpl::Initialize(
chrome_build_proto_.CopyFrom(chrome_build_proto);
account_ids_ = account_ids;
- gcm_store_.reset(new GCMStoreImpl(false, path, blocking_task_runner));
+ gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner));
delegate_ = delegate;
diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc
index 229feab..709418c 100644
--- a/google_apis/gcm/gcm_client_impl_unittest.cc
+++ b/google_apis/gcm/gcm_client_impl_unittest.cc
@@ -4,11 +4,12 @@
#include "google_apis/gcm/gcm_client_impl.h"
+#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/simple_test_clock.h"
-#include "components/os_crypt/os_crypt.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
@@ -267,6 +268,11 @@ GCMClientImplTest::GCMClientImplTest()
GCMClientImplTest::~GCMClientImplTest() {}
void GCMClientImplTest::SetUp() {
+ testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
ASSERT_TRUE(temp_directory_.CreateUniqueTempDir());
run_loop_.reset(new base::RunLoop);
BuildGCMClient();
@@ -362,11 +368,6 @@ void GCMClientImplTest::InitializeGCMClient() {
url_request_context_getter_,
this);
-#if defined(OS_MACOSX)
- // On OSX, prevent the Keychain permissions popup during unit tests.
- OSCrypt::UseMockKeychain(true); // Must be after Initialize.
-#endif
-
// Start loading and check-in.
gcm_client_->Load();
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 3f48762..038f3af 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -301,8 +301,7 @@ void MCSProbe::Start() {
network_session_,
&net_log_));
gcm_store_.reset(
- new GCMStoreImpl(true,
- gcm_store_path_,
+ new GCMStoreImpl(gcm_store_path_,
file_thread_.message_loop_proxy()));
mcs_client_.reset(new MCSClient("probe",
&clock_,