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

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

Issue 2355463002: [PaymentReqeust] Add error message in PaymentDetails. (in blink side) (Closed)
Patch Set: rebase from origin Created 4 years, 2 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/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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698