| 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.
|
|
|