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

Side by Side Diff: chrome/browser/browsing_data/passwords_counter_browsertest.cc

Issue 2828083003: Show autofill sync status in CBD (Closed)
Patch Set: fix history test Created 3 years, 7 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/browsing_data/core/counters/passwords_counter.h" 5 #include "components/browsing_data/core/counters/passwords_counter.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/password_manager/password_store_factory.h" 10 #include "chrome/browser/password_manager/password_store_factory.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // We sync all datatypes by default, so starting Sync means that we start 325 // We sync all datatypes by default, so starting Sync means that we start
326 // syncing passwords, and this should restart the counter. 326 // syncing passwords, and this should restart the counter.
327 ASSERT_TRUE(SetupSync()); 327 ASSERT_TRUE(SetupSync());
328 ASSERT_TRUE(sync_service->IsSyncActive()); 328 ASSERT_TRUE(sync_service->IsSyncActive());
329 ASSERT_TRUE(sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS)); 329 ASSERT_TRUE(sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS));
330 WaitForCountingOrConfirmFinished(); 330 WaitForCountingOrConfirmFinished();
331 EXPECT_TRUE(PasswordSyncEnabled()); 331 EXPECT_TRUE(PasswordSyncEnabled());
332 332
333 // We stop syncing passwords in particular. This restarts the counter. 333 // We stop syncing passwords in particular. This restarts the counter.
334 syncer::ModelTypeSet everything_except_passwords = 334 syncer::ModelTypeSet everything_except_passwords =
335 syncer::ModelTypeSet::All(); 335 syncer::UserSelectableTypes();
336 everything_except_passwords.Remove(syncer::PASSWORDS); 336 everything_except_passwords.Remove(syncer::PASSWORDS);
337 auto sync_blocker = sync_service->GetSetupInProgressHandle(); 337 auto sync_blocker = sync_service->GetSetupInProgressHandle();
338 sync_service->ChangePreferredDataTypes(everything_except_passwords); 338 sync_service->OnUserChoseDatatypes(/*sync_everything=*/false,
339 everything_except_passwords);
340 ASSERT_FALSE(sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS));
339 sync_blocker.reset(); 341 sync_blocker.reset();
340 WaitForCountingOrConfirmFinished(); 342 WaitForCountingOrConfirmFinished();
343 ASSERT_FALSE(sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS));
341 EXPECT_FALSE(PasswordSyncEnabled()); 344 EXPECT_FALSE(PasswordSyncEnabled());
342 345
343 // If password sync is not affected, the counter is not restarted. 346 // If password sync is not affected, the counter is not restarted.
344 syncer::ModelTypeSet only_history(syncer::HISTORY_DELETE_DIRECTIVES); 347 syncer::ModelTypeSet only_history(syncer::HISTORY_DELETE_DIRECTIVES);
345 sync_service->ChangePreferredDataTypes(only_history); 348 sync_service->ChangePreferredDataTypes(only_history);
346 sync_blocker = sync_service->GetSetupInProgressHandle(); 349 sync_blocker = sync_service->GetSetupInProgressHandle();
347 sync_service->ChangePreferredDataTypes(only_history); 350 sync_service->ChangePreferredDataTypes(only_history);
348 sync_blocker.reset(); 351 sync_blocker.reset();
349 EXPECT_FALSE(CountingFinishedSinceLastAsked()); 352 EXPECT_FALSE(CountingFinishedSinceLastAsked());
350 353
351 // We start syncing passwords again. This restarts the counter. 354 // We start syncing passwords again. This restarts the counter.
352 sync_blocker = sync_service->GetSetupInProgressHandle(); 355 sync_blocker = sync_service->GetSetupInProgressHandle();
353 sync_service->ChangePreferredDataTypes(syncer::ModelTypeSet::All()); 356 sync_service->ChangePreferredDataTypes(syncer::ModelTypeSet::All());
354 sync_blocker.reset(); 357 sync_blocker.reset();
355 WaitForCountingOrConfirmFinished(); 358 WaitForCountingOrConfirmFinished();
356 EXPECT_TRUE(PasswordSyncEnabled()); 359 EXPECT_TRUE(PasswordSyncEnabled());
357 360
358 // Stopping the Sync service triggers a restart. 361 // Stopping the Sync service triggers a restart.
359 sync_service->RequestStop(syncer::SyncService::CLEAR_DATA); 362 sync_service->RequestStop(syncer::SyncService::CLEAR_DATA);
360 WaitForCountingOrConfirmFinished(); 363 WaitForCountingOrConfirmFinished();
361 EXPECT_FALSE(PasswordSyncEnabled()); 364 EXPECT_FALSE(PasswordSyncEnabled());
362 } 365 }
363 366
364 } // namespace 367 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698