Index: sync/engine/nudge_tracker_unittest.cc |
diff --git a/sync/engine/nudge_tracker_unittest.cc b/sync/engine/nudge_tracker_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ce84b20dec0cf07c922d301416b40eb72793b008 |
--- /dev/null |
+++ b/sync/engine/nudge_tracker_unittest.cc |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "sync/engine/nudge_tracker.h" |
+ |
+#include "sync/internal_api/public/base/model_type_invalidation_map.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace syncer { |
+ |
+namespace { |
+ |
+ModelTypeSet ParamsMeaningAllEnabledTypes() { |
+ ModelTypeSet request_params(BOOKMARKS, AUTOFILL); |
+ return request_params; |
+} |
+ |
+ModelTypeSet ParamsMeaningJustOneEnabledType() { |
+ return ModelTypeSet(AUTOFILL); |
+} |
+ |
+} // namespace |
+ |
+TEST(NudgeTrackerTest, CoalesceSources) { |
tim (not reviewing)
2013/04/15 22:37:49
Would it be feasible to have a test that demonstra
rlarocque
2013/04/16 01:30:26
Good idea. Done.
|
+ ModelTypeInvalidationMap one_type = |
+ ModelTypeSetToInvalidationMap( |
+ ParamsMeaningJustOneEnabledType(), |
+ std::string()); |
+ ModelTypeInvalidationMap all_types = |
+ ModelTypeSetToInvalidationMap( |
+ ParamsMeaningAllEnabledTypes(), |
+ std::string()); |
+ sessions::SyncSourceInfo source_one( |
+ sync_pb::GetUpdatesCallerInfo::PERIODIC, one_type); |
+ sessions::SyncSourceInfo source_two( |
+ sync_pb::GetUpdatesCallerInfo::LOCAL, all_types); |
+ |
+ NudgeTracker tracker; |
+ EXPECT_TRUE(tracker.IsEmpty()); |
+ |
+ tracker.CoalesceSources(source_one); |
+ EXPECT_EQ(source_one.updates_source, tracker.source_info().updates_source); |
+ |
+ tracker.CoalesceSources(source_two); |
+ EXPECT_EQ(source_two.updates_source, tracker.source_info().updates_source); |
+} |
+ |
+} // namespace syncer |