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

Unified Diff: chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc

Issue 2766353004: [Payments] Support canMakePayment on Desktop (Closed)
Patch Set: only support valid instruments, added test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc b/chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31836bf58fe5feb2ab68723ec8ddf7d979f67315
--- /dev/null
+++ b/chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc
@@ -0,0 +1,53 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
+#include "components/autofill/core/browser/autofill_test_utils.h"
+#include "components/autofill/core/browser/credit_card.h"
+#include "content/public/test/browser_test_utils.h"
+
+namespace payments {
+
+class PaymentRequestCanMakePaymentQueryTest
+ : public PaymentRequestBrowserTestBase {
+ protected:
+ PaymentRequestCanMakePaymentQueryTest()
+ : PaymentRequestBrowserTestBase(
+ "/payment_request_can_make_payment_query_test.html") {}
+
+ void CallCanMakePayment() {
+ ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "buy();"));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PaymentRequestCanMakePaymentQueryTest);
+};
+
+// Visa is required, and user has a visa instrument.
+IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest,
+ CanMakePayment_Supported) {
+ const autofill::CreditCard card = autofill::test::GetCreditCard(); // Visa.
+ AddCreditCard(card);
+
+ CallCanMakePayment();
+
+ ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("true")});
+}
+
+// Visa is required, and user doesn't have a visa instrument.
+IN_PROC_BROWSER_TEST_F(PaymentRequestCanMakePaymentQueryTest,
+ CanMakePayment_NotSupported) {
+ const autofill::CreditCard card = autofill::test::GetCreditCard2(); // Amex.
+ AddCreditCard(card);
+
+ CallCanMakePayment();
+
+ ExpectBodyContains(std::vector<base::string16>{base::ASCIIToUTF16("false")});
+}
+
+} // namespace payments
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698