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

Unified Diff: components/invalidation/impl/ticl_profile_settings_provider_unittest.cc

Issue 1418573005: [invalidation] Componentize TiclProfileSettingsProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Maintain pref registration on Android Created 5 years, 2 months 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 | « components/invalidation/impl/ticl_profile_settings_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/invalidation/impl/ticl_profile_settings_provider_unittest.cc
diff --git a/chrome/browser/invalidation/ticl_profile_settings_provider_unittest.cc b/components/invalidation/impl/ticl_profile_settings_provider_unittest.cc
similarity index 64%
rename from chrome/browser/invalidation/ticl_profile_settings_provider_unittest.cc
rename to components/invalidation/impl/ticl_profile_settings_provider_unittest.cc
index baf1d0fcb9359f657c93683e3f89ad9d93950859..1a454c3b506e6b970931cec00262629983e88c28 100644
--- a/chrome/browser/invalidation/ticl_profile_settings_provider_unittest.cc
+++ b/components/invalidation/impl/ticl_profile_settings_provider_unittest.cc
@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/invalidation/ticl_profile_settings_provider.h"
+#include "components/invalidation/impl/ticl_profile_settings_provider.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/services/gcm/gcm_profile_service.h"
-#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/test/base/testing_profile.h"
+#include "components/gcm_driver/fake_gcm_driver.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/invalidation/impl/fake_invalidation_state_tracker.h"
+#include "components/invalidation/impl/invalidation_prefs.h"
#include "components/invalidation/impl/invalidation_state_tracker.h"
+#include "components/invalidation/impl/profile_invalidation_provider.h"
#include "components/invalidation/impl/ticl_invalidation_service.h"
#include "components/invalidation/impl/ticl_settings_provider.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "components/pref_registry/testing_pref_service_syncable.h"
#include "google_apis/gaia/fake_identity_provider.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
#include "google_apis/gaia/identity_provider.h"
#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace invalidation {
@@ -36,8 +36,10 @@ class TiclProfileSettingsProviderTest : public testing::Test {
TiclInvalidationService::InvalidationNetworkChannel GetNetworkChannel();
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
+ base::MessageLoop message_loop_;
+ scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
+ gcm::FakeGCMDriver gcm_driver_;
+ user_prefs::TestingPrefServiceSyncable pref_service_;
FakeOAuth2TokenService token_service_;
scoped_ptr<TiclInvalidationService> invalidation_service_;
@@ -46,20 +48,23 @@ class TiclProfileSettingsProviderTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(TiclProfileSettingsProviderTest);
};
-TiclProfileSettingsProviderTest::TiclProfileSettingsProviderTest() {
-}
+TiclProfileSettingsProviderTest::TiclProfileSettingsProviderTest() {}
-TiclProfileSettingsProviderTest::~TiclProfileSettingsProviderTest() {
-}
+TiclProfileSettingsProviderTest::~TiclProfileSettingsProviderTest() {}
void TiclProfileSettingsProviderTest::SetUp() {
+ gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(pref_service_.registry());
+ ProfileInvalidationProvider::RegisterProfilePrefs(pref_service_.registry());
+
+ request_context_getter_ =
+ new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get());
+
invalidation_service_.reset(new TiclInvalidationService(
"TestUserAgent",
scoped_ptr<IdentityProvider>(new FakeIdentityProvider(&token_service_)),
scoped_ptr<TiclSettingsProvider>(
- new TiclProfileSettingsProvider(&profile_)),
- gcm::GCMProfileServiceFactory::GetForProfile(&profile_)->driver(),
- profile_.GetRequestContext()));
+ new TiclProfileSettingsProvider(&pref_service_)),
+ &gcm_driver_, request_context_getter_));
invalidation_service_->Init(scoped_ptr<syncer::InvalidationStateTracker>(
new syncer::FakeInvalidationStateTracker));
}
@@ -76,31 +81,30 @@ TiclProfileSettingsProviderTest::GetNetworkChannel() {
TEST_F(TiclProfileSettingsProviderTest, ChannelSelectionTest) {
// Default value should be GCM channel.
EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel());
- PrefService* prefs = profile_.GetPrefs();
// If GCM is enabled and invalidation channel setting is not set or set to
// true then use GCM channel.
- prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true);
- prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
+ pref_service_.SetBoolean(gcm::prefs::kGCMChannelStatus, true);
+ pref_service_.SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel());
- prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true);
- prefs->ClearPref(prefs::kInvalidationServiceUseGCMChannel);
+ pref_service_.SetBoolean(gcm::prefs::kGCMChannelStatus, true);
+ pref_service_.ClearPref(prefs::kInvalidationServiceUseGCMChannel);
EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel());
- prefs->ClearPref(gcm::prefs::kGCMChannelStatus);
- prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
+ pref_service_.ClearPref(gcm::prefs::kGCMChannelStatus);
+ pref_service_.SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel());
// If invalidation channel setting says use GCM but GCM is not enabled, do not
// fall back to push channel.
- prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, false);
- prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
+ pref_service_.SetBoolean(gcm::prefs::kGCMChannelStatus, false);
+ pref_service_.SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true);
EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel());
// If invalidation channel setting is set to false, fall back to push channel.
- prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true);
- prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, false);
+ pref_service_.SetBoolean(gcm::prefs::kGCMChannelStatus, true);
+ pref_service_.SetBoolean(prefs::kInvalidationServiceUseGCMChannel, false);
EXPECT_EQ(TiclInvalidationService::PUSH_CLIENT_CHANNEL, GetNetworkChannel());
}
« no previous file with comments | « components/invalidation/impl/ticl_profile_settings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698