| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 | 1117 |
| 1118 // Test config tasks don't run during normal mode. | 1118 // Test config tasks don't run during normal mode. |
| 1119 // TODO(tim): Implement this test and then the functionality! | 1119 // TODO(tim): Implement this test and then the functionality! |
| 1120 TEST_F(SyncSchedulerTest, DISABLED_NoConfigDuringNormal) { | 1120 TEST_F(SyncSchedulerTest, DISABLED_NoConfigDuringNormal) { |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 // Test that starting the syncer thread without a valid connection doesn't | 1123 // Test that starting the syncer thread without a valid connection doesn't |
| 1124 // break things when a connection is detected. | 1124 // break things when a connection is detected. |
| 1125 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { | 1125 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { |
| 1126 connection()->SetServerNotReachable(); | 1126 connection()->SetServerNotReachable(); |
| 1127 connection()->UpdateConnectionStatus(); |
| 1127 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 1128 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 1128 .WillOnce(Invoke(sessions::test_util::SimulateDownloadUpdatesFailed)) | 1129 .WillOnce(Invoke(sessions::test_util::SimulateConnectionFailure)) |
| 1129 .WillOnce(QuitLoopNowAction()); | 1130 .WillOnce(QuitLoopNowAction()); |
| 1130 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1131 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1131 MessageLoop::current()->RunAllPending(); | 1132 MessageLoop::current()->RunAllPending(); |
| 1132 | 1133 |
| 1133 scheduler()->ScheduleNudge( | 1134 scheduler()->ScheduleNudge( |
| 1134 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); | 1135 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); |
| 1135 // Should save the nudge for until after the server is reachable. | 1136 // Should save the nudge for until after the server is reachable. |
| 1136 MessageLoop::current()->RunAllPending(); | 1137 MessageLoop::current()->RunAllPending(); |
| 1137 | 1138 |
| 1138 connection()->SetServerReachable(); | 1139 connection()->SetServerReachable(); |
| 1140 connection()->UpdateConnectionStatus(); |
| 1139 scheduler()->OnConnectionStatusChange(); | 1141 scheduler()->OnConnectionStatusChange(); |
| 1140 MessageLoop::current()->RunAllPending(); | 1142 MessageLoop::current()->RunAllPending(); |
| 1141 } | 1143 } |
| 1142 | 1144 |
| 1143 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { | 1145 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { |
| 1144 ModelSafeRoutingInfo info; | 1146 ModelSafeRoutingInfo info; |
| 1145 EXPECT_TRUE(info == context()->previous_session_routing_info()); | 1147 EXPECT_TRUE(info == context()->previous_session_routing_info()); |
| 1146 ModelSafeRoutingInfo expected; | 1148 ModelSafeRoutingInfo expected; |
| 1147 context()->registrar()->GetModelSafeRoutingInfo(&expected); | 1149 context()->registrar()->GetModelSafeRoutingInfo(&expected); |
| 1148 ASSERT_FALSE(expected.empty()); | 1150 ASSERT_FALSE(expected.empty()); |
| 1149 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); | 1151 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); |
| 1150 | 1152 |
| 1151 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1153 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1152 RunLoop(); | 1154 RunLoop(); |
| 1153 | 1155 |
| 1154 scheduler()->ScheduleNudge( | 1156 scheduler()->ScheduleNudge( |
| 1155 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); | 1157 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); |
| 1156 PumpLoop(); | 1158 PumpLoop(); |
| 1157 // Pump again to run job. | 1159 // Pump again to run job. |
| 1158 PumpLoop(); | 1160 PumpLoop(); |
| 1159 | 1161 |
| 1160 StopSyncScheduler(); | 1162 StopSyncScheduler(); |
| 1161 | 1163 |
| 1162 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1164 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
| 1163 } | 1165 } |
| 1164 | 1166 |
| 1165 } // namespace browser_sync | 1167 } // namespace browser_sync |
| OLD | NEW |