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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp

Issue 2748093003: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. (Closed)
Patch Set: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp b/third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp
index d4e326b88afb2b7e3883cc540c1dd7b8b77e1bda..5f543fa5c588df433d7450056bc2f826dc001ed6 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentTestHelper.cpp
@@ -55,6 +55,40 @@ void setValues(PaymentItemOrPaymentShippingOption& original,
}
}
+void buildPaymentDetailsBase(PaymentTestDetailToChange detail,
+ PaymentTestDataToChange data,
+ PaymentTestModificationType modificationType,
+ const String& valueToUse,
+ PaymentDetailsBase* details) {
+ PaymentItem item;
+ if (detail == PaymentTestDetailItem)
+ item = buildPaymentItemForTest(data, modificationType, valueToUse);
+ else
+ item = buildPaymentItemForTest();
+
+ PaymentShippingOption shippingOption;
+ if (detail == PaymentTestDetailShippingOption) {
+ shippingOption =
+ buildShippingOptionForTest(data, modificationType, valueToUse);
+ } else {
+ shippingOption = buildShippingOptionForTest();
+ }
+
+ PaymentDetailsModifier modifier;
+ if (detail == PaymentTestDetailModifierTotal ||
+ detail == PaymentTestDetailModifierItem) {
+ modifier = buildPaymentDetailsModifierForTest(detail, data,
+ modificationType, valueToUse);
+ } else {
+ modifier = buildPaymentDetailsModifierForTest();
+ }
+
+ details->setDisplayItems(HeapVector<PaymentItem>(1, item));
+ details->setShippingOptions(
+ HeapVector<PaymentShippingOption>(1, shippingOption));
+ details->setModifiers(HeapVector<PaymentDetailsModifier>(1, modifier));
+}
+
} // namespace
PaymentItem buildPaymentItemForTest(
@@ -106,54 +140,50 @@ PaymentDetailsModifier buildPaymentDetailsModifierForTest(
return modifier;
}
-PaymentDetails buildPaymentDetailsForTest(
+PaymentDetailsInit buildPaymentDetailsInitForTest(
PaymentTestDetailToChange detail,
PaymentTestDataToChange data,
PaymentTestModificationType modificationType,
const String& valueToUse) {
- PaymentItem total;
- if (detail == PaymentTestDetailTotal)
- total = buildPaymentItemForTest(data, modificationType, valueToUse);
- else
- total = buildPaymentItemForTest();
+ PaymentDetailsInit details;
+ buildPaymentDetailsBase(detail, data, modificationType, valueToUse, &details);
- PaymentItem item;
- if (detail == PaymentTestDetailItem)
- item = buildPaymentItemForTest(data, modificationType, valueToUse);
- else
- item = buildPaymentItemForTest();
+ if (detail == PaymentTestDetailTotal) {
+ details.setTotal(
+ buildPaymentItemForTest(data, modificationType, valueToUse));
+ } else {
+ details.setTotal(buildPaymentItemForTest());
+ }
- PaymentShippingOption shippingOption;
- if (detail == PaymentTestDetailShippingOption)
- shippingOption =
- buildShippingOptionForTest(data, modificationType, valueToUse);
- else
- shippingOption = buildShippingOptionForTest();
+ return details;
+}
- PaymentDetailsModifier modifier;
- if (detail == PaymentTestDetailModifierTotal ||
- detail == PaymentTestDetailModifierItem)
- modifier = buildPaymentDetailsModifierForTest(detail, data,
- modificationType, valueToUse);
- else
- modifier = buildPaymentDetailsModifierForTest();
+PaymentDetailsUpdate buildPaymentDetailsUpdateForTest(
+ PaymentTestDetailToChange detail,
+ PaymentTestDataToChange data,
+ PaymentTestModificationType modificationType,
+ const String& valueToUse) {
+ PaymentDetailsUpdate details;
+ buildPaymentDetailsBase(detail, data, modificationType, valueToUse, &details);
- PaymentDetails result;
- result.setTotal(total);
- result.setDisplayItems(HeapVector<PaymentItem>(1, item));
- result.setShippingOptions(
- HeapVector<PaymentShippingOption>(1, shippingOption));
- result.setModifiers(HeapVector<PaymentDetailsModifier>(1, modifier));
+ if (detail == PaymentTestDetailTotal) {
+ details.setTotal(
+ buildPaymentItemForTest(data, modificationType, valueToUse));
+ } else {
+ details.setTotal(buildPaymentItemForTest());
+ }
if (detail == PaymentTestDetailError)
- result.setError(valueToUse);
+ details.setError(valueToUse);
- return result;
+ return details;
}
-PaymentDetails buildPaymentDetailsErrorMsgForTest(const String& valueToUse) {
- return buildPaymentDetailsForTest(PaymentTestDetailError, PaymentTestDataNone,
- PaymentTestOverwriteValue, valueToUse);
+PaymentDetailsUpdate buildPaymentDetailsErrorMsgForTest(
+ const String& valueToUse) {
+ return buildPaymentDetailsUpdateForTest(
+ PaymentTestDetailError, PaymentTestDataNone, PaymentTestOverwriteValue,
+ valueToUse);
}
HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() {

Powered by Google App Engine
This is Rietveld 408576698