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

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

Issue 2734693002: [Payments] Convert interactive tests to browsertests (Closed)
Patch Set: Initial 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
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_dialog_view_ids.h"
7 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba se.h"
8 #include "components/autofill/core/browser/autofill_profile.h"
9 #include "components/autofill/core/browser/autofill_test_utils.h"
10 #include "components/autofill/core/browser/credit_card.h"
11 #include "components/autofill/core/browser/field_types.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace payments {
15
16 // A simple PaymentRequest which simply requests 'visa' or 'mastercard' and
17 // nothing else.
18 class PaymentSheetViewControllerNoShippingTest
19 : public PaymentRequestInteractiveTestBase {
20 protected:
21 PaymentSheetViewControllerNoShippingTest()
22 : PaymentRequestInteractiveTestBase(
23 "/payment_request_no_shipping_test.html") {}
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerNoShippingTest);
27 };
28
29 // With no data present, the pay button should be disabled.
30 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, NoData) {
31 InvokePaymentRequestUI();
32
33 EXPECT_FALSE(IsPayButtonEnabled());
34 }
35
36 // With a supported card (Visa) present, the pay button should be enabled.
37 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest,
38 SupportedCard) {
39 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
40
41 InvokePaymentRequestUI();
42 EXPECT_TRUE(IsPayButtonEnabled());
43 }
44
45 // With only an unsupported card (Amex) in the database, the pay button should
46 // be disabled.
47 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest,
48 UnsupportedCard) {
49 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card.
50
51 InvokePaymentRequestUI();
52 EXPECT_FALSE(IsPayButtonEnabled());
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
71 // Accepts 'visa' cards and requests the full contact details.
72 class PaymentSheetViewControllerContactDetailsTest
73 : public PaymentRequestInteractiveTestBase {
74 protected:
75 PaymentSheetViewControllerContactDetailsTest()
76 : PaymentRequestInteractiveTestBase(
77 "/payment_request_contact_details_and_free_shipping_test.html") {}
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(PaymentSheetViewControllerContactDetailsTest);
81 };
82
83 // With no data present, the pay button should be disabled.
84 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest, NoData) {
85 InvokePaymentRequestUI();
86
87 EXPECT_FALSE(IsPayButtonEnabled());
88 }
89
90 // With a supported card (Visa) present, the pay button is still disabled
91 // because there is no contact details.
92 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
93 SupportedCard_NoContactInfo) {
94 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
95
96 InvokePaymentRequestUI();
97 EXPECT_FALSE(IsPayButtonEnabled());
98 }
99
100 // With a supported card (Visa) present and a complete address profile, there is
101 // enough information to enable the pay button.
102 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
103 SupportedCard_CompleteContactInfo) {
104 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
105 AddAutofillProfile(autofill::test::GetFullProfile());
106
107 InvokePaymentRequestUI();
108 EXPECT_TRUE(IsPayButtonEnabled());
109 }
110
111 // With only an unsupported card present and a complete address profile, the pay
112 // button is disabled.
113 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
114 UnsupportedCard_CompleteContactInfo) {
115 AddCreditCard(autofill::test::GetCreditCard2()); // Amex card.
116 AddAutofillProfile(autofill::test::GetFullProfile());
117
118 InvokePaymentRequestUI();
119 EXPECT_FALSE(IsPayButtonEnabled());
120 }
121
122 // With a supported card (Visa) present and a *incomplete* address profile, the
123 // pay button is disabled.
124 IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerContactDetailsTest,
125 SupportedCard_IncompleteContactInfo) {
126 AddCreditCard(autofill::test::GetCreditCard()); // Visa card.
127
128 autofill::AutofillProfile profile = autofill::test::GetFullProfile();
129 // Remove the name from the profile to be stored.
130 profile.SetRawInfo(autofill::NAME_FIRST, base::ASCIIToUTF16(""));
131 profile.SetRawInfo(autofill::NAME_MIDDLE, base::ASCIIToUTF16(""));
132 profile.SetRawInfo(autofill::NAME_LAST, base::ASCIIToUTF16(""));
133 AddAutofillProfile(profile);
134
135 InvokePaymentRequestUI();
136 EXPECT_FALSE(IsPayButtonEnabled());
137 }
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
154 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698