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

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

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve rebased code. Created 6 years, 7 months 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
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 19ba317c3b0e482ff9371cd311ac066578faefcc..d6aa76c00756ab36ea3b8b9c368ee39c3d221708 100644
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -48,6 +48,9 @@ class MockPasswordManagerDriver
void(const std::vector<autofill::FormData>&));
MOCK_METHOD2(AcceptPasswordAutofillSuggestion,
void(const base::string16&, const base::string16&));
+ MOCK_METHOD2(PreviewPasswordAutofillSuggestion,
+ void(const base::string16&, const base::string16&));
+ MOCK_METHOD0(ClearPasswordPreviewedForm, void());
MOCK_METHOD0(GetPasswordAutofillManager,
password_manager::PasswordAutofillManager*());
};
@@ -160,6 +163,33 @@ TEST_F(PasswordAutofillManagerTest, AcceptSuggestion) {
username_field_, test_username_));
}
+TEST_F(PasswordAutofillManagerTest, SelectSuggestion) {
+ scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient);
+ InitializePasswordAutofillManager(client.get(), NULL);
+
+ EXPECT_CALL(
+ *client->mock_driver(),
+ PreviewPasswordAutofillSuggestion(test_username_, test_password_));
+ EXPECT_TRUE(password_autofill_manager_->SelectSuggestionForTest(
+ username_field_, test_username_));
+ testing::Mock::VerifyAndClearExpectations(client->mock_driver());
+
+ EXPECT_CALL(*client->mock_driver(),
+ PreviewPasswordAutofillSuggestion(_, _)).Times(0);
+ EXPECT_FALSE(password_autofill_manager_->SelectSuggestionForTest(
+ username_field_, base::ASCIIToUTF16(kInvalidUsername)));
+
+ autofill::FormFieldData invalid_username_field;
+ invalid_username_field.name = base::ASCIIToUTF16(kInvalidUsername);
+
+ EXPECT_FALSE(password_autofill_manager_->SelectSuggestionForTest(
+ invalid_username_field, test_username_));
+
+ password_autofill_manager_->Reset();
+ EXPECT_FALSE(password_autofill_manager_->SelectSuggestionForTest(
+ username_field_, test_username_));
+}
+
// Test that the popup is marked as visible after recieving password
// suggestions.
TEST_F(PasswordAutofillManagerTest, ExternalDelegatePasswordSuggestions) {

Powered by Google App Engine
This is Rietveld 408576698