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

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

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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::ConflictResolution; 21 using syncer_v2::ConflictResolution;
22 using syncer::FakeModelTypeService; 22 using syncer_v2::FakeModelTypeService;
23 using syncer::ModelTypeService; 23 using syncer_v2::ModelTypeService;
24 using syncer::SharedModelTypeProcessor; 24 using syncer_v2::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::MetadataChangeList> metadata_changes, 62 std::unique_ptr<syncer_v2::MetadataChangeList> metadata_changes,
63 syncer::EntityChangeList entity_changes) override { 63 syncer_v2::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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false); 214 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false);
215 } 215 }
216 216
217 bool TestUsesSelfNotifications() override { return false; } 217 bool TestUsesSelfNotifications() override { return false; }
218 218
219 TestModelTypeService* GetModelTypeService(int i) { 219 TestModelTypeService* GetModelTypeService(int i) {
220 return services_.at(i).get(); 220 return services_.at(i).get();
221 } 221 }
222 222
223 protected: 223 protected:
224 std::unique_ptr<syncer::SyncClient> CreateSyncClient(Profile* profile) { 224 std::unique_ptr<sync_driver::SyncClient> CreateSyncClient(Profile* profile) {
225 if (!first_client_ignored_) { 225 if (!first_client_ignored_) {
226 // The test infra creates a profile before the two made for sync tests. 226 // The test infra creates a profile before the two made for sync tests.
227 first_client_ignored_ = true; 227 first_client_ignored_ = true;
228 return base::MakeUnique<ChromeSyncClient>(profile); 228 return base::MakeUnique<ChromeSyncClient>(profile);
229 } 229 }
230 auto service = base::MakeUnique<TestModelTypeService>(); 230 auto service = base::MakeUnique<TestModelTypeService>();
231 auto client = base::MakeUnique<TestSyncClient>(profile, service.get()); 231 auto client = base::MakeUnique<TestSyncClient>(profile, service.get());
232 clients_.push_back(client.get()); 232 clients_.push_back(client.get());
233 services_.push_back(std::move(service)); 233 services_.push_back(std::move(service));
234 return std::move(client); 234 return std::move(client);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 model2->SetServiceError(syncer::SyncError::DATATYPE_ERROR); 332 model2->SetServiceError(syncer::SyncError::DATATYPE_ERROR);
333 // Write an item on model 1 to trigger a GetUpdates in model 2. 333 // Write an item on model 1 to trigger a GetUpdates in model 2.
334 model1->WriteItem(kKey1, kValue2); 334 model1->WriteItem(kKey1, kValue2);
335 335
336 // The type should stop syncing but keep tracking metadata. 336 // The type should stop syncing but keep tracking metadata.
337 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); 337 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait());
338 ASSERT_EQ(1U, model2->db().metadata_count()); 338 ASSERT_EQ(1U, model2->db().metadata_count());
339 model2->WriteItem(kKey2, kValue2); 339 model2->WriteItem(kKey2, kValue2);
340 ASSERT_EQ(2U, model2->db().metadata_count()); 340 ASSERT_EQ(2U, model2->db().metadata_count());
341 } 341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698