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

Side by Side Diff: ios/web/payments/payment_request_unittest.cc

Issue 2289263003: Revert of Add support for method selection in the Payment Request UI on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 | « ios/web/payments/payment_request.cc ('k') | ios/web/public/payments/payment_request.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/web/public/payments/payment_request.h" 5 #include "ios/web/public/payments/payment_request.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 EXPECT_TRUE(output_request.FromDictionaryValue(request_dict)); 98 EXPECT_TRUE(output_request.FromDictionaryValue(request_dict));
99 EXPECT_EQ(expected_request, output_request); 99 EXPECT_EQ(expected_request, output_request);
100 } 100 }
101 101
102 // PaymentResponse serialization tests. 102 // PaymentResponse serialization tests.
103 103
104 // Tests that serializing a default PaymentResponse yields an empty dictionary. 104 // Tests that serializing a default PaymentResponse yields an empty dictionary.
105 TEST(PaymentRequestTest, EmptyResponseDictionary) { 105 TEST(PaymentRequestTest, EmptyResponseDictionary) {
106 base::DictionaryValue expected_value; 106 base::DictionaryValue expected_value;
107 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); 107 base::DictionaryValue output_value;
108 std::unique_ptr<base::DictionaryValue> address(new base::DictionaryValue);
109 details->Set("billingAddress", std::move(address));
110 expected_value.Set("details", std::move(details));
111 108
112 PaymentResponse payment_response; 109 PaymentResponse payment_response;
113 EXPECT_TRUE( 110 payment_response.ToDictionaryValue(&output_value);
114 expected_value.Equals(payment_response.ToDictionaryValue().get())); 111 EXPECT_TRUE(expected_value.Equals(&output_value));
115 } 112 }
116 113
117 // Tests that serializing a populated PaymentResponse yields the expected 114 // Tests that serializing a populated PaymentResponse yields the expected
118 // result. 115 // result.
119 TEST(PaymentRequestTest, PopulatedResponseDictionary) { 116 TEST(PaymentRequestTest, PopulatedResponseDictionary) {
120 base::DictionaryValue expected_value; 117 base::DictionaryValue expected_value;
121 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); 118 base::DictionaryValue output_value;
122 std::unique_ptr<base::DictionaryValue> address(new base::DictionaryValue);
123 details->Set("billingAddress", std::move(address));
124 expected_value.Set("details", std::move(details));
125 119
126 expected_value.SetString("methodName", "American Express"); 120 expected_value.SetString("methodName", "American Express");
127 PaymentResponse payment_response; 121 PaymentResponse payment_response;
128 payment_response.method_name = base::ASCIIToUTF16("American Express"); 122 payment_response.method_name = base::ASCIIToUTF16("American Express");
129 EXPECT_TRUE( 123 payment_response.ToDictionaryValue(&output_value);
130 expected_value.Equals(payment_response.ToDictionaryValue().get())); 124 EXPECT_TRUE(expected_value.Equals(&output_value));
131 125
132 details.reset(new base::DictionaryValue); 126 expected_value.SetString("details", "{cardSecurityCode: '123'}");
133 address.reset(new base::DictionaryValue); 127 payment_response.details = base::ASCIIToUTF16("{cardSecurityCode: '123'}");
134 address->SetString("postalCode", "90210"); 128 payment_response.ToDictionaryValue(&output_value);
135 details->Set("billingAddress", std::move(address)); 129 EXPECT_TRUE(expected_value.Equals(&output_value));
136 expected_value.Set("details", std::move(details));
137 payment_response.details.billing_address.postal_code =
138 base::ASCIIToUTF16("90210");
139 EXPECT_TRUE(
140 expected_value.Equals(payment_response.ToDictionaryValue().get()));
141 } 130 }
142 131
143 // Value equality tests. 132 // Value equality tests.
144 133
145 // Tests that two addresses are not equal if their property values differ or 134 // Tests that two addresses are not equal if their property values differ or
146 // one is missing a value present in the other, and equal otherwise. 135 // one is missing a value present in the other, and equal otherwise.
147 TEST(PaymentRequestTest, PaymentAddressEquality) { 136 TEST(PaymentRequestTest, PaymentAddressEquality) {
148 PaymentAddress address1; 137 PaymentAddress address1;
149 PaymentAddress address2; 138 PaymentAddress address2;
150 EXPECT_EQ(address1, address2); 139 EXPECT_EQ(address1, address2);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 EXPECT_EQ(request1, request2); 512 EXPECT_EQ(request1, request2);
524 513
525 PaymentOptions options; 514 PaymentOptions options;
526 options.request_shipping = true; 515 options.request_shipping = true;
527 request1.options = options; 516 request1.options = options;
528 EXPECT_NE(request1, request2); 517 EXPECT_NE(request1, request2);
529 request2.options = options; 518 request2.options = options;
530 EXPECT_EQ(request1, request2); 519 EXPECT_EQ(request1, request2);
531 } 520 }
532 521
533 // Tests that two credit card response objects are not equal if their property
534 // values differ or one is missing a value present in the other, and equal
535 // otherwise. Doesn't test all properties of child objects, relying instead on
536 // their respective tests.
537 TEST(PaymentRequestTest, BasicCardResponseEquality) {
538 BasicCardResponse card_response1;
539 BasicCardResponse card_response2;
540 EXPECT_EQ(card_response1, card_response2);
541
542 card_response1.cardholder_name = base::ASCIIToUTF16("Shadow Moon");
543 EXPECT_NE(card_response1, card_response2);
544 card_response2.cardholder_name = base::ASCIIToUTF16("Mad Sweeney");
545 EXPECT_NE(card_response1, card_response2);
546 card_response2.cardholder_name = base::ASCIIToUTF16("Shadow Moon");
547 EXPECT_EQ(card_response1, card_response2);
548
549 card_response1.card_number = base::ASCIIToUTF16("4111111111111111");
550 EXPECT_NE(card_response1, card_response2);
551 card_response2.card_number = base::ASCIIToUTF16("1111");
552 EXPECT_NE(card_response1, card_response2);
553 card_response2.card_number = base::ASCIIToUTF16("4111111111111111");
554 EXPECT_EQ(card_response1, card_response2);
555
556 card_response1.expiry_month = base::ASCIIToUTF16("01");
557 EXPECT_NE(card_response1, card_response2);
558 card_response2.expiry_month = base::ASCIIToUTF16("11");
559 EXPECT_NE(card_response1, card_response2);
560 card_response2.expiry_month = base::ASCIIToUTF16("01");
561 EXPECT_EQ(card_response1, card_response2);
562
563 card_response1.expiry_year = base::ASCIIToUTF16("27");
564 EXPECT_NE(card_response1, card_response2);
565 card_response2.expiry_year = base::ASCIIToUTF16("72");
566 EXPECT_NE(card_response1, card_response2);
567 card_response2.expiry_year = base::ASCIIToUTF16("27");
568 EXPECT_EQ(card_response1, card_response2);
569
570 card_response1.expiry_year = base::ASCIIToUTF16("123");
571 EXPECT_NE(card_response1, card_response2);
572 card_response2.expiry_year = base::ASCIIToUTF16("999");
573 EXPECT_NE(card_response1, card_response2);
574 card_response2.expiry_year = base::ASCIIToUTF16("123");
575 EXPECT_EQ(card_response1, card_response2);
576
577 PaymentAddress billing_address1;
578 billing_address1.postal_code = base::ASCIIToUTF16("90210");
579 PaymentAddress billing_address2;
580 billing_address2.postal_code = base::ASCIIToUTF16("01209");
581 card_response1.billing_address = billing_address1;
582 EXPECT_NE(card_response1, card_response2);
583 card_response2.billing_address = billing_address2;
584 EXPECT_NE(card_response1, card_response2);
585 card_response2.billing_address = billing_address1;
586 EXPECT_EQ(card_response1, card_response2);
587 }
588
589 // Tests that two payment response objects are not equal if their property 522 // Tests that two payment response objects are not equal if their property
590 // values differ or one is missing a value present in the other, and equal 523 // values differ or one is missing a value present in the other, and equal
591 // otherwise. Doesn't test all properties of child objects, relying instead on 524 // otherwise.
592 // their respective tests.
593 TEST(PaymentRequestTest, PaymentResponseEquality) { 525 TEST(PaymentRequestTest, PaymentResponseEquality) {
594 PaymentResponse response1; 526 PaymentResponse response1;
595 PaymentResponse response2; 527 PaymentResponse response2;
596 EXPECT_EQ(response1, response2); 528 EXPECT_EQ(response1, response2);
597 529
598 response1.method_name = base::ASCIIToUTF16("Visa"); 530 response1.method_name = base::ASCIIToUTF16("Visa");
599 EXPECT_NE(response1, response2); 531 EXPECT_NE(response1, response2);
600 response2.method_name = base::ASCIIToUTF16("Mastercard"); 532 response2.method_name = base::ASCIIToUTF16("Mastercard");
601 EXPECT_NE(response1, response2); 533 EXPECT_NE(response1, response2);
602 response2.method_name = base::ASCIIToUTF16("Visa"); 534 response2.method_name = base::ASCIIToUTF16("Visa");
603 EXPECT_EQ(response1, response2); 535 EXPECT_EQ(response1, response2);
604 536
605 BasicCardResponse card_response1; 537 response1.details = base::ASCIIToUTF16("{cardSecurityCode: '123'}");
606 card_response1.card_number = base::ASCIIToUTF16("1234");
607 BasicCardResponse card_response2;
608 card_response2.card_number = base::ASCIIToUTF16("8888");
609 response1.details = card_response1;
610 EXPECT_NE(response1, response2); 538 EXPECT_NE(response1, response2);
611 response2.details = card_response2; 539 response2.details = base::ASCIIToUTF16("{cardSecurityCode: '---'}");
612 EXPECT_NE(response1, response2); 540 EXPECT_NE(response1, response2);
613 response2.details = card_response1; 541 response2.details = base::ASCIIToUTF16("{cardSecurityCode: '123'}");
614 EXPECT_EQ(response1, response2); 542 EXPECT_EQ(response1, response2);
615 } 543 }
616 544
617 } // namespace web 545 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/payments/payment_request.cc ('k') | ios/web/public/payments/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698