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

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

Issue 2779813003: [Payments] Add Ship. Addr. & Contact Info in Payment Response on Desktop. (Closed)
Patch Set: Added Contact Details and some new browser tests 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
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 3f1ac1166e406cd7aca68d9550fc7ba823e45604..f92169d8bc4f31ca7076ae4eee17ec182d7d24f6 100644
--- a/components/payments/content/payment_request_state_unittest.cc
+++ b/components/payments/content/payment_request_state_unittest.cc
@@ -340,4 +340,65 @@ TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_BasicCard) {
response()->stringified_details);
}
+// Tests the the generated PaymentResponse has the correct values for the
+// shipping address.
+TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_ShippingAddress) {
+ mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New();
+ options->request_shipping = true;
+ RecreateStateWithOptions(std::move(options));
+
+ EXPECT_TRUE(state()->is_ready_to_pay());
+ state()->GeneratePaymentResponse();
+
+ // Check that all the expected values were set.
+ EXPECT_EQ("US", response()->shipping_address->country);
+ EXPECT_EQ("666 Erebus St.", response()->shipping_address->address_line[0]);
+ EXPECT_EQ("Apt 8", response()->shipping_address->address_line[1]);
+ EXPECT_EQ("CA", response()->shipping_address->region);
+ EXPECT_EQ("Elysium", response()->shipping_address->city);
+ EXPECT_EQ("", response()->shipping_address->dependent_locality);
+ EXPECT_EQ("91111", response()->shipping_address->postal_code);
+ EXPECT_EQ("", response()->shipping_address->sorting_code);
+ EXPECT_EQ("", response()->shipping_address->language_code);
+ EXPECT_EQ("Underworld", response()->shipping_address->organization);
+ EXPECT_EQ("John H. Doe", response()->shipping_address->recipient);
+ EXPECT_EQ("16502111111", response()->shipping_address->phone);
+}
+
+// Tests the the generated PaymentResponse has the correct values for the
+// contact details when all values are requested.
+TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_ContactDetails_All) {
+ // Request all contact detail values.
+ mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New();
+ options->request_payer_name = true;
+ options->request_payer_phone = true;
+ options->request_payer_email = true;
+ RecreateStateWithOptions(std::move(options));
+
+ EXPECT_TRUE(state()->is_ready_to_pay());
+ state()->GeneratePaymentResponse();
+
+ // Check that all the expected values were set.
+ EXPECT_EQ("John H. Doe", response()->payer_name.value());
+ EXPECT_EQ("16502111111", response()->payer_phone.value());
+ EXPECT_EQ("johndoe@hades.com", response()->payer_email.value());
+}
+
+// Tests the the generated PaymentResponse has the correct values for the
+// contact details when all values are requested.
+TEST_F(PaymentRequestStateTest, GeneratePaymentResponse_ContactDetails_Some) {
+ // Request one contact detail value.
+ mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New();
+ options->request_payer_name = true;
+ RecreateStateWithOptions(std::move(options));
+
+ EXPECT_TRUE(state()->is_ready_to_pay());
+ state()->GeneratePaymentResponse();
+
+ // Check that the name was set, but not the other values.
+ EXPECT_EQ("John H. Doe", response()->payer_name.value());
+ EXPECT_FALSE(response()->payer_phone.has_value());
+ EXPECT_FALSE(response()->payer_email.has_value());
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698