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

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

Issue 2250793003: Separate PaymentRequest initialization and display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update payment-request-mock.js Created 4 years, 3 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/JSONValuesForV8.h" 7 #include "bindings/core/v8/JSONValuesForV8.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 V8TestingScope scope; 215 V8TestingScope scope;
216 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 216 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
217 makePaymentRequestOriginSecure(scope.document()); 217 makePaymentRequestOriginSecure(scope.document());
218 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionSt ate()); 218 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionSt ate());
219 EXPECT_FALSE(scope.getExceptionState().hadException()); 219 EXPECT_FALSE(scope.getExceptionState().hadException());
220 request->show(scope.getScriptState()); 220 request->show(scope.getScriptState());
221 221
222 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec tCall()); 222 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec tCall());
223 } 223 }
224 224
225 TEST(PaymentRequestTest, CannotShowAfterAborted)
226 {
227 V8TestingScope scope;
228 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
229 makePaymentRequestOriginSecure(scope.document());
230 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionSt ate());
231 EXPECT_FALSE(scope.getExceptionState().hadException());
232 request->show(scope.getScriptState());
233 request->abort(scope.getScriptState());
234 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(true);
235
236 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec tCall());
237 }
238
225 TEST(PaymentRequestTest, RejectShowPromiseOnErrorPaymentMethodNotSupported) 239 TEST(PaymentRequestTest, RejectShowPromiseOnErrorPaymentMethodNotSupported)
226 { 240 {
227 V8TestingScope scope; 241 V8TestingScope scope;
228 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 242 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
229 makePaymentRequestOriginSecure(scope.document()); 243 makePaymentRequestOriginSecure(scope.document());
230 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionSt ate()); 244 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionSt ate());
231 EXPECT_FALSE(scope.getExceptionState().hadException()); 245 EXPECT_FALSE(scope.getExceptionState().hadException());
232 246
233 String errorMessage; 247 String errorMessage;
234 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec tCall(&errorMessage)); 248 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec tCall(&errorMessage));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 "{\"id\": \"fast\", \"label\": \"Fast\", \"amount\": {\"currency\": \"US D\", \"value\": \"50.00\"}, \"selected\": true}]}"; 388 "{\"id\": \"fast\", \"label\": \"Fast\", \"amount\": {\"currency\": \"US D\", \"value\": \"50.00\"}, \"selected\": true}]}";
375 389
376 request->onUpdatePaymentDetails(ScriptValue::from(scope.getScriptState(), fr omJSONString(scope.getScriptState(), detail, scope.getExceptionState()))); 390 request->onUpdatePaymentDetails(ScriptValue::from(scope.getScriptState(), fr omJSONString(scope.getScriptState(), detail, scope.getExceptionState())));
377 EXPECT_FALSE(scope.getExceptionState().hadException()); 391 EXPECT_FALSE(scope.getExceptionState().hadException());
378 392
379 EXPECT_EQ("fast", request->shippingOption()); 393 EXPECT_EQ("fast", request->shippingOption());
380 } 394 }
381 395
382 } // namespace 396 } // namespace
383 } // namespace blink 397 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698