Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sessions/ordered_commit_set.h" | 5 #include "sync/sessions/ordered_commit_set.h" |
| 6 #include "sync/test/engine/test_id_factory.h" | 6 #include "sync/test/engine/test_id_factory.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using std::vector; | 9 using std::vector; |
| 10 | 10 |
| 11 namespace syncer { | |
| 12 namespace sessions { | |
| 13 namespace { | |
|
rlarocque
2012/07/02 18:42:02
This (anonymous namespace) looks like a good idea.
akalin
2012/07/02 18:44:53
We should. ODR violations in test helper class na
| |
| 14 | |
| 11 class OrderedCommitSetTest : public testing::Test { | 15 class OrderedCommitSetTest : public testing::Test { |
| 12 public: | 16 public: |
| 13 OrderedCommitSetTest() { | 17 OrderedCommitSetTest() { |
| 14 routes_[syncable::BOOKMARKS] = syncer::GROUP_UI; | 18 routes_[syncable::BOOKMARKS] = syncer::GROUP_UI; |
| 15 routes_[syncable::PREFERENCES] = syncer::GROUP_UI; | 19 routes_[syncable::PREFERENCES] = syncer::GROUP_UI; |
| 16 routes_[syncable::AUTOFILL] = syncer::GROUP_DB; | 20 routes_[syncable::AUTOFILL] = syncer::GROUP_DB; |
| 17 routes_[syncable::TOP_LEVEL_FOLDER] = syncer::GROUP_PASSIVE; | 21 routes_[syncable::TOP_LEVEL_FOLDER] = syncer::GROUP_PASSIVE; |
| 18 } | 22 } |
| 19 protected: | 23 protected: |
| 20 syncer::TestIdFactory ids_; | 24 syncer::TestIdFactory ids_; |
| 21 syncer::ModelSafeRoutingInfo routes_; | 25 syncer::ModelSafeRoutingInfo routes_; |
| 22 }; | 26 }; |
| 23 | 27 |
| 24 namespace syncer { | |
| 25 namespace sessions { | |
| 26 | |
| 27 TEST_F(OrderedCommitSetTest, Projections) { | 28 TEST_F(OrderedCommitSetTest, Projections) { |
| 28 vector<syncable::Id> expected; | 29 vector<syncable::Id> expected; |
| 29 for (int i = 0; i < 8; i++) | 30 for (int i = 0; i < 8; i++) |
| 30 expected.push_back(ids_.NewLocalId()); | 31 expected.push_back(ids_.NewLocalId()); |
| 31 | 32 |
| 32 OrderedCommitSet commit_set1(routes_), commit_set2(routes_); | 33 OrderedCommitSet commit_set1(routes_), commit_set2(routes_); |
| 33 commit_set1.AddCommitItem(0, expected[0], syncable::BOOKMARKS); | 34 commit_set1.AddCommitItem(0, expected[0], syncable::BOOKMARKS); |
| 34 commit_set1.AddCommitItem(1, expected[1], syncable::BOOKMARKS); | 35 commit_set1.AddCommitItem(1, expected[1], syncable::BOOKMARKS); |
| 35 commit_set1.AddCommitItem(2, expected[2], syncable::PREFERENCES); | 36 commit_set1.AddCommitItem(2, expected[2], syncable::PREFERENCES); |
| 36 // Duplicates should be dropped. | 37 // Duplicates should be dropped. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 | 121 |
| 121 ASSERT_TRUE(commit_set.Empty()); | 122 ASSERT_TRUE(commit_set.Empty()); |
| 122 | 123 |
| 123 commit_set.AddCommitItem(0, ids_.NewLocalId(), syncable::AUTOFILL); | 124 commit_set.AddCommitItem(0, ids_.NewLocalId(), syncable::AUTOFILL); |
| 124 ASSERT_EQ(static_cast<size_t>(1), commit_set.Size()); | 125 ASSERT_EQ(static_cast<size_t>(1), commit_set.Size()); |
| 125 | 126 |
| 126 commit_set.Clear(); | 127 commit_set.Clear(); |
| 127 ASSERT_TRUE(commit_set.Empty()); | 128 ASSERT_TRUE(commit_set.Empty()); |
| 128 } | 129 } |
| 129 | 130 |
| 131 } // namespace | |
| 130 } // namespace sessions | 132 } // namespace sessions |
| 131 } // namespace syncer | 133 } // namespace syncer |
| 132 | |
| OLD | NEW |