1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/password_manager/sync/browser/sync_username_test_base.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "components/signin/core/common/signin_pref_names.h"
10 using autofill::PasswordForm
;
12 namespace password_manager
{
14 SyncUsernameTestBase::LocalFakeSyncService::LocalFakeSyncService()
15 : syncing_passwords_(true) {}
17 SyncUsernameTestBase::LocalFakeSyncService::~LocalFakeSyncService() {}
20 SyncUsernameTestBase::LocalFakeSyncService::GetPreferredDataTypes() const {
21 if (syncing_passwords_
)
22 return syncer::ModelTypeSet(syncer::PASSWORDS
);
23 return syncer::ModelTypeSet();
26 SyncUsernameTestBase::SyncUsernameTestBase()
27 : signin_client_(&prefs_
),
28 signin_manager_(&signin_client_
, &account_tracker_
) {
29 SigninManagerBase::RegisterProfilePrefs(prefs_
.registry());
30 AccountTrackerService::RegisterPrefs(prefs_
.registry());
31 account_tracker_
.Initialize(&signin_client_
);
34 SyncUsernameTestBase::~SyncUsernameTestBase() {}
36 void SyncUsernameTestBase::FakeSigninAs(const std::string
& email
) {
37 signin_manager_
.SetAuthenticatedAccountInfo("12345", email
);
40 void SyncUsernameTestBase::FakeSignout() {
41 signin_manager_
.clear_authenticated_user();
42 prefs_
.SetString(prefs::kGoogleServicesAccountId
, std::string());
46 PasswordForm
SyncUsernameTestBase::SimpleGaiaForm(const char* username
) {
48 form
.signon_realm
= "https://accounts.google.com";
49 form
.username_value
= base::ASCIIToUTF16(username
);
54 PasswordForm
SyncUsernameTestBase::SimpleNonGaiaForm(const char* username
) {
56 form
.signon_realm
= "https://site.com";
57 form
.username_value
= base::ASCIIToUTF16(username
);
61 void SyncUsernameTestBase::SetSyncingPasswords(bool syncing_passwords
) {
62 sync_service_
.set_syncing_passwords(syncing_passwords
);
65 } // namespace password_manager