OLD | NEW |
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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE); | 1286 scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE); |
1287 | 1287 |
1288 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry. | 1288 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry. |
1289 ASSERT_TRUE(scheduler()->IsBackingOff()); | 1289 ASSERT_TRUE(scheduler()->IsBackingOff()); |
1290 | 1290 |
1291 // Before we run the scheduled canary, trigger a server connection change. | 1291 // Before we run the scheduled canary, trigger a server connection change. |
1292 scheduler()->OnConnectionStatusChange(); | 1292 scheduler()->OnConnectionStatusChange(); |
1293 connection()->SetServerReachable(); | 1293 connection()->SetServerReachable(); |
1294 connection()->UpdateConnectionStatus(); | 1294 connection()->UpdateConnectionStatus(); |
1295 scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE); | 1295 scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE); |
1296 MessageLoop::current()->RunUntilIdle(); | 1296 base::MessageLoop::current()->RunUntilIdle(); |
1297 } | 1297 } |
1298 | 1298 |
1299 // Tests that we don't crash trying to run two canaries at once if we receive | 1299 // Tests that we don't crash trying to run two canaries at once if we receive |
1300 // extra connection status change notifications. See crbug.com/190085. | 1300 // extra connection status change notifications. See crbug.com/190085. |
1301 TEST_F(SyncSchedulerTest, DoubleCanaryInConfigure) { | 1301 TEST_F(SyncSchedulerTest, DoubleCanaryInConfigure) { |
1302 EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)) | 1302 EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)) |
1303 .WillRepeatedly(DoAll( | 1303 .WillRepeatedly(DoAll( |
1304 Invoke(sessions::test_util::SimulateConnectionFailure), | 1304 Invoke(sessions::test_util::SimulateConnectionFailure), |
1305 Return(true))); | 1305 Return(true))); |
1306 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 1306 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
1307 connection()->SetServerNotReachable(); | 1307 connection()->SetServerNotReachable(); |
1308 connection()->UpdateConnectionStatus(); | 1308 connection()->UpdateConnectionStatus(); |
1309 | 1309 |
1310 ModelTypeSet model_types(BOOKMARKS); | 1310 ModelTypeSet model_types(BOOKMARKS); |
1311 CallbackCounter counter; | 1311 CallbackCounter counter; |
1312 ConfigurationParams params( | 1312 ConfigurationParams params( |
1313 GetUpdatesCallerInfo::RECONFIGURATION, | 1313 GetUpdatesCallerInfo::RECONFIGURATION, |
1314 model_types, | 1314 model_types, |
1315 TypesToRoutingInfo(model_types), | 1315 TypesToRoutingInfo(model_types), |
1316 base::Bind(&CallbackCounter::Callback, base::Unretained(&counter))); | 1316 base::Bind(&CallbackCounter::Callback, base::Unretained(&counter))); |
1317 scheduler()->ScheduleConfiguration(params); | 1317 scheduler()->ScheduleConfiguration(params); |
1318 | 1318 |
1319 scheduler()->OnConnectionStatusChange(); | 1319 scheduler()->OnConnectionStatusChange(); |
1320 scheduler()->OnConnectionStatusChange(); | 1320 scheduler()->OnConnectionStatusChange(); |
1321 | 1321 |
1322 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry. | 1322 PumpLoop(); // Run the nudge, that will fail and schedule a quick retry. |
1323 } | 1323 } |
1324 | 1324 |
1325 } // namespace syncer | 1325 } // namespace syncer |
OLD | NEW |