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

Unified Diff: components/payments/content/payment_request_state_unittest.cc

Issue 2779453002: [Payments] Return the preferred payment method name to the merchant (Closed)
Patch Set: compile fix 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 | « components/payments/content/payment_request_state.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/content/payment_request_state_unittest.cc
diff --git a/components/payments/content/payment_request_state_unittest.cc b/components/payments/content/payment_request_state_unittest.cc
index 65293eab02e044c920ef8c49848496122e2840a4..3f1ac1166e406cd7aca68d9550fc7ba823e45604 100644
--- a/components/payments/content/payment_request_state_unittest.cc
+++ b/components/payments/content/payment_request_state_unittest.cc
@@ -273,7 +273,7 @@ TEST_F(PaymentRequestStateTest, ReadyToPay_ContactInfo) {
}
// Test generating a PaymentResponse.
-TEST_F(PaymentRequestStateTest, GeneratePaymentResponse) {
+TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_SupportedMethod) {
// Default options (no shipping, no contact info).
RecreateStateWithOptions(mojom::PaymentOptions::New());
state()->SetSelectedInstrument(state()->available_instruments()[0].get());
@@ -281,6 +281,8 @@ TEST_F(PaymentRequestStateTest, GeneratePaymentResponse) {
EXPECT_TRUE(state()->is_ready_to_pay());
// TODO(mathp): Currently synchronous, when async will need a RunLoop.
+ // "visa" is specified directly in the supportedMethods so it is returned
+ // as the method name.
state()->GeneratePaymentResponse();
EXPECT_EQ("visa", response()->method_name);
EXPECT_EQ(
@@ -301,4 +303,41 @@ TEST_F(PaymentRequestStateTest, GeneratePaymentResponse) {
response()->stringified_details);
}
+// Test generating a PaymentResponse when the method is specified through
+// "basic-card".
+TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_BasicCard) {
+ // The method data supports visa through basic-card.
+ mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
+ entry->supported_methods.push_back("basic-card");
+ entry->supported_networks.push_back(mojom::BasicCardNetwork::VISA);
+ std::vector<mojom::PaymentMethodDataPtr> method_data;
+ method_data.push_back(std::move(entry));
+ RecreateStateWithOptionsAndDetails(mojom::PaymentOptions::New(),
+ mojom::PaymentDetails::New(),
+ std::move(method_data));
+
+ EXPECT_TRUE(state()->is_ready_to_pay());
+
+ // TODO(mathp): Currently synchronous, when async will need a RunLoop.
+ // "basic-card" is specified so it is returned as the method name.
+ state()->GeneratePaymentResponse();
+ EXPECT_EQ("basic-card", response()->method_name);
+ EXPECT_EQ(
+ "{\"billingAddress\":"
+ "{\"addressLine\":[\"666 Erebus St.\",\"Apt 8\"],"
+ "\"city\":\"Elysium\","
+ "\"country\":\"US\","
+ "\"organization\":\"Underworld\","
+ "\"phone\":\"16502111111\","
+ "\"postalCode\":\"91111\","
+ "\"recipient\":\"John H. Doe\","
+ "\"region\":\"CA\"},"
+ "\"cardNumber\":\"4111111111111111\","
+ "\"cardSecurityCode\":\"123\","
+ "\"cardholderName\":\"Test User\","
+ "\"expiryMonth\":\"11\","
+ "\"expiryYear\":\"2017\"}",
+ response()->stringified_details);
+}
+
} // namespace payments
« no previous file with comments | « components/payments/content/payment_request_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698