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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp

Issue 2145553002: Parameterize OnError method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing integration test failures Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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..3ca10494231e058565fe64100fbc597b81032f42 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 errorMessage;
+ request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectCall(&errorMessage));
+
+ 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", errorMessage);
+}
+
+TEST(PaymentRequestTest, RejectShowPromiseOnErrorCancelled)
+{
+ 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 errorMessage;
+ request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectCall(&errorMessage));
+
+ static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError(mojom::blink::PaymentErrorReason::USER_CANCEL);
+
+ v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate());
+ EXPECT_EQ("Request cancelled", errorMessage);
}
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 errorMessage;
+ request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall(&errorMessage));
+
+ 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("UnknownError: Request failed", errorMessage);
}
// 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());
}

Powered by Google App Engine
This is Rietveld 408576698