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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" | 9 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
10 #include "components/autofill/core/browser/autofill_test_utils.h" | 10 #include "components/autofill/core/browser/autofill_test_utils.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 }; | 31 }; |
32 | 32 |
33 // Visa is required, and user has a visa instrument. | 33 // Visa is required, and user has a visa instrument. |
34 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, | 34 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, |
35 CanMakePayment_Supported) { | 35 CanMakePayment_Supported) { |
36 const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa. | 36 const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa. |
37 AddCreditCard(card); | 37 AddCreditCard(card); |
38 | 38 |
39 CallCanMakePayment(); | 39 CallCanMakePayment(); |
40 | 40 |
41 ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("true")}); | 41 ExpectBodyContains({"true"}); |
| 42 } |
| 43 |
| 44 // Pages without a valid SSL cerificate always get "false" from |
| 45 // .canMakePayment(). |
| 46 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, |
| 47 CanMakePayment_InvalidSSL) { |
| 48 SetInvalidSsl(); |
| 49 |
| 50 const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa. |
| 51 AddCreditCard(card); |
| 52 |
| 53 CallCanMakePayment(); |
| 54 |
| 55 ExpectBodyContains({"false"}); |
42 } | 56 } |
43 | 57 |
44 // Visa is required, user has a visa instrument, and user is in incognito | 58 // Visa is required, user has a visa instrument, and user is in incognito |
45 // mode. | 59 // mode. |
46 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, | 60 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, |
47 CanMakePayment_Supported_InIncognitoMode) { | 61 CanMakePayment_Supported_InIncognitoMode) { |
48 SetIncognitoForTesting(); | 62 SetIncognito(); |
49 | 63 |
50 const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa. | 64 const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa. |
51 AddCreditCard(card); | 65 AddCreditCard(card); |
52 | 66 |
53 CallCanMakePayment(); | 67 CallCanMakePayment(); |
54 | 68 |
55 ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("true")}); | 69 ExpectBodyContains({"true"}); |
56 } | 70 } |
57 | 71 |
58 // Visa is required, and user doesn't have a visa instrument. | 72 // Visa is required, and user doesn't have a visa instrument. |
59 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, | 73 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, |
60 CanMakePayment_NotSupported) { | 74 CanMakePayment_NotSupported) { |
61 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex. | 75 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex. |
62 AddCreditCard(card); | 76 AddCreditCard(card); |
63 | 77 |
64 CallCanMakePayment(); | 78 CallCanMakePayment(); |
65 | 79 |
66 ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("false")}); | 80 ExpectBodyContains({"false"}); |
67 } | 81 } |
68 | 82 |
69 // Visa is required, user doesn't have a visa instrument and the user is in | 83 // Visa is required, user doesn't have a visa instrument and the user is in |
70 // incognito mode. In this case canMakePayment always returns true. | 84 // incognito mode. In this case canMakePayment always returns true. |
71 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, | 85 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest, |
72 CanMakePayment_NotSupported_InIncognitoMode) { | 86 CanMakePayment_NotSupported_InIncognitoMode) { |
73 SetIncognitoForTesting(); | 87 SetIncognito(); |
74 | 88 |
75 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex. | 89 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex. |
76 AddCreditCard(card); | 90 AddCreditCard(card); |
77 | 91 |
78 CallCanMakePayment(); | 92 CallCanMakePayment(); |
79 | 93 |
80 // Returns true because the user is in incognito mode, even though it should | 94 // Returns true because the user is in incognito mode, even though it should |
81 // return false in a normal profile. | 95 // return false in a normal profile. |
82 ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("true")}); | 96 ExpectBodyContains({"true"}); |
83 } | 97 } |
84 | 98 |
85 } // namespace payments | 99 } // namespace payments |
OLD | NEW |