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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 workers_.begin(); it != workers_.end(); ++it) { | 113 workers_.begin(); it != workers_.end(); ++it) { |
114 workers.push_back(it->get()); | 114 workers.push_back(it->get()); |
115 } | 115 } |
116 | 116 |
117 connection_.reset(new MockConnectionManager(directory())); | 117 connection_.reset(new MockConnectionManager(directory())); |
118 connection_->SetServerReachable(); | 118 connection_->SetServerReachable(); |
119 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); | 119 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
120 context_.reset(new SyncSessionContext( | 120 context_.reset(new SyncSessionContext( |
121 connection_.get(), directory(), routing_info, workers, | 121 connection_.get(), directory(), routing_info, workers, |
122 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), | 122 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), |
123 std::vector<SyncEngineEventListener*>(), NULL, NULL)); | 123 std::vector<SyncEngineEventListener*>(), NULL, NULL, |
| 124 true /* enable keystore encryption */)); |
124 context_->set_notifications_enabled(true); | 125 context_->set_notifications_enabled(true); |
125 context_->set_account_name("Test"); | 126 context_->set_account_name("Test"); |
126 scheduler_.reset( | 127 scheduler_.reset( |
127 new SyncScheduler("TestSyncScheduler", context(), syncer_)); | 128 new SyncScheduler("TestSyncScheduler", context(), syncer_)); |
128 } | 129 } |
129 | 130 |
130 SyncScheduler* scheduler() { return scheduler_.get(); } | 131 SyncScheduler* scheduler() { return scheduler_.get(); } |
131 MockSyncer* syncer() { return syncer_; } | 132 MockSyncer* syncer() { return syncer_; } |
132 MockDelayProvider* delay() { return delay_; } | 133 MockDelayProvider* delay() { return delay_; } |
133 MockConnectionManager* connection() { return connection_.get(); } | 134 MockConnectionManager* connection() { return connection_.get(); } |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 scheduler()->ScheduleNudgeAsync( | 1060 scheduler()->ScheduleNudgeAsync( |
1060 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); | 1061 zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE); |
1061 PumpLoop(); | 1062 PumpLoop(); |
1062 // Pump again to run job. | 1063 // Pump again to run job. |
1063 PumpLoop(); | 1064 PumpLoop(); |
1064 | 1065 |
1065 StopSyncScheduler(); | 1066 StopSyncScheduler(); |
1066 Mock::VerifyAndClearExpectations(syncer()); | 1067 Mock::VerifyAndClearExpectations(syncer()); |
1067 | 1068 |
1068 // Configuration. | 1069 // Configuration. |
1069 EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)) | 1070 EXPECT_CALL(*syncer(), SyncShare(_, GET_ENCRYPTION_KEY, APPLY_UPDATES)) |
1070 .WillOnce(Invoke(sessions::test_util::SimulateSuccess)); | 1071 .WillOnce(Invoke(sessions::test_util::SimulateSuccess)); |
1071 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 1072 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
1072 | 1073 |
1073 syncer::ModelTypeSet model_types(syncer::BOOKMARKS); | 1074 syncer::ModelTypeSet model_types(syncer::BOOKMARKS); |
1074 CallbackCounter counter; | 1075 CallbackCounter counter; |
1075 ConfigurationParams params( | 1076 ConfigurationParams params( |
1076 GetUpdatesCallerInfo::RECONFIGURATION, | 1077 GetUpdatesCallerInfo::RECONFIGURATION, |
1077 model_types, | 1078 model_types, |
1078 TypesToRoutingInfo(model_types), | 1079 TypesToRoutingInfo(model_types), |
1079 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY, | 1080 ConfigurationParams::KEYSTORE_KEY_NEEDED, |
1080 base::Bind(&CallbackCounter::Callback, base::Unretained(&counter))); | 1081 base::Bind(&CallbackCounter::Callback, base::Unretained(&counter))); |
1081 ASSERT_TRUE(scheduler()->ScheduleConfiguration(params)); | 1082 ASSERT_TRUE(scheduler()->ScheduleConfiguration(params)); |
1082 ASSERT_EQ(1, counter.times_called()); | 1083 ASSERT_EQ(1, counter.times_called()); |
1083 // Runs directly so no need to pump the loop. | 1084 // Runs directly so no need to pump the loop. |
1084 StopSyncScheduler(); | 1085 StopSyncScheduler(); |
1085 Mock::VerifyAndClearExpectations(syncer()); | 1086 Mock::VerifyAndClearExpectations(syncer()); |
1086 | 1087 |
1087 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1088 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
1088 | 1089 |
1089 // Poll. | 1090 // Poll. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 // Should save the nudge for until after the server is reachable. | 1124 // Should save the nudge for until after the server is reachable. |
1124 MessageLoop::current()->RunAllPending(); | 1125 MessageLoop::current()->RunAllPending(); |
1125 | 1126 |
1126 connection()->SetServerReachable(); | 1127 connection()->SetServerReachable(); |
1127 connection()->UpdateConnectionStatus(); | 1128 connection()->UpdateConnectionStatus(); |
1128 scheduler()->OnConnectionStatusChange(); | 1129 scheduler()->OnConnectionStatusChange(); |
1129 MessageLoop::current()->RunAllPending(); | 1130 MessageLoop::current()->RunAllPending(); |
1130 } | 1131 } |
1131 | 1132 |
1132 } // namespace browser_sync | 1133 } // namespace browser_sync |
OLD | NEW |