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

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: ToT 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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG, 944 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG,
945 hash); 945 hash);
946 EXPECT_TRUE(entry.good()); 946 EXPECT_TRUE(entry.good());
947 if (!entry.GetIsUnsynced()) 947 if (!entry.GetIsUnsynced())
948 return false; 948 return false;
949 entry.PutIsUnsynced(false); 949 entry.PutIsUnsynced(false);
950 return true; 950 return true;
951 } 951 }
952 952
953 virtual InternalComponentsFactory* GetFactory() { 953 virtual InternalComponentsFactory* GetFactory() {
954 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_IN_MEMORY); 954 return new TestInternalComponentsFactory(
955 GetSwitches(), InternalComponentsFactory::STORAGE_IN_MEMORY,
956 InternalComponentsFactory::STORAGE_ON_DISK);
955 } 957 }
956 958
957 // Returns true if we are currently encrypting all sync data. May 959 // Returns true if we are currently encrypting all sync data. May
958 // be called on any thread. 960 // be called on any thread.
959 bool EncryptEverythingEnabledForTest() { 961 bool EncryptEverythingEnabledForTest() {
960 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled(); 962 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled();
961 } 963 }
962 964
963 // Gets the set of encrypted types from the cryptographer 965 // Gets the set of encrypted types from the cryptographer
964 // Note: opens a transaction. May be called from any thread. 966 // Note: opens a transaction. May be called from any thread.
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 2405
2404 MOCK_METHOD1(Start, void(SyncScheduler::Mode)); 2406 MOCK_METHOD1(Start, void(SyncScheduler::Mode));
2405 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&)); 2407 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&));
2406 }; 2408 };
2407 2409
2408 class ComponentsFactory : public TestInternalComponentsFactory { 2410 class ComponentsFactory : public TestInternalComponentsFactory {
2409 public: 2411 public:
2410 ComponentsFactory(const Switches& switches, 2412 ComponentsFactory(const Switches& switches,
2411 SyncScheduler* scheduler_to_use, 2413 SyncScheduler* scheduler_to_use,
2412 sessions::SyncSessionContext** session_context) 2414 sessions::SyncSessionContext** session_context)
2413 : TestInternalComponentsFactory(switches, syncer::STORAGE_IN_MEMORY), 2415 : TestInternalComponentsFactory(
2416 switches, InternalComponentsFactory::STORAGE_IN_MEMORY,
2417 InternalComponentsFactory::STORAGE_ON_DISK),
2414 scheduler_to_use_(scheduler_to_use), 2418 scheduler_to_use_(scheduler_to_use),
2415 session_context_(session_context) {} 2419 session_context_(session_context) {}
2416 virtual ~ComponentsFactory() {} 2420 virtual ~ComponentsFactory() {}
2417 2421
2418 virtual scoped_ptr<SyncScheduler> BuildScheduler( 2422 virtual scoped_ptr<SyncScheduler> BuildScheduler(
2419 const std::string& name, 2423 const std::string& name,
2420 sessions::SyncSessionContext* context, 2424 sessions::SyncSessionContext* context,
2421 CancelationSignal* stop_handle) OVERRIDE { 2425 CancelationSignal* stop_handle) OVERRIDE {
2422 *session_context_ = context; 2426 *session_context_ = context;
2423 return scheduler_to_use_.Pass(); 2427 return scheduler_to_use_.Pass();
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 // do so it should fail initialization. This test verifies this behavior. 3174 // do so it should fail initialization. This test verifies this behavior.
3171 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides 3175 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides
3172 // InternalComponentsFactory to return DirectoryBackingStore that always fails 3176 // InternalComponentsFactory to return DirectoryBackingStore that always fails
3173 // to load. 3177 // to load.
3174 class SyncManagerInitInvalidStorageTest : public SyncManagerTest { 3178 class SyncManagerInitInvalidStorageTest : public SyncManagerTest {
3175 public: 3179 public:
3176 SyncManagerInitInvalidStorageTest() { 3180 SyncManagerInitInvalidStorageTest() {
3177 } 3181 }
3178 3182
3179 virtual InternalComponentsFactory* GetFactory() OVERRIDE { 3183 virtual InternalComponentsFactory* GetFactory() OVERRIDE {
3180 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_INVALID); 3184 return new TestInternalComponentsFactory(
3185 GetSwitches(), InternalComponentsFactory::STORAGE_INVALID,
3186 InternalComponentsFactory::STORAGE_ON_DISK);
3181 } 3187 }
3182 }; 3188 };
3183 3189
3184 // SyncManagerInitInvalidStorageTest::GetFactory will return 3190 // SyncManagerInitInvalidStorageTest::GetFactory will return
3185 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3191 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3186 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3192 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3187 // task is to ensure that SyncManagerImpl reported initialization failure in 3193 // task is to ensure that SyncManagerImpl reported initialization failure in
3188 // OnInitializationComplete callback. 3194 // OnInitializationComplete callback.
3189 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3195 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3190 EXPECT_FALSE(initialization_succeeded_); 3196 EXPECT_FALSE(initialization_succeeded_);
3191 } 3197 }
3192 3198
3193 } // namespace syncer 3199 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698