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 "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/sync/test/integration/sync_test.h"
13 #include "components/autofill/core/common/password_form.h"
17 namespace passwords_helper
{
19 // Adds the login held in |form| to the password store |store|. Even though
20 // logins are normally added asynchronously, this method will block until the
22 void AddLogin(PasswordStore
* store
, const autofill::PasswordForm
& form
);
24 // Update the data held in password store |store| with a modified |form|.
25 // This method blocks until the operation is complete.
26 void UpdateLogin(PasswordStore
* store
, const autofill::PasswordForm
& form
);
28 // Searches |store| for all logins matching a fake signon realm used only by
29 // LivePasswordsSyncTest and adds the results to |matches|. Note that the
30 // caller is responsible for deleting the forms added to |matches|.
31 void GetLogins(PasswordStore
* store
,
32 std::vector
<autofill::PasswordForm
>& matches
);
34 // Removes the login held in |form| from the password store |store|. This
35 // method blocks until the operation is complete.
36 void RemoveLogin(PasswordStore
* store
, const autofill::PasswordForm
& form
);
38 // Removes all password forms from the password store |store|.
39 void RemoveLogins(PasswordStore
* store
);
41 // Sets the cryptographer's encryption passphrase for the profile at index
42 // |index| to |passphrase|, and passphrase type |type|.
43 void SetEncryptionPassphrase(int index
,
44 const std::string
& passphrase
,
45 ProfileSyncService::PassphraseType type
);
47 // Sets the cryptographer's decryption passphrase for the profile at index
48 // |index| to |passphrase|. Returns false if the operation failed, and true
50 bool SetDecryptionPassphrase(int index
, const std::string
& passphrase
);
52 // Gets the password store of the profile with index |index|.
53 PasswordStore
* GetPasswordStore(int index
);
55 // Gets the password store of the verifier profile.
56 PasswordStore
* GetVerifierPasswordStore();
58 // Returns true iff the profile with index |index| contains the same password
59 // forms as the verifier profile.
60 bool ProfileContainsSamePasswordFormsAsVerifier(int index
);
62 // Returns true iff the profile with index |index_a| contains the same
63 // password forms as the profile with index |index_b|.
64 bool ProfilesContainSamePasswordForms(int index_a
, int index_b
);
66 // Returns true iff all profiles contain the same password forms as the
68 bool AllProfilesContainSamePasswordFormsAsVerifier();
70 // Returns true iff all profiles contain the same password forms.
71 bool AllProfilesContainSamePasswordForms();
73 // Returns the number of forms in the password store of the profile with index
75 int GetPasswordCount(int index
);
77 // Returns the number of forms in the password store of the verifier profile.
78 int GetVerifierPasswordCount();
80 // Creates a test password form with a well known fake signon realm used only
81 // by LivePasswordsSyncTest based on |index|.
82 autofill::PasswordForm
CreateTestPasswordForm(int index
);
84 } // namespace passwords_helper
86 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_