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

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: 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 | « third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp ('k') | 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 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaym entDetailsForTest(PaymentTestDetailNoItems), getExceptionState());
please use gerrit instead 2016/04/11 21:46:36 I would prefer this to be: -----------------------
rwlbuis 2016/04/12 01:19:16 Good idea, done :)
82
83 EXPECT_TRUE(getExceptionState().hadException());
84 EXPECT_EQ(V8TypeError, getExceptionState().code());
85 }
86
79 TEST_F(PaymentRequestTest, AtLeastOnePaymentDetailsItemRequired) 87 TEST_F(PaymentRequestTest, AtLeastOnePaymentDetailsItemRequired)
80 { 88 {
81 PaymentDetails details; 89 PaymentDetails details;
82 details.setShippingOptions(HeapVector<ShippingOption>(2, buildShippingOption ForTest())); 90 details.setShippingOptions(HeapVector<ShippingOption>(2, buildShippingOption ForTest()));
83 91
84 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), details, getExceptionState()); 92 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), details, getExceptionState());
85 93
86 EXPECT_TRUE(getExceptionState().hadException()); 94 EXPECT_TRUE(getExceptionState().hadException());
87 EXPECT_EQ(V8TypeError, getExceptionState().code()); 95 EXPECT_EQ(V8TypeError, getExceptionState().code());
88 } 96 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 { 131 {
124 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); 132 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState());
125 EXPECT_FALSE(getExceptionState().hadException()); 133 EXPECT_FALSE(getExceptionState().hadException());
126 134
127 request->abort(getExceptionState()); 135 request->abort(getExceptionState());
128 EXPECT_TRUE(getExceptionState().hadException()); 136 EXPECT_TRUE(getExceptionState().hadException());
129 } 137 }
130 138
131 } // namespace 139 } // namespace
132 } // namespace blink 140 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentDetailsTestHelper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698