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

Unified Diff: chrome/browser/sync/engine/syncer_thread_unittest.cc

Issue 2923006: Handle birthday errors by disabling sync and deleting sync data. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « chrome/browser/sync/engine/syncer_thread.cc ('k') | chrome/browser/sync/engine/syncer_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncer_thread_unittest.cc
===================================================================
--- chrome/browser/sync/engine/syncer_thread_unittest.cc (revision 52107)
+++ chrome/browser/sync/engine/syncer_thread_unittest.cc (working copy)
@@ -716,6 +716,43 @@
EXPECT_TRUE(syncer_thread()->Stop(2000));
}
+TEST_F(SyncerThreadWithSyncerTest, StopSyncPermanently) {
+ // The SyncerThread should request an exit from the Syncer and set
+ // conditions for termination.
+ const TimeDelta poll_interval = TimeDelta::FromMilliseconds(10);
+ syncer_thread()->SetSyncerShortPollInterval(poll_interval);
+
+ ListenerMock listener;
+ WaitableEvent sync_cycle_ended_event(false, false);
+ WaitableEvent syncer_thread_exiting_event(false, false);
+ scoped_ptr<ChannelHookup<SyncerEvent> > hookup;
+ hookup.reset(syncer_thread()->relay_channel()->AddObserver(&listener));
+
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::STATUS_CHANGED))).
+ Times(AnyNumber());
+
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNC_CYCLE_ENDED))).
+ Times(AnyNumber()).
+ WillOnce(SignalEvent(&sync_cycle_ended_event));
+
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened,
+ SyncerEvent::STOP_SYNCING_PERMANENTLY)));
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNCER_THREAD_EXITING))).
+ WillOnce(SignalEvent(&syncer_thread_exiting_event));
+
+ EXPECT_TRUE(syncer_thread()->Start());
+ metadb()->Open();
+ ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
+
+ connection()->set_store_birthday("NotYourLuckyDay");
+ ASSERT_TRUE(syncer_thread_exiting_event.TimedWait(max_wait_time_));
+ EXPECT_TRUE(syncer_thread()->Stop(0));
+}
+
TEST_F(SyncerThreadWithSyncerTest, AuthInvalid) {
SyncShareIntercept interceptor;
connection()->SetMidCommitObserver(&interceptor);
@@ -783,6 +820,8 @@
EXPECT_CALL(listener, HandleChannelEvent(
Field(&SyncerEvent::what_happened, SyncerEvent::SYNC_CYCLE_ENDED))).
WillOnce(SignalEvent(&sync_cycle_ended_event));
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNCER_THREAD_EXITING)));
ASSERT_TRUE(syncer_thread()->Start());
metadb()->Open();
ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
@@ -823,6 +862,8 @@
EXPECT_CALL(listener, HandleChannelEvent(
Field(&SyncerEvent::what_happened, SyncerEvent::STATUS_CHANGED))).
Times(AnyNumber());
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNCER_THREAD_EXITING)));
connection()->SetServerNotReachable();
metadb()->Open();
@@ -922,6 +963,9 @@
EXPECT_CALL(listener, HandleChannelEvent(
Field(&SyncerEvent::what_happened, SyncerEvent::SYNC_CYCLE_ENDED))).
WillOnce(SignalEvent(&sync_cycle_ended_event));
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNCER_THREAD_EXITING)));
+
syncer_thread()->NudgeSyncer(0, SyncerThread::kUnknown);
ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
@@ -953,9 +997,11 @@
EXPECT_CALL(listener, HandleChannelEvent(
Field(&SyncerEvent::what_happened, SyncerEvent::SYNC_CYCLE_ENDED))).
WillOnce(SignalEvent(&sync_cycle_ended_event));
+ EXPECT_CALL(listener, HandleChannelEvent(
+ Field(&SyncerEvent::what_happened, SyncerEvent::SYNCER_THREAD_EXITING)));
+
ASSERT_TRUE(Resume(&listener));
ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
-
EXPECT_TRUE(syncer_thread()->Stop(2000));
}
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.cc ('k') | chrome/browser/sync/engine/syncer_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698