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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 14613002: Tests for invalid suggestions (i.e. expired cards) in the Autofill dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
index c0a631394995769adf565e58d85d4d161945ce3c..5708c266e5301134b282a07b5ef6e184e8e614f0 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
@@ -17,6 +17,7 @@
#include "components/autofill/browser/autofill_common_test.h"
#include "components/autofill/browser/autofill_metrics.h"
#include "components/autofill/browser/test_personal_data_manager.h"
+#include "components/autofill/browser/validation.h"
#include "components/autofill/browser/wallet/wallet_test_util.h"
#include "components/autofill/common/form_data.h"
#include "components/autofill/common/form_field_data.h"
@@ -116,15 +117,19 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl {
}
// Increase visibility for testing.
- AutofillDialogView* view() { return AutofillDialogControllerImpl::view(); }
- const DetailInput* input_showing_popup() const {
- return AutofillDialogControllerImpl::input_showing_popup();
- }
+ using AutofillDialogControllerImpl::view;
+ using AutofillDialogControllerImpl::input_showing_popup;
TestPersonalDataManager* GetTestingManager() {
return &test_manager_;
}
+ bool IsSectionInEditState(DialogSection section) const {
+ const std::map<DialogSection, bool>& state = section_editing_state();
+ std::map<DialogSection, bool>::const_iterator it = state.find(section);
+ return it != state.end() && it->second;
+ }
+
using AutofillDialogControllerImpl::DisableWallet;
protected:
@@ -465,6 +470,38 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) {
}
ASSERT_LT(i, add_inputs.size());
}
+
+// Ensure that expired cards trigger invalid suggestions.
+IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) {
+ InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
+ controller()->DisableWallet();
+
+ CreditCard verified_card(test::GetCreditCard());
+ verified_card.set_origin("Chrome settings");
+ ASSERT_TRUE(verified_card.IsVerified());
+ controller()->GetTestingManager()->AddTestingCreditCard(&verified_card);
+
+ CreditCard expired_card(test::GetCreditCard());
+ expired_card.set_origin("Chrome settings");
+ expired_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2007"));
+ ASSERT_TRUE(expired_card.IsVerified());
+ ASSERT_FALSE(
+ autofill::IsValidCreditCardExpirationDate(
+ expired_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR),
+ expired_card.GetRawInfo(CREDIT_CARD_EXP_MONTH),
+ base::Time::Now()));
+ controller()->GetTestingManager()->AddTestingCreditCard(&expired_card);
+
+ ui::MenuModel* model = controller()->MenuModelForSection(SECTION_CC);
+ ASSERT_EQ(4, model->GetItemCount());
+
+ ASSERT_TRUE(model->IsItemCheckedAt(0));
+ EXPECT_FALSE(controller()->IsSectionInEditState(SECTION_CC));
+
+ model->ActivatedAt(1);
+ ASSERT_TRUE(model->IsItemCheckedAt(1));
+ EXPECT_TRUE(controller()->IsSectionInEditState(SECTION_CC));
+}
#endif // defined(TOOLKIT_VIEWS)
} // namespace autofill
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698