| 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 "components/password_manager/core/browser/password_manager.h" | 5 #include "components/password_manager/core/browser/password_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ~TestPasswordManager() override {} | 84 ~TestPasswordManager() override {} |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(TestPasswordManager); | 87 DISALLOW_COPY_AND_ASSIGN(TestPasswordManager); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace | 90 } // namespace |
| 91 | 91 |
| 92 class PasswordManagerTest : public testing::Test { | 92 class PasswordManagerTest : public testing::Test { |
| 93 protected: | 93 protected: |
| 94 virtual void SetUp() { | 94 void SetUp() override { |
| 95 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled, | 95 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled, |
| 96 true); | 96 true); |
| 97 | 97 |
| 98 store_ = new MockPasswordStore; | 98 store_ = new MockPasswordStore; |
| 99 EXPECT_CALL(*store_.get(), ReportMetrics(_, _)).Times(AnyNumber()); | 99 EXPECT_CALL(*store_.get(), ReportMetrics(_, _)).Times(AnyNumber()); |
| 100 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare())); | 100 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare())); |
| 101 | 101 |
| 102 EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage()) | 102 EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage()) |
| 103 .WillRepeatedly(Return(true)); | 103 .WillRepeatedly(Return(true)); |
| 104 EXPECT_CALL(client_, IsSyncAccountCredential(_, _)) | 104 EXPECT_CALL(client_, IsSyncAccountCredential(_, _)) |
| 105 .WillRepeatedly(Return(false)); | 105 .WillRepeatedly(Return(false)); |
| 106 EXPECT_CALL(client_, GetPasswordStore()) | 106 EXPECT_CALL(client_, GetPasswordStore()) |
| 107 .WillRepeatedly(Return(store_.get())); | 107 .WillRepeatedly(Return(store_.get())); |
| 108 EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_)); | 108 EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_)); |
| 109 EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_)); | 109 EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_)); |
| 110 | 110 |
| 111 manager_.reset(new TestPasswordManager(&client_)); | 111 manager_.reset(new TestPasswordManager(&client_)); |
| 112 password_autofill_manager_.reset( | 112 password_autofill_manager_.reset( |
| 113 new PasswordAutofillManager(&client_, NULL)); | 113 new PasswordAutofillManager(&client_, NULL)); |
| 114 | 114 |
| 115 EXPECT_CALL(driver_, GetPasswordManager()) | 115 EXPECT_CALL(driver_, GetPasswordManager()) |
| 116 .WillRepeatedly(Return(manager_.get())); | 116 .WillRepeatedly(Return(manager_.get())); |
| 117 EXPECT_CALL(driver_, GetPasswordAutofillManager()) | 117 EXPECT_CALL(driver_, GetPasswordAutofillManager()) |
| 118 .WillRepeatedly(Return(password_autofill_manager_.get())); | 118 .WillRepeatedly(Return(password_autofill_manager_.get())); |
| 119 EXPECT_CALL(driver_, DidLastPageLoadEncounterSSLErrors()) | 119 EXPECT_CALL(driver_, DidLastPageLoadEncounterSSLErrors()) |
| 120 .WillRepeatedly(Return(false)); | 120 .WillRepeatedly(Return(false)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual void TearDown() { | 123 void TearDown() override { |
| 124 store_->Shutdown(); | 124 store_->Shutdown(); |
| 125 store_ = NULL; | 125 store_ = NULL; |
| 126 } | 126 } |
| 127 | 127 |
| 128 PasswordForm MakeSimpleForm() { | 128 PasswordForm MakeSimpleForm() { |
| 129 PasswordForm form; | 129 PasswordForm form; |
| 130 form.origin = GURL("http://www.google.com/a/LoginAuth"); | 130 form.origin = GURL("http://www.google.com/a/LoginAuth"); |
| 131 form.action = GURL("http://www.google.com/a/Login"); | 131 form.action = GURL("http://www.google.com/a/Login"); |
| 132 form.username_element = ASCIIToUTF16("Email"); | 132 form.username_element = ASCIIToUTF16("Email"); |
| 133 form.password_element = ASCIIToUTF16("Passwd"); | 133 form.password_element = ASCIIToUTF16("Passwd"); |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 true); // The post-navigation layout. | 865 true); // The post-navigation layout. |
| 866 | 866 |
| 867 ASSERT_TRUE(form_to_save.get()); | 867 ASSERT_TRUE(form_to_save.get()); |
| 868 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))); | 868 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))); |
| 869 | 869 |
| 870 // Simulate saving the form, as if the info bar was accepted. | 870 // Simulate saving the form, as if the info bar was accepted. |
| 871 form_to_save->Save(); | 871 form_to_save->Save(); |
| 872 } | 872 } |
| 873 | 873 |
| 874 } // namespace password_manager | 874 } // namespace password_manager |
| OLD | NEW |