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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_uss_sync_test.cc

Issue 2388163002: [Sync] Move //components/sync to the syncer namespace, take 2. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "chrome/browser/sync/chrome_sync_client.h" 8 #include "chrome/browser/sync/chrome_sync_client.h"
9 #include "chrome/browser/sync/profile_sync_service_factory.h" 9 #include "chrome/browser/sync/profile_sync_service_factory.h"
10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
11 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" 11 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
12 #include "chrome/browser/sync/test/integration/status_change_checker.h" 12 #include "chrome/browser/sync/test/integration/status_change_checker.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h" 14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "components/browser_sync/profile_sync_components_factory_impl.h" 15 #include "components/browser_sync/profile_sync_components_factory_impl.h"
16 #include "components/browser_sync/profile_sync_service.h" 16 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/sync/api/fake_model_type_service.h" 17 #include "components/sync/api/fake_model_type_service.h"
18 18
19 using browser_sync::ChromeSyncClient; 19 using browser_sync::ChromeSyncClient;
20 using browser_sync::ProfileSyncComponentsFactoryImpl; 20 using browser_sync::ProfileSyncComponentsFactoryImpl;
21 using syncer_v2::ConflictResolution; 21 using syncer::ConflictResolution;
22 using syncer_v2::FakeModelTypeService; 22 using syncer::FakeModelTypeService;
23 using syncer_v2::ModelTypeService; 23 using syncer::ModelTypeService;
24 using syncer_v2::SharedModelTypeProcessor; 24 using syncer::SharedModelTypeProcessor;
25 25
26 const char kKey1[] = "key1"; 26 const char kKey1[] = "key1";
27 const char kKey2[] = "key2"; 27 const char kKey2[] = "key2";
28 const char kValue1[] = "value1"; 28 const char kValue1[] = "value1";
29 const char kValue2[] = "value2"; 29 const char kValue2[] = "value2";
30 const char kValue3[] = "value3"; 30 const char kValue3[] = "value3";
31 31
32 // A ChromeSyncClient that provides a ModelTypeService for PREFERENCES. 32 // A ChromeSyncClient that provides a ModelTypeService for PREFERENCES.
33 class TestSyncClient : public ChromeSyncClient { 33 class TestSyncClient : public ChromeSyncClient {
34 public: 34 public:
(...skipping 17 matching lines...) Expand all
52 class Observer { 52 class Observer {
53 public: 53 public:
54 virtual void OnApplySyncChanges() = 0; 54 virtual void OnApplySyncChanges() = 0;
55 }; 55 };
56 56
57 TestModelTypeService() 57 TestModelTypeService()
58 : FakeModelTypeService( 58 : FakeModelTypeService(
59 base::Bind(&SharedModelTypeProcessor::CreateAsChangeProcessor)) {} 59 base::Bind(&SharedModelTypeProcessor::CreateAsChangeProcessor)) {}
60 60
61 syncer::SyncError ApplySyncChanges( 61 syncer::SyncError ApplySyncChanges(
62 std::unique_ptr<syncer_v2::MetadataChangeList> metadata_changes, 62 std::unique_ptr<syncer::MetadataChangeList> metadata_changes,
63 syncer_v2::EntityChangeList entity_changes) override { 63 syncer::EntityChangeList entity_changes) override {
64 syncer::SyncError error = FakeModelTypeService::ApplySyncChanges( 64 syncer::SyncError error = FakeModelTypeService::ApplySyncChanges(
65 std::move(metadata_changes), entity_changes); 65 std::move(metadata_changes), entity_changes);
66 NotifyObservers(); 66 NotifyObservers();
67 return error; 67 return error;
68 } 68 }
69 69
70 void OnChangeProcessorSet() override { 70 void OnChangeProcessorSet() override {
71 change_processor()->OnMetadataLoaded(syncer::SyncError(), 71 change_processor()->OnMetadataLoaded(syncer::SyncError(),
72 db().CreateMetadataBatch()); 72 db().CreateMetadataBatch());
73 } 73 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false); 201 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false);
202 } 202 }
203 203
204 bool TestUsesSelfNotifications() override { return false; } 204 bool TestUsesSelfNotifications() override { return false; }
205 205
206 TestModelTypeService* GetModelTypeService(int i) { 206 TestModelTypeService* GetModelTypeService(int i) {
207 return services_.at(i).get(); 207 return services_.at(i).get();
208 } 208 }
209 209
210 protected: 210 protected:
211 std::unique_ptr<sync_driver::SyncClient> CreateSyncClient(Profile* profile) { 211 std::unique_ptr<syncer::SyncClient> CreateSyncClient(Profile* profile) {
212 if (!first_client_ignored_) { 212 if (!first_client_ignored_) {
213 // The test infra creates a profile before the two made for sync tests. 213 // The test infra creates a profile before the two made for sync tests.
214 first_client_ignored_ = true; 214 first_client_ignored_ = true;
215 return base::MakeUnique<ChromeSyncClient>(profile); 215 return base::MakeUnique<ChromeSyncClient>(profile);
216 } 216 }
217 auto service = base::MakeUnique<TestModelTypeService>(); 217 auto service = base::MakeUnique<TestModelTypeService>();
218 auto client = base::MakeUnique<TestSyncClient>(profile, service.get()); 218 auto client = base::MakeUnique<TestSyncClient>(profile, service.get());
219 clients_.push_back(client.get()); 219 clients_.push_back(client.get());
220 services_.push_back(std::move(service)); 220 services_.push_back(std::move(service));
221 return std::move(client); 221 return std::move(client);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 model2->SetServiceError(syncer::SyncError::DATATYPE_ERROR); 319 model2->SetServiceError(syncer::SyncError::DATATYPE_ERROR);
320 // Write an item on model 1 to trigger a GetUpdates in model 2. 320 // Write an item on model 1 to trigger a GetUpdates in model 2.
321 model1->WriteItem(kKey1, kValue2); 321 model1->WriteItem(kKey1, kValue2);
322 322
323 // The type should stop syncing but keep tracking metadata. 323 // The type should stop syncing but keep tracking metadata.
324 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); 324 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait());
325 ASSERT_EQ(1U, model2->db().metadata_count()); 325 ASSERT_EQ(1U, model2->db().metadata_count());
326 model2->WriteItem(kKey2, kValue2); 326 model2->WriteItem(kKey2, kValue2);
327 ASSERT_EQ(2U, model2->db().metadata_count()); 327 ASSERT_EQ(2U, model2->db().metadata_count());
328 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698