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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 455023003: Let SyncBackupManager keep backup data in memory until shutdown. Only persist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG, 948 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG,
949 hash); 949 hash);
950 EXPECT_TRUE(entry.good()); 950 EXPECT_TRUE(entry.good());
951 if (!entry.GetIsUnsynced()) 951 if (!entry.GetIsUnsynced())
952 return false; 952 return false;
953 entry.PutIsUnsynced(false); 953 entry.PutIsUnsynced(false);
954 return true; 954 return true;
955 } 955 }
956 956
957 virtual InternalComponentsFactory* GetFactory() { 957 virtual InternalComponentsFactory* GetFactory() {
958 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_IN_MEMORY); 958 return new TestInternalComponentsFactory(
959 GetSwitches(), InternalComponentsFactory::STORAGE_IN_MEMORY,
960 InternalComponentsFactory::STORAGE_ON_DISK);
959 } 961 }
960 962
961 // Returns true if we are currently encrypting all sync data. May 963 // Returns true if we are currently encrypting all sync data. May
962 // be called on any thread. 964 // be called on any thread.
963 bool EncryptEverythingEnabledForTest() { 965 bool EncryptEverythingEnabledForTest() {
964 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled(); 966 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled();
965 } 967 }
966 968
967 // Gets the set of encrypted types from the cryptographer 969 // Gets the set of encrypted types from the cryptographer
968 // Note: opens a transaction. May be called from any thread. 970 // Note: opens a transaction. May be called from any thread.
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 2409
2408 MOCK_METHOD1(Start, void(SyncScheduler::Mode)); 2410 MOCK_METHOD1(Start, void(SyncScheduler::Mode));
2409 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&)); 2411 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&));
2410 }; 2412 };
2411 2413
2412 class ComponentsFactory : public TestInternalComponentsFactory { 2414 class ComponentsFactory : public TestInternalComponentsFactory {
2413 public: 2415 public:
2414 ComponentsFactory(const Switches& switches, 2416 ComponentsFactory(const Switches& switches,
2415 SyncScheduler* scheduler_to_use, 2417 SyncScheduler* scheduler_to_use,
2416 sessions::SyncSessionContext** session_context) 2418 sessions::SyncSessionContext** session_context)
2417 : TestInternalComponentsFactory(switches, syncer::STORAGE_IN_MEMORY), 2419 : TestInternalComponentsFactory(
2420 switches, InternalComponentsFactory::STORAGE_IN_MEMORY,
2421 InternalComponentsFactory::STORAGE_ON_DISK),
2418 scheduler_to_use_(scheduler_to_use), 2422 scheduler_to_use_(scheduler_to_use),
2419 session_context_(session_context) {} 2423 session_context_(session_context) {}
2420 virtual ~ComponentsFactory() {} 2424 virtual ~ComponentsFactory() {}
2421 2425
2422 virtual scoped_ptr<SyncScheduler> BuildScheduler( 2426 virtual scoped_ptr<SyncScheduler> BuildScheduler(
2423 const std::string& name, 2427 const std::string& name,
2424 sessions::SyncSessionContext* context, 2428 sessions::SyncSessionContext* context,
2425 CancelationSignal* stop_handle) OVERRIDE { 2429 CancelationSignal* stop_handle) OVERRIDE {
2426 *session_context_ = context; 2430 *session_context_ = context;
2427 return scheduler_to_use_.Pass(); 2431 return scheduler_to_use_.Pass();
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 // do so it should fail initialization. This test verifies this behavior. 3178 // do so it should fail initialization. This test verifies this behavior.
3175 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides 3179 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides
3176 // InternalComponentsFactory to return DirectoryBackingStore that always fails 3180 // InternalComponentsFactory to return DirectoryBackingStore that always fails
3177 // to load. 3181 // to load.
3178 class SyncManagerInitInvalidStorageTest : public SyncManagerTest { 3182 class SyncManagerInitInvalidStorageTest : public SyncManagerTest {
3179 public: 3183 public:
3180 SyncManagerInitInvalidStorageTest() { 3184 SyncManagerInitInvalidStorageTest() {
3181 } 3185 }
3182 3186
3183 virtual InternalComponentsFactory* GetFactory() OVERRIDE { 3187 virtual InternalComponentsFactory* GetFactory() OVERRIDE {
3184 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_INVALID); 3188 return new TestInternalComponentsFactory(
3189 GetSwitches(), InternalComponentsFactory::STORAGE_INVALID,
3190 InternalComponentsFactory::STORAGE_ON_DISK);
3185 } 3191 }
3186 }; 3192 };
3187 3193
3188 // SyncManagerInitInvalidStorageTest::GetFactory will return 3194 // SyncManagerInitInvalidStorageTest::GetFactory will return
3189 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3195 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3190 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3196 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3191 // task is to ensure that SyncManagerImpl reported initialization failure in 3197 // task is to ensure that SyncManagerImpl reported initialization failure in
3192 // OnInitializationComplete callback. 3198 // OnInitializationComplete callback.
3193 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3199 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3194 EXPECT_FALSE(initialization_succeeded_); 3200 EXPECT_FALSE(initialization_succeeded_);
3195 } 3201 }
3196 3202
3197 } // namespace syncer 3203 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698