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

Side by Side Diff: sync/syncable/directory_unittest.cc

Issue 582913002: Make GenericChangeProcessor upload attachments on startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 6 years, 3 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
« no previous file with comments | « sync/syncable/directory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/syncable/directory_unittest.h" 5 #include "sync/syncable/directory_unittest.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/test/values_test_util.h" 8 #include "base/test/values_test_util.h"
9 #include "sync/internal_api/public/base/attachment_id_proto.h" 9 #include "sync/internal_api/public/base/attachment_id_proto.h"
10 #include "sync/syncable/syncable_proto_util.h" 10 #include "sync/syncable/syncable_proto_util.h"
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 SimulateSaveAndReloadDir(); 1712 SimulateSaveAndReloadDir();
1713 ASSERT_TRUE(dir()->IsAttachmentLinked(attachment_id_proto)); 1713 ASSERT_TRUE(dir()->IsAttachmentLinked(attachment_id_proto));
1714 1714
1715 // Delete the second entry, reload the Directory, see that the attachment is 1715 // Delete the second entry, reload the Directory, see that the attachment is
1716 // no loner linked. 1716 // no loner linked.
1717 DeleteEntry(id2); 1717 DeleteEntry(id2);
1718 SimulateSaveAndReloadDir(); 1718 SimulateSaveAndReloadDir();
1719 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id_proto)); 1719 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id_proto));
1720 } 1720 }
1721 1721
1722 TEST_F(SyncableDirectoryTest, Directory_GetAttachmentIdsToUpload) {
1723 // Create one attachment, referenced by two entries.
1724 AttachmentId attachment_id = AttachmentId::Create();
1725 sync_pb::AttachmentIdProto attachment_id_proto = attachment_id.GetProto();
1726 sync_pb::AttachmentMetadata attachment_metadata;
1727 sync_pb::AttachmentMetadataRecord* record = attachment_metadata.add_record();
1728 *record->mutable_id() = attachment_id_proto;
1729 const Id id1 = TestIdFactory::FromNumber(-1);
1730 const Id id2 = TestIdFactory::FromNumber(-2);
1731 CreateEntryWithAttachmentMetadata(
1732 PREFERENCES, "some entry", id1, attachment_metadata);
1733 CreateEntryWithAttachmentMetadata(
1734 PREFERENCES, "some other entry", id2, attachment_metadata);
1735
1736 // See that Directory reports that this attachment is not on the server.
1737 AttachmentIdSet id_set;
1738 {
1739 ReadTransaction trans(FROM_HERE, dir().get());
1740 dir()->GetAttachmentIdsToUpload(&trans, PREFERENCES, &id_set);
1741 }
1742 ASSERT_EQ(1U, id_set.size());
1743 ASSERT_EQ(attachment_id, *id_set.begin());
1744
1745 // Call again, but this time with a ModelType for which there are no entries.
1746 // See that Directory correctly reports that there are none.
1747 {
1748 ReadTransaction trans(FROM_HERE, dir().get());
1749 dir()->GetAttachmentIdsToUpload(&trans, PASSWORDS, &id_set);
1750 }
1751 ASSERT_TRUE(id_set.empty());
1752
1753 // Now, mark the attachment as "on the server" via entry_1.
1754 {
1755 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1756 MutableEntry entry_1(&trans, GET_BY_ID, id1);
1757 entry_1.MarkAttachmentAsOnServer(attachment_id_proto);
1758 }
1759
1760 // See that Directory no longer reports that this attachment is not on the
1761 // server.
1762 {
1763 ReadTransaction trans(FROM_HERE, dir().get());
1764 dir()->GetAttachmentIdsToUpload(&trans, PREFERENCES, &id_set);
1765 }
1766 ASSERT_TRUE(id_set.empty());
1767 }
1768
1722 } // namespace syncable 1769 } // namespace syncable
1723 1770
1724 } // namespace syncer 1771 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698