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

Unified Diff: components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Chromeos fix Created 3 years, 11 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: components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc
diff --git a/components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc b/components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc
index b10c7d56f093f308f89710855367f5c2d4df8d4b..bcdf618f9dba948ed9de7cb131e9023125725b3b 100644
--- a/components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc
+++ b/components/ntp_snippets/sessions/tab_delegate_sync_adapter_unittest.cc
@@ -57,11 +57,12 @@ class MockOpenTabsUIDelegate : public OpenTabsUIDelegate {
class TabDelegateSyncAdapterTest : public Test {
public:
- TabDelegateSyncAdapterTest() : adapter_(&service_) {
+ TabDelegateSyncAdapterTest() : adapter_(service()) {
adapter_.SubscribeForForeignTabChange(base::Bind(
&TabDelegateSyncAdapterTest::OnChange, base::Unretained(this)));
}
+ syncer::SyncService* service() { return &service_; }
SyncServiceObserver* observer() { return &adapter_; }
void SetHasOpenTabs(bool is_enabled) {
@@ -85,28 +86,28 @@ class TabDelegateSyncAdapterTest : public Test {
// having open tabs.
TEST_F(TabDelegateSyncAdapterTest, CallbackCount) {
ASSERT_EQ(0, CallbackCount());
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(0, CallbackCount());
SetHasOpenTabs(true);
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(1, CallbackCount());
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(1, CallbackCount());
SetHasOpenTabs(false);
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(2, CallbackCount());
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(2, CallbackCount());
// OnSyncCycleCompleted should behave like OnStateChanged.
- observer()->OnSyncCycleCompleted();
+ observer()->OnSyncCycleCompleted(service());
EXPECT_EQ(2, CallbackCount());
SetHasOpenTabs(true);
- observer()->OnSyncCycleCompleted();
+ observer()->OnSyncCycleCompleted(service());
EXPECT_EQ(3, CallbackCount());
- observer()->OnSyncCycleCompleted();
+ observer()->OnSyncCycleCompleted(service());
EXPECT_EQ(3, CallbackCount());
}
@@ -114,26 +115,26 @@ TEST_F(TabDelegateSyncAdapterTest, CallbackCount) {
TEST_F(TabDelegateSyncAdapterTest, OnSyncConfigurationCompleted) {
ASSERT_EQ(0, CallbackCount());
- observer()->OnSyncConfigurationCompleted();
+ observer()->OnSyncConfigurationCompleted(service());
EXPECT_EQ(0, CallbackCount());
SetHasOpenTabs(true);
- observer()->OnSyncConfigurationCompleted();
+ observer()->OnSyncConfigurationCompleted(service());
EXPECT_EQ(0, CallbackCount());
}
// OnForeignSessionUpdated should always trigger a callback.
TEST_F(TabDelegateSyncAdapterTest, OnForeignSessionUpdated) {
ASSERT_EQ(0, CallbackCount());
- observer()->OnForeignSessionUpdated();
+ observer()->OnForeignSessionUpdated(service());
EXPECT_EQ(1, CallbackCount());
- observer()->OnForeignSessionUpdated();
+ observer()->OnForeignSessionUpdated(service());
EXPECT_EQ(2, CallbackCount());
SetHasOpenTabs(true);
- observer()->OnForeignSessionUpdated();
+ observer()->OnForeignSessionUpdated(service());
EXPECT_EQ(3, CallbackCount());
- observer()->OnForeignSessionUpdated();
+ observer()->OnForeignSessionUpdated(service());
EXPECT_EQ(4, CallbackCount());
}
@@ -141,10 +142,10 @@ TEST_F(TabDelegateSyncAdapterTest, OnForeignSessionUpdated) {
// OnStateChanged should not trigger a callback.
TEST_F(TabDelegateSyncAdapterTest, OnForeignSessionUpdatedUpdatesState) {
SetHasOpenTabs(true);
- observer()->OnForeignSessionUpdated();
+ observer()->OnForeignSessionUpdated(service());
EXPECT_EQ(1, CallbackCount());
- observer()->OnStateChanged();
+ observer()->OnStateChanged(service());
EXPECT_EQ(1, CallbackCount());
}

Powered by Google App Engine
This is Rietveld 408576698