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

Unified Diff: sync/sessions/ordered_commit_set_unittest.cc

Issue 23694004: sync: Remove IDs from OrderedCommitSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/sessions/ordered_commit_set.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/sessions/ordered_commit_set_unittest.cc
diff --git a/sync/sessions/ordered_commit_set_unittest.cc b/sync/sessions/ordered_commit_set_unittest.cc
index 4bf1d6156b0ed23b4ad94c1a4bb5af10954ddbed..4aca4f406c7d95f9143bbe0d2a7e29479ee9b8fd 100644
--- a/sync/sessions/ordered_commit_set_unittest.cc
+++ b/sync/sessions/ordered_commit_set_unittest.cc
@@ -26,90 +26,91 @@ class OrderedCommitSetTest : public testing::Test {
};
TEST_F(OrderedCommitSetTest, Projections) {
- vector<syncable::Id> expected;
- for (int i = 0; i < 8; i++)
- expected.push_back(ids_.NewLocalId());
+ vector<int64> expected;
+ for (int64 i = 0; i < 8; i++)
+ expected.push_back(i);
OrderedCommitSet commit_set1(routes_), commit_set2(routes_);
- commit_set1.AddCommitItem(0, expected[0], BOOKMARKS);
- commit_set1.AddCommitItem(1, expected[1], BOOKMARKS);
- commit_set1.AddCommitItem(2, expected[2], PREFERENCES);
+ commit_set1.AddCommitItem(expected[0], BOOKMARKS);
+ commit_set1.AddCommitItem(expected[1], BOOKMARKS);
+ commit_set1.AddCommitItem(expected[2], PREFERENCES);
// Duplicates should be dropped.
- commit_set1.AddCommitItem(2, expected[2], PREFERENCES);
- commit_set1.AddCommitItem(3, expected[3], SESSIONS);
- commit_set1.AddCommitItem(4, expected[4], SESSIONS);
- commit_set2.AddCommitItem(7, expected[7], AUTOFILL);
- commit_set2.AddCommitItem(6, expected[6], AUTOFILL);
- commit_set2.AddCommitItem(5, expected[5], AUTOFILL);
+ commit_set1.AddCommitItem(expected[2], PREFERENCES);
+ commit_set1.AddCommitItem(expected[3], SESSIONS);
+ commit_set1.AddCommitItem(expected[4], SESSIONS);
+ commit_set2.AddCommitItem(expected[7], AUTOFILL);
+ commit_set2.AddCommitItem(expected[6], AUTOFILL);
+ commit_set2.AddCommitItem(expected[5], AUTOFILL);
// Add something in set1 to set2, which should get dropped by AppendReverse.
- commit_set2.AddCommitItem(0, expected[0], BOOKMARKS);
+ commit_set2.AddCommitItem(expected[0], BOOKMARKS);
commit_set1.AppendReverse(commit_set2);
+ EXPECT_EQ(8U, commit_set1.Size());
+
// First, we should verify the projections are correct. Second, we want to
// do the same verification after truncating by 1. Next, try truncating
// the set to a size of 4, so that the DB projection is wiped out and
// PASSIVE has one element removed. Finally, truncate to 1 so only UI is
// remaining.
- int j = 0;
- do {
- SCOPED_TRACE(::testing::Message("Iteration j = ") << j);
- vector<syncable::Id> all_ids = commit_set1.GetAllCommitIds();
- EXPECT_EQ(expected.size(), all_ids.size());
- for (size_t i = 0; i < expected.size(); i++) {
- SCOPED_TRACE(::testing::Message("CommitSet mismatch at iteration i = ")
- << i);
+ std::vector<size_t> sizes;
+ sizes.push_back(8);
+ sizes.push_back(7);
+ sizes.push_back(4);
+ sizes.push_back(1);
+ for (std::vector<size_t>::iterator it = sizes.begin();
+ it != sizes.end(); ++it) {
+ commit_set1.Truncate(*it);
+ size_t expected_size = *it;
+
+ SCOPED_TRACE(::testing::Message("Iteration size = ") << *it);
+ std::vector<int64> all_ids = commit_set1.GetAllCommitHandles();
+ EXPECT_EQ(expected_size, all_ids.size());
+ for (size_t i = 0; i < expected_size; i++) {
EXPECT_TRUE(expected[i] == all_ids[i]);
- EXPECT_TRUE(expected[i] == commit_set1.GetCommitIdAt(i));
+ EXPECT_TRUE(expected[i] == commit_set1.GetCommitHandleAt(i));
}
OrderedCommitSet::Projection p1, p2, p3;
p1 = commit_set1.GetCommitIdProjection(GROUP_UI);
p2 = commit_set1.GetCommitIdProjection(GROUP_PASSIVE);
p3 = commit_set1.GetCommitIdProjection(GROUP_DB);
- EXPECT_TRUE(p1.size() + p2.size() + p3.size() == expected.size()) << "Sum"
+ EXPECT_TRUE(p1.size() + p2.size() + p3.size() == expected_size) << "Sum"
<< "of sizes of projections should equal full expected size!";
for (size_t i = 0; i < p1.size(); i++) {
SCOPED_TRACE(::testing::Message("UI projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p1[i]] == commit_set1.GetCommitIdAt(p1[i]))
+ EXPECT_TRUE(expected[p1[i]] == commit_set1.GetCommitHandleAt(p1[i]))
<< "expected[p1[i]] = " << expected[p1[i]]
- << ", commit_set1[p1[i]] = " << commit_set1.GetCommitIdAt(p1[i]);
+ << ", commit_set1[p1[i]] = " << commit_set1.GetCommitHandleAt(p1[i]);
}
for (size_t i = 0; i < p2.size(); i++) {
SCOPED_TRACE(::testing::Message("PASSIVE projection mismatch at i = ")
<< i);
- EXPECT_TRUE(expected[p2[i]] == commit_set1.GetCommitIdAt(p2[i]))
+ EXPECT_TRUE(expected[p2[i]] == commit_set1.GetCommitHandleAt(p2[i]))
<< "expected[p2[i]] = " << expected[p2[i]]
- << ", commit_set1[p2[i]] = " << commit_set1.GetCommitIdAt(p2[i]);
+ << ", commit_set1[p2[i]] = " << commit_set1.GetCommitHandleAt(p2[i]);
}
for (size_t i = 0; i < p3.size(); i++) {
SCOPED_TRACE(::testing::Message("DB projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p3[i]] == commit_set1.GetCommitIdAt(p3[i]))
+ EXPECT_TRUE(expected[p3[i]] == commit_set1.GetCommitHandleAt(p3[i]))
<< "expected[p3[i]] = " << expected[p3[i]]
- << ", commit_set1[p3[i]] = " << commit_set1.GetCommitIdAt(p3[i]);
+ << ", commit_set1[p3[i]] = " << commit_set1.GetCommitHandleAt(p3[i]);
}
-
- int cut_to_size = 7 - 3 * j++;
- if (cut_to_size < 0)
- break;
-
- expected.resize(cut_to_size);
- commit_set1.Truncate(cut_to_size);
- } while (true);
+ }
}
TEST_F(OrderedCommitSetTest, HasBookmarkCommitId) {
OrderedCommitSet commit_set(routes_);
- commit_set.AddCommitItem(0, ids_.NewLocalId(), AUTOFILL);
- commit_set.AddCommitItem(1, ids_.NewLocalId(), SESSIONS);
+ commit_set.AddCommitItem(0, AUTOFILL);
+ commit_set.AddCommitItem(1, SESSIONS);
EXPECT_FALSE(commit_set.HasBookmarkCommitId());
- commit_set.AddCommitItem(2, ids_.NewLocalId(), PREFERENCES);
- commit_set.AddCommitItem(3, ids_.NewLocalId(), PREFERENCES);
+ commit_set.AddCommitItem(2, PREFERENCES);
+ commit_set.AddCommitItem(3, PREFERENCES);
EXPECT_FALSE(commit_set.HasBookmarkCommitId());
- commit_set.AddCommitItem(4, ids_.NewLocalId(), BOOKMARKS);
+ commit_set.AddCommitItem(4, BOOKMARKS);
EXPECT_TRUE(commit_set.HasBookmarkCommitId());
commit_set.Truncate(4);
@@ -121,7 +122,7 @@ TEST_F(OrderedCommitSetTest, AddAndRemoveEntries) {
ASSERT_TRUE(commit_set.Empty());
- commit_set.AddCommitItem(0, ids_.NewLocalId(), AUTOFILL);
+ commit_set.AddCommitItem(0, AUTOFILL);
ASSERT_EQ(static_cast<size_t>(1), commit_set.Size());
commit_set.Clear();
« no previous file with comments | « sync/sessions/ordered_commit_set.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698