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

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

Issue 1877943002: Add unit test for providing empty list of detail items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comment Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698