| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_autofill_manager.h" | 5 #include "components/password_manager/core/browser/password_autofill_manager.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/autofill/core/browser/popup_item_ids.h" | 10 #include "components/autofill/core/browser/popup_item_ids.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 autofill::PasswordFormFillData fill_data_; | 112 autofill::PasswordFormFillData fill_data_; |
| 113 const int fill_data_id_; | 113 const int fill_data_id_; |
| 114 | 114 |
| 115 // The TestAutofillDriver uses a SequencedWorkerPool which expects the | 115 // The TestAutofillDriver uses a SequencedWorkerPool which expects the |
| 116 // existence of a MessageLoop. | 116 // existence of a MessageLoop. |
| 117 base::MessageLoop message_loop_; | 117 base::MessageLoop message_loop_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 TEST_F(PasswordAutofillManagerTest, FillSuggestion) { | 120 TEST_F(PasswordAutofillManagerTest, FillSuggestion) { |
| 121 scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); | 121 scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); |
| 122 InitializePasswordAutofillManager(client.get(), NULL); | 122 InitializePasswordAutofillManager(client.get(), nullptr); |
| 123 | 123 |
| 124 EXPECT_CALL(*client->mock_driver(), | 124 EXPECT_CALL(*client->mock_driver(), |
| 125 FillSuggestion(test_username_, test_password_)); | 125 FillSuggestion(test_username_, test_password_)); |
| 126 EXPECT_TRUE(password_autofill_manager_->FillSuggestionForTest( | 126 EXPECT_TRUE(password_autofill_manager_->FillSuggestionForTest( |
| 127 fill_data_id(), test_username_)); | 127 fill_data_id(), test_username_)); |
| 128 testing::Mock::VerifyAndClearExpectations(client->mock_driver()); | 128 testing::Mock::VerifyAndClearExpectations(client->mock_driver()); |
| 129 | 129 |
| 130 EXPECT_CALL(*client->mock_driver(), FillSuggestion(_, _)).Times(0); | 130 EXPECT_CALL(*client->mock_driver(), FillSuggestion(_, _)).Times(0); |
| 131 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( | 131 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( |
| 132 fill_data_id(), base::ASCIIToUTF16(kInvalidUsername))); | 132 fill_data_id(), base::ASCIIToUTF16(kInvalidUsername))); |
| 133 | 133 |
| 134 const int invalid_fill_data_id = fill_data_id() + 1; | 134 const int invalid_fill_data_id = fill_data_id() + 1; |
| 135 | 135 |
| 136 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( | 136 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( |
| 137 invalid_fill_data_id, test_username_)); | 137 invalid_fill_data_id, test_username_)); |
| 138 | 138 |
| 139 password_autofill_manager_->DidNavigateMainFrame(); | 139 password_autofill_manager_->DidNavigateMainFrame(); |
| 140 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( | 140 EXPECT_FALSE(password_autofill_manager_->FillSuggestionForTest( |
| 141 fill_data_id(), test_username_)); | 141 fill_data_id(), test_username_)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(PasswordAutofillManagerTest, PreviewSuggestion) { | 144 TEST_F(PasswordAutofillManagerTest, PreviewSuggestion) { |
| 145 scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); | 145 scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); |
| 146 InitializePasswordAutofillManager(client.get(), NULL); | 146 InitializePasswordAutofillManager(client.get(), nullptr); |
| 147 | 147 |
| 148 EXPECT_CALL(*client->mock_driver(), | 148 EXPECT_CALL(*client->mock_driver(), |
| 149 PreviewSuggestion(test_username_, test_password_)); | 149 PreviewSuggestion(test_username_, test_password_)); |
| 150 EXPECT_TRUE(password_autofill_manager_->PreviewSuggestionForTest( | 150 EXPECT_TRUE(password_autofill_manager_->PreviewSuggestionForTest( |
| 151 fill_data_id(), test_username_)); | 151 fill_data_id(), test_username_)); |
| 152 testing::Mock::VerifyAndClearExpectations(client->mock_driver()); | 152 testing::Mock::VerifyAndClearExpectations(client->mock_driver()); |
| 153 | 153 |
| 154 EXPECT_CALL(*client->mock_driver(), PreviewSuggestion(_, _)).Times(0); | 154 EXPECT_CALL(*client->mock_driver(), PreviewSuggestion(_, _)).Times(0); |
| 155 EXPECT_FALSE(password_autofill_manager_->PreviewSuggestionForTest( | 155 EXPECT_FALSE(password_autofill_manager_->PreviewSuggestionForTest( |
| 156 fill_data_id(), base::ASCIIToUTF16(kInvalidUsername))); | 156 fill_data_id(), base::ASCIIToUTF16(kInvalidUsername))); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 SuggestionVectorValuesAre(testing::UnorderedElementsAre( | 300 SuggestionVectorValuesAre(testing::UnorderedElementsAre( |
| 301 title, | 301 title, |
| 302 test_username_)), | 302 test_username_)), |
| 303 _)); | 303 _)); |
| 304 password_autofill_manager_->OnShowPasswordSuggestions( | 304 password_autofill_manager_->OnShowPasswordSuggestions( |
| 305 dummy_key, base::i18n::RIGHT_TO_LEFT, test_username_, | 305 dummy_key, base::i18n::RIGHT_TO_LEFT, test_username_, |
| 306 autofill::IS_PASSWORD_FIELD, element_bounds); | 306 autofill::IS_PASSWORD_FIELD, element_bounds); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace password_manager | 309 } // namespace password_manager |
| OLD | NEW |