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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp

Issue 1981903002: PaymentRequest: Rename 'currencyCode' to 'currency' in CurrencyAmount.idl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « third_party/WebKit/Source/modules/payments/PaymentRequest.cpp ('k') | no next file » | 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 "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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 { 413 {
414 ScriptState::Scope scope(getScriptState()); 414 ScriptState::Scope scope(getScriptState());
415 PaymentDetails details; 415 PaymentDetails details;
416 details.setItems(HeapVector<PaymentItem>(1, buildPaymentItemForTest())); 416 details.setItems(HeapVector<PaymentItem>(1, buildPaymentItemForTest()));
417 PaymentOptions options; 417 PaymentOptions options;
418 options.setRequestShipping(true); 418 options.setRequestShipping(true);
419 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), details, options, getExceptionState()); 419 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), details, options, getExceptionState());
420 EXPECT_FALSE(getExceptionState().hadException()); 420 EXPECT_FALSE(getExceptionState().hadException());
421 EXPECT_TRUE(request->shippingOption().isNull()); 421 EXPECT_TRUE(request->shippingOption().isNull());
422 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectNoCall(getScriptState())); 422 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectNoCall(getScriptState()));
423 String detailWithShippingOptions = "{\"items\": [{\"id\": \"total\", \"label \": \"Total\", \"amount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\"}}]," 423 String detailWithShippingOptions = "{\"items\": [{\"id\": \"total\", \"label \": \"Total\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}],"
424 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \ "Standard shipping\", \"amount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\ "}}]}"; 424 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \ "Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}] }";
425 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detailWithShippingOptions, getExceptionState()))); 425 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detailWithShippingOptions, getExceptionState())));
426 EXPECT_FALSE(getExceptionState().hadException()); 426 EXPECT_FALSE(getExceptionState().hadException());
427 EXPECT_EQ("standardShippingOption", request->shippingOption()); 427 EXPECT_EQ("standardShippingOption", request->shippingOption());
428 String detailWithoutShippingOptions = "{\"items\": [{\"id\": \"total\", \"la bel\": \"Total\", \"amount\": {\"currencyCode\": \"USD\", \"value\": \"5.00\"}}] }"; 428 String detailWithoutShippingOptions = "{\"items\": [{\"id\": \"total\", \"la bel\": \"Total\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}]}";
429 429
430 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detailWithoutShippingOptions, getExceptionState()))); 430 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detailWithoutShippingOptions, getExceptionState())));
431 431
432 EXPECT_FALSE(getExceptionState().hadException()); 432 EXPECT_FALSE(getExceptionState().hadException());
433 EXPECT_TRUE(request->shippingOption().isNull()); 433 EXPECT_TRUE(request->shippingOption().isNull());
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\": {\"currency\": \"US D\", \"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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698