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

Side by Side Diff: sync/engine/sync_scheduler_unittest.cc

Issue 11341030: sync: reland scheduler ownership refactoring, now with less crash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(BOOKMARKS), FROM_HERE); 1126 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(BOOKMARKS), FROM_HERE);
1127 // Should save the nudge for until after the server is reachable. 1127 // Should save the nudge for until after the server is reachable.
1128 MessageLoop::current()->RunAllPending(); 1128 MessageLoop::current()->RunAllPending();
1129 1129
1130 connection()->SetServerReachable(); 1130 connection()->SetServerReachable();
1131 connection()->UpdateConnectionStatus(); 1131 connection()->UpdateConnectionStatus();
1132 scheduler()->OnConnectionStatusChange(); 1132 scheduler()->OnConnectionStatusChange();
1133 MessageLoop::current()->RunAllPending(); 1133 MessageLoop::current()->RunAllPending();
1134 } 1134 }
1135 1135
1136 TEST_F(SyncSchedulerTest, ServerConnectionChangeDuringBackoff) {
1137 UseMockDelayProvider();
1138 EXPECT_CALL(*delay(), GetDelay(_))
1139 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(0)));
1140
1141 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
1142 connection()->SetServerNotReachable();
1143 connection()->UpdateConnectionStatus();
1144
1145 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
1146 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConnectionFailure),
1147 Return(true)))
1148 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
1149 QuitLoopNowAction()));
1150
1151 scheduler()->ScheduleNudgeAsync(
1152 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(BOOKMARKS), FROM_HERE);
1153
1154 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry.
1155 ASSERT_TRUE(scheduler()->IsBackingOff());
1156
1157 // Before we run the scheduled canary, trigger a server connection change.
1158 connection()->SetServerReachable();
1159 connection()->UpdateConnectionStatus();
1160 scheduler()->OnConnectionStatusChange();
1161 MessageLoop::current()->RunAllPending();
1162 }
1163
1136 } // namespace syncer 1164 } // namespace syncer
OLDNEW
« sync/engine/sync_scheduler_impl.cc ('K') | « sync/engine/sync_scheduler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698