OLD | NEW |
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/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
11 #include "modules/payments/CurrencyAmount.h" | 11 #include "modules/payments/CurrencyAmount.h" |
12 #include "modules/payments/PaymentDetailsTestHelper.h" | 12 #include "modules/payments/PaymentDetailsTestHelper.h" |
13 #include "modules/payments/PaymentItem.h" | 13 #include "modules/payments/PaymentItem.h" |
14 #include "modules/payments/ShippingOption.h" | 14 #include "modules/payments/ShippingOption.h" |
15 #include "platform/heap/HeapAllocator.h" | 15 #include "platform/heap/HeapAllocator.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "wtf/OwnPtr.h" | 17 #include "wtf/OwnPtr.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | |
21 namespace { | 20 namespace { |
22 | 21 |
23 class PaymentRequestTest : public testing::Test { | 22 class PaymentRequestTest : public testing::Test { |
24 public: | 23 public: |
25 PaymentRequestTest() | 24 PaymentRequestTest() |
26 : m_page(DummyPageHolder::create()) | 25 : m_page(DummyPageHolder::create()) |
27 { | 26 { |
28 setSecurityOrigin("https://www.example.com/"); | 27 setSecurityOrigin("https://www.example.com/"); |
29 } | 28 } |
30 | 29 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 115 |
117 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), details, getExceptionState()); | 116 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), details, getExceptionState()); |
118 | 117 |
119 EXPECT_TRUE(request->shippingOption().isNull()); | 118 EXPECT_TRUE(request->shippingOption().isNull()); |
120 } | 119 } |
121 | 120 |
122 TEST_F(PaymentRequestTest, SelectSingleAvailableShippingOption) | 121 TEST_F(PaymentRequestTest, SelectSingleAvailableShippingOption) |
123 { | 122 { |
124 PaymentDetails details; | 123 PaymentDetails details; |
125 details.setItems(HeapVector<PaymentItem>(1, buildPaymentItemForTest())); | 124 details.setItems(HeapVector<PaymentItem>(1, buildPaymentItemForTest())); |
126 details.setShippingOptions(HeapVector<ShippingOption>(1, buildShippingOption
ForTest())); | 125 details.setShippingOptions(HeapVector<ShippingOption>(1, buildShippingOption
ForTest(PaymentTestDataId, PaymentTestOverwriteValue, "standard"))); |
127 | 126 |
128 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), details, getExceptionState()); | 127 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), details, getExceptionState()); |
129 | 128 |
130 EXPECT_EQ("standard", request->shippingOption()); | 129 EXPECT_EQ("standard", request->shippingOption()); |
131 } | 130 } |
132 | 131 |
133 TEST_F(PaymentRequestTest, AbortWithoutShowShouldThrow) | 132 TEST_F(PaymentRequestTest, AbortWithoutShowShouldThrow) |
134 { | 133 { |
135 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); | 134 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); |
136 EXPECT_FALSE(getExceptionState().hadException()); | 135 EXPECT_FALSE(getExceptionState().hadException()); |
137 | 136 |
138 request->abort(getExceptionState()); | 137 request->abort(getExceptionState()); |
139 EXPECT_TRUE(getExceptionState().hadException()); | 138 EXPECT_TRUE(getExceptionState().hadException()); |
140 } | 139 } |
141 | 140 |
142 } // namespace | 141 } // namespace |
143 } // namespace blink | 142 } // namespace blink |
OLD | NEW |