| 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 28 matching lines...) Expand all Loading... |
| 39 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 39 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 40 #include "sync/internal_api/public/test/test_user_share.h" | 40 #include "sync/internal_api/public/test/test_user_share.h" |
| 41 #include "sync/internal_api/public/write_node.h" | 41 #include "sync/internal_api/public/write_node.h" |
| 42 #include "sync/internal_api/public/write_transaction.h" | 42 #include "sync/internal_api/public/write_transaction.h" |
| 43 #include "sync/internal_api/sync_encryption_handler_impl.h" | 43 #include "sync/internal_api/sync_encryption_handler_impl.h" |
| 44 #include "sync/internal_api/sync_manager_impl.h" | 44 #include "sync/internal_api/sync_manager_impl.h" |
| 45 #include "sync/internal_api/syncapi_internal.h" | 45 #include "sync/internal_api/syncapi_internal.h" |
| 46 #include "sync/js/js_backend.h" | 46 #include "sync/js/js_backend.h" |
| 47 #include "sync/js/js_event_handler.h" | 47 #include "sync/js/js_event_handler.h" |
| 48 #include "sync/js/js_test_util.h" | 48 #include "sync/js/js_test_util.h" |
| 49 #include "sync/notifier/invalidation_handler.h" | |
| 50 #include "sync/notifier/invalidator.h" | |
| 51 #include "sync/protocol/bookmark_specifics.pb.h" | 49 #include "sync/protocol/bookmark_specifics.pb.h" |
| 52 #include "sync/protocol/encryption.pb.h" | 50 #include "sync/protocol/encryption.pb.h" |
| 53 #include "sync/protocol/extension_specifics.pb.h" | 51 #include "sync/protocol/extension_specifics.pb.h" |
| 54 #include "sync/protocol/password_specifics.pb.h" | 52 #include "sync/protocol/password_specifics.pb.h" |
| 55 #include "sync/protocol/preference_specifics.pb.h" | 53 #include "sync/protocol/preference_specifics.pb.h" |
| 56 #include "sync/protocol/proto_value_conversions.h" | 54 #include "sync/protocol/proto_value_conversions.h" |
| 57 #include "sync/protocol/sync.pb.h" | 55 #include "sync/protocol/sync.pb.h" |
| 58 #include "sync/sessions/sync_session.h" | 56 #include "sync/sessions/sync_session.h" |
| 59 #include "sync/syncable/directory.h" | 57 #include "sync/syncable/directory.h" |
| 60 #include "sync/syncable/entry.h" | 58 #include "sync/syncable/entry.h" |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 return GetEncryptedTypesWithTrans(&trans); | 971 return GetEncryptedTypesWithTrans(&trans); |
| 974 } | 972 } |
| 975 | 973 |
| 976 ModelTypeSet GetEncryptedTypesWithTrans(BaseTransaction* trans) { | 974 ModelTypeSet GetEncryptedTypesWithTrans(BaseTransaction* trans) { |
| 977 return trans->GetDirectory()->GetNigoriHandler()-> | 975 return trans->GetDirectory()->GetNigoriHandler()-> |
| 978 GetEncryptedTypes(trans->GetWrappedTrans()); | 976 GetEncryptedTypes(trans->GetWrappedTrans()); |
| 979 } | 977 } |
| 980 | 978 |
| 981 void SimulateInvalidatorStateChangeForTest(InvalidatorState state) { | 979 void SimulateInvalidatorStateChangeForTest(InvalidatorState state) { |
| 982 DCHECK(sync_manager_.thread_checker_.CalledOnValidThread()); | 980 DCHECK(sync_manager_.thread_checker_.CalledOnValidThread()); |
| 983 sync_manager_.OnInvalidatorStateChange(state); | 981 sync_manager_.SetInvalidatorEnabled(state == INVALIDATIONS_ENABLED); |
| 984 } | 982 } |
| 985 | 983 |
| 986 void SetProgressMarkerForType(ModelType type, bool set) { | 984 void SetProgressMarkerForType(ModelType type, bool set) { |
| 987 if (set) { | 985 if (set) { |
| 988 sync_pb::DataTypeProgressMarker marker; | 986 sync_pb::DataTypeProgressMarker marker; |
| 989 marker.set_token("token"); | 987 marker.set_token("token"); |
| 990 marker.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); | 988 marker.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); |
| 991 sync_manager_.directory()->SetDownloadProgress(type, marker); | 989 sync_manager_.directory()->SetDownloadProgress(type, marker); |
| 992 } else { | 990 } else { |
| 993 sync_pb::DataTypeProgressMarker marker; | 991 sync_pb::DataTypeProgressMarker marker; |
| (...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3128 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3126 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3129 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3127 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3130 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3128 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3131 // task is to ensure that SyncManagerImpl reported initialization failure in | 3129 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3132 // OnInitializationComplete callback. | 3130 // OnInitializationComplete callback. |
| 3133 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3131 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3134 EXPECT_FALSE(initialization_succeeded_); | 3132 EXPECT_FALSE(initialization_succeeded_); |
| 3135 } | 3133 } |
| 3136 | 3134 |
| 3137 } // namespace syncer | 3135 } // namespace syncer |
| OLD | NEW |