| OLD | NEW |
| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 ModelTypeSet GetEncryptedTypesWithTrans(BaseTransaction* trans) { | 972 ModelTypeSet GetEncryptedTypesWithTrans(BaseTransaction* trans) { |
| 973 return trans->GetDirectory()->GetNigoriHandler()-> | 973 return trans->GetDirectory()->GetNigoriHandler()-> |
| 974 GetEncryptedTypes(trans->GetWrappedTrans()); | 974 GetEncryptedTypes(trans->GetWrappedTrans()); |
| 975 } | 975 } |
| 976 | 976 |
| 977 void SimulateInvalidatorStateChangeForTest(InvalidatorState state) { | 977 void SimulateInvalidatorStateChangeForTest(InvalidatorState state) { |
| 978 DCHECK(sync_manager_.thread_checker_.CalledOnValidThread()); | 978 DCHECK(sync_manager_.thread_checker_.CalledOnValidThread()); |
| 979 sync_manager_.OnInvalidatorStateChange(state); | 979 sync_manager_.OnInvalidatorStateChange(state); |
| 980 } | 980 } |
| 981 | 981 |
| 982 void TriggerOnIncomingNotificationForTest(ModelTypeSet model_types) { | |
| 983 DCHECK(sync_manager_.thread_checker_.CalledOnValidThread()); | |
| 984 ObjectIdSet id_set = ModelTypeSetToObjectIdSet(model_types); | |
| 985 ObjectIdInvalidationMap invalidation_map = | |
| 986 ObjectIdInvalidationMap::InvalidateAll(id_set); | |
| 987 sync_manager_.OnIncomingInvalidation(invalidation_map); | |
| 988 } | |
| 989 | |
| 990 void SetProgressMarkerForType(ModelType type, bool set) { | 982 void SetProgressMarkerForType(ModelType type, bool set) { |
| 991 if (set) { | 983 if (set) { |
| 992 sync_pb::DataTypeProgressMarker marker; | 984 sync_pb::DataTypeProgressMarker marker; |
| 993 marker.set_token("token"); | 985 marker.set_token("token"); |
| 994 marker.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); | 986 marker.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); |
| 995 sync_manager_.directory()->SetDownloadProgress(type, marker); | 987 sync_manager_.directory()->SetDownloadProgress(type, marker); |
| 996 } else { | 988 } else { |
| 997 sync_pb::DataTypeProgressMarker marker; | 989 sync_pb::DataTypeProgressMarker marker; |
| 998 sync_manager_.directory()->SetDownloadProgress(type, marker); | 990 sync_manager_.directory()->SetDownloadProgress(type, marker); |
| 999 } | 991 } |
| (...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3124 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3133 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3125 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3134 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3126 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3135 // task is to ensure that SyncManagerImpl reported initialization failure in | 3127 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3136 // OnInitializationComplete callback. | 3128 // OnInitializationComplete callback. |
| 3137 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3129 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3138 EXPECT_FALSE(initialization_succeeded_); | 3130 EXPECT_FALSE(initialization_succeeded_); |
| 3139 } | 3131 } |
| 3140 | 3132 |
| 3141 } // namespace syncer | 3133 } // namespace syncer |
| OLD | NEW |