Index: components/password_manager/core/browser/password_autofill_manager_unittest.cc |
diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc |
index 374081ebffe3bfe4719a184983d0e2229a564814..083b18d3a0043e701de8bc244369a18b57ab0a8e 100644 |
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc |
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc |
@@ -14,8 +14,10 @@ |
#include "components/autofill/core/common/password_form_fill_data.h" |
#include "components/password_manager/core/browser/stub_password_manager_client.h" |
#include "components/password_manager/core/browser/stub_password_manager_driver.h" |
+#include "components/strings/grit/components_strings.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/base/l10n/l10n_util.h" |
#include "ui/gfx/geometry/rect_f.h" |
// The name of the username/password element in the form. |
@@ -261,4 +263,45 @@ TEST_F(PasswordAutofillManagerTest, ExtractSuggestions) { |
element_bounds); |
} |
+TEST_F(PasswordAutofillManagerTest, FillSuggestionPasswordField) { |
+ scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient); |
+ scoped_ptr<MockAutofillClient> autofill_client(new MockAutofillClient); |
+ InitializePasswordAutofillManager(client.get(), autofill_client.get()); |
+ |
+ gfx::RectF element_bounds; |
+ autofill::PasswordFormFillData data; |
+ data.username_field.value = test_username_; |
+ data.password_field.value = test_password_; |
+ data.preferred_realm = "http://foo.com/"; |
+ |
+ autofill::PasswordAndRealm additional; |
+ additional.realm = "https://foobarrealm.org"; |
+ base::string16 additional_username(base::ASCIIToUTF16("John Foo")); |
+ data.additional_logins[additional_username] = additional; |
+ |
+ autofill::UsernamesCollectionKey usernames_key; |
+ usernames_key.realm = "http://yetanother.net"; |
+ std::vector<base::string16> other_names; |
+ base::string16 other_username(base::ASCIIToUTF16("John Different")); |
+ other_names.push_back(other_username); |
+ data.other_possible_usernames[usernames_key] = other_names; |
+ |
+ int dummy_key = 0; |
+ password_autofill_manager_->OnAddPasswordFormMapping(dummy_key, data); |
+ |
+ // Simulate displaying suggestions matching a username and specifying that the |
+ // field is a password field. |
+ base::string16 title = l10n_util::GetStringUTF16( |
+ IDS_AUTOFILL_PASSWORD_FIELD_SUGGESTIONS_TITLE); |
+ EXPECT_CALL(*autofill_client, |
+ ShowAutofillPopup( |
+ element_bounds, _, |
+ testing::UnorderedElementsAre(title, test_username_), |
+ _, _, _, _)); |
+ password_autofill_manager_->OnShowPasswordSuggestions( |
+ dummy_key, base::i18n::RIGHT_TO_LEFT, test_username_, |
+ autofill::ShowPasswordSuggestionsOptions::IS_PASSWORD_FIELD, |
+ element_bounds); |
+} |
+ |
} // namespace password_manager |