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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1073 |
1074 // Test config tasks don't run during normal mode. | 1074 // Test config tasks don't run during normal mode. |
1075 // TODO(tim): Implement this test and then the functionality! | 1075 // TODO(tim): Implement this test and then the functionality! |
1076 TEST_F(SyncSchedulerTest, DISABLED_NoConfigDuringNormal) { | 1076 TEST_F(SyncSchedulerTest, DISABLED_NoConfigDuringNormal) { |
1077 } | 1077 } |
1078 | 1078 |
1079 // Test that starting the syncer thread without a valid connection doesn't | 1079 // Test that starting the syncer thread without a valid connection doesn't |
1080 // break things when a connection is detected. | 1080 // break things when a connection is detected. |
1081 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { | 1081 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { |
1082 connection()->SetServerNotReachable(); | 1082 connection()->SetServerNotReachable(); |
| 1083 connection()->UpdateConnectionStatus(); |
1083 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 1084 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
1084 .WillOnce(Invoke(sessions::test_util::SimulateDownloadUpdatesFailed)) | 1085 .WillOnce(Invoke(sessions::test_util::SimulateConnectionFailure)) |
1085 .WillOnce(QuitLoopNowAction()); | 1086 .WillOnce(QuitLoopNowAction()); |
1086 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1087 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
1087 MessageLoop::current()->RunAllPending(); | 1088 MessageLoop::current()->RunAllPending(); |
1088 | 1089 |
1089 scheduler()->ScheduleNudge( | 1090 scheduler()->ScheduleNudge( |
1090 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); | 1091 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); |
1091 // Should save the nudge for until after the server is reachable. | 1092 // Should save the nudge for until after the server is reachable. |
1092 MessageLoop::current()->RunAllPending(); | 1093 MessageLoop::current()->RunAllPending(); |
1093 | 1094 |
1094 connection()->SetServerReachable(); | 1095 connection()->SetServerReachable(); |
| 1096 connection()->UpdateConnectionStatus(); |
1095 scheduler()->OnConnectionStatusChange(); | 1097 scheduler()->OnConnectionStatusChange(); |
1096 MessageLoop::current()->RunAllPending(); | 1098 MessageLoop::current()->RunAllPending(); |
1097 } | 1099 } |
1098 | 1100 |
1099 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { | 1101 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { |
1100 ModelSafeRoutingInfo info; | 1102 ModelSafeRoutingInfo info; |
1101 EXPECT_TRUE(info == context()->previous_session_routing_info()); | 1103 EXPECT_TRUE(info == context()->previous_session_routing_info()); |
1102 ModelSafeRoutingInfo expected; | 1104 ModelSafeRoutingInfo expected; |
1103 context()->registrar()->GetModelSafeRoutingInfo(&expected); | 1105 context()->registrar()->GetModelSafeRoutingInfo(&expected); |
1104 ASSERT_FALSE(expected.empty()); | 1106 ASSERT_FALSE(expected.empty()); |
1105 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); | 1107 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); |
1106 | 1108 |
1107 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1109 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
1108 RunLoop(); | 1110 RunLoop(); |
1109 | 1111 |
1110 scheduler()->ScheduleNudge( | 1112 scheduler()->ScheduleNudge( |
1111 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); | 1113 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); |
1112 PumpLoop(); | 1114 PumpLoop(); |
1113 // Pump again to run job. | 1115 // Pump again to run job. |
1114 PumpLoop(); | 1116 PumpLoop(); |
1115 | 1117 |
1116 StopSyncScheduler(); | 1118 StopSyncScheduler(); |
1117 | 1119 |
1118 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1120 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
1119 } | 1121 } |
1120 | 1122 |
1121 } // namespace browser_sync | 1123 } // namespace browser_sync |
OLD | NEW |