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/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/JSONValuesForV8.h" | 8 #include "bindings/core/v8/JSONValuesForV8.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 | 435 |
436 TEST_F(PaymentRequestTest, ClearShippingOptionOnPaymentDetailsUpdateWithMultiple
ShippingOptions) | 436 TEST_F(PaymentRequestTest, ClearShippingOptionOnPaymentDetailsUpdateWithMultiple
ShippingOptions) |
437 { | 437 { |
438 ScriptState::Scope scope(getScriptState()); | 438 ScriptState::Scope scope(getScriptState()); |
439 PaymentOptions options; | 439 PaymentOptions options; |
440 options.setRequestShipping(true); | 440 options.setRequestShipping(true); |
441 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState()); | 441 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState()); |
442 EXPECT_FALSE(getExceptionState().hadException()); | 442 EXPECT_FALSE(getExceptionState().hadException()); |
443 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta
te()), MockFunction::expectNoCall(getScriptState())); | 443 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta
te()), MockFunction::expectNoCall(getScriptState())); |
444 String detail = "{\"items\": [{\"id\": \"total\", \"label\": \"Total\", \"am
ount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\"}}]," | 444 String detail = "{\"items\": [{\"id\": \"total\", \"label\": \"Total\", \"am
ount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}]," |
445 "\"shippingOptions\": [{\"id\": \"slow\", \"label\": \"Slow\", \"amount\
": {\"currencyCode\": \"USD\", \"value\": \"5.00\"}}," | 445 "\"shippingOptions\": [{\"id\": \"slow\", \"label\": \"Slow\", \"amount\
": {\"currency\": \"USD\", \"value\": \"5.00\"}}," |
446 "{\"id\": \"fast\", \"label\": \"Fast\", \"amount\": {\"currencyCode\":
\"USD\", \"value\": \"50.00\"}}]}"; | 446 "{\"id\": \"fast\", \"label\": \"Fast\", \"amount\": {\"currencyCode\":
\"USD\", \"value\": \"50.00\"}}]}"; |
447 | 447 |
448 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON
String(getScriptState(), detail, getExceptionState()))); | 448 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON
String(getScriptState(), detail, getExceptionState()))); |
449 EXPECT_FALSE(getExceptionState().hadException()); | 449 EXPECT_FALSE(getExceptionState().hadException()); |
450 | 450 |
451 EXPECT_TRUE(request->shippingOption().isNull()); | 451 EXPECT_TRUE(request->shippingOption().isNull()); |
452 } | 452 } |
453 | 453 |
454 TEST_F(PaymentRequestTest, UseTheSingleShippingOptionFromPaymentDetailsUpdate) | 454 TEST_F(PaymentRequestTest, UseTheSingleShippingOptionFromPaymentDetailsUpdate) |
455 { | 455 { |
456 ScriptState::Scope scope(getScriptState()); | 456 ScriptState::Scope scope(getScriptState()); |
457 PaymentOptions options; | 457 PaymentOptions options; |
458 options.setRequestShipping(true); | 458 options.setRequestShipping(true); |
459 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState()); | 459 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState()); |
460 EXPECT_FALSE(getExceptionState().hadException()); | 460 EXPECT_FALSE(getExceptionState().hadException()); |
461 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta
te()), MockFunction::expectNoCall(getScriptState())); | 461 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta
te()), MockFunction::expectNoCall(getScriptState())); |
462 String detail = "{\"items\": [{\"id\": \"total\", \"label\": \"Total\", \"am
ount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\"}}]," | 462 String detail = "{\"items\": [{\"id\": \"total\", \"label\": \"Total\", \"am
ount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}]," |
463 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \
"Standard shipping\", \"amount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\
"}}]}"; | 463 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \
"Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}]
}"; |
464 | 464 |
465 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON
String(getScriptState(), detail, getExceptionState()))); | 465 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON
String(getScriptState(), detail, getExceptionState()))); |
466 EXPECT_FALSE(getExceptionState().hadException()); | 466 EXPECT_FALSE(getExceptionState().hadException()); |
467 | 467 |
468 EXPECT_EQ("standardShippingOption", request->shippingOption()); | 468 EXPECT_EQ("standardShippingOption", request->shippingOption()); |
469 } | 469 } |
470 | 470 |
471 } // namespace | 471 } // namespace |
472 } // namespace blink | 472 } // namespace blink |
OLD | NEW |