| 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_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 9 | 9 |
| 10 namespace payments { | 10 namespace payments { |
| 11 | 11 |
| 12 class PaymentRequestCvcUnmaskViewControllerTest | 12 class PaymentRequestCvcUnmaskViewControllerTest |
| 13 : public PaymentRequestBrowserTestBase { | 13 : public PaymentRequestBrowserTestBase { |
| 14 protected: | 14 protected: |
| 15 PaymentRequestCvcUnmaskViewControllerTest() | 15 PaymentRequestCvcUnmaskViewControllerTest() |
| 16 : PaymentRequestBrowserTestBase( | 16 : PaymentRequestBrowserTestBase( |
| 17 "/payment_request_no_shipping_test.html") {} | 17 "/payment_request_no_shipping_test.html") {} |
| 18 | 18 |
| 19 private: | 19 private: |
| 20 DISALLOW_COPY_AND_ASSIGN(PaymentRequestCvcUnmaskViewControllerTest); | 20 DISALLOW_COPY_AND_ASSIGN(PaymentRequestCvcUnmaskViewControllerTest); |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, | 23 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, |
| 24 CvcSentToResponse) { | 24 CvcSentToResponse) { |
| 25 AddCreditCard(autofill::test::GetCreditCard()); // Visa. | 25 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 26 AddAutofillProfile(profile); |
| 27 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 28 card.set_billing_address_id(profile.guid()); |
| 29 AddCreditCard(card); |
| 26 | 30 |
| 27 InvokePaymentRequestUI(); | 31 InvokePaymentRequestUI(); |
| 28 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 32 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
| 29 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); | 33 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); |
| 30 | 34 |
| 31 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); | 35 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); |
| 32 } | 36 } |
| 33 | 37 |
| 34 // Test that going in the CVC editor, backing out and opening it again to pay | 38 // Test that going in the CVC editor, backing out and opening it again to pay |
| 35 // does not crash. | 39 // does not crash. |
| 36 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, | 40 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, |
| 37 OpenGoBackOpenPay) { | 41 OpenGoBackOpenPay) { |
| 38 AddCreditCard(autofill::test::GetCreditCard()); // Visa. | 42 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 43 AddAutofillProfile(profile); |
| 44 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 45 card.set_billing_address_id(profile.guid()); |
| 46 AddCreditCard(card); |
| 39 | 47 |
| 40 InvokePaymentRequestUI(); | 48 InvokePaymentRequestUI(); |
| 41 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); | 49 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); |
| 42 | 50 |
| 43 // Go back before confirming the CVC. | 51 // Go back before confirming the CVC. |
| 44 ClickOnBackArrow(); | 52 ClickOnBackArrow(); |
| 45 | 53 |
| 46 // Now pay for real. | 54 // Now pay for real. |
| 47 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); | 55 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); |
| 48 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); | 56 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); |
| 49 } | 57 } |
| 50 | 58 |
| 51 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, | 59 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, |
| 52 EnterAcceleratorConfirmsCvc) { | 60 EnterAcceleratorConfirmsCvc) { |
| 53 AddCreditCard(autofill::test::GetCreditCard()); // Visa. | 61 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 62 AddAutofillProfile(profile); |
| 63 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 64 card.set_billing_address_id(profile.guid()); |
| 65 AddCreditCard(card); |
| 54 | 66 |
| 55 InvokePaymentRequestUI(); | 67 InvokePaymentRequestUI(); |
| 68 |
| 56 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 69 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
| 70 // This prevents a timeout in error cases where PAY_BUTTON is disabled. |
| 71 ASSERT_TRUE(dialog_view() |
| 72 ->GetViewByID(static_cast<int>(DialogViewID::PAY_BUTTON)) |
| 73 ->enabled()); |
| 57 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); | 74 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); |
| 58 | 75 |
| 59 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 76 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
| 60 views::View* cvc_sheet = dialog_view()->GetViewByID( | 77 views::View* cvc_sheet = dialog_view()->GetViewByID( |
| 61 static_cast<int>(DialogViewID::CVC_UNMASK_SHEET)); | 78 static_cast<int>(DialogViewID::CVC_UNMASK_SHEET)); |
| 62 cvc_sheet->AcceleratorPressed(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 79 cvc_sheet->AcceleratorPressed(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| 63 WaitForAnimation(); | 80 WaitForAnimation(); |
| 64 WaitForObservedEvent(); | 81 WaitForObservedEvent(); |
| 65 | 82 |
| 66 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); | 83 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); |
| 67 } | 84 } |
| 68 | 85 |
| 69 } // namespace payments | 86 } // namespace payments |
| OLD | NEW |