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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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/PaymentRequest.h" 5 #include "modules/payments/PaymentRequest.h"
6 6
7 #include "bindings/core/v8/V8BindingForTesting.h" 7 #include "bindings/core/v8/V8BindingForTesting.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 #include "modules/payments/PaymentTestHelper.h" 10 #include "modules/payments/PaymentTestHelper.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 EXPECT_TRUE(request->shippingOption().isNull()); 102 EXPECT_TRUE(request->shippingOption().isNull());
103 } 103 }
104 104
105 TEST(PaymentRequestTest, DontSelectSingleAvailableShippingOptionByDefault) { 105 TEST(PaymentRequestTest, DontSelectSingleAvailableShippingOptionByDefault) {
106 V8TestingScope scope; 106 V8TestingScope scope;
107 makePaymentRequestOriginSecure(scope.document()); 107 makePaymentRequestOriginSecure(scope.document());
108 PaymentDetails details; 108 PaymentDetails details;
109 details.setTotal(buildPaymentItemForTest()); 109 details.setTotal(buildPaymentItemForTest());
110 details.setShippingOptions(HeapVector<PaymentShippingOption>( 110 details.setShippingOptions(HeapVector<PaymentShippingOption>(
111 1, buildShippingOptionForTest(PaymentTestDataId, 111 1,
112 PaymentTestOverwriteValue, "standard"))); 112 buildShippingOptionForTest(PaymentTestDataId, PaymentTestOverwriteValue,
113 "standard")));
113 114
114 PaymentRequest* request = 115 PaymentRequest* request =
115 PaymentRequest::create(scope.document(), buildPaymentMethodDataForTest(), 116 PaymentRequest::create(scope.document(), buildPaymentMethodDataForTest(),
116 details, scope.getExceptionState()); 117 details, scope.getExceptionState());
117 118
118 EXPECT_TRUE(request->shippingOption().isNull()); 119 EXPECT_TRUE(request->shippingOption().isNull());
119 } 120 }
120 121
121 TEST(PaymentRequestTest, 122 TEST(PaymentRequestTest,
122 DontSelectSingleAvailableShippingOptionWhenShippingNotRequested) { 123 DontSelectSingleAvailableShippingOptionWhenShippingNotRequested) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_TRUE(request->shippingOption().isNull()); 155 EXPECT_TRUE(request->shippingOption().isNull());
155 } 156 }
156 157
157 TEST(PaymentRequestTest, 158 TEST(PaymentRequestTest,
158 SelectSingleSelectedShippingOptionWhenShippingRequested) { 159 SelectSingleSelectedShippingOptionWhenShippingRequested) {
159 V8TestingScope scope; 160 V8TestingScope scope;
160 makePaymentRequestOriginSecure(scope.document()); 161 makePaymentRequestOriginSecure(scope.document());
161 PaymentDetails details; 162 PaymentDetails details;
162 details.setTotal(buildPaymentItemForTest()); 163 details.setTotal(buildPaymentItemForTest());
163 HeapVector<PaymentShippingOption> shippingOptions( 164 HeapVector<PaymentShippingOption> shippingOptions(
164 1, buildShippingOptionForTest(PaymentTestDataId, 165 1,
165 PaymentTestOverwriteValue, "standard")); 166 buildShippingOptionForTest(PaymentTestDataId, PaymentTestOverwriteValue,
167 "standard"));
166 shippingOptions[0].setSelected(true); 168 shippingOptions[0].setSelected(true);
167 details.setShippingOptions(shippingOptions); 169 details.setShippingOptions(shippingOptions);
168 PaymentOptions options; 170 PaymentOptions options;
169 options.setRequestShipping(true); 171 options.setRequestShipping(true);
170 172
171 PaymentRequest* request = 173 PaymentRequest* request =
172 PaymentRequest::create(scope.document(), buildPaymentMethodDataForTest(), 174 PaymentRequest::create(scope.document(), buildPaymentMethodDataForTest(),
173 details, options, scope.getExceptionState()); 175 details, options, scope.getExceptionState());
174 176
175 EXPECT_EQ("standard", request->shippingOption()); 177 EXPECT_EQ("standard", request->shippingOption());
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 464 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
463 makePaymentRequestOriginSecure(scope.document()); 465 makePaymentRequestOriginSecure(scope.document());
464 PaymentRequest* request = PaymentRequest::create( 466 PaymentRequest* request = PaymentRequest::create(
465 scope.document(), buildPaymentMethodDataForTest(), 467 scope.document(), buildPaymentMethodDataForTest(),
466 buildPaymentDetailsForTest(), scope.getExceptionState()); 468 buildPaymentDetailsForTest(), scope.getExceptionState());
467 EXPECT_FALSE(scope.getExceptionState().hadException()); 469 EXPECT_FALSE(scope.getExceptionState().hadException());
468 470
469 request->show(scope.getScriptState()) 471 request->show(scope.getScriptState())
470 .then(funcs.expectNoCall(), funcs.expectCall()); 472 .then(funcs.expectNoCall(), funcs.expectCall());
471 473
472 request->onUpdatePaymentDetails(ScriptValue::from( 474 request->onUpdatePaymentDetails(
473 scope.getScriptState(), fromJSONString(scope.getScriptState()->isolate(), 475 ScriptValue::from(scope.getScriptState(),
474 "{}", scope.getExceptionState()))); 476 fromJSONString(scope.getScriptState()->isolate(), "{}",
477 scope.getExceptionState())));
475 EXPECT_FALSE(scope.getExceptionState().hadException()); 478 EXPECT_FALSE(scope.getExceptionState().hadException());
476 } 479 }
477 480
478 TEST(PaymentRequestTest, 481 TEST(PaymentRequestTest,
479 ClearShippingOptionOnPaymentDetailsUpdateWithoutShippingOptions) { 482 ClearShippingOptionOnPaymentDetailsUpdateWithoutShippingOptions) {
480 V8TestingScope scope; 483 V8TestingScope scope;
481 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 484 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
482 makePaymentRequestOriginSecure(scope.document()); 485 makePaymentRequestOriginSecure(scope.document());
483 PaymentDetails details; 486 PaymentDetails details;
484 details.setTotal(buildPaymentItemForTest()); 487 details.setTotal(buildPaymentItemForTest());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 scope.getScriptState(), 638 scope.getScriptState(),
636 fromJSONString(scope.getScriptState()->isolate(), 639 fromJSONString(scope.getScriptState()->isolate(),
637 detailWithShippingOptions, scope.getExceptionState()))); 640 detailWithShippingOptions, scope.getExceptionState())));
638 641
639 EXPECT_FALSE(scope.getExceptionState().hadException()); 642 EXPECT_FALSE(scope.getExceptionState().hadException());
640 EXPECT_TRUE(request->shippingOption().isNull()); 643 EXPECT_TRUE(request->shippingOption().isNull());
641 } 644 }
642 645
643 } // namespace 646 } // namespace
644 } // namespace blink 647 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698