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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 shippingOption = buildShippingOptionForTest(data, modificationType, valu
eToUse); | 107 shippingOption = buildShippingOptionForTest(data, modificationType, valu
eToUse); |
108 else | 108 else |
109 shippingOption = buildShippingOptionForTest(); | 109 shippingOption = buildShippingOptionForTest(); |
110 | 110 |
111 PaymentDetailsModifier modifier; | 111 PaymentDetailsModifier modifier; |
112 if (detail == PaymentTestDetailModifierTotal || detail == PaymentTestDetailM
odifierItem) | 112 if (detail == PaymentTestDetailModifierTotal || detail == PaymentTestDetailM
odifierItem) |
113 modifier = buildPaymentDetailsModifierForTest(detail, data, modification
Type, valueToUse); | 113 modifier = buildPaymentDetailsModifierForTest(detail, data, modification
Type, valueToUse); |
114 else | 114 else |
115 modifier = buildPaymentDetailsModifierForTest(); | 115 modifier = buildPaymentDetailsModifierForTest(); |
116 | 116 |
| 117 String errorMessage = ""; |
| 118 if (detail == PaymentTestDetailError) |
| 119 errorMessage = valueToUse; |
| 120 |
117 PaymentDetails result; | 121 PaymentDetails result; |
118 result.setTotal(total); | 122 result.setTotal(total); |
119 result.setDisplayItems(HeapVector<PaymentItem>(1, item)); | 123 result.setDisplayItems(HeapVector<PaymentItem>(1, item)); |
120 result.setShippingOptions(HeapVector<PaymentShippingOption>(1, shippingOptio
n)); | 124 result.setShippingOptions(HeapVector<PaymentShippingOption>(1, shippingOptio
n)); |
121 result.setModifiers(HeapVector<PaymentDetailsModifier>(1, modifier)); | 125 result.setModifiers(HeapVector<PaymentDetailsModifier>(1, modifier)); |
| 126 result.setError(errorMessage); |
122 | 127 |
123 return result; | 128 return result; |
124 } | 129 } |
125 | 130 |
| 131 PaymentDetails buildPaymentDetailsErrorMsgForTest(const String& valueToUse) |
| 132 { |
| 133 return buildPaymentDetailsForTest(PaymentTestDetailError, PaymentTestDataNon
e, PaymentTestOverwriteValue, valueToUse); |
| 134 } |
| 135 |
126 HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() | 136 HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() |
127 { | 137 { |
128 HeapVector<PaymentMethodData> methodData(1, PaymentMethodData()); | 138 HeapVector<PaymentMethodData> methodData(1, PaymentMethodData()); |
129 methodData[0].setSupportedMethods(Vector<String>(1, "foo")); | 139 methodData[0].setSupportedMethods(Vector<String>(1, "foo")); |
130 return methodData; | 140 return methodData; |
131 } | 141 } |
132 | 142 |
133 mojom::blink::PaymentResponsePtr buildPaymentResponseForTest() | 143 mojom::blink::PaymentResponsePtr buildPaymentResponseForTest() |
134 { | 144 { |
135 mojom::blink::PaymentResponsePtr result = mojom::blink::PaymentResponse::New
(); | 145 mojom::blink::PaymentResponsePtr result = mojom::blink::PaymentResponse::New
(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 ON_CALL(*this, call(testing::_)).WillByDefault( | 203 ON_CALL(*this, call(testing::_)).WillByDefault( |
194 testing::DoAll(SaveValueIn(m_value), testing::ReturnArg<0>())); | 204 testing::DoAll(SaveValueIn(m_value), testing::ReturnArg<0>())); |
195 } | 205 } |
196 | 206 |
197 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() | 207 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() |
198 { | 208 { |
199 return bindToV8Function(); | 209 return bindToV8Function(); |
200 } | 210 } |
201 | 211 |
202 } // namespace blink | 212 } // namespace blink |
OLD | NEW |