Chromium Code Reviews| Index: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
| index 50cf1db993900ae65b9c91b4f46bb48428a9c812..7778a3ffa7244594b7d360367e51a0e84fa3d8ea 100644 |
| --- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
| +++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
| @@ -237,7 +237,7 @@ TEST(PaymentRequestTest, CannotCallCompleteTwice) |
| request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall()); |
| } |
| -TEST(PaymentRequestTest, RejectShowPromiseOnError) |
| +TEST(PaymentRequestTest, RejectShowPromiseOnErrorPaymentMethodNotSupported) |
| { |
| V8TestingScope scope; |
| PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| @@ -245,9 +245,30 @@ TEST(PaymentRequestTest, RejectShowPromiseOnError) |
| PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionState()); |
| EXPECT_FALSE(scope.getExceptionState().hadException()); |
| - request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectCall()); |
| + String onRejected; |
|
please use gerrit instead
2016/07/13 15:55:26
Let's use the variable name "errorMessage".
pals
2016/07/14 08:37:38
Done.
|
| + request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectCall(&onRejected)); |
| + |
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(mojom::blink::PaymentErrorReason::NOT_SUPPORTED); |
| - static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(); |
| + v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate()); |
| + EXPECT_EQ("NotSupportedError: The payment method is not supported", onRejected); |
| +} |
| + |
| +TEST(PaymentRequestTest, RejectShowPromiseOnErrorUserCancelled) |
| +{ |
| + V8TestingScope scope; |
| + PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| + makePaymentRequestOriginSecure(scope.document()); |
| + PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionState()); |
| + EXPECT_FALSE(scope.getExceptionState().hadException()); |
| + |
| + String onRejected; |
|
please use gerrit instead
2016/07/13 15:55:26
errorMessage
pals
2016/07/14 08:37:38
Done.
|
| + request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectCall(&onRejected)); |
| + |
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(mojom::blink::PaymentErrorReason::USER_CANCEL); |
| + |
| + v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate()); |
| + EXPECT_EQ("SyntaxError: User cancelled the payment request", onRejected); |
| } |
| TEST(PaymentRequestTest, RejectCompletePromiseOnError) |
| @@ -260,9 +281,13 @@ TEST(PaymentRequestTest, RejectCompletePromiseOnError) |
| request->show(scope.getScriptState()); |
| static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(buildPaymentResponseForTest()); |
| - request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall()); |
| + String onRejected; |
|
please use gerrit instead
2016/07/13 15:55:26
errorMessage
pals
2016/07/14 08:37:38
Done.
|
| + request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall(&onRejected)); |
| + |
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(mojom::blink::PaymentErrorReason::UNKNOWN); |
| - static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(); |
| + v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate()); |
| + EXPECT_EQ("SyntaxError: The payment request is cancelled due to unknown reasons", onRejected); |
| } |
| // If user cancels the transaction during processing, the complete() promise |
| @@ -276,7 +301,7 @@ TEST(PaymentRequestTest, RejectCompletePromiseAfterError) |
| EXPECT_FALSE(scope.getExceptionState().hadException()); |
| request->show(scope.getScriptState()); |
| static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(buildPaymentResponseForTest()); |
| - static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(); |
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(mojom::blink::PaymentErrorReason::USER_CANCEL); |
| request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall()); |
| } |