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

Unified Diff: chrome/browser/autofill/autofill_external_delegate_unittest.cc

Issue 11411364: Correctly Mark the new Autofill Popup as Visible when showing just passwords. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 | « chrome/browser/autofill/autofill_external_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_external_delegate_unittest.cc
diff --git a/chrome/browser/autofill/autofill_external_delegate_unittest.cc b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
index 5c1a29d17648c252a34434058f45b5a984fa9441..3eb5f028220fc39cd489d987e593a5f395dfa17f 100644
--- a/chrome/browser/autofill/autofill_external_delegate_unittest.cc
+++ b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
@@ -40,6 +40,10 @@ class MockAutofillExternalDelegate :
: TestAutofillExternalDelegate(web_contents, autofill_manger) {}
~MockAutofillExternalDelegate() {}
+ bool popup_visible() {
+ return autofill::TestAutofillExternalDelegate::popup_visible();
+ }
+
MOCK_METHOD4(ApplyAutofillSuggestions, void(
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
@@ -48,8 +52,6 @@ class MockAutofillExternalDelegate :
MOCK_METHOD0(ClearPreviewedForm, void());
- MOCK_METHOD0(HideAutofillPopup, void());
-
MOCK_METHOD1(SetBounds, void(const gfx::Rect& bounds));
private:
@@ -149,9 +151,10 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
autofill_item,
autofill_item,
autofill_ids);
+ EXPECT_TRUE(external_delegate_->popup_visible());
-
- EXPECT_CALL(*external_delegate_, HideAutofillPopup());
+ // Called when hiding the popup.
+ EXPECT_CALL(*external_delegate_, ClearPreviewedForm());
// Called by DidAutofillSuggestions, add expectation to remove warning.
EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _));
@@ -160,6 +163,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
// we've selected an option.
external_delegate_->DidAcceptAutofillSuggestions(autofill_item[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.
@@ -250,7 +254,55 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
// Test that the popup is hidden once we are done editing the autofill field.
TEST_F(AutofillExternalDelegateUnitTest,
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();
+
+ 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());
}
« no previous file with comments | « chrome/browser/autofill/autofill_external_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698