OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/sync/driver/generic_change_processor.h" | 5 #include "components/sync/driver/generic_change_processor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | |
13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/test/scoped_task_environment.h" |
15 #include "components/sync/base/model_type.h" | 15 #include "components/sync/base/model_type.h" |
16 #include "components/sync/device_info/local_device_info_provider.h" | 16 #include "components/sync/device_info/local_device_info_provider.h" |
17 #include "components/sync/driver/fake_sync_client.h" | 17 #include "components/sync/driver/fake_sync_client.h" |
18 #include "components/sync/driver/sync_api_component_factory.h" | 18 #include "components/sync/driver/sync_api_component_factory.h" |
19 #include "components/sync/engine/attachments/fake_attachment_downloader.h" | 19 #include "components/sync/engine/attachments/fake_attachment_downloader.h" |
20 #include "components/sync/engine/attachments/fake_attachment_uploader.h" | 20 #include "components/sync/engine/attachments/fake_attachment_uploader.h" |
21 #include "components/sync/engine/sync_encryption_handler.h" | 21 #include "components/sync/engine/sync_encryption_handler.h" |
22 #include "components/sync/model/attachments/attachment_id.h" | 22 #include "components/sync/model/attachments/attachment_id.h" |
23 #include "components/sync/model/data_type_error_handler_mock.h" | 23 #include "components/sync/model/data_type_error_handler_mock.h" |
24 #include "components/sync/model/fake_syncable_service.h" | 24 #include "components/sync/model/fake_syncable_service.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 MockAttachmentService* mock_attachment_service_; | 116 MockAttachmentService* mock_attachment_service_; |
117 }; | 117 }; |
118 | 118 |
119 class SyncGenericChangeProcessorTest : public testing::Test { | 119 class SyncGenericChangeProcessorTest : public testing::Test { |
120 public: | 120 public: |
121 // Most test cases will use this type. For those that need a | 121 // Most test cases will use this type. For those that need a |
122 // GenericChangeProcessor for a different type, use |InitializeForType|. | 122 // GenericChangeProcessor for a different type, use |InitializeForType|. |
123 static const ModelType kType = PREFERENCES; | 123 static const ModelType kType = PREFERENCES; |
124 | 124 |
125 SyncGenericChangeProcessorTest() | 125 SyncGenericChangeProcessorTest() |
126 : syncable_service_ptr_factory_(&fake_syncable_service_), | 126 : scoped_task_environment_( |
| 127 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
| 128 syncable_service_ptr_factory_(&fake_syncable_service_), |
127 mock_attachment_service_(nullptr), | 129 mock_attachment_service_(nullptr), |
128 sync_client_(&sync_factory_) {} | 130 sync_client_(&sync_factory_) {} |
129 | 131 |
130 void SetUp() override { | 132 void SetUp() override { |
131 // Use kType by default, but allow test cases to re-initialize with whatever | 133 // Use kType by default, but allow test cases to re-initialize with whatever |
132 // type they choose. Therefore, it's important that all type dependent | 134 // type they choose. Therefore, it's important that all type dependent |
133 // initialization occurs in InitializeForType. | 135 // initialization occurs in InitializeForType. |
134 InitializeForType(kType); | 136 InitializeForType(kType); |
135 } | 137 } |
136 | 138 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 MockAttachmentService* mock_attachment_service() { | 188 MockAttachmentService* mock_attachment_service() { |
187 return mock_attachment_service_; | 189 return mock_attachment_service_; |
188 } | 190 } |
189 | 191 |
190 void RunLoop() { | 192 void RunLoop() { |
191 base::RunLoop run_loop; | 193 base::RunLoop run_loop; |
192 run_loop.RunUntilIdle(); | 194 run_loop.RunUntilIdle(); |
193 } | 195 } |
194 | 196 |
195 private: | 197 private: |
196 base::MessageLoopForUI loop_; | 198 base::test::ScopedTaskEnvironment scoped_task_environment_; |
197 | 199 |
198 std::unique_ptr<SyncMergeResult> sync_merge_result_; | 200 std::unique_ptr<SyncMergeResult> sync_merge_result_; |
199 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>> | 201 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>> |
200 merge_result_ptr_factory_; | 202 merge_result_ptr_factory_; |
201 | 203 |
202 FakeSyncableService fake_syncable_service_; | 204 FakeSyncableService fake_syncable_service_; |
203 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_; | 205 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_; |
204 | 206 |
205 std::unique_ptr<TestUserShare> test_user_share_; | 207 std::unique_ptr<TestUserShare> test_user_share_; |
206 MockAttachmentService* mock_attachment_service_; | 208 MockAttachmentService* mock_attachment_service_; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS); | 503 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS); |
502 ASSERT_EQ(sync_data.size(), 1U); | 504 ASSERT_EQ(sync_data.size(), 1U); |
503 ASSERT_EQ("session tag 2", | 505 ASSERT_EQ("session tag 2", |
504 sync_data[0].GetSpecifics().session().session_tag()); | 506 sync_data[0].GetSpecifics().session().session_tag()); |
505 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); | 507 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); |
506 } | 508 } |
507 | 509 |
508 } // namespace | 510 } // namespace |
509 | 511 |
510 } // namespace syncer | 512 } // namespace syncer |
OLD | NEW |