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

Unified Diff: sync/notifier/p2p_invalidator_unittest.cc

Issue 23441042: Refactor common invalidation framework types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sync/notifier/p2p_invalidator_unittest.cc
diff --git a/sync/notifier/p2p_invalidator_unittest.cc b/sync/notifier/p2p_invalidator_unittest.cc
index 24cfe027f6cb83df84f6ba26c8e76fcce64d1476..3cbabaf67f43885895bef794ec731af320334eb9 100644
--- a/sync/notifier/p2p_invalidator_unittest.cc
+++ b/sync/notifier/p2p_invalidator_unittest.cc
@@ -10,7 +10,6 @@
#include "sync/internal_api/public/base/model_type.h"
#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/invalidator_test_template.h"
-#include "sync/notifier/object_id_invalidation_map_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
@@ -98,9 +97,7 @@ class P2PInvalidatorTest : public testing::Test {
ObjectIdInvalidationMap MakeInvalidationMap(ModelTypeSet types) {
ObjectIdInvalidationMap invalidations;
ObjectIdSet ids = ModelTypeSetToObjectIdSet(types);
- return ObjectIdSetToInvalidationMap(ids,
- Invalidation::kUnknownVersion,
- std::string());
+ return ObjectIdInvalidationMap::InvalidateAll(ids);
}
// Simulate receiving all the notifications we sent out since last
@@ -166,10 +163,10 @@ TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
EXPECT_TRUE(notification_data.IsTargeted(std::string()));
EXPECT_FALSE(notification_data.IsTargeted("other1"));
EXPECT_FALSE(notification_data.IsTargeted("other2"));
- EXPECT_TRUE(notification_data.GetIdInvalidationMap().empty());
+ EXPECT_TRUE(notification_data.GetIdInvalidationMap().Empty());
const std::string& notification_data_str = notification_data.ToString();
EXPECT_EQ(
- "{\"idInvalidationMap\":[],\"notificationType\":\"notifySelf\","
+ "{\"invalidations\":[],\"notificationType\":\"notifySelf\","
"\"senderId\":\"\"}", notification_data_str);
P2PNotificationData notification_data_parsed;
@@ -180,27 +177,22 @@ TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
// Make sure the P2PNotificationData <-> string conversions work for a
// non-default-constructed P2PNotificationData.
TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) {
- const ObjectIdInvalidationMap& invalidation_map =
- ObjectIdSetToInvalidationMap(
- ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)),
- Invalidation::kUnknownVersion,
- std::string());
- const P2PNotificationData notification_data(
- "sender", NOTIFY_ALL, invalidation_map);
+ ObjectIdInvalidationMap invalidation_map =
+ MakeInvalidationMap(ModelTypeSet(BOOKMARKS, THEMES));
+ const P2PNotificationData notification_data("sender",
+ NOTIFY_ALL,
+ invalidation_map);
EXPECT_TRUE(notification_data.IsTargeted("sender"));
EXPECT_TRUE(notification_data.IsTargeted("other1"));
EXPECT_TRUE(notification_data.IsTargeted("other2"));
- EXPECT_THAT(invalidation_map,
- Eq(notification_data.GetIdInvalidationMap()));
+ EXPECT_EQ(invalidation_map, notification_data.GetIdInvalidationMap());
const std::string& notification_data_str = notification_data.ToString();
EXPECT_EQ(
- "{\"idInvalidationMap\":["
- "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004},"
- "\"state\":{\"ackHandle\":{\"state\":\"\",\"timestamp\":\"0\"},"
- "\"payload\":\"\",\"version\":\"-1\"}},"
- "{\"objectId\":{\"name\":\"THEME\",\"source\":1004},"
- "\"state\":{\"ackHandle\":{\"state\":\"\",\"timestamp\":\"0\"},"
- "\"payload\":\"\",\"version\":\"-1\"}}"
+ "{\"invalidations\":["
+ "{\"isUnknownVersion\":true,"
+ "\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}},"
+ "{\"isUnknownVersion\":true,"
+ "\"objectId\":{\"name\":\"THEME\",\"source\":1004}}"
"],\"notificationType\":\"notifyAll\","
"\"senderId\":\"sender\"}", notification_data_str);
@@ -248,14 +240,8 @@ TEST_F(P2PInvalidatorTest, NotificationsBasic) {
// Sent with target NOTIFY_OTHERS so should not be propagated to
// |fake_handler_|.
- {
- const ObjectIdInvalidationMap& invalidation_map =
- ObjectIdSetToInvalidationMap(
- ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)),
- Invalidation::kUnknownVersion,
- std::string());
- invalidator->SendInvalidation(invalidation_map);
- }
+ invalidator->SendInvalidation(
+ ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)));
ReflectSentNotifications();
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
@@ -270,9 +256,7 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
const ModelTypeSet expected_types(THEMES);
const ObjectIdInvalidationMap& invalidation_map =
- ObjectIdSetToInvalidationMap(ModelTypeSetToObjectIdSet(changed_types),
- Invalidation::kUnknownVersion,
- std::string());
+ MakeInvalidationMap(changed_types);
P2PInvalidator* const invalidator = delegate_.GetInvalidator();
notifier::FakePushClient* const push_client = delegate_.GetPushClient();
@@ -288,23 +272,23 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
ReflectSentNotifications();
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(MakeInvalidationMap(enabled_types),
- Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_EQ(ModelTypeSetToObjectIdSet(enabled_types),
+ fake_handler_.GetLastInvalidationMap().GetObjectIds());
// Should be dropped.
invalidator->SendNotificationDataForTest(P2PNotificationData());
ReflectSentNotifications();
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
- const ObjectIdInvalidationMap& expected_ids =
- MakeInvalidationMap(expected_types);
+ const ObjectIdSet& expected_ids = ModelTypeSetToObjectIdSet(expected_types);
// Should be propagated.
invalidator->SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_SELF, invalidation_map));
ReflectSentNotifications();
EXPECT_EQ(2, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_EQ(expected_ids,
+ fake_handler_.GetLastInvalidationMap().GetObjectIds());
// Should be dropped.
invalidator->SendNotificationDataForTest(
@@ -329,7 +313,8 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
P2PNotificationData("sender2", NOTIFY_OTHERS, invalidation_map));
ReflectSentNotifications();
EXPECT_EQ(3, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_EQ(expected_ids,
+ fake_handler_.GetLastInvalidationMap().GetObjectIds());
// Should be dropped.
invalidator->SendNotificationDataForTest(
@@ -342,14 +327,16 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
P2PNotificationData("sender", NOTIFY_ALL, invalidation_map));
ReflectSentNotifications();
EXPECT_EQ(4, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_EQ(expected_ids,
+ fake_handler_.GetLastInvalidationMap().GetObjectIds());
// Should be propagated.
invalidator->SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_ALL, invalidation_map));
ReflectSentNotifications();
EXPECT_EQ(5, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_EQ(expected_ids,
+ fake_handler_.GetLastInvalidationMap().GetObjectIds());
// Should be dropped.
invalidator->SendNotificationDataForTest(

Powered by Google App Engine
This is Rietveld 408576698