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

Unified Diff: components/autofill/core/browser/autofill_external_delegate_unittest.cc

Issue 2473493002: [Autofill] Credit card signin promo: do not require a local suggestion first. (Closed)
Patch Set: added test Created 4 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
Index: components/autofill/core/browser/autofill_external_delegate_unittest.cc
diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
index 7b274c61316bbd233247406f54985ba28b64c473..8807132a05910d4d699a5353985bd46e90b9fc95 100644
--- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
+++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
@@ -196,8 +196,9 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
}
// Test that our external delegate properly adds the signin promo and its
-// separator in the popup items.
-TEST_F(AutofillExternalDelegateUnitTest, TestSigninPromoIsAdded) {
+// separator in the popup items when there are suggestions.
+TEST_F(AutofillExternalDelegateUnitTest,
+ TestSigninPromoIsAdded_WithSuggestions) {
EXPECT_CALL(*autofill_manager_, ShouldShowCreditCardSigninPromo(_, _))
.WillOnce(testing::Return(true));
@@ -239,6 +240,39 @@ TEST_F(AutofillExternalDelegateUnitTest, TestSigninPromoIsAdded) {
autofill_item[0].frontend_id, 0);
}
+// Test that our external delegate properly adds the signin promo and no
+// separator in the dropdown, when there are no suggestions.
+TEST_F(AutofillExternalDelegateUnitTest,
+ TestSigninPromoIsAdded_WithNoSuggestions) {
+ EXPECT_CALL(*autofill_manager_, ShouldShowCreditCardSigninPromo(_, _))
+ .WillOnce(testing::Return(true));
+
+ IssueOnQuery(kQueryId);
+
+ // The enums must be cast to ints to prevent compile errors on linux_rel.
+ auto element_ids = testing::ElementsAre(
+ static_cast<int>(POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO));
+
+ EXPECT_CALL(autofill_client_,
+ ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _));
+
+ base::UserActionTester user_action_tester;
+
+ // This should call ShowAutofillPopup.
+ std::vector<Suggestion> items;
+ external_delegate_->OnSuggestionsReturned(kQueryId, items);
+ EXPECT_EQ(1, user_action_tester.GetActionCount(
+ "Signin_Impression_FromAutofillDropdown"));
+
+ EXPECT_CALL(autofill_client_, StartSigninFlow());
+ EXPECT_CALL(autofill_client_, HideAutofillPopup());
+
+ // This should trigger a call to start the signin flow and hide the popup
+ // since we've selected the sign-in promo option.
+ external_delegate_->DidAcceptSuggestion(
+ base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0);
+}
+
// Test that data list elements for a node will appear in the Autofill popup.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
IssueOnQuery(kQueryId);
« no previous file with comments | « components/autofill/core/browser/autofill_external_delegate.cc ('k') | components/autofill/core/browser/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698