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

Side by Side Diff: components/sync/core/shared_model_type_processor_unittest.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (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 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/core/shared_model_type_processor.h" 5 #include "components/sync/core/shared_model_type_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 14 matching lines...) Expand all
25 #include "components/sync/core/simple_metadata_change_list.h" 25 #include "components/sync/core/simple_metadata_change_list.h"
26 #include "components/sync/engine/commit_queue.h" 26 #include "components/sync/engine/commit_queue.h"
27 #include "components/sync/protocol/sync.pb.h" 27 #include "components/sync/protocol/sync.pb.h"
28 #include "components/sync/test/engine/mock_model_type_worker.h" 28 #include "components/sync/test/engine/mock_model_type_worker.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using sync_pb::EntitySpecifics; 31 using sync_pb::EntitySpecifics;
32 using sync_pb::EntityMetadata; 32 using sync_pb::EntityMetadata;
33 using sync_pb::DataTypeState; 33 using sync_pb::DataTypeState;
34 34
35 namespace syncer_v2 { 35 namespace syncer {
36 36
37 namespace { 37 namespace {
38 38
39 const char kKey1[] = "key1"; 39 const char kKey1[] = "key1";
40 const char kKey2[] = "key2"; 40 const char kKey2[] = "key2";
41 const char kKey3[] = "key3"; 41 const char kKey3[] = "key3";
42 const char kKey4[] = "key4"; 42 const char kKey4[] = "key4";
43 const char kKey5[] = "key5"; 43 const char kKey5[] = "key5";
44 const char kValue1[] = "value1"; 44 const char kValue1[] = "value1";
45 const char kValue2[] = "value2"; 45 const char kValue2[] = "value2";
46 const char kValue3[] = "value3"; 46 const char kValue3[] = "value3";
47 const std::string kHash1(FakeModelTypeService::TagHashFromKey(kKey1)); 47 const std::string kHash1(FakeModelTypeService::TagHashFromKey(kKey1));
48 const std::string kHash2(FakeModelTypeService::TagHashFromKey(kKey2)); 48 const std::string kHash2(FakeModelTypeService::TagHashFromKey(kKey2));
49 const std::string kHash3(FakeModelTypeService::TagHashFromKey(kKey3)); 49 const std::string kHash3(FakeModelTypeService::TagHashFromKey(kKey3));
50 const std::string kHash4(FakeModelTypeService::TagHashFromKey(kKey4)); 50 const std::string kHash4(FakeModelTypeService::TagHashFromKey(kKey4));
51 const std::string kHash5(FakeModelTypeService::TagHashFromKey(kKey5)); 51 const std::string kHash5(FakeModelTypeService::TagHashFromKey(kKey5));
52 52
53 // Typically used for verification after a delete. The specifics given to the 53 // Typically used for verification after a delete. The specifics given to the
54 // worker/processor will not have been initialized and thus empty. 54 // worker/processor will not have been initialized and thus empty.
55 const EntitySpecifics kEmptySpecifics; 55 const EntitySpecifics kEmptySpecifics;
56 56
57 syncer::SyncError CreateSyncError(syncer::SyncError::ErrorType error_type) { 57 SyncError CreateSyncError(SyncError::ErrorType error_type) {
58 return syncer::SyncError(FROM_HERE, error_type, "TestError", 58 return SyncError(FROM_HERE, error_type, "TestError", PREFERENCES);
59 syncer::PREFERENCES);
60 } 59 }
61 60
62 } // namespace 61 } // namespace
63 62
64 // Tests the various functionality of SharedModelTypeProcessor. 63 // Tests the various functionality of SharedModelTypeProcessor.
65 // 64 //
66 // The processor sits between the service (implemented by this test class) and 65 // The processor sits between the service (implemented by this test class) and
67 // the worker, which is represented by a MockModelTypeWorker. This test suite 66 // the worker, which is represented by a MockModelTypeWorker. This test suite
68 // exercises the initialization flows (whether initial sync is done, performing 67 // exercises the initialization flows (whether initial sync is done, performing
69 // the initial merge, etc) as well as normal functionality: 68 // the initial merge, etc) as well as normal functionality:
(...skipping 24 matching lines...) Expand all
94 // Initialize to a "ready-to-commit" state. 93 // Initialize to a "ready-to-commit" state.
95 void InitializeToReadyState() { 94 void InitializeToReadyState() {
96 InitializeToMetadataLoaded(); 95 InitializeToMetadataLoaded();
97 if (!data_callback_.is_null()) { 96 if (!data_callback_.is_null()) {
98 OnPendingCommitDataLoaded(); 97 OnPendingCommitDataLoaded();
99 } 98 }
100 OnSyncStarting(); 99 OnSyncStarting();
101 } 100 }
102 101
103 void OnMetadataLoaded() { 102 void OnMetadataLoaded() {
104 type_processor()->OnMetadataLoaded(syncer::SyncError(), 103 type_processor()->OnMetadataLoaded(SyncError(), db_.CreateMetadataBatch());
105 db_.CreateMetadataBatch());
106 } 104 }
107 105
108 void OnPendingCommitDataLoaded() { 106 void OnPendingCommitDataLoaded() {
109 DCHECK(!data_callback_.is_null()); 107 DCHECK(!data_callback_.is_null());
110 data_callback_.Run(); 108 data_callback_.Run();
111 data_callback_.Reset(); 109 data_callback_.Reset();
112 } 110 }
113 111
114 void OnSyncStarting() { 112 void OnSyncStarting() {
115 std::unique_ptr<syncer::DataTypeErrorHandlerMock> error_handler = 113 std::unique_ptr<DataTypeErrorHandlerMock> error_handler =
116 base::MakeUnique<syncer::DataTypeErrorHandlerMock>(); 114 base::MakeUnique<DataTypeErrorHandlerMock>();
117 error_handler_ = error_handler.get(); 115 error_handler_ = error_handler.get();
118 type_processor()->OnSyncStarting( 116 type_processor()->OnSyncStarting(
119 std::move(error_handler), 117 std::move(error_handler),
120 base::Bind(&SharedModelTypeProcessorTest::OnReadyToConnect, 118 base::Bind(&SharedModelTypeProcessorTest::OnReadyToConnect,
121 base::Unretained(this))); 119 base::Unretained(this)));
122 } 120 }
123 121
124 void DisconnectSync() { 122 void DisconnectSync() {
125 type_processor()->DisconnectSync(); 123 type_processor()->DisconnectSync();
126 worker_ = nullptr; 124 worker_ = nullptr;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 169 }
172 170
173 // Return the number of entities the processor has metadata for. 171 // Return the number of entities the processor has metadata for.
174 size_t ProcessorEntityCount() const { 172 size_t ProcessorEntityCount() const {
175 DCHECK(type_processor()); 173 DCHECK(type_processor());
176 return type_processor()->entities_.size(); 174 return type_processor()->entities_.size();
177 } 175 }
178 176
179 // Sets the error type that OnReadyToConnect (our StartCallback) expects to 177 // Sets the error type that OnReadyToConnect (our StartCallback) expects to
180 // receive. 178 // receive.
181 void ExpectStartError(syncer::SyncError::ErrorType error_type) { 179 void ExpectStartError(SyncError::ErrorType error_type) {
182 DCHECK(expected_start_error_ == syncer::SyncError::UNSET); 180 DCHECK(expected_start_error_ == SyncError::UNSET);
183 expected_start_error_ = error_type; 181 expected_start_error_ = error_type;
184 } 182 }
185 183
186 MockModelTypeWorker* worker() { return worker_; } 184 MockModelTypeWorker* worker() { return worker_; }
187 185
188 SharedModelTypeProcessor* type_processor() const { 186 SharedModelTypeProcessor* type_processor() const {
189 return static_cast<SharedModelTypeProcessor*>(change_processor()); 187 return static_cast<SharedModelTypeProcessor*>(change_processor());
190 } 188 }
191 189
192 syncer::DataTypeErrorHandlerMock* error_handler() { 190 DataTypeErrorHandlerMock* error_handler() {
193 DCHECK(error_handler_); 191 DCHECK(error_handler_);
194 return error_handler_; 192 return error_handler_;
195 } 193 }
196 194
197 int merge_call_count() const { return merge_call_count_; } 195 int merge_call_count() const { return merge_call_count_; }
198 196
199 private: 197 private:
200 void CheckPostConditions() override { 198 void CheckPostConditions() override {
201 FakeModelTypeService::CheckPostConditions(); 199 FakeModelTypeService::CheckPostConditions();
202 DCHECK(data_callback_.is_null()); 200 DCHECK(data_callback_.is_null());
203 DCHECK_EQ(syncer::SyncError::UNSET, expected_start_error_); 201 DCHECK_EQ(SyncError::UNSET, expected_start_error_);
204 } 202 }
205 203
206 void OnReadyToConnect(syncer::SyncError error, 204 void OnReadyToConnect(SyncError error,
207 std::unique_ptr<ActivationContext> context) { 205 std::unique_ptr<ActivationContext> context) {
208 if (expected_start_error_ != syncer::SyncError::UNSET) { 206 if (expected_start_error_ != SyncError::UNSET) {
209 EXPECT_TRUE(error.IsSet()); 207 EXPECT_TRUE(error.IsSet());
210 EXPECT_EQ(expected_start_error_, error.error_type()); 208 EXPECT_EQ(expected_start_error_, error.error_type());
211 EXPECT_EQ(nullptr, context); 209 EXPECT_EQ(nullptr, context);
212 expected_start_error_ = syncer::SyncError::UNSET; 210 expected_start_error_ = SyncError::UNSET;
213 return; 211 return;
214 } 212 }
215 213
216 std::unique_ptr<MockModelTypeWorker> worker( 214 std::unique_ptr<MockModelTypeWorker> worker(
217 new MockModelTypeWorker(context->data_type_state, type_processor())); 215 new MockModelTypeWorker(context->data_type_state, type_processor()));
218 // Keep an unsafe pointer to the commit queue the processor will use. 216 // Keep an unsafe pointer to the commit queue the processor will use.
219 worker_ = worker.get(); 217 worker_ = worker.get();
220 // The context contains a proxy to the processor, but this call is 218 // The context contains a proxy to the processor, but this call is
221 // side-stepping that completely and connecting directly to the real 219 // side-stepping that completely and connecting directly to the real
222 // processor, since these tests are single-threaded and don't need proxies. 220 // processor, since these tests are single-threaded and don't need proxies.
223 type_processor()->ConnectSync(std::move(worker)); 221 type_processor()->ConnectSync(std::move(worker));
224 } 222 }
225 223
226 // FakeModelTypeService overrides. 224 // FakeModelTypeService overrides.
227 225
228 syncer::SyncError MergeSyncData(std::unique_ptr<MetadataChangeList> mcl, 226 SyncError MergeSyncData(std::unique_ptr<MetadataChangeList> mcl,
229 EntityDataMap entity_data_map) override { 227 EntityDataMap entity_data_map) override {
230 merge_call_count_++; 228 merge_call_count_++;
231 return FakeModelTypeService::MergeSyncData(std::move(mcl), entity_data_map); 229 return FakeModelTypeService::MergeSyncData(std::move(mcl), entity_data_map);
232 } 230 }
233 231
234 void CaptureDataCallback(DataCallback callback, 232 void CaptureDataCallback(DataCallback callback,
235 syncer::SyncError error, 233 SyncError error,
236 std::unique_ptr<DataBatch> data) { 234 std::unique_ptr<DataBatch> data) {
237 data_callback_ = base::Bind(callback, error, base::Passed(std::move(data))); 235 data_callback_ = base::Bind(callback, error, base::Passed(std::move(data)));
238 } 236 }
239 237
240 void GetData(StorageKeyList keys, DataCallback callback) override { 238 void GetData(StorageKeyList keys, DataCallback callback) override {
241 FakeModelTypeService::GetData( 239 FakeModelTypeService::GetData(
242 keys, base::Bind(&SharedModelTypeProcessorTest::CaptureDataCallback, 240 keys, base::Bind(&SharedModelTypeProcessorTest::CaptureDataCallback,
243 base::Unretained(this), callback)); 241 base::Unretained(this), callback));
244 } 242 }
245 243
246 // This sets ThreadTaskRunnerHandle on the current thread, which the type 244 // This sets ThreadTaskRunnerHandle on the current thread, which the type
247 // processor will pick up as the sync task runner. 245 // processor will pick up as the sync task runner.
248 base::MessageLoop sync_loop_; 246 base::MessageLoop sync_loop_;
249 247
250 // The current mock queue, which is owned by |type_processor()|. 248 // The current mock queue, which is owned by |type_processor()|.
251 MockModelTypeWorker* worker_; 249 MockModelTypeWorker* worker_;
252 250
253 // Stores the data callback between GetData() and OnPendingCommitDataLoaded(). 251 // Stores the data callback between GetData() and OnPendingCommitDataLoaded().
254 base::Closure data_callback_; 252 base::Closure data_callback_;
255 253
256 // The processor's error handler. 254 // The processor's error handler.
257 syncer::DataTypeErrorHandlerMock* error_handler_; 255 DataTypeErrorHandlerMock* error_handler_;
258 256
259 // The error to expect in OnReadyToConnect(). 257 // The error to expect in OnReadyToConnect().
260 syncer::SyncError::ErrorType expected_start_error_ = syncer::SyncError::UNSET; 258 SyncError::ErrorType expected_start_error_ = SyncError::UNSET;
261 259
262 // The number of times MergeSyncData has been called. 260 // The number of times MergeSyncData has been called.
263 int merge_call_count_ = 0; 261 int merge_call_count_ = 0;
264 }; 262 };
265 263
266 // Test that an initial sync handles local and remote items properly. 264 // Test that an initial sync handles local and remote items properly.
267 TEST_F(SharedModelTypeProcessorTest, InitialSync) { 265 TEST_F(SharedModelTypeProcessorTest, InitialSync) {
268 CreateChangeProcessor(); 266 CreateChangeProcessor();
269 OnMetadataLoaded(); 267 OnMetadataLoaded();
270 OnSyncStarting(); 268 OnSyncStarting();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 EXPECT_EQ(2U, db().data_count()); 308 EXPECT_EQ(2U, db().data_count());
311 EXPECT_EQ(2U, db().metadata_count()); 309 EXPECT_EQ(2U, db().metadata_count());
312 } 310 }
313 311
314 // Test that an error during the merge is propagated to the error handler. 312 // Test that an error during the merge is propagated to the error handler.
315 TEST_F(SharedModelTypeProcessorTest, InitialSyncError) { 313 TEST_F(SharedModelTypeProcessorTest, InitialSyncError) {
316 CreateChangeProcessor(); 314 CreateChangeProcessor();
317 OnMetadataLoaded(); 315 OnMetadataLoaded();
318 OnSyncStarting(); 316 OnSyncStarting();
319 317
320 SetServiceError(syncer::SyncError::DATATYPE_ERROR); 318 SetServiceError(SyncError::DATATYPE_ERROR);
321 error_handler()->ExpectError(syncer::SyncError::DATATYPE_ERROR); 319 error_handler()->ExpectError(SyncError::DATATYPE_ERROR);
322 worker()->UpdateFromServer(); 320 worker()->UpdateFromServer();
323 } 321 }
324 322
325 // Test that errors before it's called are passed to |start_callback| correctly. 323 // Test that errors before it's called are passed to |start_callback| correctly.
326 TEST_F(SharedModelTypeProcessorTest, StartErrors) { 324 TEST_F(SharedModelTypeProcessorTest, StartErrors) {
327 CreateChangeProcessor(); 325 CreateChangeProcessor();
328 type_processor()->OnMetadataLoaded( 326 type_processor()->OnMetadataLoaded(CreateSyncError(SyncError::DATATYPE_ERROR),
329 CreateSyncError(syncer::SyncError::DATATYPE_ERROR), nullptr); 327 nullptr);
330 ExpectStartError(syncer::SyncError::DATATYPE_ERROR); 328 ExpectStartError(SyncError::DATATYPE_ERROR);
331 OnSyncStarting(); 329 OnSyncStarting();
332 330
333 // Test OnSyncStarting happening first. 331 // Test OnSyncStarting happening first.
334 ResetState(); 332 ResetState();
335 CreateChangeProcessor(); 333 CreateChangeProcessor();
336 OnSyncStarting(); 334 OnSyncStarting();
337 ExpectStartError(syncer::SyncError::DATATYPE_ERROR); 335 ExpectStartError(SyncError::DATATYPE_ERROR);
338 type_processor()->OnMetadataLoaded( 336 type_processor()->OnMetadataLoaded(CreateSyncError(SyncError::DATATYPE_ERROR),
339 CreateSyncError(syncer::SyncError::DATATYPE_ERROR), nullptr); 337 nullptr);
340 338
341 // Test an error loading pending data. 339 // Test an error loading pending data.
342 ResetStateWriteItem(kKey1, kValue1); 340 ResetStateWriteItem(kKey1, kValue1);
343 SetServiceError(syncer::SyncError::DATATYPE_ERROR); 341 SetServiceError(SyncError::DATATYPE_ERROR);
344 InitializeToMetadataLoaded(); 342 InitializeToMetadataLoaded();
345 OnPendingCommitDataLoaded(); 343 OnPendingCommitDataLoaded();
346 ExpectStartError(syncer::SyncError::DATATYPE_ERROR); 344 ExpectStartError(SyncError::DATATYPE_ERROR);
347 OnSyncStarting(); 345 OnSyncStarting();
348 } 346 }
349 347
350 // This test covers race conditions during loading pending data. All cases 348 // This test covers race conditions during loading pending data. All cases
351 // start with no processor and one acked (committed to the server) item with a 349 // start with no processor and one acked (committed to the server) item with a
352 // pending commit. There are three different events that can occur in any order 350 // pending commit. There are three different events that can occur in any order
353 // once metadata is loaded: 351 // once metadata is loaded:
354 // 352 //
355 // - Pending commit data is loaded. 353 // - Pending commit data is loaded.
356 // - Sync gets connected. 354 // - Sync gets connected.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 EXPECT_EQ(1, acked_metadata.sequence_number()); 599 EXPECT_EQ(1, acked_metadata.sequence_number());
602 EXPECT_EQ(1, acked_metadata.acked_sequence_number()); 600 EXPECT_EQ(1, acked_metadata.acked_sequence_number());
603 EXPECT_EQ(1, acked_metadata.server_version()); 601 EXPECT_EQ(1, acked_metadata.server_version());
604 } 602 }
605 603
606 // Test that an error applying metadata changes from a commit response is 604 // Test that an error applying metadata changes from a commit response is
607 // propagated to the error handler. 605 // propagated to the error handler.
608 TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) { 606 TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) {
609 InitializeToReadyState(); 607 InitializeToReadyState();
610 WriteItem(kKey1, kValue1); 608 WriteItem(kKey1, kValue1);
611 SetServiceError(syncer::SyncError::DATATYPE_ERROR); 609 SetServiceError(SyncError::DATATYPE_ERROR);
612 error_handler()->ExpectError(syncer::SyncError::DATATYPE_ERROR); 610 error_handler()->ExpectError(SyncError::DATATYPE_ERROR);
613 worker()->AckOnePendingCommit(); 611 worker()->AckOnePendingCommit();
614 } 612 }
615 613
616 // The purpose of this test case is to test setting |client_tag_hash| and |id| 614 // The purpose of this test case is to test setting |client_tag_hash| and |id|
617 // on the EntityData object as we pass it into the Put method of the processor. 615 // on the EntityData object as we pass it into the Put method of the processor.
618 TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemWithOverrides) { 616 TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemWithOverrides) {
619 const std::string kId1 = "cid1"; 617 const std::string kId1 = "cid1";
620 const std::string kId2 = "cid2"; 618 const std::string kId2 = "cid2";
621 619
622 InitializeToReadyState(); 620 InitializeToReadyState();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 EXPECT_EQ(1, metadata.server_version()); 764 EXPECT_EQ(1, metadata.server_version());
767 EXPECT_TRUE(metadata.has_creation_time()); 765 EXPECT_TRUE(metadata.has_creation_time());
768 EXPECT_TRUE(metadata.has_modification_time()); 766 EXPECT_TRUE(metadata.has_modification_time());
769 EXPECT_TRUE(metadata.has_specifics_hash()); 767 EXPECT_TRUE(metadata.has_specifics_hash());
770 } 768 }
771 769
772 // Test that an error applying changes from a server update is 770 // Test that an error applying changes from a server update is
773 // propagated to the error handler. 771 // propagated to the error handler.
774 TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) { 772 TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) {
775 InitializeToReadyState(); 773 InitializeToReadyState();
776 SetServiceError(syncer::SyncError::DATATYPE_ERROR); 774 SetServiceError(SyncError::DATATYPE_ERROR);
777 error_handler()->ExpectError(syncer::SyncError::DATATYPE_ERROR); 775 error_handler()->ExpectError(SyncError::DATATYPE_ERROR);
778 worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1)); 776 worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1));
779 } 777 }
780 778
781 // Thoroughly tests the data generated by a server item creation. 779 // Thoroughly tests the data generated by a server item creation.
782 TEST_F(SharedModelTypeProcessorTest, ServerUpdateItem) { 780 TEST_F(SharedModelTypeProcessorTest, ServerUpdateItem) {
783 InitializeToReadyState(); 781 InitializeToReadyState();
784 782
785 // Local add writes data and metadata; ack writes metadata again. 783 // Local add writes data and metadata; ack writes metadata again.
786 WriteItemAndAck(kKey1, kValue1); 784 WriteItemAndAck(kKey1, kValue1);
787 EXPECT_EQ(1U, db().data_change_count()); 785 EXPECT_EQ(1U, db().data_change_count());
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 OnPendingCommitDataLoaded(); 1105 OnPendingCommitDataLoaded();
1108 ASSERT_EQ(3U, worker()->GetNumPendingCommits()); 1106 ASSERT_EQ(3U, worker()->GetNumPendingCommits());
1109 worker()->ExpectNthPendingCommit(2, kHash1, specifics1); 1107 worker()->ExpectNthPendingCommit(2, kHash1, specifics1);
1110 } 1108 }
1111 1109
1112 // Test that an error loading pending commit data for re-encryption is 1110 // Test that an error loading pending commit data for re-encryption is
1113 // propagated to the error handler. 1111 // propagated to the error handler.
1114 TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) { 1112 TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) {
1115 InitializeToReadyState(); 1113 InitializeToReadyState();
1116 WriteItemAndAck(kKey1, kValue1); 1114 WriteItemAndAck(kKey1, kValue1);
1117 SetServiceError(syncer::SyncError::DATATYPE_ERROR); 1115 SetServiceError(SyncError::DATATYPE_ERROR);
1118 worker()->UpdateWithEncryptionKey("k1"); 1116 worker()->UpdateWithEncryptionKey("k1");
1119 error_handler()->ExpectError(syncer::SyncError::DATATYPE_ERROR); 1117 error_handler()->ExpectError(SyncError::DATATYPE_ERROR);
1120 OnPendingCommitDataLoaded(); 1118 OnPendingCommitDataLoaded();
1121 } 1119 }
1122 1120
1123 // Test receipt of updates with new and old keys. 1121 // Test receipt of updates with new and old keys.
1124 TEST_F(SharedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) { 1122 TEST_F(SharedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) {
1125 InitializeToReadyState(); 1123 InitializeToReadyState();
1126 1124
1127 // Receive an unencrypted update. 1125 // Receive an unencrypted update.
1128 worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1)); 1126 worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1));
1129 ASSERT_EQ(0U, worker()->GetNumPendingCommits()); 1127 ASSERT_EQ(0U, worker()->GetNumPendingCommits());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 worker()->ExpectNthPendingCommit(0, kHash1, specifics2); 1267 worker()->ExpectNthPendingCommit(0, kHash1, specifics2);
1270 1268
1271 UpdateResponseDataList update; 1269 UpdateResponseDataList update;
1272 update.push_back(worker()->GenerateUpdateData(kHash1, specifics1, 1, "k1")); 1270 update.push_back(worker()->GenerateUpdateData(kHash1, specifics1, 1, "k1"));
1273 worker()->UpdateWithEncryptionKey("k1", update); 1271 worker()->UpdateWithEncryptionKey("k1", update);
1274 1272
1275 EXPECT_EQ(2U, worker()->GetNumPendingCommits()); 1273 EXPECT_EQ(2U, worker()->GetNumPendingCommits());
1276 worker()->ExpectNthPendingCommit(1, kHash1, specifics2); 1274 worker()->ExpectNthPendingCommit(1, kHash1, specifics2);
1277 } 1275 }
1278 1276
1279 } // namespace syncer_v2 1277 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core/shared_model_type_processor.cc ('k') | components/sync/core/simple_metadata_change_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698