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

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

Issue 477813002: Revert of 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
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | sync/internal_api/sync_rollback_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 args.invalidator_client_id = "fake_invalidator_client_id"; 827 args.invalidator_client_id = "fake_invalidator_client_id";
828 args.internal_components_factory.reset(GetFactory()); 828 args.internal_components_factory.reset(GetFactory());
829 args.encryptor = &encryptor_; 829 args.encryptor = &encryptor_;
830 args.unrecoverable_error_handler.reset(new TestUnrecoverableErrorHandler); 830 args.unrecoverable_error_handler.reset(new TestUnrecoverableErrorHandler);
831 args.cancelation_signal = &cancelation_signal_; 831 args.cancelation_signal = &cancelation_signal_;
832 sync_manager_.Init(&args); 832 sync_manager_.Init(&args);
833 833
834 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); 834 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_);
835 835
836 EXPECT_TRUE(js_backend_.IsInitialized()); 836 EXPECT_TRUE(js_backend_.IsInitialized());
837 EXPECT_EQ(InternalComponentsFactory::STORAGE_ON_DISK,
838 storage_used_);
839 837
840 if (initialization_succeeded_) { 838 if (initialization_succeeded_) {
841 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 839 for (ModelSafeRoutingInfo::iterator i = routing_info.begin();
842 i != routing_info.end(); ++i) { 840 i != routing_info.end(); ++i) {
843 type_roots_[i->first] = MakeServerNodeForType( 841 type_roots_[i->first] = MakeServerNodeForType(
844 sync_manager_.GetUserShare(), i->first); 842 sync_manager_.GetUserShare(), i->first);
845 } 843 }
846 } 844 }
847 845
848 PumpLoop(); 846 PumpLoop();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG, 944 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG,
947 hash); 945 hash);
948 EXPECT_TRUE(entry.good()); 946 EXPECT_TRUE(entry.good());
949 if (!entry.GetIsUnsynced()) 947 if (!entry.GetIsUnsynced())
950 return false; 948 return false;
951 entry.PutIsUnsynced(false); 949 entry.PutIsUnsynced(false);
952 return true; 950 return true;
953 } 951 }
954 952
955 virtual InternalComponentsFactory* GetFactory() { 953 virtual InternalComponentsFactory* GetFactory() {
956 return new TestInternalComponentsFactory( 954 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_IN_MEMORY);
957 GetSwitches(), InternalComponentsFactory::STORAGE_IN_MEMORY,
958 &storage_used_);
959 } 955 }
960 956
961 // Returns true if we are currently encrypting all sync data. May 957 // Returns true if we are currently encrypting all sync data. May
962 // be called on any thread. 958 // be called on any thread.
963 bool EncryptEverythingEnabledForTest() { 959 bool EncryptEverythingEnabledForTest() {
964 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled(); 960 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled();
965 } 961 }
966 962
967 // Gets the set of encrypted types from the cryptographer 963 // Gets the set of encrypted types from the cryptographer
968 // Note: opens a transaction. May be called from any thread. 964 // Note: opens a transaction. May be called from any thread.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1004
1009 protected: 1005 protected:
1010 FakeEncryptor encryptor_; 1006 FakeEncryptor encryptor_;
1011 SyncManagerImpl sync_manager_; 1007 SyncManagerImpl sync_manager_;
1012 CancelationSignal cancelation_signal_; 1008 CancelationSignal cancelation_signal_;
1013 WeakHandle<JsBackend> js_backend_; 1009 WeakHandle<JsBackend> js_backend_;
1014 bool initialization_succeeded_; 1010 bool initialization_succeeded_;
1015 StrictMock<SyncManagerObserverMock> manager_observer_; 1011 StrictMock<SyncManagerObserverMock> manager_observer_;
1016 StrictMock<SyncEncryptionHandlerObserverMock> encryption_observer_; 1012 StrictMock<SyncEncryptionHandlerObserverMock> encryption_observer_;
1017 InternalComponentsFactory::Switches switches_; 1013 InternalComponentsFactory::Switches switches_;
1018 InternalComponentsFactory::StorageOption storage_used_;
1019 }; 1014 };
1020 1015
1021 TEST_F(SyncManagerTest, GetAllNodesForTypeTest) { 1016 TEST_F(SyncManagerTest, GetAllNodesForTypeTest) {
1022 ModelSafeRoutingInfo routing_info; 1017 ModelSafeRoutingInfo routing_info;
1023 GetModelSafeRoutingInfo(&routing_info); 1018 GetModelSafeRoutingInfo(&routing_info);
1024 sync_manager_.StartSyncingNormally(routing_info); 1019 sync_manager_.StartSyncingNormally(routing_info);
1025 1020
1026 scoped_ptr<base::ListValue> node_list( 1021 scoped_ptr<base::ListValue> node_list(
1027 sync_manager_.GetAllNodesForType(syncer::PREFERENCES)); 1022 sync_manager_.GetAllNodesForType(syncer::PREFERENCES));
1028 1023
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 2403
2409 MOCK_METHOD1(Start, void(SyncScheduler::Mode)); 2404 MOCK_METHOD1(Start, void(SyncScheduler::Mode));
2410 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&)); 2405 MOCK_METHOD1(ScheduleConfiguration, void(const ConfigurationParams&));
2411 }; 2406 };
2412 2407
2413 class ComponentsFactory : public TestInternalComponentsFactory { 2408 class ComponentsFactory : public TestInternalComponentsFactory {
2414 public: 2409 public:
2415 ComponentsFactory(const Switches& switches, 2410 ComponentsFactory(const Switches& switches,
2416 SyncScheduler* scheduler_to_use, 2411 SyncScheduler* scheduler_to_use,
2417 sessions::SyncSessionContext** session_context) 2412 sessions::SyncSessionContext** session_context)
2418 : TestInternalComponentsFactory( 2413 : TestInternalComponentsFactory(switches, syncer::STORAGE_IN_MEMORY),
2419 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, NULL),
2420 scheduler_to_use_(scheduler_to_use), 2414 scheduler_to_use_(scheduler_to_use),
2421 session_context_(session_context) {} 2415 session_context_(session_context) {}
2422 virtual ~ComponentsFactory() {} 2416 virtual ~ComponentsFactory() {}
2423 2417
2424 virtual scoped_ptr<SyncScheduler> BuildScheduler( 2418 virtual scoped_ptr<SyncScheduler> BuildScheduler(
2425 const std::string& name, 2419 const std::string& name,
2426 sessions::SyncSessionContext* context, 2420 sessions::SyncSessionContext* context,
2427 CancelationSignal* stop_handle) OVERRIDE { 2421 CancelationSignal* stop_handle) OVERRIDE {
2428 *session_context_ = context; 2422 *session_context_ = context;
2429 return scheduler_to_use_.Pass(); 2423 return scheduler_to_use_.Pass();
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 // do so it should fail initialization. This test verifies this behavior. 3170 // do so it should fail initialization. This test verifies this behavior.
3177 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides 3171 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides
3178 // InternalComponentsFactory to return DirectoryBackingStore that always fails 3172 // InternalComponentsFactory to return DirectoryBackingStore that always fails
3179 // to load. 3173 // to load.
3180 class SyncManagerInitInvalidStorageTest : public SyncManagerTest { 3174 class SyncManagerInitInvalidStorageTest : public SyncManagerTest {
3181 public: 3175 public:
3182 SyncManagerInitInvalidStorageTest() { 3176 SyncManagerInitInvalidStorageTest() {
3183 } 3177 }
3184 3178
3185 virtual InternalComponentsFactory* GetFactory() OVERRIDE { 3179 virtual InternalComponentsFactory* GetFactory() OVERRIDE {
3186 return new TestInternalComponentsFactory( 3180 return new TestInternalComponentsFactory(GetSwitches(), STORAGE_INVALID);
3187 GetSwitches(), InternalComponentsFactory::STORAGE_INVALID,
3188 &storage_used_);
3189 } 3181 }
3190 }; 3182 };
3191 3183
3192 // SyncManagerInitInvalidStorageTest::GetFactory will return 3184 // SyncManagerInitInvalidStorageTest::GetFactory will return
3193 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3185 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3194 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3186 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3195 // task is to ensure that SyncManagerImpl reported initialization failure in 3187 // task is to ensure that SyncManagerImpl reported initialization failure in
3196 // OnInitializationComplete callback. 3188 // OnInitializationComplete callback.
3197 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3189 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3198 EXPECT_FALSE(initialization_succeeded_); 3190 EXPECT_FALSE(initialization_succeeded_);
3199 } 3191 }
3200 3192
3201 } // namespace syncer 3193 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | sync/internal_api/sync_rollback_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698