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

Side by Side Diff: components/sync_driver/startup_controller_unittest.cc

Issue 1789433002: [Sync] Start up immediately when entering the sync setup UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setup
Patch Set: Created 4 years, 9 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync_driver/startup_controller.h" 5 #include "components/sync_driver/startup_controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 controller()->TryStart(); 161 controller()->TryStart();
162 ExpectNotStarted(); 162 ExpectNotStarted();
163 } 163 }
164 164
165 // Test that sync doesn't start until all conditions are met and a 165 // Test that sync doesn't start until all conditions are met and a
166 // data type triggers sync startup. 166 // data type triggers sync startup.
167 TEST_F(StartupControllerTest, DataTypeTriggered) { 167 TEST_F(StartupControllerTest, DataTypeTriggered) {
168 sync_prefs()->SetFirstSetupComplete(); 168 sync_prefs()->SetFirstSetupComplete();
169 signin()->set_account_id(kTestUser); 169 signin()->set_account_id(kTestUser);
170 token_service()->UpdateCredentials(kTestUser, kTestToken); 170 token_service()->UpdateCredentials(kTestUser, kTestToken);
171 controller()->TryStart();
172 ExpectStartDeferred();
173 171
172 // Test a cold start.
174 controller()->OnDataTypeRequestsSyncStartup(syncer::SESSIONS); 173 controller()->OnDataTypeRequestsSyncStartup(syncer::SESSIONS);
175 ExpectStarted(); 174 ExpectStarted();
176 175
176 clear_started();
177 controller()->Reset(syncer::UserTypes());
178 ExpectNotStarted();
179
180 // Test interrupting a deferred start.
Nicolas Zea 2016/03/14 22:42:01 Maybe split this into two separate tests?
maxbogue 2016/03/15 17:41:01 Done.
181 controller()->TryStart();
182 ExpectStartDeferred();
183 controller()->OnDataTypeRequestsSyncStartup(syncer::SESSIONS);
184 ExpectStarted();
185
177 // The fallback timer shouldn't result in another invocation of the closure 186 // The fallback timer shouldn't result in another invocation of the closure
178 // we passed to the StartupController. 187 // we passed to the StartupController.
179 clear_started(); 188 clear_started();
180 base::RunLoop().RunUntilIdle(); 189 base::RunLoop().RunUntilIdle();
181 EXPECT_FALSE(started()); 190 EXPECT_FALSE(started());
182 } 191 }
183 192
184 // Test that the fallback timer starts sync in the event all 193 // Test that the fallback timer starts sync in the event all
185 // conditions are met and no data type requests sync. 194 // conditions are met and no data type requests sync.
186 TEST_F(StartupControllerTest, FallbackTimer) { 195 TEST_F(StartupControllerTest, FallbackTimer) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ExpectNotStarted(); 229 ExpectNotStarted();
221 base::RunLoop().RunUntilIdle(); 230 base::RunLoop().RunUntilIdle();
222 ExpectNotStarted(); 231 ExpectNotStarted();
223 } 232 }
224 233
225 // Test that start isn't deferred when setup is in progress. 234 // Test that start isn't deferred when setup is in progress.
226 TEST_F(StartupControllerTest, NoDeferralWithSetupInProgress) { 235 TEST_F(StartupControllerTest, NoDeferralWithSetupInProgress) {
227 sync_prefs()->SetFirstSetupComplete(); 236 sync_prefs()->SetFirstSetupComplete();
228 signin()->set_account_id(kTestUser); 237 signin()->set_account_id(kTestUser);
229 token_service()->UpdateCredentials(kTestUser, kTestToken); 238 token_service()->UpdateCredentials(kTestUser, kTestToken);
230 controller()->set_setup_in_progress(true); 239
240 // Test a cold start.
241 controller()->SetSetupInProgress(true);
242 ExpectStarted();
243
244 clear_started();
245 controller()->Reset(syncer::UserTypes());
246 controller()->SetSetupInProgress(false);
247 ExpectNotStarted();
248
249 // Test interrupting a deferred start.
Nicolas Zea 2016/03/14 22:42:01 This also seems like it could be two different tes
maxbogue 2016/03/15 17:41:01 Done.
231 controller()->TryStart(); 250 controller()->TryStart();
251 ExpectStartDeferred();
252 controller()->SetSetupInProgress(true);
232 ExpectStarted(); 253 ExpectStarted();
233 } 254 }
234 255
235 // Test that start isn't deferred on the first start but is on restarts. 256 // Test that start isn't deferred on the first start but is on restarts.
236 TEST_F(StartupControllerTest, DeferralOnRestart) { 257 TEST_F(StartupControllerTest, DeferralOnRestart) {
237 signin()->set_account_id(kTestUser); 258 signin()->set_account_id(kTestUser);
238 token_service()->UpdateCredentials(kTestUser, kTestToken); 259 token_service()->UpdateCredentials(kTestUser, kTestToken);
239 controller()->TryStart(); 260 controller()->TryStart();
240 ExpectStarted(); 261 ExpectStarted();
241 262
242 clear_started(); 263 clear_started();
243 controller()->Reset(syncer::UserTypes()); 264 controller()->Reset(syncer::UserTypes());
244 ExpectNotStarted(); 265 ExpectNotStarted();
245 controller()->TryStart(); 266 controller()->TryStart();
246 ExpectStartDeferred(); 267 ExpectStartDeferred();
247 } 268 }
248 269
249 // Test that setup-in-progress tracking is persistent across a Reset. 270 // Test that setup-in-progress tracking is persistent across a Reset.
250 TEST_F(StartupControllerTest, ResetDuringSetup) { 271 TEST_F(StartupControllerTest, ResetDuringSetup) {
251 signin()->set_account_id(kTestUser); 272 signin()->set_account_id(kTestUser);
252 token_service()->UpdateCredentials(kTestUser, kTestToken); 273 token_service()->UpdateCredentials(kTestUser, kTestToken);
253 274
254 // Simulate UI telling us setup is in progress. 275 // Simulate UI telling us setup is in progress.
255 controller()->set_setup_in_progress(true); 276 controller()->SetSetupInProgress(true);
256 277
257 // This could happen if the UI triggers a stop-syncing permanently call. 278 // This could happen if the UI triggers a stop-syncing permanently call.
258 controller()->Reset(syncer::UserTypes()); 279 controller()->Reset(syncer::UserTypes());
259 280
260 // From the UI's point of view, setup is still in progress. 281 // From the UI's point of view, setup is still in progress.
261 EXPECT_TRUE(controller()->IsSetupInProgress()); 282 EXPECT_TRUE(controller()->IsSetupInProgress());
262 } 283 }
263 284
264 } // namespace browser_sync 285 } // namespace browser_sync
OLDNEW
« components/sync_driver/startup_controller.cc ('K') | « components/sync_driver/startup_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698