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

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

Issue 2458013002: [Sync] Rename ModelTypeService to ModelTypeSyncBridge. (Closed)
Patch Set: Created 4 years, 1 month 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/model/fake_model_type_service.h" 17 #include "components/sync/model/fake_model_type_sync_bridge.h"
18 #include "components/sync/model/metadata_change_list.h" 18 #include "components/sync/model/metadata_change_list.h"
19 #include "components/sync/model/model_type_change_processor.h" 19 #include "components/sync/model/model_type_change_processor.h"
20 20
21 using browser_sync::ChromeSyncClient; 21 using browser_sync::ChromeSyncClient;
22 using browser_sync::ProfileSyncComponentsFactoryImpl; 22 using browser_sync::ProfileSyncComponentsFactoryImpl;
23 using syncer::ConflictResolution; 23 using syncer::ConflictResolution;
24 using syncer::FakeModelTypeService; 24 using syncer::FakeModelTypeSyncBridge;
25 using syncer::ModelTypeChangeProcessor; 25 using syncer::ModelTypeChangeProcessor;
26 using syncer::ModelTypeService; 26 using syncer::ModelTypeSyncBridge;
27 27
28 namespace { 28 namespace {
29 29
30 const char kKey1[] = "key1"; 30 const char kKey1[] = "key1";
31 const char kKey2[] = "key2"; 31 const char kKey2[] = "key2";
32 const char kKey3[] = "key3"; 32 const char kKey3[] = "key3";
33 const char kKey4[] = "key4"; 33 const char kKey4[] = "key4";
34 const char kValue1[] = "value1"; 34 const char kValue1[] = "value1";
35 const char kValue2[] = "value2"; 35 const char kValue2[] = "value2";
36 const char kValue3[] = "value3"; 36 const char kValue3[] = "value3";
37 const char* kPassphrase = "12345"; 37 const char* kPassphrase = "12345";
38 38
39 // A ChromeSyncClient that provides a ModelTypeService for PREFERENCES. 39 // A ChromeSyncClient that provides a ModelTypeSyncBridge for PREFERENCES.
40 class TestSyncClient : public ChromeSyncClient { 40 class TestSyncClient : public ChromeSyncClient {
41 public: 41 public:
42 TestSyncClient(Profile* profile, ModelTypeService* service) 42 TestSyncClient(Profile* profile, ModelTypeSyncBridge* sync_bridge)
43 : ChromeSyncClient(profile), service_(service) {} 43 : ChromeSyncClient(profile), sync_bridge_(sync_bridge) {}
44 44
45 base::WeakPtr<ModelTypeService> GetModelTypeServiceForType( 45 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridgeForModelType(
46 syncer::ModelType type) override { 46 syncer::ModelType type) override {
47 return type == syncer::PREFERENCES 47 return type == syncer::PREFERENCES
48 ? service_->AsWeakPtr() 48 ? sync_bridge_->AsWeakPtr()
49 : ChromeSyncClient::GetModelTypeServiceForType(type); 49 : ChromeSyncClient::GetSyncBridgeForModelType(type);
50 } 50 }
51 51
52 private: 52 private:
53 ModelTypeService* const service_; 53 ModelTypeSyncBridge* const sync_bridge_;
54 }; 54 };
55 55
56 // A FakeModelTypeService that supports observing ApplySyncChanges. 56 // A FakeModelTypeSyncBridge that supports observing ApplySyncChanges.
57 class TestModelTypeService : public FakeModelTypeService { 57 class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge {
58 public: 58 public:
59 class Observer { 59 class Observer {
60 public: 60 public:
61 virtual void OnApplySyncChanges() = 0; 61 virtual void OnApplySyncChanges() = 0;
62 }; 62 };
63 63
64 TestModelTypeService() 64 TestModelTypeSyncBridge()
65 : FakeModelTypeService(base::Bind(&ModelTypeChangeProcessor::Create)) { 65 : FakeModelTypeSyncBridge(base::Bind(&ModelTypeChangeProcessor::Create)) {
66 change_processor()->OnMetadataLoaded(syncer::SyncError(), 66 change_processor()->OnMetadataLoaded(syncer::SyncError(),
67 db().CreateMetadataBatch()); 67 db().CreateMetadataBatch());
68 } 68 }
69 69
70 syncer::SyncError ApplySyncChanges( 70 syncer::SyncError ApplySyncChanges(
71 std::unique_ptr<syncer::MetadataChangeList> metadata_changes, 71 std::unique_ptr<syncer::MetadataChangeList> metadata_changes,
72 syncer::EntityChangeList entity_changes) override { 72 syncer::EntityChangeList entity_changes) override {
73 syncer::SyncError error = FakeModelTypeService::ApplySyncChanges( 73 syncer::SyncError error = FakeModelTypeSyncBridge::ApplySyncChanges(
74 std::move(metadata_changes), entity_changes); 74 std::move(metadata_changes), entity_changes);
75 NotifyObservers(); 75 NotifyObservers();
76 return error; 76 return error;
77 } 77 }
78 78
79 void AddObserver(Observer* observer) { observers_.insert(observer); } 79 void AddObserver(Observer* observer) { observers_.insert(observer); }
80 void RemoveObserver(Observer* observer) { observers_.erase(observer); } 80 void RemoveObserver(Observer* observer) { observers_.erase(observer); }
81 81
82 private: 82 private:
83 void NotifyObservers() { 83 void NotifyObservers() {
84 for (Observer* observer : observers_) { 84 for (Observer* observer : observers_) {
85 observer->OnApplySyncChanges(); 85 observer->OnApplySyncChanges();
86 } 86 }
87 } 87 }
88 88
89 std::set<Observer*> observers_; 89 std::set<Observer*> observers_;
90 }; 90 };
91 91
92 // A StatusChangeChecker for checking the status of keys in a 92 // A StatusChangeChecker for checking the status of keys in a
93 // TestModelTypeService::Store. 93 // TestModelTypeSyncBridge::Store.
94 class KeyChecker : public StatusChangeChecker, 94 class KeyChecker : public StatusChangeChecker,
95 public TestModelTypeService::Observer { 95 public TestModelTypeSyncBridge::Observer {
96 public: 96 public:
97 KeyChecker(TestModelTypeService* service, const std::string& key) 97 KeyChecker(TestModelTypeSyncBridge* sync_bridge, const std::string& key)
98 : service_(service), key_(key) { 98 : sync_bridge_(sync_bridge), key_(key) {
99 service_->AddObserver(this); 99 sync_bridge_->AddObserver(this);
100 } 100 }
101 101
102 ~KeyChecker() override { service_->RemoveObserver(this); } 102 ~KeyChecker() override { sync_bridge_->RemoveObserver(this); }
103 103
104 void OnApplySyncChanges() override { CheckExitCondition(); } 104 void OnApplySyncChanges() override { CheckExitCondition(); }
105 105
106 protected: 106 protected:
107 TestModelTypeService* const service_; 107 TestModelTypeSyncBridge* const sync_bridge_;
108 const std::string key_; 108 const std::string key_;
109 }; 109 };
110 110
111 // Wait for data for a key to have a certain value. 111 // Wait for data for a key to have a certain value.
112 class DataChecker : public KeyChecker { 112 class DataChecker : public KeyChecker {
113 public: 113 public:
114 DataChecker(TestModelTypeService* service, 114 DataChecker(TestModelTypeSyncBridge* sync_bridge,
115 const std::string& key, 115 const std::string& key,
116 const std::string& value) 116 const std::string& value)
117 : KeyChecker(service, key), value_(value) {} 117 : KeyChecker(sync_bridge, key), value_(value) {}
118 118
119 bool IsExitConditionSatisfied() override { 119 bool IsExitConditionSatisfied() override {
120 const auto& db = service_->db(); 120 const auto& db = sync_bridge_->db();
121 return db.HasData(key_) && db.GetValue(key_) == value_; 121 return db.HasData(key_) && db.GetValue(key_) == value_;
122 } 122 }
123 123
124 std::string GetDebugMessage() const override { 124 std::string GetDebugMessage() const override {
125 return "Waiting for data for key '" + key_ + "' to be '" + value_ + "'."; 125 return "Waiting for data for key '" + key_ + "' to be '" + value_ + "'.";
126 } 126 }
127 127
128 private: 128 private:
129 const std::string value_; 129 const std::string value_;
130 }; 130 };
131 131
132 // Wait for data for a key to be absent. 132 // Wait for data for a key to be absent.
133 class DataAbsentChecker : public KeyChecker { 133 class DataAbsentChecker : public KeyChecker {
134 public: 134 public:
135 DataAbsentChecker(TestModelTypeService* service, const std::string& key) 135 DataAbsentChecker(TestModelTypeSyncBridge* sync_bridge,
136 : KeyChecker(service, key) {} 136 const std::string& key)
137 : KeyChecker(sync_bridge, key) {}
137 138
138 bool IsExitConditionSatisfied() override { 139 bool IsExitConditionSatisfied() override {
139 return !service_->db().HasData(key_); 140 return !sync_bridge_->db().HasData(key_);
140 } 141 }
141 142
142 std::string GetDebugMessage() const override { 143 std::string GetDebugMessage() const override {
143 return "Waiting for data for key '" + key_ + "' to be absent."; 144 return "Waiting for data for key '" + key_ + "' to be absent.";
144 } 145 }
145 }; 146 };
146 147
147 // Wait for metadata for a key to be present. 148 // Wait for metadata for a key to be present.
148 class MetadataPresentChecker : public KeyChecker { 149 class MetadataPresentChecker : public KeyChecker {
149 public: 150 public:
150 MetadataPresentChecker(TestModelTypeService* service, const std::string& key) 151 MetadataPresentChecker(TestModelTypeSyncBridge* sync_bridge,
151 : KeyChecker(service, key) {} 152 const std::string& key)
153 : KeyChecker(sync_bridge, key) {}
152 154
153 bool IsExitConditionSatisfied() override { 155 bool IsExitConditionSatisfied() override {
154 return service_->db().HasMetadata(key_); 156 return sync_bridge_->db().HasMetadata(key_);
155 } 157 }
156 158
157 std::string GetDebugMessage() const override { 159 std::string GetDebugMessage() const override {
158 return "Waiting for metadata for key '" + key_ + "' to be present."; 160 return "Waiting for metadata for key '" + key_ + "' to be present.";
159 } 161 }
160 }; 162 };
161 163
162 // Wait for metadata for a key to be absent. 164 // Wait for metadata for a key to be absent.
163 class MetadataAbsentChecker : public KeyChecker { 165 class MetadataAbsentChecker : public KeyChecker {
164 public: 166 public:
165 MetadataAbsentChecker(TestModelTypeService* service, const std::string& key) 167 MetadataAbsentChecker(TestModelTypeSyncBridge* sync_bridge,
166 : KeyChecker(service, key) {} 168 const std::string& key)
169 : KeyChecker(sync_bridge, key) {}
167 170
168 bool IsExitConditionSatisfied() override { 171 bool IsExitConditionSatisfied() override {
169 return !service_->db().HasMetadata(key_); 172 return !sync_bridge_->db().HasMetadata(key_);
170 } 173 }
171 174
172 std::string GetDebugMessage() const override { 175 std::string GetDebugMessage() const override {
173 return "Waiting for metadata for key '" + key_ + "' to be absent."; 176 return "Waiting for metadata for key '" + key_ + "' to be absent.";
174 } 177 }
175 }; 178 };
176 179
177 // Wait for PREFERENCES to no longer be running. 180 // Wait for PREFERENCES to no longer be running.
178 class PrefsNotRunningChecker : public SingleClientStatusChangeChecker { 181 class PrefsNotRunningChecker : public SingleClientStatusChangeChecker {
179 public: 182 public:
(...skipping 20 matching lines...) Expand all
200 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(true); 203 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(true);
201 } 204 }
202 205
203 ~TwoClientUssSyncTest() override { 206 ~TwoClientUssSyncTest() override {
204 ProfileSyncServiceFactory::SetSyncClientFactoryForTest(nullptr); 207 ProfileSyncServiceFactory::SetSyncClientFactoryForTest(nullptr);
205 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false); 208 ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(false);
206 } 209 }
207 210
208 bool TestUsesSelfNotifications() override { return false; } 211 bool TestUsesSelfNotifications() override { return false; }
209 212
210 TestModelTypeService* GetModelTypeService(int i) { 213 TestModelTypeSyncBridge* GetModelTypeSyncBridge(int i) {
211 return services_.at(i).get(); 214 return sync_bridges_.at(i).get();
212 } 215 }
213 216
214 protected: 217 protected:
215 std::unique_ptr<syncer::SyncClient> CreateSyncClient(Profile* profile) { 218 std::unique_ptr<syncer::SyncClient> CreateSyncClient(Profile* profile) {
216 if (!first_client_ignored_) { 219 if (!first_client_ignored_) {
217 // The test infra creates a profile before the two made for sync tests. 220 // The test infra creates a profile before the two made for sync tests.
218 first_client_ignored_ = true; 221 first_client_ignored_ = true;
219 return base::MakeUnique<ChromeSyncClient>(profile); 222 return base::MakeUnique<ChromeSyncClient>(profile);
220 } 223 }
221 auto service = base::MakeUnique<TestModelTypeService>(); 224 auto sync_bridge = base::MakeUnique<TestModelTypeSyncBridge>();
222 auto client = base::MakeUnique<TestSyncClient>(profile, service.get()); 225 auto client = base::MakeUnique<TestSyncClient>(profile, sync_bridge.get());
223 clients_.push_back(client.get()); 226 clients_.push_back(client.get());
224 services_.push_back(std::move(service)); 227 sync_bridges_.push_back(std::move(sync_bridge));
225 return std::move(client); 228 return std::move(client);
226 } 229 }
227 230
228 ProfileSyncServiceFactory::SyncClientFactory sync_client_factory_; 231 ProfileSyncServiceFactory::SyncClientFactory sync_client_factory_;
229 std::vector<std::unique_ptr<TestModelTypeService>> services_; 232 std::vector<std::unique_ptr<TestModelTypeSyncBridge>> sync_bridges_;
230 std::vector<TestSyncClient*> clients_; 233 std::vector<TestSyncClient*> clients_;
231 bool first_client_ignored_ = false; 234 bool first_client_ignored_ = false;
232 235
233 private: 236 private:
234 DISALLOW_COPY_AND_ASSIGN(TwoClientUssSyncTest); 237 DISALLOW_COPY_AND_ASSIGN(TwoClientUssSyncTest);
235 }; 238 };
236 239
237 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Sanity) { 240 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Sanity) {
238 ASSERT_TRUE(SetupSync()); 241 ASSERT_TRUE(SetupSync());
239 ASSERT_EQ(2U, clients_.size()); 242 ASSERT_EQ(2U, clients_.size());
240 ASSERT_EQ(2U, services_.size()); 243 ASSERT_EQ(2U, sync_bridges_.size());
241 TestModelTypeService* model0 = GetModelTypeService(0); 244 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
242 TestModelTypeService* model1 = GetModelTypeService(1); 245 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
243 246
244 // Add an entity. 247 // Add an entity.
245 model0->WriteItem(kKey1, kValue1); 248 model0->WriteItem(kKey1, kValue1);
246 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); 249 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait());
247 250
248 // Update an entity. 251 // Update an entity.
249 model0->WriteItem(kKey1, kValue2); 252 model0->WriteItem(kKey1, kValue2);
250 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait()); 253 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait());
251 254
252 // Delete an entity. 255 // Delete an entity.
253 model0->DeleteItem(kKey1); 256 model0->DeleteItem(kKey1);
254 ASSERT_TRUE(DataAbsentChecker(model1, kKey1).Wait()); 257 ASSERT_TRUE(DataAbsentChecker(model1, kKey1).Wait());
255 } 258 }
256 259
257 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, DisableEnable) { 260 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, DisableEnable) {
258 ASSERT_TRUE(SetupSync()); 261 ASSERT_TRUE(SetupSync());
259 TestModelTypeService* model0 = GetModelTypeService(0); 262 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
260 TestModelTypeService* model1 = GetModelTypeService(1); 263 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
261 264
262 // Add an entity to test with. 265 // Add an entity to test with.
263 model0->WriteItem(kKey1, kValue1); 266 model0->WriteItem(kKey1, kValue1);
264 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); 267 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait());
265 ASSERT_EQ(1U, model0->db().data_count()); 268 ASSERT_EQ(1U, model0->db().data_count());
266 ASSERT_EQ(1U, model0->db().metadata_count()); 269 ASSERT_EQ(1U, model0->db().metadata_count());
267 ASSERT_EQ(1U, model1->db().data_count()); 270 ASSERT_EQ(1U, model1->db().data_count());
268 ASSERT_EQ(1U, model1->db().metadata_count()); 271 ASSERT_EQ(1U, model1->db().metadata_count());
269 272
270 // Disable PREFERENCES. 273 // Disable PREFERENCES.
(...skipping 15 matching lines...) Expand all
286 // Wait for metadata to be re-added. 289 // Wait for metadata to be re-added.
287 ASSERT_TRUE(MetadataPresentChecker(model0, kKey1).Wait()); 290 ASSERT_TRUE(MetadataPresentChecker(model0, kKey1).Wait());
288 ASSERT_EQ(1U, model0->db().data_count()); 291 ASSERT_EQ(1U, model0->db().data_count());
289 ASSERT_EQ(1U, model0->db().metadata_count()); 292 ASSERT_EQ(1U, model0->db().metadata_count());
290 ASSERT_EQ(1U, model1->db().data_count()); 293 ASSERT_EQ(1U, model1->db().data_count());
291 ASSERT_EQ(1U, model1->db().metadata_count()); 294 ASSERT_EQ(1U, model1->db().metadata_count());
292 } 295 }
293 296
294 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, ConflictResolution) { 297 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, ConflictResolution) {
295 ASSERT_TRUE(SetupSync()); 298 ASSERT_TRUE(SetupSync());
296 TestModelTypeService* model0 = GetModelTypeService(0); 299 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
297 TestModelTypeService* model1 = GetModelTypeService(1); 300 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
298 model0->SetConflictResolution(ConflictResolution::UseNew( 301 model0->SetConflictResolution(ConflictResolution::UseNew(
299 FakeModelTypeService::GenerateEntityData(kKey1, kValue3))); 302 FakeModelTypeSyncBridge::GenerateEntityData(kKey1, kValue3)));
300 model1->SetConflictResolution(ConflictResolution::UseNew( 303 model1->SetConflictResolution(ConflictResolution::UseNew(
301 FakeModelTypeService::GenerateEntityData(kKey1, kValue3))); 304 FakeModelTypeSyncBridge::GenerateEntityData(kKey1, kValue3)));
302 305
303 // Write conflicting entities. 306 // Write conflicting entities.
304 model0->WriteItem(kKey1, kValue1); 307 model0->WriteItem(kKey1, kValue1);
305 model1->WriteItem(kKey1, kValue2); 308 model1->WriteItem(kKey1, kValue2);
306 309
307 // Wait for them to be resolved to kResolutionValue by the custom conflict 310 // Wait for them to be resolved to kResolutionValue by the custom conflict
308 // resolution logic in TestModelTypeService. 311 // resolution logic in TestModelTypeSyncBridge.
309 ASSERT_TRUE(DataChecker(model0, kKey1, kValue3).Wait()); 312 ASSERT_TRUE(DataChecker(model0, kKey1, kValue3).Wait());
310 ASSERT_TRUE(DataChecker(model1, kKey1, kValue3).Wait()); 313 ASSERT_TRUE(DataChecker(model1, kKey1, kValue3).Wait());
311 } 314 }
312 315
313 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) { 316 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) {
314 ASSERT_TRUE(SetupSync()); 317 ASSERT_TRUE(SetupSync());
315 TestModelTypeService* model0 = GetModelTypeService(0); 318 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
316 TestModelTypeService* model1 = GetModelTypeService(1); 319 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
317 320
318 // Add an entity. 321 // Add an entity.
319 model0->WriteItem(kKey1, kValue1); 322 model0->WriteItem(kKey1, kValue1);
320 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); 323 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait());
321 324
322 // Set an error in model 1 to trigger in the next GetUpdates. 325 // Set an error in model 1 to trigger in the next GetUpdates.
323 model1->SetServiceError(syncer::SyncError::DATATYPE_ERROR); 326 model1->SetServiceError(syncer::SyncError::DATATYPE_ERROR);
324 // Write an item on model 0 to trigger a GetUpdates in model 1. 327 // Write an item on model 0 to trigger a GetUpdates in model 1.
325 model0->WriteItem(kKey1, kValue2); 328 model0->WriteItem(kKey1, kValue2);
326 329
327 // The type should stop syncing but keep tracking metadata. 330 // The type should stop syncing but keep tracking metadata.
328 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); 331 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait());
329 ASSERT_EQ(1U, model1->db().metadata_count()); 332 ASSERT_EQ(1U, model1->db().metadata_count());
330 model1->WriteItem(kKey2, kValue2); 333 model1->WriteItem(kKey2, kValue2);
331 ASSERT_EQ(2U, model1->db().metadata_count()); 334 ASSERT_EQ(2U, model1->db().metadata_count());
332 } 335 }
333 336
334 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Encryption) { 337 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Encryption) {
335 ASSERT_TRUE(SetupSync()); 338 ASSERT_TRUE(SetupSync());
336 TestModelTypeService* model0 = GetModelTypeService(0); 339 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
337 TestModelTypeService* model1 = GetModelTypeService(1); 340 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
338 341
339 model0->WriteItem(kKey1, kValue1); 342 model0->WriteItem(kKey1, kValue1);
340 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); 343 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait());
341 344
342 GetSyncService(0)->SetEncryptionPassphrase(kPassphrase, 345 GetSyncService(0)->SetEncryptionPassphrase(kPassphrase,
343 syncer::SyncService::EXPLICIT); 346 syncer::SyncService::EXPLICIT);
344 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait()); 347 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait());
345 // Wait for client 1 to know that a passphrase is happening to avoid potential 348 // Wait for client 1 to know that a passphrase is happening to avoid potential
346 // race conditions and make the functionality this case tests more consistent. 349 // race conditions and make the functionality this case tests more consistent.
347 ASSERT_TRUE(PassphraseRequiredChecker(GetSyncService(1)).Wait()); 350 ASSERT_TRUE(PassphraseRequiredChecker(GetSyncService(1)).Wait());
348 351
349 model0->WriteItem(kKey1, kValue2); 352 model0->WriteItem(kKey1, kValue2);
350 model0->WriteItem(kKey2, kValue1); 353 model0->WriteItem(kKey2, kValue1);
351 model1->WriteItem(kKey3, kValue1); 354 model1->WriteItem(kKey3, kValue1);
352 355
353 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kPassphrase)); 356 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kPassphrase));
354 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(1)).Wait()); 357 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(1)).Wait());
355 358
356 model0->WriteItem(kKey4, kValue1); 359 model0->WriteItem(kKey4, kValue1);
357 360
358 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait()); 361 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait());
359 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait()); 362 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait());
360 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait()); 363 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait());
361 364
362 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait()); 365 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait());
363 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait()); 366 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait());
364 } 367 }
365 368
366 } // namespace 369 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698