| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" | 6 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 8 #include "components/autofill/core/browser/autofill_profile.h" | 8 #include "components/autofill/core/browser/autofill_profile.h" |
| 9 #include "components/autofill/core/browser/autofill_test_utils.h" | 9 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // With no data present, the pay button should be disabled. | 29 // With no data present, the pay button should be disabled. |
| 30 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, NoData) { | 30 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, NoData) { |
| 31 InvokePaymentRequestUI(); | 31 InvokePaymentRequestUI(); |
| 32 | 32 |
| 33 EXPECT_FALSE(IsPayButtonEnabled()); | 33 EXPECT_FALSE(IsPayButtonEnabled()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // With a supported card (Visa) present, the pay button should be enabled. | 36 // With a supported card (Visa) present, the pay button should be enabled. |
| 37 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, | 37 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, |
| 38 SupportedCard) { | 38 SupportedCard) { |
| 39 AddCreditCard(autofill::test::GetCreditCard()); // Visa card. | 39 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 40 AddAutofillProfile(profile); |
| 41 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 42 card.set_billing_address_id(profile.guid()); |
| 43 AddCreditCard(card); |
| 40 | 44 |
| 41 InvokePaymentRequestUI(); | 45 InvokePaymentRequestUI(); |
| 42 EXPECT_TRUE(IsPayButtonEnabled()); | 46 EXPECT_TRUE(IsPayButtonEnabled()); |
| 43 } | 47 } |
| 44 | 48 |
| 45 // With only an unsupported card (Amex) in the database, the pay button should | 49 // With only an unsupported card (Amex) in the database, the pay button should |
| 46 // be disabled. | 50 // be disabled. |
| 47 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, | 51 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, |
| 48 UnsupportedCard) { | 52 UnsupportedCard) { |
| 49 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. | 53 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 AddCreditCard(autofill::test::GetCreditCard()); // Visa card. | 102 AddCreditCard(autofill::test::GetCreditCard()); // Visa card. |
| 99 | 103 |
| 100 InvokePaymentRequestUI(); | 104 InvokePaymentRequestUI(); |
| 101 EXPECT_FALSE(IsPayButtonEnabled()); | 105 EXPECT_FALSE(IsPayButtonEnabled()); |
| 102 } | 106 } |
| 103 | 107 |
| 104 // With a supported card (Visa) present and a complete address profile, there is | 108 // With a supported card (Visa) present and a complete address profile, there is |
| 105 // enough information to enable the pay button. | 109 // enough information to enable the pay button. |
| 106 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, | 110 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, |
| 107 SupportedCard_CompleteContactInfo) { | 111 SupportedCard_CompleteContactInfo) { |
| 108 AddCreditCard(autofill::test::GetCreditCard()); // Visa card. | 112 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 109 AddAutofillProfile(autofill::test::GetFullProfile()); | 113 AddAutofillProfile(profile); |
| 114 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 115 card.set_billing_address_id(profile.guid()); |
| 116 AddCreditCard(card); |
| 110 | 117 |
| 111 InvokePaymentRequestUI(); | 118 InvokePaymentRequestUI(); |
| 112 EXPECT_TRUE(IsPayButtonEnabled()); | 119 EXPECT_TRUE(IsPayButtonEnabled()); |
| 113 } | 120 } |
| 114 | 121 |
| 115 // With only an unsupported card present and a complete address profile, the pay | 122 // With only an unsupported card present and a complete address profile, the pay |
| 116 // button is disabled. | 123 // button is disabled. |
| 117 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, | 124 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, |
| 118 UnsupportedCard_CompleteContactInfo) { | 125 UnsupportedCard_CompleteContactInfo) { |
| 119 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. | 126 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 EXPECT_NE(nullptr, | 163 EXPECT_NE(nullptr, |
| 157 dialog_view()->GetViewByID(static_cast<int>( | 164 dialog_view()->GetViewByID(static_cast<int>( |
| 158 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON))); | 165 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON))); |
| 159 EXPECT_NE(nullptr, | 166 EXPECT_NE(nullptr, |
| 160 dialog_view()->GetViewByID(static_cast<int>( | 167 dialog_view()->GetViewByID(static_cast<int>( |
| 161 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION_BUTTON))); | 168 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION_BUTTON))); |
| 162 } | 169 } |
| 163 | 170 |
| 164 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, | 171 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, |
| 165 AllClickableRowsPresent) { | 172 AllClickableRowsPresent) { |
| 166 AddCreditCard(autofill::test::GetCreditCard()); // Visa card. | 173 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 167 AddAutofillProfile(autofill::test::GetFullProfile()); | 174 AddAutofillProfile(profile); |
| 175 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 176 card.set_billing_address_id(profile.guid()); |
| 177 AddCreditCard(card); |
| 168 InvokePaymentRequestUI(); | 178 InvokePaymentRequestUI(); |
| 169 | 179 |
| 170 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( | 180 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 171 DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION))); | 181 DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION))); |
| 172 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( | 182 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 173 DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION))); | 183 DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION))); |
| 174 EXPECT_NE(nullptr, | 184 EXPECT_NE(nullptr, |
| 175 dialog_view()->GetViewByID(static_cast<int>( | 185 dialog_view()->GetViewByID(static_cast<int>( |
| 176 DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION))); | 186 DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION))); |
| 177 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( | 187 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 178 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); | 188 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); |
| 179 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( | 189 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 180 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION))); | 190 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION))); |
| 181 } | 191 } |
| 182 | 192 |
| 183 } // namespace payments | 193 } // namespace payments |
| OLD | NEW |