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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "chrome/browser/sync/glue/local_device_info_provider_mock.h" | |
7 #include "components/sync_driver/device_info_sync_service.h" | 6 #include "components/sync_driver/device_info_sync_service.h" |
8 #include "content/public/test/test_browser_thread_bundle.h" | 7 #include "components/sync_driver/local_device_info_provider_mock.h" |
9 #include "sync/api/sync_change.h" | 8 #include "sync/api/sync_change.h" |
10 #include "sync/api/sync_change_processor.h" | 9 #include "sync/api/sync_change_processor.h" |
11 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 10 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
12 #include "sync/api/sync_error_factory_mock.h" | 11 #include "sync/api/sync_error_factory_mock.h" |
13 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" | 12 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" |
14 #include "sync/util/time.h" | 13 #include "sync/util/time.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 | 15 |
17 using sync_driver::DeviceInfoSyncService; | |
18 using sync_driver::DeviceInfoTracker; | |
19 using syncer::AttachmentIdList; | 16 using syncer::AttachmentIdList; |
20 using syncer::AttachmentServiceProxyForTest; | 17 using syncer::AttachmentServiceProxyForTest; |
21 using syncer::ModelType; | 18 using syncer::ModelType; |
22 using syncer::SyncChange; | 19 using syncer::SyncChange; |
23 using syncer::SyncChangeList; | 20 using syncer::SyncChangeList; |
24 using syncer::SyncChangeProcessor; | 21 using syncer::SyncChangeProcessor; |
25 using syncer::SyncChangeProcessorWrapperForTest; | 22 using syncer::SyncChangeProcessorWrapperForTest; |
26 using syncer::SyncData; | 23 using syncer::SyncData; |
27 using syncer::SyncDataList; | 24 using syncer::SyncDataList; |
28 using syncer::SyncError; | 25 using syncer::SyncError; |
29 using syncer::SyncErrorFactory; | 26 using syncer::SyncErrorFactory; |
30 using syncer::SyncErrorFactoryMock; | 27 using syncer::SyncErrorFactoryMock; |
31 using syncer::SyncMergeResult; | 28 using syncer::SyncMergeResult; |
32 | 29 |
33 namespace browser_sync { | 30 namespace sync_driver { |
34 | 31 |
35 namespace { | 32 namespace { |
36 | 33 |
37 class TestChangeProcessor : public SyncChangeProcessor { | 34 class TestChangeProcessor : public SyncChangeProcessor { |
38 public: | 35 public: |
39 TestChangeProcessor() {} | 36 TestChangeProcessor() {} |
40 virtual ~TestChangeProcessor() {} | 37 virtual ~TestChangeProcessor() {} |
41 | 38 |
42 // SyncChangeProcessor implementation. | 39 // SyncChangeProcessor implementation. |
43 // Store a copy of all the changes passed in so we can examine them later. | 40 // Store a copy of all the changes passed in so we can examine them later. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 SyncData sync_data = CreateRemoteData(client_id, client_name); | 149 SyncData sync_data = CreateRemoteData(client_id, client_name); |
153 SyncChange sync_change(FROM_HERE, change_type, sync_data); | 150 SyncChange sync_change(FROM_HERE, change_type, sync_data); |
154 change_list.push_back(sync_change); | 151 change_list.push_back(sync_change); |
155 } | 152 } |
156 | 153 |
157 protected: | 154 protected: |
158 int num_device_info_changed_callbacks_; | 155 int num_device_info_changed_callbacks_; |
159 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; | 156 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; |
160 scoped_ptr<DeviceInfoSyncService> sync_service_; | 157 scoped_ptr<DeviceInfoSyncService> sync_service_; |
161 scoped_ptr<TestChangeProcessor> sync_processor_; | 158 scoped_ptr<TestChangeProcessor> sync_processor_; |
162 content::TestBrowserThreadBundle thread_bundle_; | 159 base::MessageLoopForUI message_loop_; |
163 }; | 160 }; |
164 | 161 |
165 // Sync with empty initial data. | 162 // Sync with empty initial data. |
166 TEST_F(DeviceInfoSyncServiceTest, StartSyncEmptyInitialData) { | 163 TEST_F(DeviceInfoSyncServiceTest, StartSyncEmptyInitialData) { |
167 SyncMergeResult merge_result = | 164 SyncMergeResult merge_result = |
168 sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO, | 165 sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO, |
169 SyncDataList(), | 166 SyncDataList(), |
170 PassProcessor(), | 167 PassProcessor(), |
171 CreateAndPassSyncErrorFactory()); | 168 CreateAndPassSyncErrorFactory()); |
172 | 169 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0)); | 546 EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0)); |
550 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); | 547 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); |
551 | 548 |
552 backup_time = syncer::ProtoTimeToTime( | 549 backup_time = syncer::ProtoTimeToTime( |
553 sync_processor_->device_info_at(0).backup_timestamp()); | 550 sync_processor_->device_info_at(0).backup_timestamp()); |
554 EXPECT_EQ(6000, backup_time.ToTimeT()); | 551 EXPECT_EQ(6000, backup_time.ToTimeT()); |
555 } | 552 } |
556 | 553 |
557 } // namespace | 554 } // namespace |
558 | 555 |
559 } // namespace browser_sync | 556 } // namespace sync_driver |
OLD | NEW |