OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_invalidation_service.h" | 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 8 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
9 #include "chrome/browser/invalidation/invalidation_service_test_template.h" | 9 #include "chrome/browser/invalidation/invalidation_service_test_template.h" |
10 #include "chrome/browser/invalidation/invalidator_storage.h" | 10 #include "chrome/browser/invalidation/invalidator_storage.h" |
| 11 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 12 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 13 #include "chrome/browser/services/gcm/gcm_service.h" |
11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
12 #include "chrome/browser/signin/fake_signin_manager.h" | 15 #include "chrome/browser/signin/fake_signin_manager.h" |
13 #include "chrome/browser/signin/profile_identity_provider.h" | 16 #include "chrome/browser/signin/profile_identity_provider.h" |
14 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
15 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
16 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
17 #include "components/signin/core/browser/signin_manager.h" | 20 #include "components/signin/core/browser/signin_manager.h" |
18 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
20 #include "sync/notifier/fake_invalidation_handler.h" | 23 #include "sync/notifier/fake_invalidation_handler.h" |
(...skipping 18 matching lines...) Expand all Loading... |
39 } | 42 } |
40 | 43 |
41 void CreateUninitializedInvalidationService() { | 44 void CreateUninitializedInvalidationService() { |
42 profile_.reset(new TestingProfile()); | 45 profile_.reset(new TestingProfile()); |
43 token_service_.reset(new FakeProfileOAuth2TokenService); | 46 token_service_.reset(new FakeProfileOAuth2TokenService); |
44 invalidation_service_.reset(new TiclInvalidationService( | 47 invalidation_service_.reset(new TiclInvalidationService( |
45 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | 48 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( |
46 SigninManagerFactory::GetForProfile(profile_.get()), | 49 SigninManagerFactory::GetForProfile(profile_.get()), |
47 token_service_.get(), | 50 token_service_.get(), |
48 NULL)), | 51 NULL)), |
| 52 gcm::GCMProfileServiceFactory::GetForProfile(profile_.get()), |
49 profile_->GetRequestContext(), | 53 profile_->GetRequestContext(), |
50 profile_.get())); | 54 profile_.get())); |
51 } | 55 } |
52 | 56 |
53 void InitializeInvalidationService() { | 57 void InitializeInvalidationService() { |
54 fake_invalidator_ = new syncer::FakeInvalidator(); | 58 fake_invalidator_ = new syncer::FakeInvalidator(); |
55 invalidation_service_->InitForTest( | 59 invalidation_service_->InitForTest( |
56 scoped_ptr<syncer::InvalidationStateTracker>( | 60 scoped_ptr<syncer::InvalidationStateTracker>( |
57 new InvalidatorStorage(profile_->GetPrefs())), | 61 new InvalidatorStorage(profile_->GetPrefs())), |
58 fake_invalidator_); | 62 fake_invalidator_); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 FakeSigninManagerBase::Build); | 100 FakeSigninManagerBase::Build); |
97 profile_ = builder.Build(); | 101 profile_ = builder.Build(); |
98 fake_signin_manager_ = static_cast<SigninManagerBase*>( | 102 fake_signin_manager_ = static_cast<SigninManagerBase*>( |
99 SigninManagerFactory::GetForProfile(profile_.get())); | 103 SigninManagerFactory::GetForProfile(profile_.get())); |
100 token_service_.reset(new FakeProfileOAuth2TokenService); | 104 token_service_.reset(new FakeProfileOAuth2TokenService); |
101 | 105 |
102 scoped_ptr<IdentityProvider> identity_provider(new ProfileIdentityProvider( | 106 scoped_ptr<IdentityProvider> identity_provider(new ProfileIdentityProvider( |
103 fake_signin_manager_, token_service_.get(), NULL)); | 107 fake_signin_manager_, token_service_.get(), NULL)); |
104 invalidation_service_.reset(new TiclInvalidationService( | 108 invalidation_service_.reset(new TiclInvalidationService( |
105 identity_provider.Pass(), | 109 identity_provider.Pass(), |
| 110 gcm::GCMProfileServiceFactory::GetForProfile(profile_.get()), |
106 profile_->GetRequestContext(), | 111 profile_->GetRequestContext(), |
107 profile_.get())); | 112 profile_.get())); |
108 invalidation_service_->Init(scoped_ptr<syncer::InvalidationStateTracker>( | 113 invalidation_service_->Init(scoped_ptr<syncer::InvalidationStateTracker>( |
109 new InvalidatorStorage(profile_->GetPrefs()))); | 114 new InvalidatorStorage(profile_->GetPrefs()))); |
110 } | 115 } |
111 | 116 |
112 virtual void TearDown() OVERRIDE { | 117 virtual void TearDown() OVERRIDE { |
113 invalidation_service_->Shutdown(); | 118 invalidation_service_->Shutdown(); |
114 } | 119 } |
115 | 120 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_FALSE(fake_container.called_); | 205 EXPECT_FALSE(fake_container.called_); |
201 | 206 |
202 delegate->InitializeInvalidationService(); | 207 delegate->InitializeInvalidationService(); |
203 | 208 |
204 invalidator->RequestDetailedStatus( | 209 invalidator->RequestDetailedStatus( |
205 base::Bind(&internal::FakeCallbackContainer::FakeCallback, | 210 base::Bind(&internal::FakeCallbackContainer::FakeCallback, |
206 fake_container.weak_ptr_factory_.GetWeakPtr())); | 211 fake_container.weak_ptr_factory_.GetWeakPtr())); |
207 EXPECT_TRUE(fake_container.called_); | 212 EXPECT_TRUE(fake_container.called_); |
208 } | 213 } |
209 } // namespace invalidation | 214 } // namespace invalidation |
OLD | NEW |