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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp

Issue 2351533002: PaymentRequest: Add support for shipping type. (in blink side) (Closed)
Patch Set: PaymentRequest: Add support for shipping type. (in blink side) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequest.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
index 7e8704b3fc3c64fe23293987007ce7ded97f44d9..5c93ec672f06aaed3b52fbe945496dfabf380d10 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
@@ -184,6 +184,79 @@ TEST(PaymentRequestTest, SelectLastSelectedShippingOptionWhenShippingRequested)
EXPECT_EQ("express", request->shippingOption());
}
+TEST(PaymentRequestTest, NullShippingTypeWhenRequestShippingIsFalse)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ PaymentOptions options;
+ options.setRequestShipping(false);
+
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, scope.getExceptionState());
+
+ EXPECT_TRUE(request->shippingType().isNull());
+}
+
+TEST(PaymentRequestTest, DefaultShippingTypeWhenRequestShippingIsTrueWithNoSpecificType)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ PaymentOptions options;
+ options.setRequestShipping(true);
+
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, scope.getExceptionState());
+
+ EXPECT_EQ("shipping", request->shippingType());
+}
+
+TEST(PaymentRequestTest, DeliveryShippingTypeWhenShippingTypeIsDelivery)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ PaymentOptions options;
+ options.setRequestShipping(true);
+ options.setShippingType("delivery");
+
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, scope.getExceptionState());
+
+ EXPECT_EQ("delivery", request->shippingType());
+}
+
+TEST(PaymentRequestTest, PickupShippingTypeWhenShippingTypeIsPickup)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ PaymentOptions options;
+ options.setRequestShipping(true);
+ options.setShippingType("pickup");
+
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, scope.getExceptionState());
+
+ EXPECT_EQ("pickup", request->shippingType());
+}
+
+TEST(PaymentRequestTest, DefaultShippingTypeWhenShippingTypeIsInvalid)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ PaymentOptions options;
+ options.setRequestShipping(true);
+ options.setShippingType("invalid");
+
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, scope.getExceptionState());
+
+ EXPECT_EQ("shipping", request->shippingType());
+}
+
TEST(PaymentRequestTest, RejectShowPromiseOnInvalidShippingAddress)
{
V8TestingScope scope;
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequest.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698