Commit 4cfe5e0a authored by csharp@chromium.org's avatar csharp@chromium.org

Correctly Mark the new Autofill Popup as Visible when showing just passwords.

BUG=164091


Review URL: https://chromiumcodereview.appspot.com/11411364

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171085 0039d316-1c4b-4281-b951-d872f2087c98
parent b5ec90e6
...@@ -149,6 +149,7 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions( ...@@ -149,6 +149,7 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions(
std::vector<string16> empty(suggestions.size()); std::vector<string16> empty(suggestions.size());
std::vector<int> password_ids(suggestions.size(), std::vector<int> password_ids(suggestions.size(),
WebAutofillClient::MenuItemIDPasswordEntry); WebAutofillClient::MenuItemIDPasswordEntry);
popup_visible_ = true;
ApplyAutofillSuggestions(suggestions, empty, empty, password_ids); ApplyAutofillSuggestions(suggestions, empty, empty, password_ids);
} }
......
...@@ -40,6 +40,10 @@ class MockAutofillExternalDelegate : ...@@ -40,6 +40,10 @@ class MockAutofillExternalDelegate :
: TestAutofillExternalDelegate(web_contents, autofill_manger) {} : TestAutofillExternalDelegate(web_contents, autofill_manger) {}
~MockAutofillExternalDelegate() {} ~MockAutofillExternalDelegate() {}
bool popup_visible() {
return autofill::TestAutofillExternalDelegate::popup_visible();
}
MOCK_METHOD4(ApplyAutofillSuggestions, void( MOCK_METHOD4(ApplyAutofillSuggestions, void(
const std::vector<string16>& autofill_values, const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels, const std::vector<string16>& autofill_labels,
...@@ -48,8 +52,6 @@ class MockAutofillExternalDelegate : ...@@ -48,8 +52,6 @@ class MockAutofillExternalDelegate :
MOCK_METHOD0(ClearPreviewedForm, void()); MOCK_METHOD0(ClearPreviewedForm, void());
MOCK_METHOD0(HideAutofillPopup, void());
MOCK_METHOD1(SetBounds, void(const gfx::Rect& bounds)); MOCK_METHOD1(SetBounds, void(const gfx::Rect& bounds));
private: private:
...@@ -149,9 +151,10 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { ...@@ -149,9 +151,10 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
autofill_item, autofill_item,
autofill_item, autofill_item,
autofill_ids); autofill_ids);
EXPECT_TRUE(external_delegate_->popup_visible());
// Called when hiding the popup.
EXPECT_CALL(*external_delegate_, HideAutofillPopup()); EXPECT_CALL(*external_delegate_, ClearPreviewedForm());
// Called by DidAutofillSuggestions, add expectation to remove warning. // Called by DidAutofillSuggestions, add expectation to remove warning.
EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)); EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _));
...@@ -160,6 +163,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { ...@@ -160,6 +163,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
// we've selected an option. // we've selected an option.
external_delegate_->DidAcceptAutofillSuggestions(autofill_item[0], external_delegate_->DidAcceptAutofillSuggestions(autofill_item[0],
autofill_ids[0], 0); autofill_ids[0], 0);
EXPECT_FALSE(external_delegate_->popup_visible());
} }
// Test that data list elements for a node will appear in the Autofill popup. // Test that data list elements for a node will appear in the Autofill popup.
...@@ -250,7 +254,55 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { ...@@ -250,7 +254,55 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
// Test that the popup is hidden once we are done editing the autofill field. // Test that the popup is hidden once we are done editing the autofill field.
TEST_F(AutofillExternalDelegateUnitTest, TEST_F(AutofillExternalDelegateUnitTest,
ExternalDelegateHidePopupAfterEditing) { ExternalDelegateHidePopupAfterEditing) {
EXPECT_CALL(*external_delegate_, HideAutofillPopup()); EXPECT_CALL(*external_delegate_, SetBounds(_));
EXPECT_CALL(*external_delegate_, ApplyAutofillSuggestions(_, _, _, _));
autofill::GenerateTestAutofillPopup(external_delegate_.get());
EXPECT_TRUE(external_delegate_->popup_visible());
// Called when hiding the popup.
EXPECT_CALL(*external_delegate_, ClearPreviewedForm());
external_delegate_->DidEndTextFieldEditing(); external_delegate_->DidEndTextFieldEditing();
EXPECT_FALSE(external_delegate_->popup_visible());
}
// Test that the popup is marked as visible after recieving password
// suggestions.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) {
std::vector<string16> suggestions;
suggestions.push_back(string16());
FormFieldData field;
field.is_focusable = true;
field.should_autocomplete = true;
const gfx::Rect bounds;
EXPECT_CALL(*external_delegate_, SetBounds(bounds));
// The enums must be cast to ints to prevent compile errors on linux_rel.
EXPECT_CALL(*external_delegate_,
ApplyAutofillSuggestions(_, _, _, testing::ElementsAre(
static_cast<int>(
WebAutofillClient::MenuItemIDPasswordEntry))));
external_delegate_->OnShowPasswordSuggestions(suggestions,
field,
bounds);
EXPECT_TRUE(external_delegate_->popup_visible());
// Called by DidAutofillSuggestions, add expectation to remove warning.
EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _));
// Called when hiding the popup.
EXPECT_CALL(*external_delegate_, ClearPreviewedForm());
// This should trigger a call to hide the popup since
// we've selected an option.
external_delegate_->DidAcceptAutofillSuggestions(
suggestions[0],
WebAutofillClient::MenuItemIDPasswordEntry,
0);
EXPECT_FALSE(external_delegate_->popup_visible());
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment