| Index: third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
|
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp b/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
|
| index be2f2721fcdf1db362cc429833855c5a4c505f68..b5ace517da6a72fb4c99a2e9fabaa6aa85e15a55 100644
|
| --- a/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
|
| +++ b/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
|
| @@ -5,22 +5,20 @@
|
| #include "modules/payments/PaymentDetailsTestHelper.h"
|
|
|
| #include "modules/payments/CurrencyAmount.h"
|
| -#include "modules/payments/PaymentItem.h"
|
| -#include "modules/payments/ShippingOption.h"
|
| #include "platform/heap/HeapAllocator.h"
|
|
|
| namespace blink {
|
|
|
| -PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, PaymentTestDataToChange data, PaymentTestModificationType modificationType, const String& valueToUse)
|
| +PaymentItem buildPaymentItemForTest(PaymentTestDataToChange data, PaymentTestModificationType modificationType, const String& valueToUse)
|
| {
|
| CurrencyAmount itemAmount;
|
| - if (detail == PaymentTestDetailItem && data == PaymentTestDataCurrencyCode) {
|
| + if (data == PaymentTestDataCurrencyCode) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| itemAmount.setCurrencyCode(valueToUse);
|
| } else {
|
| itemAmount.setCurrencyCode("USD");
|
| }
|
| - if (detail == PaymentTestDetailItem && data == PaymentTestDataAmount) {
|
| + if (data == PaymentTestDataAmount) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| itemAmount.setValue(valueToUse);
|
| } else {
|
| @@ -29,27 +27,32 @@ PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, Paym
|
|
|
| PaymentItem item;
|
| item.setAmount(itemAmount);
|
| - if (detail == PaymentTestDetailItem && data == PaymentTestDataId) {
|
| + if (data == PaymentTestDataId) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| item.setId(valueToUse);
|
| } else {
|
| item.setId("total");
|
| }
|
| - if (detail == PaymentTestDetailItem && data == PaymentTestDataLabel) {
|
| + if (data == PaymentTestDataLabel) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| item.setLabel(valueToUse);
|
| } else {
|
| item.setLabel("Total charge");
|
| }
|
|
|
| + return item;
|
| +}
|
| +
|
| +ShippingOption buildShippingOptionForTest(PaymentTestDataToChange data, PaymentTestModificationType modificationType, const String& valueToUse)
|
| +{
|
| CurrencyAmount shippingAmount;
|
| - if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataCurrencyCode) {
|
| + if (data == PaymentTestDataCurrencyCode) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| shippingAmount.setCurrencyCode(valueToUse);
|
| } else {
|
| shippingAmount.setCurrencyCode("USD");
|
| }
|
| - if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataAmount) {
|
| + if (data == PaymentTestDataAmount) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| shippingAmount.setValue(valueToUse);
|
| } else {
|
| @@ -58,19 +61,37 @@ PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, Paym
|
|
|
| ShippingOption shippingOption;
|
| shippingOption.setAmount(shippingAmount);
|
| - if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataId) {
|
| + if (data == PaymentTestDataId) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| shippingOption.setId(valueToUse);
|
| } else {
|
| shippingOption.setId("standard");
|
| }
|
| - if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataLabel) {
|
| + if (data == PaymentTestDataLabel) {
|
| if (modificationType == PaymentTestOverwriteValue)
|
| shippingOption.setLabel(valueToUse);
|
| } else {
|
| shippingOption.setLabel("Standard shipping");
|
| }
|
|
|
| + return shippingOption;
|
| +}
|
| +
|
| +PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, PaymentTestDataToChange data, PaymentTestModificationType modificationType, const String& valueToUse)
|
| +{
|
| +
|
| + PaymentItem item;
|
| + if (detail == PaymentTestDetailItem)
|
| + item = buildPaymentItemForTest(data, modificationType, valueToUse);
|
| + else
|
| + item = buildPaymentItemForTest();
|
| +
|
| + ShippingOption shippingOption;
|
| + if (detail == PaymentTestDetailShippingOption)
|
| + shippingOption = buildShippingOptionForTest(data, modificationType, valueToUse);
|
| + else
|
| + shippingOption = buildShippingOptionForTest();
|
| +
|
| PaymentDetails result;
|
| result.setItems(HeapVector<PaymentItem>(1, item));
|
| result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption));
|
|
|