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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_
10 #include "base/memory/scoped_vector.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "chrome/browser/sync/test/integration/sync_test.h"
14 #include "components/autofill/core/common/password_form.h"
16 namespace password_manager
{
20 namespace passwords_helper
{
22 // Adds the login held in |form| to the password store |store|. Even though
23 // logins are normally added asynchronously, this method will block until the
25 void AddLogin(password_manager::PasswordStore
* store
,
26 const autofill::PasswordForm
& form
);
28 // Update the data held in password store |store| with a modified |form|.
29 // This method blocks until the operation is complete.
30 void UpdateLogin(password_manager::PasswordStore
* store
,
31 const autofill::PasswordForm
& form
);
33 // Returns all logins from |store| matching a fake signon realm used only by
34 // PasswordsSyncPerfTest.
35 ScopedVector
<autofill::PasswordForm
> GetLogins(
36 password_manager::PasswordStore
* store
);
38 // Removes the login held in |form| from the password store |store|. This
39 // method blocks until the operation is complete.
40 void RemoveLogin(password_manager::PasswordStore
* store
,
41 const autofill::PasswordForm
& form
);
43 // Removes all password forms from the password store |store|.
44 void RemoveLogins(password_manager::PasswordStore
* store
);
46 // Sets the cryptographer's encryption passphrase for the profile at index
47 // |index| to |passphrase|, and passphrase type |type|.
48 void SetEncryptionPassphrase(int index
,
49 const std::string
& passphrase
,
50 ProfileSyncService::PassphraseType type
);
52 // Sets the cryptographer's decryption passphrase for the profile at index
53 // |index| to |passphrase|. Returns false if the operation failed, and true
55 bool SetDecryptionPassphrase(int index
, const std::string
& passphrase
);
57 // Gets the password store of the profile with index |index|.
58 password_manager::PasswordStore
* GetPasswordStore(int index
);
60 // Gets the password store of the verifier profile.
61 password_manager::PasswordStore
* GetVerifierPasswordStore();
63 // Returns true iff the profile with index |index| contains the same password
64 // forms as the verifier profile.
65 bool ProfileContainsSamePasswordFormsAsVerifier(int index
);
67 // Returns true iff the profile with index |index_a| contains the same
68 // password forms as the profile with index |index_b|.
69 bool ProfilesContainSamePasswordForms(int index_a
, int index_b
);
71 // Returns true iff all profiles contain the same password forms as the
73 bool AllProfilesContainSamePasswordFormsAsVerifier();
75 // Returns true iff all profiles contain the same password forms.
76 bool AllProfilesContainSamePasswordForms();
78 // Returns true if all profiles contain the same password forms and
79 // it doesn't time out.
80 bool AwaitAllProfilesContainSamePasswordForms();
82 // Returns true if specified profile contains the same password forms as the
83 // verifier and it doesn't time out.
84 bool AwaitProfileContainsSamePasswordFormsAsVerifier(int index
);
86 // Returns the number of forms in the password store of the profile with index
88 int GetPasswordCount(int index
);
90 // Returns the number of forms in the password store of the verifier profile.
91 int GetVerifierPasswordCount();
93 // Creates a test password form with a well known fake signon realm used only
94 // by PasswordsSyncPerfTest based on |index|.
95 autofill::PasswordForm
CreateTestPasswordForm(int index
);
97 } // namespace passwords_helper
99 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_