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

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

Issue 1994913002: PaymentRequest: Remove id attribute from PaymentItem. (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
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/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.
please use gerrit instead 2016/05/19 17:48:20 ... except for the "id" field, which is present on
zino 2016/05/19 19:11:40 Done.
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.setCurrencyCode(valueToUse);
21 } else { 21 } else {
22 itemAmount.setCurrencyCode("USD"); 22 itemAmount.setCurrencyCode("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);
33 33
34 if (data == PaymentTestDataId) {
please use gerrit instead 2016/05/19 17:48:20 Move this clause into buildShippingOptionForTest()
zino 2016/05/19 19:11:40 Done.
35 if (modificationType == PaymentTestOverwriteValue)
36 original.setId(valueToUse);
37 } else {
38 original.setId("id");
39 }
40 if (data == PaymentTestDataLabel) { 34 if (data == PaymentTestDataLabel) {
41 if (modificationType == PaymentTestOverwriteValue) 35 if (modificationType == PaymentTestOverwriteValue)
42 original.setLabel(valueToUse); 36 original.setLabel(valueToUse);
43 } else { 37 } else {
44 original.setLabel("Label"); 38 original.setLabel("Label");
45 } 39 }
46 } 40 }
47 41
48 } // namespace 42 } // namespace
49 43
50 PaymentItem buildPaymentItemForTest(PaymentTestDataToChange data, PaymentTestMod ificationType modificationType, const String& valueToUse) 44 PaymentItem buildPaymentItemForTest(PaymentTestDataToChange data, PaymentTestMod ificationType modificationType, const String& valueToUse)
please use gerrit instead 2016/05/19 17:49:50 DCHECK_NE(data, PaymentTestDataId);
zino 2016/05/19 19:11:40 Done.
51 { 45 {
52 PaymentItem item; 46 PaymentItem item;
53 setValues(item, data, modificationType, valueToUse); 47 setValues(item, data, modificationType, valueToUse);
54 return item; 48 return item;
55 } 49 }
56 50
57 ShippingOption buildShippingOptionForTest(PaymentTestDataToChange data, PaymentT estModificationType modificationType, const String& valueToUse) 51 ShippingOption buildShippingOptionForTest(PaymentTestDataToChange data, PaymentT estModificationType modificationType, const String& valueToUse)
58 { 52 {
59 ShippingOption shippingOption; 53 ShippingOption shippingOption;
60 setValues(shippingOption, data, modificationType, valueToUse); 54 setValues(shippingOption, data, modificationType, valueToUse);
(...skipping 15 matching lines...) Expand all
76 shippingOption = buildShippingOptionForTest(); 70 shippingOption = buildShippingOptionForTest();
77 71
78 PaymentDetails result; 72 PaymentDetails result;
79 result.setItems(HeapVector<PaymentItem>(1, item)); 73 result.setItems(HeapVector<PaymentItem>(1, item));
80 result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption)); 74 result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption));
81 75
82 return result; 76 return result;
83 } 77 }
84 78
85 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698