| 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 // Tests for PaymentRequest::abort(). | 5 // Tests for PaymentRequest::abort(). |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8BindingForTesting.h" | 7 #include "bindings/core/v8/V8BindingForTesting.h" |
| 8 #include "modules/payments/PaymentRequest.h" | 8 #include "modules/payments/PaymentRequest.h" |
| 9 #include "modules/payments/PaymentTestHelper.h" | 9 #include "modules/payments/PaymentTestHelper.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 64 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 65 makePaymentRequestOriginSecure(scope.document()); | 65 makePaymentRequestOriginSecure(scope.document()); |
| 66 PaymentRequest* request = PaymentRequest::create( | 66 PaymentRequest* request = PaymentRequest::create( |
| 67 scope.getScriptState(), buildPaymentMethodDataForTest(), | 67 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 68 buildPaymentDetailsForTest(), scope.getExceptionState()); | 68 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 69 request->show(scope.getScriptState()); | 69 request->show(scope.getScriptState()); |
| 70 | 70 |
| 71 request->abort(scope.getScriptState()) | 71 request->abort(scope.getScriptState()) |
| 72 .then(funcs.expectNoCall(), funcs.expectCall()); | 72 .then(funcs.expectNoCall(), funcs.expectCall()); |
| 73 | 73 |
| 74 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(false); | 74 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( |
| 75 false); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // After the browser is unable to abort the payment once, the second abort() | 78 // After the browser is unable to abort the payment once, the second abort() |
| 78 // call should not be rejected, as it's not a duplicate request anymore. | 79 // call should not be rejected, as it's not a duplicate request anymore. |
| 79 TEST(AbortTest, CanAbortAgainAfterFirstAbortRejected) { | 80 TEST(AbortTest, CanAbortAgainAfterFirstAbortRejected) { |
| 80 V8TestingScope scope; | 81 V8TestingScope scope; |
| 81 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 82 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 82 makePaymentRequestOriginSecure(scope.document()); | 83 makePaymentRequestOriginSecure(scope.document()); |
| 83 PaymentRequest* request = PaymentRequest::create( | 84 PaymentRequest* request = PaymentRequest::create( |
| 84 scope.getScriptState(), buildPaymentMethodDataForTest(), | 85 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 85 buildPaymentDetailsForTest(), scope.getExceptionState()); | 86 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 86 request->show(scope.getScriptState()); | 87 request->show(scope.getScriptState()); |
| 87 request->abort(scope.getScriptState()); | 88 request->abort(scope.getScriptState()); |
| 88 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(false); | 89 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( |
| 90 false); |
| 89 | 91 |
| 90 request->abort(scope.getScriptState()) | 92 request->abort(scope.getScriptState()) |
| 91 .then(funcs.expectNoCall(), funcs.expectNoCall()); | 93 .then(funcs.expectNoCall(), funcs.expectNoCall()); |
| 92 } | 94 } |
| 93 | 95 |
| 94 // If the browser successfully aborts the payment, then the request.show() | 96 // If the browser successfully aborts the payment, then the request.show() |
| 95 // promise should be rejected, and request.abort() promise should be resolved. | 97 // promise should be rejected, and request.abort() promise should be resolved. |
| 96 TEST(AbortTest, SuccessfulAbortShouldRejectShowPromiseAndResolveAbortPromise) { | 98 TEST(AbortTest, SuccessfulAbortShouldRejectShowPromiseAndResolveAbortPromise) { |
| 97 V8TestingScope scope; | 99 V8TestingScope scope; |
| 98 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 100 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 99 makePaymentRequestOriginSecure(scope.document()); | 101 makePaymentRequestOriginSecure(scope.document()); |
| 100 PaymentRequest* request = PaymentRequest::create( | 102 PaymentRequest* request = PaymentRequest::create( |
| 101 scope.getScriptState(), buildPaymentMethodDataForTest(), | 103 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 102 buildPaymentDetailsForTest(), scope.getExceptionState()); | 104 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 103 | 105 |
| 104 request->show(scope.getScriptState()) | 106 request->show(scope.getScriptState()) |
| 105 .then(funcs.expectNoCall(), funcs.expectCall()); | 107 .then(funcs.expectNoCall(), funcs.expectCall()); |
| 106 request->abort(scope.getScriptState()) | 108 request->abort(scope.getScriptState()) |
| 107 .then(funcs.expectCall(), funcs.expectNoCall()); | 109 .then(funcs.expectCall(), funcs.expectNoCall()); |
| 108 | 110 |
| 109 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(true); | 111 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( |
| 112 true); |
| 110 } | 113 } |
| 111 | 114 |
| 112 } // namespace | 115 } // namespace |
| 113 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |