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/PaymentTestHelper.h" | 5 #include "modules/payments/PaymentTestHelper.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "modules/payments/PaymentCurrencyAmount.h" | 9 #include "modules/payments/PaymentCurrencyAmount.h" |
10 #include "modules/payments/PaymentMethodData.h" | 10 #include "modules/payments/PaymentMethodData.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (data == PaymentTestDataId) { | 59 if (data == PaymentTestDataId) { |
60 if (modificationType == PaymentTestOverwriteValue) | 60 if (modificationType == PaymentTestOverwriteValue) |
61 shippingOption.setId(valueToUse); | 61 shippingOption.setId(valueToUse); |
62 } else { | 62 } else { |
63 shippingOption.setId("id"); | 63 shippingOption.setId("id"); |
64 } | 64 } |
65 setValues(shippingOption, data, modificationType, valueToUse); | 65 setValues(shippingOption, data, modificationType, valueToUse); |
66 return shippingOption; | 66 return shippingOption; |
67 } | 67 } |
68 | 68 |
| 69 PaymentDetailsModifier buildPaymentDetailsModifierForTest(PaymentTestDetailToCha
nge detail, PaymentTestDataToChange data, PaymentTestModificationType modificati
onType, const String& valueToUse) |
| 70 { |
| 71 PaymentItem total; |
| 72 if (detail == PaymentTestDetailModifierTotal) |
| 73 total = buildPaymentItemForTest(data, modificationType, valueToUse); |
| 74 else |
| 75 total = buildPaymentItemForTest(); |
| 76 |
| 77 PaymentItem item; |
| 78 if (detail == PaymentTestDetailModifierItem) |
| 79 item = buildPaymentItemForTest(data, modificationType, valueToUse); |
| 80 else |
| 81 item = buildPaymentItemForTest(); |
| 82 |
| 83 PaymentDetailsModifier modifier; |
| 84 modifier.setSupportedMethods(Vector<String>(1, "foo")); |
| 85 modifier.setTotal(total); |
| 86 modifier.setAdditionalDisplayItems(HeapVector<PaymentItem>(1, item)); |
| 87 return modifier; |
| 88 } |
| 89 |
69 PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, Paym
entTestDataToChange data, PaymentTestModificationType modificationType, const St
ring& valueToUse) | 90 PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, Paym
entTestDataToChange data, PaymentTestModificationType modificationType, const St
ring& valueToUse) |
70 { | 91 { |
71 PaymentItem total; | 92 PaymentItem total; |
72 if (detail == PaymentTestDetailTotal) | 93 if (detail == PaymentTestDetailTotal) |
73 total = buildPaymentItemForTest(data, modificationType, valueToUse); | 94 total = buildPaymentItemForTest(data, modificationType, valueToUse); |
74 else | 95 else |
75 total = buildPaymentItemForTest(); | 96 total = buildPaymentItemForTest(); |
76 | 97 |
77 PaymentItem item; | 98 PaymentItem item; |
78 if (detail == PaymentTestDetailItem) | 99 if (detail == PaymentTestDetailItem) |
79 item = buildPaymentItemForTest(data, modificationType, valueToUse); | 100 item = buildPaymentItemForTest(data, modificationType, valueToUse); |
80 else | 101 else |
81 item = buildPaymentItemForTest(); | 102 item = buildPaymentItemForTest(); |
82 | 103 |
83 PaymentShippingOption shippingOption; | 104 PaymentShippingOption shippingOption; |
84 if (detail == PaymentTestDetailShippingOption) | 105 if (detail == PaymentTestDetailShippingOption) |
85 shippingOption = buildShippingOptionForTest(data, modificationType, valu
eToUse); | 106 shippingOption = buildShippingOptionForTest(data, modificationType, valu
eToUse); |
86 else | 107 else |
87 shippingOption = buildShippingOptionForTest(); | 108 shippingOption = buildShippingOptionForTest(); |
88 | 109 |
| 110 PaymentDetailsModifier modifier; |
| 111 if (detail == PaymentTestDetailModifierTotal || detail == PaymentTestDetailM
odifierItem) |
| 112 modifier = buildPaymentDetailsModifierForTest(detail, data, modification
Type, valueToUse); |
| 113 else |
| 114 modifier = buildPaymentDetailsModifierForTest(); |
| 115 |
89 PaymentDetails result; | 116 PaymentDetails result; |
90 result.setTotal(total); | 117 result.setTotal(total); |
91 result.setDisplayItems(HeapVector<PaymentItem>(1, item)); | 118 result.setDisplayItems(HeapVector<PaymentItem>(1, item)); |
92 result.setShippingOptions(HeapVector<PaymentShippingOption>(2, shippingOptio
n)); | 119 result.setShippingOptions(HeapVector<PaymentShippingOption>(2, shippingOptio
n)); |
| 120 result.setModifiers(HeapVector<PaymentDetailsModifier>(1, modifier)); |
93 | 121 |
94 return result; | 122 return result; |
95 } | 123 } |
96 | 124 |
97 HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() | 125 HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() |
98 { | 126 { |
99 HeapVector<PaymentMethodData> methodData(1, PaymentMethodData()); | 127 HeapVector<PaymentMethodData> methodData(1, PaymentMethodData()); |
100 methodData[0].setSupportedMethods(Vector<String>(1, "foo")); | 128 methodData[0].setSupportedMethods(Vector<String>(1, "foo")); |
101 return methodData; | 129 return methodData; |
102 } | 130 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 { | 172 { |
145 ON_CALL(*this, call(testing::_)).WillByDefault(testing::ReturnArg<0>()); | 173 ON_CALL(*this, call(testing::_)).WillByDefault(testing::ReturnArg<0>()); |
146 } | 174 } |
147 | 175 |
148 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() | 176 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() |
149 { | 177 { |
150 return bindToV8Function(); | 178 return bindToV8Function(); |
151 } | 179 } |
152 | 180 |
153 } // namespace blink | 181 } // namespace blink |
OLD | NEW |