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 ...@@ -388,18 +388,18 @@ public class ChromePaymentRequestService
if (hasNotifiedInvokedPaymentApp) return; if (hasNotifiedInvokedPaymentApp) return;
String detailsError = mSpec.getPaymentDetails().error; mPaymentUiService.showShippingAddressErrorIfApplicable(details.error);
mPaymentUiService.showShippingAddressErrorIfApplicable(detailsError);
mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo(); mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo();
} }
// Implements BrowserPaymentRequest: // Implements BrowserPaymentRequest:
@Override @Override
public String continueShow(boolean isFinishedQueryingPaymentApps) { public String continueShowWithUpdatedDetails(
PaymentDetails details, boolean isFinishedQueryingPaymentApps) {
Context context = mDelegate.getContext(mRenderFrameHost); Context context = mDelegate.getContext(mRenderFrameHost);
if (context == null) return ErrorStrings.CONTEXT_NOT_FOUND; if (context == null) return ErrorStrings.CONTEXT_NOT_FOUND;
mPaymentUiService.updateDetailsOnPaymentRequestUI(mSpec.getPaymentDetails()); mPaymentUiService.updateDetailsOnPaymentRequestUI(details);
if (isFinishedQueryingPaymentApps && !mHasSkippedAppSelector) { if (isFinishedQueryingPaymentApps && !mHasSkippedAppSelector) {
mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo(); mPaymentUiService.enableAndUpdatePaymentRequestUIWithPaymentInfo();
......
...@@ -210,12 +210,14 @@ public interface BrowserPaymentRequest { ...@@ -210,12 +210,14 @@ public interface BrowserPaymentRequest {
/** /**
* Continues the unfinished part of show() that was blocked for the payment details that was * Continues the unfinished part of show() that was blocked for the payment details that was
* pending to be updated. * pending to be updated.
* @param details The updated payment details.
* @param isFinishedQueryingPaymentApps Whether all payment app factories have been queried for * @param isFinishedQueryingPaymentApps Whether all payment app factories have been queried for
* their payment apps. * their payment apps.
* @return The error if it fails; null otherwise. * @return The error if it fails; null otherwise.
*/ */
@Nullable @Nullable
default String continueShow(boolean isFinishedQueryingPaymentApps) { default String continueShowWithUpdatedDetails(
PaymentDetails details, boolean isFinishedQueryingPaymentApps) {
return null; return null;
} }
......
...@@ -1181,7 +1181,7 @@ public class PaymentRequestService ...@@ -1181,7 +1181,7 @@ public class PaymentRequestService
&& mBrowserPaymentRequest.parseAndValidateDetailsFurtherIfNeeded(details); && mBrowserPaymentRequest.parseAndValidateDetailsFurtherIfNeeded(details);
} }
private String continueShow(@Nullable PaymentDetails details) { private String continueShowWithUpdatedDetails(@Nullable PaymentDetails details) {
assert mIsShowWaitingForUpdatedDetails; assert mIsShowWaitingForUpdatedDetails;
assert mBrowserPaymentRequest != null; assert mBrowserPaymentRequest != null;
// mSpec.updateWith() can be used only when mSpec has not been destroyed. // mSpec.updateWith() can be used only when mSpec has not been destroyed.
...@@ -1197,7 +1197,8 @@ public class PaymentRequestService ...@@ -1197,7 +1197,8 @@ public class PaymentRequestService
mSpec.updateWith(details); mSpec.updateWith(details);
mIsShowWaitingForUpdatedDetails = false; mIsShowWaitingForUpdatedDetails = false;
String error = mBrowserPaymentRequest.continueShow(mIsFinishedQueryingPaymentApps); String error = mBrowserPaymentRequest.continueShowWithUpdatedDetails(
mSpec.getPaymentDetails(), mIsFinishedQueryingPaymentApps);
if (error != null) return error; if (error != null) return error;
if (!mIsFinishedQueryingPaymentApps) return null; if (!mIsFinishedQueryingPaymentApps) return null;
...@@ -1214,7 +1215,7 @@ public class PaymentRequestService ...@@ -1214,7 +1215,7 @@ public class PaymentRequestService
if (mIsShowWaitingForUpdatedDetails) { if (mIsShowWaitingForUpdatedDetails) {
// Under this condition, updateWith() is called in response to the resolution of // Under this condition, updateWith() is called in response to the resolution of
// show()'s PaymentDetailsUpdate promise. // show()'s PaymentDetailsUpdate promise.
String error = continueShow(details); String error = continueShowWithUpdatedDetails(details);
if (error != null) { if (error != null) {
onShowFailed(error); onShowFailed(error);
return; return;
......
...@@ -285,6 +285,11 @@ public class PaymentRequestServiceTest implements PaymentRequestClient { ...@@ -285,6 +285,11 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
.recordTransactionAmount(Mockito.eq("CNY"), Mockito.eq("123"), Mockito.eq(false)); .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 @Test
@Feature({"Payments"}) @Feature({"Payments"})
public void testNullFrameOriginFailsCreation() { public void testNullFrameOriginFailsCreation() {
...@@ -409,7 +414,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient { ...@@ -409,7 +414,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
assertNoError(); assertNoError();
service.updateWith(null); service.updateWith(null);
assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL); assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL);
Mockito.verify(mBrowserPaymentRequest, Mockito.never()).continueShow(Mockito.anyBoolean()); verifyContinuedShowWithUpdatedDetails(0);
} }
@Test @Test
...@@ -422,7 +427,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient { ...@@ -422,7 +427,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
details.id = "testId"; details.id = "testId";
service.updateWith(details); service.updateWith(details);
assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL); assertErrorAndReason(ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL);
Mockito.verify(mBrowserPaymentRequest, Mockito.never()).continueShow(Mockito.anyBoolean()); verifyContinuedShowWithUpdatedDetails(0);
} }
@Test @Test
...@@ -432,7 +437,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient { ...@@ -432,7 +437,7 @@ public class PaymentRequestServiceTest implements PaymentRequestClient {
service.show(mIsUserGestureDefaultValue, true); service.show(mIsUserGestureDefaultValue, true);
updateWith(service); updateWith(service);
assertNoError(); assertNoError();
Mockito.verify(mBrowserPaymentRequest, Mockito.times(1)).continueShow(Mockito.anyBoolean()); verifyContinuedShowWithUpdatedDetails(1);
} }
@Test @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