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

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

Issue 1753543002: PaymentRequest Mojo bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface
Patch Set: haraken@'s + esprehn@'s comments Created 4 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/PaymentDetailsTestHelper.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp b/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..be2f2721fcdf1db362cc429833855c5a4c505f68
--- /dev/null
+++ b/third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp
@@ -0,0 +1,81 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/payments/PaymentDetailsTestHelper.h"
+
+#include "modules/payments/CurrencyAmount.h"
+#include "modules/payments/PaymentItem.h"
+#include "modules/payments/ShippingOption.h"
+#include "platform/heap/HeapAllocator.h"
+
+namespace blink {
+
+PaymentDetails buildPaymentDetailsForTest(PaymentTestDetailToChange detail, PaymentTestDataToChange data, PaymentTestModificationType modificationType, const String& valueToUse)
+{
+ CurrencyAmount itemAmount;
+ if (detail == PaymentTestDetailItem && data == PaymentTestDataCurrencyCode) {
+ if (modificationType == PaymentTestOverwriteValue)
+ itemAmount.setCurrencyCode(valueToUse);
+ } else {
+ itemAmount.setCurrencyCode("USD");
+ }
+ if (detail == PaymentTestDetailItem && data == PaymentTestDataAmount) {
+ if (modificationType == PaymentTestOverwriteValue)
+ itemAmount.setValue(valueToUse);
+ } else {
+ itemAmount.setValue("9.99");
+ }
+
+ PaymentItem item;
+ item.setAmount(itemAmount);
+ if (detail == PaymentTestDetailItem && data == PaymentTestDataId) {
+ if (modificationType == PaymentTestOverwriteValue)
+ item.setId(valueToUse);
+ } else {
+ item.setId("total");
+ }
+ if (detail == PaymentTestDetailItem && data == PaymentTestDataLabel) {
+ if (modificationType == PaymentTestOverwriteValue)
+ item.setLabel(valueToUse);
+ } else {
+ item.setLabel("Total charge");
+ }
+
+ CurrencyAmount shippingAmount;
+ if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataCurrencyCode) {
+ if (modificationType == PaymentTestOverwriteValue)
+ shippingAmount.setCurrencyCode(valueToUse);
+ } else {
+ shippingAmount.setCurrencyCode("USD");
+ }
+ if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataAmount) {
+ if (modificationType == PaymentTestOverwriteValue)
+ shippingAmount.setValue(valueToUse);
+ } else {
+ shippingAmount.setValue("9.99");
+ }
+
+ ShippingOption shippingOption;
+ shippingOption.setAmount(shippingAmount);
+ if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataId) {
+ if (modificationType == PaymentTestOverwriteValue)
+ shippingOption.setId(valueToUse);
+ } else {
+ shippingOption.setId("standard");
+ }
+ if (detail == PaymentTestDetailShippingOption && data == PaymentTestDataLabel) {
+ if (modificationType == PaymentTestOverwriteValue)
+ shippingOption.setLabel(valueToUse);
+ } else {
+ shippingOption.setLabel("Standard shipping");
+ }
+
+ PaymentDetails result;
+ result.setItems(HeapVector<PaymentItem>(1, item));
+ result.setShippingOptions(HeapVector<ShippingOption>(2, shippingOption));
+
+ return result;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698