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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 TEST_F(PaymentRequestTest, ItemListRequired) | 71 TEST_F(PaymentRequestTest, ItemListRequired) |
72 { | 72 { |
73 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), PaymentDe
tails(), getExceptionState()); | 73 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), PaymentDe
tails(), getExceptionState()); |
74 | 74 |
75 EXPECT_TRUE(getExceptionState().hadException()); | 75 EXPECT_TRUE(getExceptionState().hadException()); |
76 EXPECT_EQ(V8TypeError, getExceptionState().code()); | 76 EXPECT_EQ(V8TypeError, getExceptionState().code()); |
77 } | 77 } |
78 | 78 |
| 79 TEST_F(PaymentRequestTest, ItemListIsNotEmpty) |
| 80 { |
| 81 PaymentDetails details; |
| 82 details.setItems(HeapVector<PaymentItem>()); |
| 83 |
| 84 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), details,
getExceptionState()); |
| 85 |
| 86 EXPECT_TRUE(getExceptionState().hadException()); |
| 87 EXPECT_EQ(V8TypeError, getExceptionState().code()); |
| 88 } |
| 89 |
79 TEST_F(PaymentRequestTest, AtLeastOnePaymentDetailsItemRequired) | 90 TEST_F(PaymentRequestTest, AtLeastOnePaymentDetailsItemRequired) |
80 { | 91 { |
81 PaymentDetails details; | 92 PaymentDetails details; |
82 details.setShippingOptions(HeapVector<ShippingOption>(2, buildShippingOption
ForTest())); | 93 details.setShippingOptions(HeapVector<ShippingOption>(2, buildShippingOption
ForTest())); |
83 | 94 |
84 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), details,
getExceptionState()); | 95 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), details,
getExceptionState()); |
85 | 96 |
86 EXPECT_TRUE(getExceptionState().hadException()); | 97 EXPECT_TRUE(getExceptionState().hadException()); |
87 EXPECT_EQ(V8TypeError, getExceptionState().code()); | 98 EXPECT_EQ(V8TypeError, getExceptionState().code()); |
88 } | 99 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 { | 134 { |
124 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); | 135 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St
ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); |
125 EXPECT_FALSE(getExceptionState().hadException()); | 136 EXPECT_FALSE(getExceptionState().hadException()); |
126 | 137 |
127 request->abort(getExceptionState()); | 138 request->abort(getExceptionState()); |
128 EXPECT_TRUE(getExceptionState().hadException()); | 139 EXPECT_TRUE(getExceptionState().hadException()); |
129 } | 140 } |
130 | 141 |
131 } // namespace | 142 } // namespace |
132 } // namespace blink | 143 } // namespace blink |
OLD | NEW |