Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: chrome/browser/ui/views/payments/payment_sheet_view_controller_interactive_uitest.cc

Issue 2715213005: [Payments] Add the pay button, and control its enabled state (Closed)
Patch Set: addressed comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #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_test_utils.h"
9 #include "components/autofill/core/browser/credit_card.h"
10 #include "components/autofill/core/browser/field_types.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace payments {
14
15 // A simple PaymentRequest which simply requests 'visa' or 'mastercard' and
16 // nothing else.
17 class PaymentSheetViewControllerNoShippingTest
18 : public PaymentRequestInteractiveTestBase {
19 protected:
20 PaymentSheetViewControllerNoShippingTest()
21 : PaymentRequestInteractiveTestBase(
22 "/payment_request_no_shipping_test.html") {}
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerNoShippingTest);
26 };
27
28 // With no data present, the pay button should be disabled.
29 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, NoData) {
30 InvokePaymentRequestUI();
31
32 EXPECT_FALSE(IsPayButtonEnabled());
33 }
34
35 // With a supported card (Visa) present, the pay button should be enabled.
36 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest,
37 SupportedCard) {
38 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
39
40 InvokePaymentRequestUI();
41 EXPECT_TRUE(IsPayButtonEnabled());
42 }
43
44 // With only an unsupported card (Amex) in the database, the pay button should
45 // be disabled.
46 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest,
47 UnsupportedCard) {
48 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card.
49
50 InvokePaymentRequestUI();
51 EXPECT_FALSE(IsPayButtonEnabled());
52 }
53
54 // Accepts 'visa' cards and requests the full contact details.
55 class PaymentSheetViewControllerContactDetailsTest
56 : public PaymentRequestInteractiveTestBase {
57 protected:
58 PaymentSheetViewControllerContactDetailsTest()
59 : PaymentRequestInteractiveTestBase(
60 "/payment_request_contact_details_and_free_shipping_test.html") {}
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerContactDetailsTest);
64 };
65
66 // With no data present, the pay button should be disabled.
67 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, NoData) {
68 InvokePaymentRequestUI();
69
70 EXPECT_FALSE(IsPayButtonEnabled());
71 }
72
73 // With a supported card (Visa) present, the pay button is still disabled
74 // because there is no contact details.
75 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
76 SupportedCard_NoContactInfo) {
77 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
78
79 InvokePaymentRequestUI();
80 EXPECT_FALSE(IsPayButtonEnabled());
81 }
82
83 // With a supported card (Visa) present and a complete address profile, there is
84 // enough information to enable the pay button.
85 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
86 SupportedCard_CompleteContactInfo) {
87 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
88 AddAutofillProfile(autofill::test::GetFullProfile());
89
90 InvokePaymentRequestUI();
91 EXPECT_TRUE(IsPayButtonEnabled());
92 }
93
94 // With only an unsupported card present and a complete address profile, the pay
95 // button is disabled.
96 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
97 UnsupportedCard_CompleteContactInfo) {
98 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card.
99 AddAutofillProfile(autofill::test::GetFullProfile());
100
101 InvokePaymentRequestUI();
102 EXPECT_FALSE(IsPayButtonEnabled());
103 }
104
105 // With a supported card (Visa) present and a *incomplete* address profile, the
106 // pay button is disabled.
107 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
108 SupportedCard_IncompleteContactInfo) {
109 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
110
111 autofill::AutofillProfile profile = autofill::test::GetFullProfile();
112 // Remove the name from the profile to be stored.
113 profile.SetRawInfo(autofill::NAME_FIRST, base::ASCIIToUTF16(""));
114 profile.SetRawInfo(autofill::NAME_MIDDLE, base::ASCIIToUTF16(""));
115 profile.SetRawInfo(autofill::NAME_LAST, base::ASCIIToUTF16(""));
116 AddAutofillProfile(profile);
117
118 InvokePaymentRequestUI();
119 EXPECT_FALSE(IsPayButtonEnabled());
120 }
121
122 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698