OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/glue/sync_backend_host.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "chrome/browser/invalidation/invalidator_storage.h" |
14 #include "chrome/browser/prefs/pref_service_syncable.h" | 15 #include "chrome/browser/prefs/pref_service_syncable.h" |
15 #include "chrome/browser/sync/glue/device_info.h" | 16 #include "chrome/browser/sync/glue/device_info.h" |
16 #include "chrome/browser/sync/glue/synced_device_tracker.h" | 17 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
17 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | |
18 #include "chrome/browser/sync/sync_prefs.h" | 18 #include "chrome/browser/sync/sync_prefs.h" |
19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "components/user_prefs/pref_registry_syncable.h" | 21 #include "components/user_prefs/pref_registry_syncable.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
24 #include "google/cacheinvalidation/include/types.h" | 24 #include "google/cacheinvalidation/include/types.h" |
25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
26 #include "net/url_request/test_url_fetcher_factory.h" | 26 #include "net/url_request/test_url_fetcher_factory.h" |
27 #include "sync/internal_api/public/base/model_type.h" | 27 #include "sync/internal_api/public/base/model_type.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 io_thread_(BrowserThread::IO), | 139 io_thread_(BrowserThread::IO), |
140 fake_manager_(NULL) {} | 140 fake_manager_(NULL) {} |
141 | 141 |
142 virtual ~SyncBackendHostTest() {} | 142 virtual ~SyncBackendHostTest() {} |
143 | 143 |
144 virtual void SetUp() OVERRIDE { | 144 virtual void SetUp() OVERRIDE { |
145 io_thread_.StartIOThread(); | 145 io_thread_.StartIOThread(); |
146 profile_.reset(new TestingProfile()); | 146 profile_.reset(new TestingProfile()); |
147 profile_->CreateRequestContext(); | 147 profile_->CreateRequestContext(); |
148 sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); | 148 sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); |
149 invalidator_storage_.reset(new InvalidatorStorage( | 149 invalidator_storage_.reset(new invalidation::InvalidatorStorage( |
150 profile_->GetPrefs())); | 150 profile_->GetPrefs())); |
151 backend_.reset(new SyncBackendHost( | 151 backend_.reset(new SyncBackendHost( |
152 profile_->GetDebugName(), | 152 profile_->GetDebugName(), |
153 profile_.get(), | 153 profile_.get(), |
154 sync_prefs_->AsWeakPtr(), | 154 sync_prefs_->AsWeakPtr(), |
155 invalidator_storage_->AsWeakPtr())); | 155 invalidator_storage_->AsWeakPtr())); |
156 credentials_.email = "user@example.com"; | 156 credentials_.email = "user@example.com"; |
157 credentials_.sync_token = "sync_token"; | 157 credentials_.sync_token = "sync_token"; |
158 | 158 |
159 // These types are always implicitly enabled. | 159 // These types are always implicitly enabled. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 } | 256 } |
257 | 257 |
258 MessageLoop ui_loop_; | 258 MessageLoop ui_loop_; |
259 content::TestBrowserThread ui_thread_; | 259 content::TestBrowserThread ui_thread_; |
260 content::TestBrowserThread io_thread_; | 260 content::TestBrowserThread io_thread_; |
261 StrictMock<MockSyncFrontend> mock_frontend_; | 261 StrictMock<MockSyncFrontend> mock_frontend_; |
262 syncer::SyncCredentials credentials_; | 262 syncer::SyncCredentials credentials_; |
263 syncer::TestUnrecoverableErrorHandler handler_; | 263 syncer::TestUnrecoverableErrorHandler handler_; |
264 scoped_ptr<TestingProfile> profile_; | 264 scoped_ptr<TestingProfile> profile_; |
265 scoped_ptr<SyncPrefs> sync_prefs_; | 265 scoped_ptr<SyncPrefs> sync_prefs_; |
266 scoped_ptr<InvalidatorStorage> invalidator_storage_; | 266 scoped_ptr<invalidation::InvalidatorStorage> invalidator_storage_; |
267 scoped_ptr<SyncBackendHost> backend_; | 267 scoped_ptr<SyncBackendHost> backend_; |
268 FakeSyncManager* fake_manager_; | 268 FakeSyncManager* fake_manager_; |
269 FakeSyncManagerFactory fake_manager_factory_; | 269 FakeSyncManagerFactory fake_manager_factory_; |
270 syncer::ModelTypeSet enabled_types_; | 270 syncer::ModelTypeSet enabled_types_; |
271 }; | 271 }; |
272 | 272 |
273 // Test basic initialization with no initial types (first time initialization). | 273 // Test basic initialization with no initial types (first time initialization). |
274 // Only the nigori should be configured. | 274 // Only the nigori should be configured. |
275 TEST_F(SyncBackendHostTest, InitShutdown) { | 275 TEST_F(SyncBackendHostTest, InitShutdown) { |
276 InitializeBackend(true); | 276 InitializeBackend(true); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 TEST_F(SyncBackendHostTest, DownloadControlTypesRestart) { | 759 TEST_F(SyncBackendHostTest, DownloadControlTypesRestart) { |
760 sync_prefs_->SetSyncSetupCompleted(); | 760 sync_prefs_->SetSyncSetupCompleted(); |
761 InitializeBackend(true); | 761 InitializeBackend(true); |
762 EXPECT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, | 762 EXPECT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, |
763 fake_manager_->GetAndResetConfigureReason()); | 763 fake_manager_->GetAndResetConfigureReason()); |
764 } | 764 } |
765 | 765 |
766 } // namespace | 766 } // namespace |
767 | 767 |
768 } // namespace browser_sync | 768 } // namespace browser_sync |
OLD | NEW |