| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/autofill/core/common/password_form.h" | 13 #include "components/autofill/core/common/password_form.h" |
| 14 #include "components/password_manager/core/browser/mock_password_store.h" | 14 #include "components/password_manager/core/browser/mock_password_store.h" |
| 15 #include "components/password_manager/core/browser/password_form_manager.h" | 15 #include "components/password_manager/core/browser/password_form_manager.h" |
| 16 #include "components/password_manager/core/browser/password_manager.h" | 16 #include "components/password_manager/core/browser/password_manager.h" |
| 17 #include "components/password_manager/core/browser/password_manager_client.h" | |
| 18 #include "components/password_manager/core/browser/password_manager_driver.h" | 17 #include "components/password_manager/core/browser/password_manager_driver.h" |
| 19 #include "components/password_manager/core/browser/password_store.h" | 18 #include "components/password_manager/core/browser/password_store.h" |
| 19 #include "components/password_manager/core/browser/stub_password_manager_client.
h" |
| 20 #include "components/password_manager/core/browser/test_password_store.h" | 20 #include "components/password_manager/core/browser/test_password_store.h" |
| 21 #include "components/password_manager/core/common/password_manager_pref_names.h" | 21 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 using autofill::PasswordForm; | 25 using autofill::PasswordForm; |
| 26 using base::ASCIIToUTF16; | 26 using base::ASCIIToUTF16; |
| 27 using ::testing::_; | 27 using ::testing::_; |
| 28 using ::testing::Eq; | 28 using ::testing::Eq; |
| 29 using ::testing::Mock; | 29 using ::testing::Mock; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 53 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); | 53 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); |
| 54 MOCK_METHOD0(IsOffTheRecord, bool()); | 54 MOCK_METHOD0(IsOffTheRecord, bool()); |
| 55 MOCK_METHOD0(GetPasswordGenerationManager, PasswordGenerationManager*()); | 55 MOCK_METHOD0(GetPasswordGenerationManager, PasswordGenerationManager*()); |
| 56 MOCK_METHOD0(GetPasswordManager, PasswordManager*()); | 56 MOCK_METHOD0(GetPasswordManager, PasswordManager*()); |
| 57 MOCK_METHOD0(GetAutofillManager, autofill::AutofillManager*()); | 57 MOCK_METHOD0(GetAutofillManager, autofill::AutofillManager*()); |
| 58 MOCK_METHOD1(AllowPasswordGenerationForForm, void(autofill::PasswordForm*)); | 58 MOCK_METHOD1(AllowPasswordGenerationForForm, void(autofill::PasswordForm*)); |
| 59 MOCK_METHOD1(AccountCreationFormsFound, | 59 MOCK_METHOD1(AccountCreationFormsFound, |
| 60 void(const std::vector<autofill::FormData>&)); | 60 void(const std::vector<autofill::FormData>&)); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class TestPasswordManagerClient : public PasswordManagerClient { | 63 class TestPasswordManagerClient : public StubPasswordManagerClient { |
| 64 public: | 64 public: |
| 65 explicit TestPasswordManagerClient(PasswordStore* password_store) | 65 explicit TestPasswordManagerClient(PasswordStore* password_store) |
| 66 : password_store_(password_store) { | 66 : password_store_(password_store) { |
| 67 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerEnabled, | 67 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerEnabled, |
| 68 true); | 68 true); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save) | 71 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save) |
| 72 OVERRIDE {} | 72 OVERRIDE {} |
| 73 virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; } | 73 virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; } |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); | 696 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); |
| 697 // By now that form has been used once. | 697 // By now that form has been used once. |
| 698 complete_form.times_used = 1; | 698 complete_form.times_used = 1; |
| 699 | 699 |
| 700 // Check that PasswordStore receives an update request with the complete form. | 700 // Check that PasswordStore receives an update request with the complete form. |
| 701 EXPECT_CALL(*mock_store(), UpdateLogin(complete_form)); | 701 EXPECT_CALL(*mock_store(), UpdateLogin(complete_form)); |
| 702 form_manager.Save(); | 702 form_manager.Save(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace password_manager | 705 } // namespace password_manager |
| OLD | NEW |