Commit 20a24ff7 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Chromium LUCI CQ

[WebLayer] Renamed continueShow

This CL does not cause behaviour change.

Changes:
* Renamed "continueShow" to "continueShowWithUpdatedDetails"
* In onPaymentDetailsUpdated(), replaced mSpec.getPaymentDetails() with
  details because they are the same object.

Bug: 1149936
Change-Id: Icea9f313b513861d4655e3f66f053c015c6f775f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590059Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837103}
parent 2c02321a
......@@ -388,18 +388,18 @@ public class ChromePaymentRequestService
if (hasNotifiedInvokedPaymentApp) return;
String detailsError = mSpec.getPaymentDetails().error;
mPaymentUiService.showShippingAddressErrorIfApplicable(detailsError);
mPaymentUiService.showShippingAddressErrorIfApplicable(details.error);
mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo();
}
// Implements BrowserPaymentRequest:
@Override
public String continueShow(boolean isFinishedQueryingPaymentApps) {
public String continueShowWithUpdatedDetails(
PaymentDetails details, boolean isFinishedQueryingPaymentApps) {
Context context = mDelegate.getContext(mRenderFrameHost);
if (context == null) return ErrorStrings.CONTEXT_NOT_FOUND;
mPaymentUiService.updateDetailsOnPaymentRequestUI(mSpec.getPaymentDetails());
mPaymentUiService.updateDetailsOnPaymentRequestUI(details);
if (isFinishedQueryingPaymentApps && !mHasSkippedAppSelector) {
mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo();
......
......@@ -210,12 +210,14 @@ public interface BrowserPaymentRequest {
/**
* Continues the unfinished part of show() that was blocked for the payment details that was
* pending to be updated.
* @param details The updated payment details.
* @param isFinishedQueryingPaymentApps Whether all payment app factories have been queried for
* their payment apps.
* @return The error if it fails; null otherwise.
*/
@Nullable
default String continueShow(boolean isFinishedQueryingPaymentApps) {
default String continueShowWithUpdatedDetails(
PaymentDetails details, boolean isFinishedQueryingPaymentApps) {
return null;
}
......
......@@ -1181,7 +1181,7 @@ public class PaymentRequestService
&& mBrowserPaymentRequest.parseAndValidateDetailsFurtherIfNeeded(details);
}
private String continueShow(@Nullable PaymentDetails details) {
private String continueShowWithUpdatedDetails(@Nullable PaymentDetails details) {
assert mIsShowWaitingForUpdatedDetails;
assert mBrowserPaymentRequest != null;
// mSpec.updateWith() can be used only when mSpec has not been destroyed.
......@@ -1197,7 +1197,8 @@ public class PaymentRequestService
mSpec.updateWith(details);
mIsShowWaitingForUpdatedDetails = false;
String error = mBrowserPaymentRequest.continueShow(mIsFinishedQueryingPaymentApps);
String error = mBrowserPaymentRequest.continueShowWithUpdatedDetails(
mSpec.getPaymentDetails(), mIsFinishedQueryingPaymentApps);
if (error != null) return error;
if (!mIsFinishedQueryingPaymentApps) return null;
......@@ -1214,7 +1215,7 @@ public class PaymentRequestService
if (mIsShowWaitingForUpdatedDetails) {
// Under this condition, updateWith() is called in response to the resolution of
// show()'s PaymentDetailsUpdate promise.
String error = continueShow(details);
String error = continueShowWithUpdatedDetails(details);
if (error != null) {
onShowFailed(error);
return;
......
......@@ -285,6 +285,11 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
.recordTransactionAmount(Mockito.eq("CNY"), Mockito.eq("123"), Mockito.eq(false));
}
private void verifyContinuedShowWithUpdatedDetails(int times) {
Mockito.verify(mBrowserPaymentRequest, Mockito.times(times))
.continueShowWithUpdatedDetails(Mockito.any(), Mockito.anyBoolean());
}
@Test
@Feature({"Payments"})
public void testNullFrameOriginFailsCreation() {
......@@ -409,7 +414,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
assertNoError();
service.updateWith(null);
assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL);
Mockito.verify(mBrowserPaymentRequest, Mockito.never()).continueShow(Mockito.anyBoolean());
verifyContinuedShowWithUpdatedDetails(0);
}
@Test
......@@ -422,7 +427,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
details.id = "testId";
service.updateWith(details);
assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL);
Mockito.verify(mBrowserPaymentRequest, Mockito.never()).continueShow(Mockito.anyBoolean());
verifyContinuedShowWithUpdatedDetails(0);
}
@Test
......@@ -432,7 +437,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
service.show(mIsUserGestureDefaultValue, true);
updateWith(service);
assertNoError();
Mockito.verify(mBrowserPaymentRequest, Mockito.times(1)).continueShow(Mockito.anyBoolean());
verifyContinuedShowWithUpdatedDetails(1);
}
@Test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment