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. 4 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_ 7 8 #include <vector> 9 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" 14 15 namespace password_manager { 16 class PasswordStore; 17 } 18 19 namespace passwords_helper { 20 21 // Adds the login held in |form| to the password store |store|. Even though 22 // logins are normally added asynchronously, this method will block until the 23 // login is added. 24 void AddLogin(password_manager::PasswordStore* store, 25 const autofill::PasswordForm& form); 26 27 // Update the data held in password store |store| with a modified |form|. 28 // This method blocks until the operation is complete. 29 void UpdateLogin(password_manager::PasswordStore* store, 30 const autofill::PasswordForm& form); 31 32 // Searches |store| for all logins matching a fake signon realm used only by 33 // LivePasswordsSyncTest and adds the results to |matches|. Note that the 34 // caller is responsible for deleting the forms added to |matches|. 35 void GetLogins(password_manager::PasswordStore* store, 36 std::vector<autofill::PasswordForm>& matches); 37 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); 42 43 // Removes all password forms from the password store |store|. 44 void RemoveLogins(password_manager::PasswordStore* store); 45 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); 51 52 // Sets the cryptographer's decryption passphrase for the profile at index 53 // |index| to |passphrase|. Returns false if the operation failed, and true 54 // otherwise. 55 bool SetDecryptionPassphrase(int index, const std::string& passphrase); 56 57 // Gets the password store of the profile with index |index|. 58 password_manager::PasswordStore* GetPasswordStore(int index); 59 60 // Gets the password store of the verifier profile. 61 password_manager::PasswordStore* GetVerifierPasswordStore(); 62 63 // Returns true iff the profile with index |index| contains the same password 64 // forms as the verifier profile. 65 bool ProfileContainsSamePasswordFormsAsVerifier(int index); 66 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); 70 71 // Returns true iff all profiles contain the same password forms as the 72 // verifier profile. 73 bool AllProfilesContainSamePasswordFormsAsVerifier(); 74 75 // Returns true iff all profiles contain the same password forms. 76 bool AllProfilesContainSamePasswordForms(); 77 78 // Returns true if all profiles contain the same password forms and 79 // it doesn't time out. 80 bool AwaitAllProfilesContainSamePasswordForms(); 81 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); 85 86 // Returns the number of forms in the password store of the profile with index 87 // |index|. 88 int GetPasswordCount(int index); 89 90 // Returns the number of forms in the password store of the verifier profile. 91 int GetVerifierPasswordCount(); 92 93 // Creates a test password form with a well known fake signon realm used only 94 // by LivePasswordsSyncTest based on |index|. 95 autofill::PasswordForm CreateTestPasswordForm(int index); 96 97 } // namespace passwords_helper 98 99 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_ 100