| 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) {
|
|
|