| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/invalidation/ticl_profile_settings_provider.h" | 5 #include "chrome/browser/invalidation/ticl_profile_settings_provider.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
| 14 #include "components/invalidation/fake_invalidation_state_tracker.h" | 15 #include "components/invalidation/fake_invalidation_state_tracker.h" |
| 15 #include "components/invalidation/invalidation_state_tracker.h" | 16 #include "components/invalidation/invalidation_state_tracker.h" |
| 16 #include "components/invalidation/ticl_invalidation_service.h" | 17 #include "components/invalidation/ticl_invalidation_service.h" |
| 17 #include "components/invalidation/ticl_settings_provider.h" | 18 #include "components/invalidation/ticl_settings_provider.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 19 #include "google_apis/gaia/fake_identity_provider.h" | 20 #include "google_apis/gaia/fake_identity_provider.h" |
| 20 #include "google_apis/gaia/fake_oauth2_token_service.h" | 21 #include "google_apis/gaia/fake_oauth2_token_service.h" |
| 21 #include "google_apis/gaia/identity_provider.h" | 22 #include "google_apis/gaia/identity_provider.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return invalidation_service_->network_channel_type_; | 73 return invalidation_service_->network_channel_type_; |
| 73 } | 74 } |
| 74 | 75 |
| 75 TEST_F(TiclProfileSettingsProviderTest, ChannelSelectionTest) { | 76 TEST_F(TiclProfileSettingsProviderTest, ChannelSelectionTest) { |
| 76 // Default value should be GCM channel. | 77 // Default value should be GCM channel. |
| 77 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); | 78 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); |
| 78 PrefService* prefs = profile_.GetPrefs(); | 79 PrefService* prefs = profile_.GetPrefs(); |
| 79 | 80 |
| 80 // If GCM is enabled and invalidation channel setting is not set or set to | 81 // If GCM is enabled and invalidation channel setting is not set or set to |
| 81 // true then use GCM channel. | 82 // true then use GCM channel. |
| 82 prefs->SetBoolean(prefs::kGCMChannelEnabled, true); | 83 prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true); |
| 83 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); | 84 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); |
| 84 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); | 85 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); |
| 85 | 86 |
| 86 prefs->SetBoolean(prefs::kGCMChannelEnabled, true); | 87 prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true); |
| 87 prefs->ClearPref(prefs::kInvalidationServiceUseGCMChannel); | 88 prefs->ClearPref(prefs::kInvalidationServiceUseGCMChannel); |
| 88 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); | 89 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); |
| 89 | 90 |
| 90 prefs->ClearPref(prefs::kGCMChannelEnabled); | 91 prefs->ClearPref(gcm::prefs::kGCMChannelStatus); |
| 91 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); | 92 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); |
| 92 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); | 93 EXPECT_EQ(TiclInvalidationService::GCM_NETWORK_CHANNEL, GetNetworkChannel()); |
| 93 | 94 |
| 94 // If invalidation channel setting is set to false, fall back to push channel. | 95 // If invalidation channel setting is set to false, fall back to push channel. |
| 95 prefs->SetBoolean(prefs::kGCMChannelEnabled, true); | 96 prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, true); |
| 96 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, false); | 97 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, false); |
| 97 EXPECT_EQ(TiclInvalidationService::PUSH_CLIENT_CHANNEL, GetNetworkChannel()); | 98 EXPECT_EQ(TiclInvalidationService::PUSH_CLIENT_CHANNEL, GetNetworkChannel()); |
| 98 | 99 |
| 99 // If invalidation channel setting says use GCM but GCM is not enabled, fall | 100 // If invalidation channel setting says use GCM but GCM is not enabled, fall |
| 100 // back to push channel. | 101 // back to push channel. |
| 101 prefs->SetBoolean(prefs::kGCMChannelEnabled, false); | 102 prefs->SetBoolean(gcm::prefs::kGCMChannelStatus, false); |
| 102 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); | 103 prefs->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, true); |
| 103 EXPECT_EQ(TiclInvalidationService::PUSH_CLIENT_CHANNEL, GetNetworkChannel()); | 104 EXPECT_EQ(TiclInvalidationService::PUSH_CLIENT_CHANNEL, GetNetworkChannel()); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace invalidation | 107 } // namespace invalidation |
| OLD | NEW |