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

Unified Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Added AddressComboboxModel unittests and fixed more compile issues. Created 3 years, 8 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: chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
diff --git a/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc b/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
index 245da2bab9680b788092f57bdb7e1857e564a8f3..fe5a9757bbcda3a57c07d298ae196d4975ba0ee6 100644
--- a/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
+++ b/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
#include <vector>
#include "base/macros.h"
@@ -10,6 +11,7 @@
#include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
#include "chrome/browser/ui/views/payments/validating_textfield.h"
+#include "components/autofill/core/browser/address_combobox_model.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/personal_data_manager.h"
@@ -20,6 +22,7 @@
#include "content/public/test/browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/controls/combobox/combobox.h"
namespace payments {
@@ -28,6 +31,7 @@ namespace {
const base::Time kJanuary2017 = base::Time::FromDoubleT(1484505871);
const base::Time kJune2017 = base::Time::FromDoubleT(1497552271);
+const auto kBillingAddressType = autofill::MAX_VALID_FIELD_TYPE;
} // namespace
class PaymentRequestCreditCardEditorTest
@@ -37,6 +41,16 @@ class PaymentRequestCreditCardEditorTest
: PaymentRequestBrowserTestBase(
"/payment_request_no_shipping_test.html") {}
+ void SelectBillingAddress(const std::string& billing_address_id) {
+ views::Combobox* address_combobox(static_cast<views::Combobox*>(
+ dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType))));
+ ASSERT_NE(address_combobox, nullptr);
+ autofill::AddressComboboxModel* address_combobox_model(
+ static_cast<autofill::AddressComboboxModel*>(
+ address_combobox->model()));
+ address_combobox->SetSelectedIndex(
+ address_combobox_model->GetIndexOfIdentifier(billing_address_id));
+ }
PersonalDataLoadedObserverMock personal_data_observer_;
private:
@@ -54,6 +68,10 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringValidData) {
EXPECT_EQ(0U, request->state()->available_instruments().size());
EXPECT_EQ(nullptr, request->state()->selected_instrument());
+ // But there must be at least one address available for billing.
+ autofill::AutofillProfile billing_profile(autofill::test::GetFullProfile());
+ PaymentRequestBrowserTestBase::AddAutofillProfile(billing_profile);
+
OpenPaymentMethodScreen();
OpenCreditCardEditorScreen();
@@ -65,6 +83,7 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringValidData) {
SetComboboxValue(base::ASCIIToUTF16("05"), autofill::CREDIT_CARD_EXP_MONTH);
SetComboboxValue(base::ASCIIToUTF16("2026"),
autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
+ SelectBillingAddress(billing_profile.guid());
// Verifying the data is in the DB.
autofill::PersonalDataManager* personal_data_manager = GetDataManager();
@@ -248,6 +267,8 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
EnteringInvalidCardNumber_AndFixingIt) {
autofill::TestAutofillClock test_clock;
test_clock.SetNow(kJune2017);
+ autofill::AutofillProfile billing_profile(autofill::test::GetFullProfile());
+ PaymentRequestBrowserTestBase::AddAutofillProfile(billing_profile);
InvokePaymentRequestUI();
@@ -265,6 +286,7 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
SetComboboxValue(base::ASCIIToUTF16("05"), autofill::CREDIT_CARD_EXP_MONTH);
SetComboboxValue(base::ASCIIToUTF16("2026"),
autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
+ SelectBillingAddress(billing_profile.guid());
ClickOnDialogViewAndWait(DialogViewID::EDITOR_SAVE_BUTTON);
@@ -310,6 +332,9 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EditingExpiredCard) {
card.set_use_date(kJanuary2017);
card.SetExpirationMonth(1);
card.SetExpirationYear(2017);
+ autofill::AutofillProfile billing_profile(autofill::test::GetFullProfile());
+ PaymentRequestBrowserTestBase::AddAutofillProfile(billing_profile);
+ card.set_billing_address_id(billing_profile.guid());
AddCreditCard(card);
autofill::TestAutofillClock test_clock;
test_clock.SetNow(kJune2017);

Powered by Google App Engine
This is Rietveld 408576698