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

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

Issue 2898223002: PaymentHandler: Rename PaymentAppRequest with PaymentRequestEventData. (Closed)
Patch Set: Rename Created 3 years, 6 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/PaymentAppRequestConversion.h" 5 #include "modules/payments/PaymentRequestEventDataConversion.h"
6 6
7 #include "bindings/core/v8/ScriptValue.h" 7 #include "bindings/core/v8/ScriptValue.h"
8 #include "bindings/core/v8/V8BindingForCore.h" 8 #include "bindings/core/v8/V8BindingForCore.h"
9 #include "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "platform/bindings/ScriptState.h" 10 #include "platform/bindings/ScriptState.h"
11 #include "public/platform/modules/payments/WebPaymentAppRequest.h" 11 #include "public/platform/modules/payments/WebPaymentRequestEventData.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace blink { 15 namespace blink {
16 namespace { 16 namespace {
17 17
18 static WebPaymentItem CreateWebPaymentItemForTest() { 18 static WebPaymentItem CreateWebPaymentItemForTest() {
19 WebPaymentItem web_item; 19 WebPaymentItem web_item;
20 web_item.label = WebString::FromUTF8("Label"); 20 web_item.label = WebString::FromUTF8("Label");
21 web_item.amount.currency = WebString::FromUTF8("USD"); 21 web_item.amount.currency = WebString::FromUTF8("USD");
22 web_item.amount.value = WebString::FromUTF8("9.99"); 22 web_item.amount.value = WebString::FromUTF8("9.99");
23 return web_item; 23 return web_item;
24 } 24 }
25 25
26 static WebPaymentMethodData CreateWebPaymentMethodDataForTest() { 26 static WebPaymentMethodData CreateWebPaymentMethodDataForTest() {
27 WebPaymentMethodData web_method_data; 27 WebPaymentMethodData web_method_data;
28 WebString method = WebString::FromUTF8("foo"); 28 WebString method = WebString::FromUTF8("foo");
29 web_method_data.supported_methods = WebVector<WebString>(&method, 1); 29 web_method_data.supported_methods = WebVector<WebString>(&method, 1);
30 web_method_data.stringified_data = "{\"merchantId\":\"12345\"}"; 30 web_method_data.stringified_data = "{\"merchantId\":\"12345\"}";
31 return web_method_data; 31 return web_method_data;
32 } 32 }
33 33
34 static WebPaymentAppRequest CreateWebPaymentAppRequestForTest() { 34 static WebPaymentRequestEventData CreateWebPaymentRequestEventDataForTest() {
35 WebPaymentAppRequest web_data; 35 WebPaymentRequestEventData web_data;
36 web_data.top_level_origin = WebString::FromUTF8("https://example.com"); 36 web_data.top_level_origin = WebString::FromUTF8("https://example.com");
37 web_data.payment_request_origin = WebString::FromUTF8("https://example.com"); 37 web_data.payment_request_origin = WebString::FromUTF8("https://example.com");
38 web_data.payment_request_id = WebString::FromUTF8("payment-request-id"); 38 web_data.payment_request_id = WebString::FromUTF8("payment-request-id");
39 Vector<WebPaymentMethodData> method_data; 39 Vector<WebPaymentMethodData> method_data;
40 method_data.push_back(CreateWebPaymentMethodDataForTest()); 40 method_data.push_back(CreateWebPaymentMethodDataForTest());
41 web_data.method_data = WebVector<WebPaymentMethodData>(method_data); 41 web_data.method_data = WebVector<WebPaymentMethodData>(method_data);
42 web_data.total = CreateWebPaymentItemForTest(); 42 web_data.total = CreateWebPaymentItemForTest();
43 web_data.instrument_key = WebString::FromUTF8("payment-instrument-key"); 43 web_data.instrument_key = WebString::FromUTF8("payment-instrument-key");
44 return web_data; 44 return web_data;
45 } 45 }
46 46
47 TEST(PaymentAppRequestConversionTest, ToPaymentAppRequest) { 47 TEST(PaymentRequestEventDataConversionTest, ToPaymentRequestEventData) {
48 V8TestingScope scope; 48 V8TestingScope scope;
49 WebPaymentAppRequest web_data = CreateWebPaymentAppRequestForTest(); 49 WebPaymentRequestEventData web_data =
50 PaymentAppRequest data = PaymentAppRequestConversion::ToPaymentAppRequest( 50 CreateWebPaymentRequestEventDataForTest();
51 scope.GetScriptState(), web_data); 51 PaymentRequestEventInit data =
52 PaymentRequestEventDataConversion::ToPaymentRequestEventInit(
53 scope.GetScriptState(), web_data);
52 54
53 ASSERT_TRUE(data.hasTopLevelOrigin()); 55 ASSERT_TRUE(data.hasTopLevelOrigin());
54 EXPECT_EQ("https://example.com", data.topLevelOrigin()); 56 EXPECT_EQ("https://example.com", data.topLevelOrigin());
55 57
56 ASSERT_TRUE(data.hasPaymentRequestOrigin()); 58 ASSERT_TRUE(data.hasPaymentRequestOrigin());
57 EXPECT_EQ("https://example.com", data.paymentRequestOrigin()); 59 EXPECT_EQ("https://example.com", data.paymentRequestOrigin());
58 60
59 ASSERT_TRUE(data.hasPaymentRequestId()); 61 ASSERT_TRUE(data.hasPaymentRequestId());
60 EXPECT_EQ("payment-request-id", data.paymentRequestId()); 62 EXPECT_EQ("payment-request-id", data.paymentRequestId());
61 63
(...skipping 20 matching lines...) Expand all
82 EXPECT_EQ("USD", data.total().amount().currency()); 84 EXPECT_EQ("USD", data.total().amount().currency());
83 ASSERT_TRUE(data.total().amount().hasValue()); 85 ASSERT_TRUE(data.total().amount().hasValue());
84 EXPECT_EQ("9.99", data.total().amount().value()); 86 EXPECT_EQ("9.99", data.total().amount().value());
85 87
86 ASSERT_TRUE(data.hasInstrumentKey()); 88 ASSERT_TRUE(data.hasInstrumentKey());
87 EXPECT_EQ("payment-instrument-key", data.instrumentKey()); 89 EXPECT_EQ("payment-instrument-key", data.instrumentKey());
88 } 90 }
89 91
90 } // namespace 92 } // namespace
91 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698