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

Side by Side Diff: components/payments/content/payment_request_spec_unittest.cc

Issue 2843513004: [Payments] Return basic-card as the method name when possible. (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
« no previous file with comments | « no previous file | components/payments/core/payment_request_data_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/payments/content/payment_request_spec.h" 5 #include "components/payments/content/payment_request_spec.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/payments/mojom/payment_request.mojom.h" 10 #include "components/payments/mojom/payment_request.mojom.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 entry2->supported_networks.push_back(mojom::BasicCardNetwork::UNIONPAY); 61 entry2->supported_networks.push_back(mojom::BasicCardNetwork::UNIONPAY);
62 entry2->supported_networks.push_back(mojom::BasicCardNetwork::JCB); 62 entry2->supported_networks.push_back(mojom::BasicCardNetwork::JCB);
63 entry2->supported_networks.push_back(mojom::BasicCardNetwork::VISA); 63 entry2->supported_networks.push_back(mojom::BasicCardNetwork::VISA);
64 64
65 std::vector<mojom::PaymentMethodDataPtr> method_data; 65 std::vector<mojom::PaymentMethodDataPtr> method_data;
66 method_data.push_back(std::move(entry)); 66 method_data.push_back(std::move(entry));
67 method_data.push_back(std::move(entry2)); 67 method_data.push_back(std::move(entry2));
68 68
69 RecreateSpecWithMethodData(std::move(method_data)); 69 RecreateSpecWithMethodData(std::move(method_data));
70 70
71 // Only unionpay and jcb are supported through basic-card. 71 // unionpay and jcb are supported through basic-card. visa is supported
72 // through basic card because it was specified in basic-card in addition to
73 // supportedMethods.
72 EXPECT_TRUE(spec()->IsMethodSupportedThroughBasicCard("unionpay")); 74 EXPECT_TRUE(spec()->IsMethodSupportedThroughBasicCard("unionpay"));
73 EXPECT_TRUE(spec()->IsMethodSupportedThroughBasicCard("jcb")); 75 EXPECT_TRUE(spec()->IsMethodSupportedThroughBasicCard("jcb"));
74 // "visa" is NOT supported through basic card because it was specified 76 EXPECT_TRUE(spec()->IsMethodSupportedThroughBasicCard("visa"));
75 // directly first in supportedMethods.
76 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("visa"));
77 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("mastercard")); 77 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("mastercard"));
78 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("diners")); 78 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("diners"));
79 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("garbage")); 79 EXPECT_FALSE(spec()->IsMethodSupportedThroughBasicCard("garbage"));
80 } 80 }
81 81
82 // Order matters when parsing the supportedMethods and basic card networks. 82 // Order matters when parsing the supportedMethods and basic card networks.
83 TEST_F(PaymentRequestSpecTest, 83 TEST_F(PaymentRequestSpecTest,
84 IsMethodSupportedThroughBasicCard_DifferentOrder) { 84 IsMethodSupportedThroughBasicCard_DifferentOrder) {
85 mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New(); 85 mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
86 entry->supported_methods.push_back("basic-card"); 86 entry->supported_methods.push_back("basic-card");
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 new_option2->id = "option:2"; 293 new_option2->id = "option:2";
294 new_option2->selected = true; 294 new_option2->selected = true;
295 new_shipping_options.push_back(std::move(new_option2)); 295 new_shipping_options.push_back(std::move(new_option2));
296 mojom::PaymentDetailsPtr new_details = mojom::PaymentDetails::New(); 296 mojom::PaymentDetailsPtr new_details = mojom::PaymentDetails::New();
297 new_details->shipping_options = std::move(new_shipping_options); 297 new_details->shipping_options = std::move(new_shipping_options);
298 298
299 spec()->UpdateWith(std::move(new_details)); 299 spec()->UpdateWith(std::move(new_details));
300 } 300 }
301 301
302 } // namespace payments 302 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | components/payments/core/payment_request_data_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698