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 "components/autofill/core/browser/autofill_test_utils.h" | 7 #include "components/autofill/core/browser/autofill_test_utils.h" |
8 | 8 |
9 namespace payments { | 9 namespace payments { |
10 | 10 |
11 class PaymentRequestCvcUnmaskViewControllerTest | 11 class PaymentRequestCvcUnmaskViewControllerTest |
12 : public PaymentRequestBrowserTestBase { | 12 : public PaymentRequestBrowserTestBase { |
13 protected: | 13 protected: |
14 PaymentRequestCvcUnmaskViewControllerTest() | 14 PaymentRequestCvcUnmaskViewControllerTest() |
15 : PaymentRequestBrowserTestBase( | 15 : PaymentRequestBrowserTestBase( |
16 "/payment_request_no_shipping_test.html") {} | 16 "/payment_request_no_shipping_test.html") {} |
17 | 17 |
18 private: | 18 private: |
19 DISALLOW_COPY_AND_ASSIGN(PaymentRequestCvcUnmaskViewControllerTest); | 19 DISALLOW_COPY_AND_ASSIGN(PaymentRequestCvcUnmaskViewControllerTest); |
20 }; | 20 }; |
21 | 21 |
22 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, | 22 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, |
23 CvcSentToResponse) { | 23 CvcSentToResponse) { |
24 AddCreditCard(autofill::test::GetCreditCard()); // Visa. | 24 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 25 AddAutofillProfile(profile); |
| 26 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 27 card.set_billing_address_id(profile.guid()); |
| 28 AddCreditCard(card); |
25 | 29 |
26 InvokePaymentRequestUI(); | 30 InvokePaymentRequestUI(); |
27 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 31 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
28 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); | 32 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); |
29 | 33 |
30 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); | 34 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); |
31 } | 35 } |
32 | 36 |
33 // Test that going in the CVC editor, backing out and opening it again to pay | 37 // Test that going in the CVC editor, backing out and opening it again to pay |
34 // does not crash. | 38 // does not crash. |
35 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, | 39 IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest, |
36 OpenGoBackOpenPay) { | 40 OpenGoBackOpenPay) { |
37 AddCreditCard(autofill::test::GetCreditCard()); // Visa. | 41 autofill::AutofillProfile profile(autofill::test::GetFullProfile()); |
| 42 AddAutofillProfile(profile); |
| 43 autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa card. |
| 44 card.set_billing_address_id(profile.guid()); |
| 45 AddCreditCard(card); |
38 | 46 |
39 InvokePaymentRequestUI(); | 47 InvokePaymentRequestUI(); |
40 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); | 48 OpenCVCPromptWithCVC(base::ASCIIToUTF16("012")); |
41 | 49 |
42 // Go back before confirming the CVC. | 50 // Go back before confirming the CVC. |
43 ClickOnBackArrow(); | 51 ClickOnBackArrow(); |
44 | 52 |
45 // Now pay for real. | 53 // Now pay for real. |
46 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); | 54 PayWithCreditCardAndWait(base::ASCIIToUTF16("012")); |
47 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); | 55 ExpectBodyContains({"\"cardSecurityCode\": \"012\""}); |
48 } | 56 } |
49 | 57 |
50 } // namespace payments | 58 } // namespace payments |
OLD | NEW |