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

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

Issue 2124343002: [Autofill] Implement Credit Card Signin Promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 5 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/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 179985d31e63d26e055e24333b5427a80239f4a2..5ebd6204cb7769aaa0270aa06f1841a0fec031e2 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -73,6 +73,8 @@ class MockAutofillClient : public TestAutofillClient {
MOCK_METHOD2(ConfirmSaveCreditCardLocally,
void(const CreditCard& card, const base::Closure& callback));
+ MOCK_METHOD0(ShouldShowSigninPromo, bool());
+
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillClient);
};
@@ -4907,6 +4909,44 @@ TEST_F(AutofillManagerTest, NoCreditCardSuggestionsForNonPrefixTokenMatch) {
EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
}
+// Test that ShouldShowCreditCardSigninPromo behaves as expected for a credit
+// card form.
+TEST_F(AutofillManagerTest, ShouldShowCreditCardSigninPromo_CreditCardField) {
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, true, false);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field;
+ test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field);
+
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(true));
+ EXPECT_TRUE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(false));
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+}
+
+// Test that ShouldShowCreditCardSigninPromo behaves as expected for an address
+// form.
+TEST_F(AutofillManagerTest, ShouldShowCreditCardSigninPromo_AddressField) {
+ // Set up our form data.
+ FormData form;
+ test::CreateTestAddressFormData(&form);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field;
+ test::CreateTestFormField("First Name", "firstname", "", "text", &field);
+
+ // Call will now return false, because it is initiated from an address field.
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo()).Times(0);
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+}
+
// Verify that typing "S" into the middle name field will match and order middle
// names "Shawn Smith" followed by "Adam Smith" i.e. prefix matched followed by
// substring matched.
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/popup_item_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698