OLD | NEW |
---|---|
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 "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
6 | 6 |
7 #include "bindings/core/v8/JSONValuesForV8.h" | 7 #include "bindings/core/v8/JSONValuesForV8.h" |
8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 "\"value\": \"5.00\"}}," | 591 "\"value\": \"5.00\"}}," |
592 "\"error\": \"This is an error message.\"}"; | 592 "\"error\": \"This is an error message.\"}"; |
593 | 593 |
594 request->onUpdatePaymentDetails(ScriptValue::from( | 594 request->onUpdatePaymentDetails(ScriptValue::from( |
595 scope.getScriptState(), | 595 scope.getScriptState(), |
596 fromJSONString(scope.getScriptState(), detailWithErrorMsg, | 596 fromJSONString(scope.getScriptState(), detailWithErrorMsg, |
597 scope.getExceptionState()))); | 597 scope.getExceptionState()))); |
598 EXPECT_FALSE(scope.getExceptionState().hadException()); | 598 EXPECT_FALSE(scope.getExceptionState().hadException()); |
599 } | 599 } |
600 | 600 |
601 TEST(PaymentRequestTest, | |
602 ShouldResolveWithEmptyShippingOptionsIfIDsOfShippingOptionsAreDuplicated) { | |
603 V8TestingScope scope; | |
604 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | |
605 makePaymentRequestOriginSecure(scope.document()); | |
606 PaymentDetails details; | |
607 details.setTotal(buildPaymentItemForTest()); | |
608 HeapVector<PaymentShippingOption> shippingOptions(2); | |
609 shippingOptions[0] = buildShippingOptionForTest( | |
610 PaymentTestDataId, PaymentTestOverwriteValue, "standard"); | |
611 shippingOptions[0].setSelected(true); | |
612 shippingOptions[1] = buildShippingOptionForTest( | |
613 PaymentTestDataId, PaymentTestOverwriteValue, "standard"); | |
614 details.setShippingOptions(shippingOptions); | |
615 PaymentOptions options; | |
616 options.setRequestShipping(true); | |
617 PaymentRequest* request = PaymentRequest::create( | |
618 scope.getScriptState(), buildPaymentMethodDataForTest(), details, options, | |
619 scope.getExceptionState()); | |
620 EXPECT_FALSE(scope.getExceptionState().hadException()); | |
621 EXPECT_TRUE(request->shippingOption().isNull()); | |
622 request->show(scope.getScriptState()) | |
623 .then(funcs.expectNoCall(), funcs.expectNoCall()); | |
624 String detailWithShippingOptions = | |
625 "{\"total\": {\"label\": \"Total\", \"amount\": {\"currency\": \"USD\", " | |
626 "\"value\": \"5.00\"}}," | |
627 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": " | |
628 "\"Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": " | |
629 "\"5.00\"}, \"selected\": true}, {\"id\": \"standardShippingOption\", " | |
630 "\"label\": \"Standard shipping\", \"amount\": {\"currency\": \"USD\", " | |
631 "\"value\": \"5.00\"}, \"selected\": true}]}"; | |
please use gerrit instead
2016/10/12 01:28:02
nit: newline
zino
2016/10/12 18:05:24
Done.
| |
632 request->onUpdatePaymentDetails(ScriptValue::from( | |
633 scope.getScriptState(), | |
634 fromJSONString(scope.getScriptState(), detailWithShippingOptions, | |
635 scope.getExceptionState()))); | |
please use gerrit instead
2016/10/12 01:28:02
nit: newline
zino
2016/10/12 18:05:24
Done.
| |
636 EXPECT_FALSE(scope.getExceptionState().hadException()); | |
637 EXPECT_TRUE(request->shippingOption().isNull()); | |
638 } | |
639 | |
601 } // namespace | 640 } // namespace |
602 } // namespace blink | 641 } // namespace blink |
OLD | NEW |