| 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/PaymentDetailsTestHelper.h" | 5 #include "modules/payments/PaymentDetailsTestHelper.h" |
| 6 | 6 |
| 7 #include "modules/payments/CurrencyAmount.h" | 7 #include "modules/payments/CurrencyAmount.h" |
| 8 #include "platform/heap/HeapAllocator.h" | 8 #include "platform/heap/HeapAllocator.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // PaymentItem and ShippingOption have identical structure. | 13 // PaymentItem and ShippingOption have identical structure. |
| 14 template <typename PaymentItemOrShippingOption> | 14 template <typename PaymentItemOrShippingOption> |
| 15 void setValues(PaymentItemOrShippingOption& original, PaymentTestDataToChange da
ta, PaymentTestModificationType modificationType, const String& valueToUse) | 15 void setValues(PaymentItemOrShippingOption& original, PaymentTestDataToChange da
ta, PaymentTestModificationType modificationType, const String& valueToUse) |
| 16 { | 16 { |
| 17 CurrencyAmount itemAmount; | 17 CurrencyAmount itemAmount; |
| 18 if (data == PaymentTestDataCurrencyCode) { | 18 if (data == PaymentTestDataCurrencyCode) { |
| 19 if (modificationType == PaymentTestOverwriteValue) | 19 if (modificationType == PaymentTestOverwriteValue) |
| 20 itemAmount.setCurrencyCode(valueToUse); | 20 itemAmount.setCurrency(valueToUse); |
| 21 } else { | 21 } else { |
| 22 itemAmount.setCurrencyCode("USD"); | 22 itemAmount.setCurrency("USD"); |
| 23 } | 23 } |
| 24 if (data == PaymentTestDataValue) { | 24 if (data == PaymentTestDataValue) { |
| 25 if (modificationType == PaymentTestOverwriteValue) | 25 if (modificationType == PaymentTestOverwriteValue) |
| 26 itemAmount.setValue(valueToUse); | 26 itemAmount.setValue(valueToUse); |
| 27 } else { | 27 } else { |
| 28 itemAmount.setValue("9.99"); | 28 itemAmount.setValue("9.99"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 if (data != PaymentTestDataAmount || modificationType != PaymentTestRemoveKe
y) | 31 if (data != PaymentTestDataAmount || modificationType != PaymentTestRemoveKe
y) |
| 32 original.setAmount(itemAmount); | 32 original.setAmount(itemAmount); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 shippingOption = buildShippingOptionForTest(); | 76 shippingOption = buildShippingOptionForTest(); |
| 77 | 77 |
| 78 PaymentDetails result; | 78 PaymentDetails result; |
| 79 result.setItems(HeapVector<PaymentItem>(1, item)); | 79 result.setItems(HeapVector<PaymentItem>(1, item)); |
| 80 result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption)); | 80 result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption)); |
| 81 | 81 |
| 82 return result; | 82 return result; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |