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

Unified Diff: sync/notifier/p2p_invalidator_unittest.cc

Issue 10875064: Rename SyncNotifier->Invalidator and SyncNotifierObserver->InvalidationHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to ToT for landing Created 8 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/notifier/p2p_invalidator.cc ('k') | sync/notifier/p2p_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/p2p_invalidator_unittest.cc
diff --git a/sync/notifier/p2p_notifier_unittest.cc b/sync/notifier/p2p_invalidator_unittest.cc
similarity index 78%
rename from sync/notifier/p2p_notifier_unittest.cc
rename to sync/notifier/p2p_invalidator_unittest.cc
index 6a62038bb6710e8bfb0b686a3de0ec2752f44f9e..c169cdfefaef8b0cd02370743f5f18d9a6bdfb8e 100644
--- a/sync/notifier/p2p_notifier_unittest.cc
+++ b/sync/notifier/p2p_invalidator_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/notifier/p2p_notifier.h"
+#include "sync/notifier/p2p_invalidator.h"
#include <cstddef>
#include "jingle/notifier/listener/fake_push_client.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/base/model_type_state_map.h"
-#include "sync/notifier/fake_sync_notifier_observer.h"
+#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/object_id_state_map_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,19 +17,19 @@ namespace syncer {
namespace {
-class P2PNotifierTest : public testing::Test {
+class P2PInvalidatorTest : public testing::Test {
protected:
- P2PNotifierTest()
+ P2PInvalidatorTest()
: fake_push_client_(new notifier::FakePushClient()),
p2p_notifier_(
scoped_ptr<notifier::PushClient>(fake_push_client_),
NOTIFY_OTHERS),
next_sent_notification_to_reflect_(0) {
- p2p_notifier_.RegisterHandler(&fake_observer_);
+ p2p_notifier_.RegisterHandler(&fake_handler_);
}
- virtual ~P2PNotifierTest() {
- p2p_notifier_.UnregisterHandler(&fake_observer_);
+ virtual ~P2PInvalidatorTest() {
+ p2p_notifier_.UnregisterHandler(&fake_handler_);
}
ModelTypeStateMap MakeStateMap(ModelTypeSet types) {
@@ -50,15 +50,15 @@ class P2PNotifierTest : public testing::Test {
// Owned by |p2p_notifier_|.
notifier::FakePushClient* fake_push_client_;
- P2PNotifier p2p_notifier_;
- FakeSyncNotifierObserver fake_observer_;
+ P2PInvalidator p2p_notifier_;
+ FakeInvalidationHandler fake_handler_;
private:
size_t next_sent_notification_to_reflect_;
};
// Make sure the P2PNotificationTarget <-> string conversions work.
-TEST_F(P2PNotifierTest, P2PNotificationTarget) {
+TEST_F(P2PInvalidatorTest, P2PNotificationTarget) {
for (int i = FIRST_NOTIFICATION_TARGET;
i <= LAST_NOTIFICATION_TARGET; ++i) {
P2PNotificationTarget target = static_cast<P2PNotificationTarget>(i);
@@ -70,7 +70,7 @@ TEST_F(P2PNotifierTest, P2PNotificationTarget) {
}
// Make sure notification targeting works correctly.
-TEST_F(P2PNotifierTest, P2PNotificationDataIsTargeted) {
+TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) {
{
const P2PNotificationData notification_data(
"sender", NOTIFY_SELF, ModelTypeSet());
@@ -96,7 +96,7 @@ TEST_F(P2PNotifierTest, P2PNotificationDataIsTargeted) {
// Make sure the P2PNotificationData <-> string conversions work for a
// default-constructed P2PNotificationData.
-TEST_F(P2PNotifierTest, P2PNotificationDataDefault) {
+TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
const P2PNotificationData notification_data;
EXPECT_TRUE(notification_data.IsTargeted(""));
EXPECT_FALSE(notification_data.IsTargeted("other1"));
@@ -114,7 +114,7 @@ TEST_F(P2PNotifierTest, P2PNotificationDataDefault) {
// Make sure the P2PNotificationData <-> string conversions work for a
// non-default-constructed P2PNotificationData.
-TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) {
+TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) {
const ModelTypeSet changed_types(BOOKMARKS, THEMES);
const P2PNotificationData notification_data(
"sender", NOTIFY_ALL, changed_types);
@@ -133,14 +133,14 @@ TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) {
EXPECT_TRUE(notification_data.Equals(notification_data_parsed));
}
-// Set up the P2PNotifier, simulate a successful connection, and send
+// Set up the P2PInvalidator, simulate a successful connection, and send
// a notification with the default target (NOTIFY_OTHERS). The
// observer should receive only a notification from the call to
// UpdateEnabledTypes().
-TEST_F(P2PNotifierTest, NotificationsBasic) {
+TEST_F(P2PInvalidatorTest, NotificationsBasic) {
const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
- p2p_notifier_.UpdateRegisteredIds(&fake_observer_,
+ p2p_notifier_.UpdateRegisteredIds(&fake_handler_,
ModelTypeSetToObjectIdSet(enabled_types));
p2p_notifier_.SetUniqueId("sender");
@@ -162,35 +162,35 @@ TEST_F(P2PNotifierTest, NotificationsBasic) {
ReflectSentNotifications();
fake_push_client_->EnableNotifications();
EXPECT_EQ(NO_NOTIFICATION_ERROR,
- fake_observer_.GetNotificationsDisabledReason());
+ fake_handler_.GetNotificationsDisabledReason());
ReflectSentNotifications();
- EXPECT_EQ(1, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(1, fake_handler_.GetNotificationCount());
EXPECT_THAT(
ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)),
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
- EXPECT_EQ(REMOTE_NOTIFICATION, fake_observer_.GetLastNotificationSource());
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
+ EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource());
// Sent with target NOTIFY_OTHERS so should not be propagated to
- // |fake_observer_|.
+ // |fake_handler_|.
{
ModelTypeSet changed_types(THEMES, APPS);
p2p_notifier_.SendNotification(changed_types);
}
ReflectSentNotifications();
- EXPECT_EQ(1, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(1, fake_handler_.GetNotificationCount());
}
-// Set up the P2PNotifier and send out notifications with various
+// Set up the P2PInvalidator and send out notifications with various
// target settings. The notifications received by the observer should
// be consistent with the target settings.
-TEST_F(P2PNotifierTest, SendNotificationData) {
+TEST_F(P2PInvalidatorTest, SendNotificationData) {
const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
const ModelTypeSet changed_types(THEMES, APPS);
const ModelTypeSet expected_types(THEMES);
- p2p_notifier_.UpdateRegisteredIds(&fake_observer_,
+ p2p_notifier_.UpdateRegisteredIds(&fake_handler_,
ModelTypeSetToObjectIdSet(enabled_types));
p2p_notifier_.SetUniqueId("sender");
@@ -199,19 +199,19 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
ReflectSentNotifications();
fake_push_client_->EnableNotifications();
EXPECT_EQ(NO_NOTIFICATION_ERROR,
- fake_observer_.GetNotificationsDisabledReason());
+ fake_handler_.GetNotificationsDisabledReason());
ReflectSentNotifications();
- EXPECT_EQ(1, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(1, fake_handler_.GetNotificationCount());
EXPECT_THAT(
ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)),
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
- EXPECT_EQ(REMOTE_NOTIFICATION, fake_observer_.GetLastNotificationSource());
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
+ EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource());
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(P2PNotificationData());
ReflectSentNotifications();
- EXPECT_EQ(1, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(1, fake_handler_.GetNotificationCount());
const ObjectIdStateMap& expected_ids =
ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types));
@@ -220,67 +220,67 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_SELF, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(2, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(2, fake_handler_.GetNotificationCount());
EXPECT_THAT(
expected_ids,
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_SELF, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(2, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(2, fake_handler_.GetNotificationCount());
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_SELF, ModelTypeSet()));
ReflectSentNotifications();
- EXPECT_EQ(2, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(2, fake_handler_.GetNotificationCount());
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_OTHERS, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(2, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(2, fake_handler_.GetNotificationCount());
// Should be propagated.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(3, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(3, fake_handler_.GetNotificationCount());
EXPECT_THAT(
expected_ids,
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_OTHERS, ModelTypeSet()));
ReflectSentNotifications();
- EXPECT_EQ(3, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(3, fake_handler_.GetNotificationCount());
// Should be propagated.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_ALL, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(4, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(4, fake_handler_.GetNotificationCount());
EXPECT_THAT(
expected_ids,
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
// Should be propagated.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_ALL, changed_types));
ReflectSentNotifications();
- EXPECT_EQ(5, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(5, fake_handler_.GetNotificationCount());
EXPECT_THAT(
expected_ids,
- Eq(fake_observer_.GetLastNotificationIdStateMap()));
+ Eq(fake_handler_.GetLastNotificationIdStateMap()));
// Should be dropped.
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_ALL, ModelTypeSet()));
ReflectSentNotifications();
- EXPECT_EQ(5, fake_observer_.GetNotificationCount());
+ EXPECT_EQ(5, fake_handler_.GetNotificationCount());
}
} // namespace
« no previous file with comments | « sync/notifier/p2p_invalidator.cc ('k') | sync/notifier/p2p_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698