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

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

Issue 2349133002: PaymentRequest: Make the PaymentResponse interface serializable. (Closed)
Patch Set: PaymentRequest: Make the PaymentResponse interface serializable. Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentResponse.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp
index 327e4a650b22beff2708c91c5c56c7bca24691b4..787a305bbcfa5443df4ae114e159e0670cfcf372 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp
@@ -9,6 +9,7 @@
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8BindingForTesting.h"
+#include "modules/payments/PaymentAddress.h"
#include "modules/payments/PaymentCompleter.h"
#include "modules/payments/PaymentTestHelper.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -110,5 +111,40 @@ TEST(PaymentResponseTest, CompleteCalledWithFailure)
output.complete(scope.getScriptState(), "fail");
}
+TEST(PaymentResponseTest, JSONSerializerTest)
+{
+ V8TestingScope scope;
+ mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New();
+ input->method_name = "foo";
+ input->stringified_details = "{\"transactionId\": 123}";
+ input->shipping_option = "standardShippingOption";
+ input->payer_email = "abc@gmail.com";
+ input->payer_phone = "0123";
+ input->shipping_address = mojom::blink::PaymentAddress::New();
+ input->shipping_address->country = "US";
+ input->shipping_address->language_code = "en";
+ input->shipping_address->script_code = "Latn";
+ input->shipping_address->address_line = mojo::WTFArray<WTF::String>::New(3);
+ input->shipping_address->address_line[0] = "340 Main St";
+ input->shipping_address->address_line[1] = "BIN1";
+ input->shipping_address->address_line[2] = "First floor";
+
+ PaymentResponse output(std::move(input), new MockPaymentCompleter);
+ ScriptValue jsonObject = output.toJSONForBinding(scope.getScriptState());
+ EXPECT_TRUE(jsonObject.isObject());
+
+ String jsonString = v8StringToWebCoreString<String>(
+ v8::JSON::Stringify(scope.context(),
+ jsonObject.v8Value().As<v8::Object>()).ToLocalChecked(),
+ DoNotExternalize);
+ String expected = "{\"methodName\":\"foo\",\"details\":{\"transactionId\":123},"
+ "\"shippingAddress\":{\"country\":\"US\",\"addressLine\":[\"340 Main St\","
+ "\"BIN1\",\"First floor\"],\"region\":\"\",\"city\":\"\",\"dependentLocality\":"
+ "\"\",\"postalCode\":\"\",\"sortingCode\":\"\",\"languageCode\":\"en-Latn\","
+ "\"organization\":\"\",\"recipient\":\"\",\"phone\":\"\"},\"shippingOption\":"
+ "\"standardShippingOption\",\"payerEmail\":\"abc@gmail.com\",\"payerPhone\":\"0123\"}";
+ EXPECT_EQ(expected, jsonString);
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentResponse.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698