| 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_dialog_view_ids.h" |
| 6 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba
se.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba
se.h" |
| 7 #include "components/autofill/core/browser/autofill_profile.h" | 8 #include "components/autofill/core/browser/autofill_profile.h" |
| 8 #include "components/autofill/core/browser/autofill_test_utils.h" | 9 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 9 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| 10 #include "components/autofill/core/browser/field_types.h" | 11 #include "components/autofill/core/browser/field_types.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace payments { | 14 namespace payments { |
| 14 | 15 |
| 15 // A simple PaymentRequest which simply requests 'visa' or 'mastercard' and | 16 // A simple PaymentRequest which simply requests 'visa' or 'mastercard' and |
| (...skipping 28 matching lines...) Expand all Loading... |
| 44 // With only an unsupported card (Amex) in the database, the pay button should | 45 // With only an unsupported card (Amex) in the database, the pay button should |
| 45 // be disabled. | 46 // be disabled. |
| 46 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, | 47 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, |
| 47 UnsupportedCard) { | 48 UnsupportedCard) { |
| 48 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. | 49 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card. |
| 49 | 50 |
| 50 InvokePaymentRequestUI(); | 51 InvokePaymentRequestUI(); |
| 51 EXPECT_FALSE(IsPayButtonEnabled()); | 52 EXPECT_FALSE(IsPayButtonEnabled()); |
| 52 } | 53 } |
| 53 | 54 |
| 55 // If shipping and contact info are not requested, their rows should not be |
| 56 // present. |
| 57 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, |
| 58 NoShippingNoContactRows) { |
| 59 InvokePaymentRequestUI(); |
| 60 |
| 61 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 62 DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION))); |
| 63 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 64 DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION))); |
| 65 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 66 DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION))); |
| 67 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 68 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION))); |
| 69 } |
| 70 |
| 54 // Accepts 'visa' cards and requests the full contact details. | 71 // Accepts 'visa' cards and requests the full contact details. |
| 55 class PaymentSheetViewControllerContactDetailsTest | 72 class PaymentSheetViewControllerContactDetailsTest |
| 56 : public PaymentRequestInteractiveTestBase { | 73 : public PaymentRequestInteractiveTestBase { |
| 57 protected: | 74 protected: |
| 58 PaymentSheetViewControllerContactDetailsTest() | 75 PaymentSheetViewControllerContactDetailsTest() |
| 59 : PaymentRequestInteractiveTestBase( | 76 : PaymentRequestInteractiveTestBase( |
| 60 "/payment_request_contact_details_and_free_shipping_test.html") {} | 77 "/payment_request_contact_details_and_free_shipping_test.html") {} |
| 61 | 78 |
| 62 private: | 79 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerContactDetailsTest); | 80 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerContactDetailsTest); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Remove the name from the profile to be stored. | 129 // Remove the name from the profile to be stored. |
| 113 profile.SetRawInfo(autofill::NAME_FIRST, base::ASCIIToUTF16("")); | 130 profile.SetRawInfo(autofill::NAME_FIRST, base::ASCIIToUTF16("")); |
| 114 profile.SetRawInfo(autofill::NAME_MIDDLE, base::ASCIIToUTF16("")); | 131 profile.SetRawInfo(autofill::NAME_MIDDLE, base::ASCIIToUTF16("")); |
| 115 profile.SetRawInfo(autofill::NAME_LAST, base::ASCIIToUTF16("")); | 132 profile.SetRawInfo(autofill::NAME_LAST, base::ASCIIToUTF16("")); |
| 116 AddAutofillProfile(profile); | 133 AddAutofillProfile(profile); |
| 117 | 134 |
| 118 InvokePaymentRequestUI(); | 135 InvokePaymentRequestUI(); |
| 119 EXPECT_FALSE(IsPayButtonEnabled()); | 136 EXPECT_FALSE(IsPayButtonEnabled()); |
| 120 } | 137 } |
| 121 | 138 |
| 139 // If shipping and contact info are requested, show all the rows. |
| 140 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, |
| 141 AllRowsPresent) { |
| 142 InvokePaymentRequestUI(); |
| 143 |
| 144 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 145 DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION))); |
| 146 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 147 DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION))); |
| 148 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 149 DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION))); |
| 150 EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
| 151 DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION))); |
| 152 } |
| 153 |
| 122 } // namespace payments | 154 } // namespace payments |
| OLD | NEW |