Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: components/password_manager/core/browser/password_autofill_manager_unittest.cc

Issue 492043003: Fill on account select in the password manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit tests Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/password_manager/core/browser/password_autofill_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e8b5bd20d2c0b3ed205c418953306700290fce84..76b07b1bf6c66e98d3c1c926ab411585e607b11f 100644
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -4,18 +4,22 @@
#include "components/password_manager/core/browser/password_autofill_manager.h"
+#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
+#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_field_data.h"
#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.
@@ -263,4 +267,48 @@ TEST_F(PasswordAutofillManagerTest, ExtractSuggestions) {
element_bounds);
}
+TEST_F(PasswordAutofillManagerTest, FillOnAccountSelectOnly) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ autofill::switches::kEnableFillOnAccountSelect);
+
+ 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
« no previous file with comments | « components/password_manager/core/browser/password_autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698