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 "sync/engine/directory_commit_contribution.h" | 5 #include "sync/engine/directory_commit_contribution.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <set> | 9 #include <set> |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "sync/internal_api/public/base/attachment_id_proto.h" | 13 #include "sync/internal_api/public/base/attachment_id_proto.h" |
12 #include "sync/sessions/status_controller.h" | 14 #include "sync/sessions/status_controller.h" |
13 #include "sync/syncable/entry.h" | 15 #include "sync/syncable/entry.h" |
14 #include "sync/syncable/mutable_entry.h" | 16 #include "sync/syncable/mutable_entry.h" |
15 #include "sync/syncable/syncable_read_transaction.h" | 17 #include "sync/syncable/syncable_read_transaction.h" |
16 #include "sync/syncable/syncable_write_transaction.h" | 18 #include "sync/syncable/syncable_write_transaction.h" |
(...skipping 12 matching lines...) Expand all Loading... |
29 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 31 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
30 CreateTypeRoot(&trans, dir(), PREFERENCES); | 32 CreateTypeRoot(&trans, dir(), PREFERENCES); |
31 CreateTypeRoot(&trans, dir(), EXTENSIONS); | 33 CreateTypeRoot(&trans, dir(), EXTENSIONS); |
32 CreateTypeRoot(&trans, dir(), ARTICLES); | 34 CreateTypeRoot(&trans, dir(), ARTICLES); |
33 CreateTypeRoot(&trans, dir(), BOOKMARKS); | 35 CreateTypeRoot(&trans, dir(), BOOKMARKS); |
34 } | 36 } |
35 | 37 |
36 void TearDown() override { dir_maker_.TearDown(); } | 38 void TearDown() override { dir_maker_.TearDown(); } |
37 | 39 |
38 protected: | 40 protected: |
39 int64 CreateUnsyncedItemWithAttachments( | 41 int64_t CreateUnsyncedItemWithAttachments( |
40 syncable::WriteTransaction* trans, | 42 syncable::WriteTransaction* trans, |
41 ModelType type, | 43 ModelType type, |
42 const std::string& tag, | 44 const std::string& tag, |
43 const sync_pb::AttachmentMetadata& attachment_metadata) { | 45 const sync_pb::AttachmentMetadata& attachment_metadata) { |
44 // For bookmarks specify the Bookmarks root folder as the parent; | 46 // For bookmarks specify the Bookmarks root folder as the parent; |
45 // for other types leave the parent ID empty | 47 // for other types leave the parent ID empty |
46 syncable::Id parent_id; | 48 syncable::Id parent_id; |
47 if (type == BOOKMARKS) { | 49 if (type == BOOKMARKS) { |
48 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); | 50 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); |
49 parent_id = parent_entry.GetId(); | 51 parent_id = parent_entry.GetId(); |
50 } | 52 } |
51 | 53 |
52 syncable::MutableEntry entry(trans, syncable::CREATE, type, parent_id, tag); | 54 syncable::MutableEntry entry(trans, syncable::CREATE, type, parent_id, tag); |
53 if (attachment_metadata.record_size() > 0) { | 55 if (attachment_metadata.record_size() > 0) { |
54 entry.PutAttachmentMetadata(attachment_metadata); | 56 entry.PutAttachmentMetadata(attachment_metadata); |
55 } | 57 } |
56 entry.PutIsUnsynced(true); | 58 entry.PutIsUnsynced(true); |
57 return entry.GetMetahandle(); | 59 return entry.GetMetahandle(); |
58 } | 60 } |
59 | 61 |
60 int64 CreateUnsyncedItem(syncable::WriteTransaction* trans, | 62 int64_t CreateUnsyncedItem(syncable::WriteTransaction* trans, |
61 ModelType type, | 63 ModelType type, |
62 const std::string& tag) { | 64 const std::string& tag) { |
63 return CreateUnsyncedItemWithAttachments( | 65 return CreateUnsyncedItemWithAttachments( |
64 trans, type, tag, sync_pb::AttachmentMetadata()); | 66 trans, type, tag, sync_pb::AttachmentMetadata()); |
65 } | 67 } |
66 | 68 |
67 int64 CreateSyncedItem(syncable::WriteTransaction* trans, | 69 int64_t CreateSyncedItem(syncable::WriteTransaction* trans, |
68 ModelType type, | 70 ModelType type, |
69 const std::string& tag) { | 71 const std::string& tag) { |
70 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); | 72 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); |
71 syncable::MutableEntry entry( | 73 syncable::MutableEntry entry( |
72 trans, | 74 trans, |
73 syncable::CREATE, | 75 syncable::CREATE, |
74 type, | 76 type, |
75 parent_entry.GetId(), | 77 parent_entry.GetId(), |
76 tag); | 78 tag); |
77 | 79 |
78 entry.PutId(syncable::Id::CreateFromServerId( | 80 entry.PutId(syncable::Id::CreateFromServerId( |
79 id_factory_.NewServerId().GetServerId())); | 81 id_factory_.NewServerId().GetServerId())); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::ObserverList<TypeDebugInfoObserver> type_observers_; | 113 base::ObserverList<TypeDebugInfoObserver> type_observers_; |
112 | 114 |
113 private: | 115 private: |
114 base::MessageLoop loop_; // Neeed to initialize the directory. | 116 base::MessageLoop loop_; // Neeed to initialize the directory. |
115 TestDirectorySetterUpper dir_maker_; | 117 TestDirectorySetterUpper dir_maker_; |
116 }; | 118 }; |
117 | 119 |
118 // Verify that the DirectoryCommitContribution contains only entries of its | 120 // Verify that the DirectoryCommitContribution contains only entries of its |
119 // specified type. | 121 // specified type. |
120 TEST_F(DirectoryCommitContributionTest, GatherByTypes) { | 122 TEST_F(DirectoryCommitContributionTest, GatherByTypes) { |
121 int64 pref1; | 123 int64_t pref1; |
122 { | 124 { |
123 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 125 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
124 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); | 126 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); |
125 CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); | 127 CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); |
126 CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); | 128 CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); |
127 } | 129 } |
128 | 130 |
129 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); | 131 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); |
130 scoped_ptr<DirectoryCommitContribution> cc( | 132 scoped_ptr<DirectoryCommitContribution> cc( |
131 DirectoryCommitContribution::Build(dir(), PREFERENCES, 5, &emitter)); | 133 DirectoryCommitContribution::Build(dir(), PREFERENCES, 5, &emitter)); |
132 ASSERT_EQ(2U, cc->GetNumEntries()); | 134 ASSERT_EQ(2U, cc->GetNumEntries()); |
133 | 135 |
134 const std::vector<int64>& metahandles = cc->metahandles_; | 136 const std::vector<int64_t>& metahandles = cc->metahandles_; |
135 EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) != | 137 EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) != |
136 metahandles.end()); | 138 metahandles.end()); |
137 EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) != | 139 EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) != |
138 metahandles.end()); | 140 metahandles.end()); |
139 | 141 |
140 cc->CleanUp(); | 142 cc->CleanUp(); |
141 } | 143 } |
142 | 144 |
143 // Verify that the DirectoryCommitContributionTest builder function | 145 // Verify that the DirectoryCommitContributionTest builder function |
144 // truncates if necessary. | 146 // truncates if necessary. |
145 TEST_F(DirectoryCommitContributionTest, GatherAndTruncate) { | 147 TEST_F(DirectoryCommitContributionTest, GatherAndTruncate) { |
146 int64 pref1; | 148 int64_t pref1; |
147 int64 pref2; | 149 int64_t pref2; |
148 { | 150 { |
149 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 151 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
150 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); | 152 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); |
151 pref2 = CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); | 153 pref2 = CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); |
152 CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); | 154 CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); |
153 } | 155 } |
154 | 156 |
155 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); | 157 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); |
156 scoped_ptr<DirectoryCommitContribution> cc( | 158 scoped_ptr<DirectoryCommitContribution> cc( |
157 DirectoryCommitContribution::Build(dir(), PREFERENCES, 1, &emitter)); | 159 DirectoryCommitContribution::Build(dir(), PREFERENCES, 1, &emitter)); |
158 ASSERT_EQ(1U, cc->GetNumEntries()); | 160 ASSERT_EQ(1U, cc->GetNumEntries()); |
159 | 161 |
160 int64 only_metahandle = cc->metahandles_[0]; | 162 int64_t only_metahandle = cc->metahandles_[0]; |
161 EXPECT_TRUE(only_metahandle == pref1 || only_metahandle == pref2); | 163 EXPECT_TRUE(only_metahandle == pref1 || only_metahandle == pref2); |
162 | 164 |
163 cc->CleanUp(); | 165 cc->CleanUp(); |
164 } | 166 } |
165 | 167 |
166 // Sanity check for building commits from DirectoryCommitContributions. | 168 // Sanity check for building commits from DirectoryCommitContributions. |
167 // This test makes two CommitContribution objects of different types and uses | 169 // This test makes two CommitContribution objects of different types and uses |
168 // them to initialize a commit message. Then it checks that the contents of the | 170 // them to initialize a commit message. Then it checks that the contents of the |
169 // commit message match those of the directory they came from. | 171 // commit message match those of the directory they came from. |
170 TEST_F(DirectoryCommitContributionTest, PrepareCommit) { | 172 TEST_F(DirectoryCommitContributionTest, PrepareCommit) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 215 } |
214 | 216 |
215 pref_cc->CleanUp(); | 217 pref_cc->CleanUp(); |
216 ext_cc->CleanUp(); | 218 ext_cc->CleanUp(); |
217 } | 219 } |
218 | 220 |
219 // Check that deletion requests include a model type. | 221 // Check that deletion requests include a model type. |
220 // This was not always the case, but was implemented to allow us to loosen some | 222 // This was not always the case, but was implemented to allow us to loosen some |
221 // other restrictions in the protocol. | 223 // other restrictions in the protocol. |
222 TEST_F(DirectoryCommitContributionTest, DeletedItemsWithSpecifics) { | 224 TEST_F(DirectoryCommitContributionTest, DeletedItemsWithSpecifics) { |
223 int64 pref1; | 225 int64_t pref1; |
224 { | 226 { |
225 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 227 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
226 pref1 = CreateSyncedItem(&trans, PREFERENCES, "pref1"); | 228 pref1 = CreateSyncedItem(&trans, PREFERENCES, "pref1"); |
227 syncable::MutableEntry e1(&trans, syncable::GET_BY_HANDLE, pref1); | 229 syncable::MutableEntry e1(&trans, syncable::GET_BY_HANDLE, pref1); |
228 e1.PutIsDel(true); | 230 e1.PutIsDel(true); |
229 e1.PutIsUnsynced(true); | 231 e1.PutIsUnsynced(true); |
230 } | 232 } |
231 | 233 |
232 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); | 234 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); |
233 scoped_ptr<DirectoryCommitContribution> pref_cc( | 235 scoped_ptr<DirectoryCommitContribution> pref_cc( |
234 DirectoryCommitContribution::Build(dir(), PREFERENCES, 25, &emitter)); | 236 DirectoryCommitContribution::Build(dir(), PREFERENCES, 25, &emitter)); |
235 ASSERT_TRUE(pref_cc); | 237 ASSERT_TRUE(pref_cc); |
236 | 238 |
237 sync_pb::ClientToServerMessage message; | 239 sync_pb::ClientToServerMessage message; |
238 pref_cc->AddToCommitMessage(&message); | 240 pref_cc->AddToCommitMessage(&message); |
239 | 241 |
240 const sync_pb::CommitMessage& commit_message = message.commit(); | 242 const sync_pb::CommitMessage& commit_message = message.commit(); |
241 ASSERT_EQ(1, commit_message.entries_size()); | 243 ASSERT_EQ(1, commit_message.entries_size()); |
242 EXPECT_TRUE( | 244 EXPECT_TRUE( |
243 commit_message.entries(0).specifics().has_preference()); | 245 commit_message.entries(0).specifics().has_preference()); |
244 | 246 |
245 pref_cc->CleanUp(); | 247 pref_cc->CleanUp(); |
246 } | 248 } |
247 | 249 |
248 // As ususal, bookmarks are special. Bookmark deletion is special. | 250 // As ususal, bookmarks are special. Bookmark deletion is special. |
249 // Deleted bookmarks include a valid "is folder" bit and their full specifics | 251 // Deleted bookmarks include a valid "is folder" bit and their full specifics |
250 // (especially the meta info, which is what server really wants). | 252 // (especially the meta info, which is what server really wants). |
251 TEST_F(DirectoryCommitContributionTest, DeletedBookmarksWithSpecifics) { | 253 TEST_F(DirectoryCommitContributionTest, DeletedBookmarksWithSpecifics) { |
252 int64 bm1; | 254 int64_t bm1; |
253 { | 255 { |
254 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 256 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
255 bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1"); | 257 bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1"); |
256 syncable::MutableEntry e1(&trans, syncable::GET_BY_HANDLE, bm1); | 258 syncable::MutableEntry e1(&trans, syncable::GET_BY_HANDLE, bm1); |
257 | 259 |
258 e1.PutIsDir(true); | 260 e1.PutIsDir(true); |
259 e1.PutServerIsDir(true); | 261 e1.PutServerIsDir(true); |
260 | 262 |
261 sync_pb::EntitySpecifics specifics; | 263 sync_pb::EntitySpecifics specifics; |
262 sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark(); | 264 sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark(); |
(...skipping 25 matching lines...) Expand all Loading... |
288 ASSERT_EQ(1, entity.specifics().bookmark().meta_info_size()); | 290 ASSERT_EQ(1, entity.specifics().bookmark().meta_info_size()); |
289 EXPECT_EQ("K", entity.specifics().bookmark().meta_info(0).key()); | 291 EXPECT_EQ("K", entity.specifics().bookmark().meta_info(0).key()); |
290 EXPECT_EQ("V", entity.specifics().bookmark().meta_info(0).value()); | 292 EXPECT_EQ("V", entity.specifics().bookmark().meta_info(0).value()); |
291 | 293 |
292 bm_cc->CleanUp(); | 294 bm_cc->CleanUp(); |
293 } | 295 } |
294 | 296 |
295 // Test that bookmarks support hierarchy. | 297 // Test that bookmarks support hierarchy. |
296 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Bookmark) { | 298 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Bookmark) { |
297 // Create a normal-looking bookmark item. | 299 // Create a normal-looking bookmark item. |
298 int64 bm1; | 300 int64_t bm1; |
299 { | 301 { |
300 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 302 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
301 bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1"); | 303 bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1"); |
302 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, bm1); | 304 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, bm1); |
303 | 305 |
304 sync_pb::EntitySpecifics specifics; | 306 sync_pb::EntitySpecifics specifics; |
305 sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark(); | 307 sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark(); |
306 bm_specifics->set_url("http://www.chrome.com"); | 308 bm_specifics->set_url("http://www.chrome.com"); |
307 bm_specifics->set_title("Chrome"); | 309 bm_specifics->set_title("Chrome"); |
308 e.PutSpecifics(specifics); | 310 e.PutSpecifics(specifics); |
(...skipping 14 matching lines...) Expand all Loading... |
323 bm_cc->CleanUp(); | 325 bm_cc->CleanUp(); |
324 | 326 |
325 ASSERT_EQ(1, commit_message.entries_size()); | 327 ASSERT_EQ(1, commit_message.entries_size()); |
326 EXPECT_TRUE(commit_message.entries(0).has_parent_id_string()); | 328 EXPECT_TRUE(commit_message.entries(0).has_parent_id_string()); |
327 EXPECT_FALSE(commit_message.entries(0).parent_id_string().empty()); | 329 EXPECT_FALSE(commit_message.entries(0).parent_id_string().empty()); |
328 } | 330 } |
329 | 331 |
330 // Test that preferences do not support hierarchy. | 332 // Test that preferences do not support hierarchy. |
331 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Preferences) { | 333 TEST_F(DirectoryCommitContributionTest, HierarchySupport_Preferences) { |
332 // Create a normal-looking prefs item. | 334 // Create a normal-looking prefs item. |
333 int64 pref1; | 335 int64_t pref1; |
334 { | 336 { |
335 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 337 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
336 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); | 338 pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); |
337 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, pref1); | 339 syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, pref1); |
338 | 340 |
339 EXPECT_FALSE(e.ShouldMaintainHierarchy()); | 341 EXPECT_FALSE(e.ShouldMaintainHierarchy()); |
340 } | 342 } |
341 | 343 |
342 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); | 344 DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_); |
343 scoped_ptr<DirectoryCommitContribution> pref_cc( | 345 scoped_ptr<DirectoryCommitContribution> pref_cc( |
(...skipping 13 matching lines...) Expand all Loading... |
357 sync_pb::AttachmentMetadataRecord record; | 359 sync_pb::AttachmentMetadataRecord record; |
358 *record.mutable_id() = CreateAttachmentIdProto(0, 0); | 360 *record.mutable_id() = CreateAttachmentIdProto(0, 0); |
359 record.set_is_on_server(is_on_server); | 361 record.set_is_on_server(is_on_server); |
360 *metadata->add_record() = record; | 362 *metadata->add_record() = record; |
361 } | 363 } |
362 | 364 |
363 // Creates some unsynced items, pretends to commit them, and hands back a | 365 // Creates some unsynced items, pretends to commit them, and hands back a |
364 // specially crafted response to the syncer in order to test commit response | 366 // specially crafted response to the syncer in order to test commit response |
365 // processing. The response simulates a succesful commit scenario. | 367 // processing. The response simulates a succesful commit scenario. |
366 TEST_F(DirectoryCommitContributionTest, ProcessCommitResponse) { | 368 TEST_F(DirectoryCommitContributionTest, ProcessCommitResponse) { |
367 int64 pref1_handle; | 369 int64_t pref1_handle; |
368 int64 pref2_handle; | 370 int64_t pref2_handle; |
369 int64 ext1_handle; | 371 int64_t ext1_handle; |
370 { | 372 { |
371 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 373 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
372 pref1_handle = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); | 374 pref1_handle = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); |
373 pref2_handle = CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); | 375 pref2_handle = CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); |
374 ext1_handle = CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); | 376 ext1_handle = CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); |
375 } | 377 } |
376 | 378 |
377 DirectoryTypeDebugInfoEmitter emitter1(PREFERENCES, &type_observers_); | 379 DirectoryTypeDebugInfoEmitter emitter1(PREFERENCES, &type_observers_); |
378 DirectoryTypeDebugInfoEmitter emitter2(EXTENSIONS, &type_observers_); | 380 DirectoryTypeDebugInfoEmitter emitter2(EXTENSIONS, &type_observers_); |
379 scoped_ptr<DirectoryCommitContribution> pref_cc( | 381 scoped_ptr<DirectoryCommitContribution> pref_cc( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 426 } |
425 | 427 |
426 pref_cc->CleanUp(); | 428 pref_cc->CleanUp(); |
427 ext_cc->CleanUp(); | 429 ext_cc->CleanUp(); |
428 } | 430 } |
429 | 431 |
430 // Creates some unsynced items with attachments and verifies that only items | 432 // Creates some unsynced items with attachments and verifies that only items |
431 // where all attachments have been uploaded to the server are eligible to be | 433 // where all attachments have been uploaded to the server are eligible to be |
432 // committed. | 434 // committed. |
433 TEST_F(DirectoryCommitContributionTest, ProcessCommitResponseWithAttachments) { | 435 TEST_F(DirectoryCommitContributionTest, ProcessCommitResponseWithAttachments) { |
434 int64 art1_handle; | 436 int64_t art1_handle; |
435 int64 art2_handle; | 437 int64_t art2_handle; |
436 int64 art3_handle; | 438 int64_t art3_handle; |
437 { | 439 { |
438 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); | 440 syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); |
439 | 441 |
440 // art1 has two attachments, both have been uploaded to the server. art1 is | 442 // art1 has two attachments, both have been uploaded to the server. art1 is |
441 // eligible to be committed. | 443 // eligible to be committed. |
442 sync_pb::AttachmentMetadata art1_attachments; | 444 sync_pb::AttachmentMetadata art1_attachments; |
443 AddAttachment(&art1_attachments, true /* is_on_server */); | 445 AddAttachment(&art1_attachments, true /* is_on_server */); |
444 AddAttachment(&art1_attachments, true /* is_on_server */); | 446 AddAttachment(&art1_attachments, true /* is_on_server */); |
445 art1_handle = CreateUnsyncedItemWithAttachments( | 447 art1_handle = CreateUnsyncedItemWithAttachments( |
446 &trans, ARTICLES, "art1", art1_attachments); | 448 &trans, ARTICLES, "art1", art1_attachments); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 EXPECT_FALSE(a3.GetId().ServerKnows()); | 506 EXPECT_FALSE(a3.GetId().ServerKnows()); |
505 EXPECT_FALSE(a3.GetSyncing()); | 507 EXPECT_FALSE(a3.GetSyncing()); |
506 EXPECT_FALSE(a3.GetDirtySync()); | 508 EXPECT_FALSE(a3.GetDirtySync()); |
507 EXPECT_EQ(0, a3.GetServerVersion()); | 509 EXPECT_EQ(0, a3.GetServerVersion()); |
508 } | 510 } |
509 | 511 |
510 art_cc->CleanUp(); | 512 art_cc->CleanUp(); |
511 } | 513 } |
512 | 514 |
513 } // namespace syncer | 515 } // namespace syncer |
OLD | NEW |