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

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

Issue 2866623003: PaymentRequest.canMakePayment() query quota on desktop. (Closed)
Patch Set: Created 3 years, 7 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex. 89 const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex.
90 AddCreditCard(card); 90 AddCreditCard(card);
91 91
92 CallCanMakePayment(); 92 CallCanMakePayment();
93 93
94 // 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
95 // return false in a normal profile. 95 // return false in a normal profile.
96 ExpectBodyContains({"true"}); 96 ExpectBodyContains({"true"});
97 } 97 }
98 98
99 class PaymentRequestCanMakePaymentQueryCCTest
100 : public PaymentRequestBrowserTestBase {
101 protected:
102 PaymentRequestCanMakePaymentQueryCCTest()
103 : PaymentRequestBrowserTestBase(
104 "/payment_request_can_make_payment_query_cc_test.html") {}
105
106 void CallCanMakePayment(bool visa) {
107 ResetEventObserver(DialogEvent::CAN_MAKE_PAYMENT_CALLED);
108 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(),
109 visa ? "buy();" : "other_buy();"));
110 WaitForObservedEvent();
111 }
112
113 private:
114 DISALLOW_COPY_AND_ASSIGN(PaymentRequestCanMakePaymentQueryCCTest);
115 };
116
117 IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryCCTest, QueryQuota) {
Mathieu 2017/05/08 15:28:11 could we have a test that first queries for basic-
please use gerrit instead 2017/05/08 17:28:47 Done.
118 CallCanMakePayment(true /* visa */);
Mathieu 2017/05/08 15:28:11 /*visa=*/true
please use gerrit instead 2017/05/08 17:28:47 Done.
119 ExpectBodyContains({"false"});
Mathieu 2017/05/08 15:28:11 // User doesn't have a visa.
please use gerrit instead 2017/05/08 17:28:47 Done.
120 CallCanMakePayment(false /* mastercard */);
Mathieu 2017/05/08 15:28:11 /*visa=*/false); // Will query for Mastercard.
please use gerrit instead 2017/05/08 17:28:47 Done.
121 ExpectBodyContains({"NotAllowedError"});
122 AddCreditCard(autofill::test::GetCreditCard()); // visa
123 CallCanMakePayment(true /* visa */);
124 ExpectBodyContains({"true"});
Mathieu 2017/05/08 15:28:11 At first read I would have expected "false" to be
please use gerrit instead 2017/05/08 17:28:47 Done.
125 CallCanMakePayment(false /* mastercard */);
126 ExpectBodyContains({"NotAllowedError"});
127 }
128
99 } // namespace payments 129 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698