Skip to content

Commit

Permalink
Update Browser Switch (#43)
Browse files Browse the repository at this point in the history
* Bump browser switch version in build.gradle file.

Signed-off-by: Steven Shropshire <steven.shropshire@getbraintree.com>

* Remove duplicated functionality for matching deep link uri scheme. This now occurs in browser switch.

Signed-off-by: Steven Shropshire <steven.shropshire@getbraintree.com>

* Update CHANGELOG.

Signed-off-by: Steven Shropshire <steven.shropshire@getbraintree.com>

Co-authored-by: Sarah Koop <skoop@paypal.com>
  • Loading branch information
sshropshire and sarahkoop authored Mar 8, 2021
1 parent 009fdd5 commit 1750848
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PopupBridge Android Release Notes

## unreleased

* Update browser-switch to 2.0.0-beta2

## 4.0.0-beta1

* Add `PopupBridgeClient`
Expand Down
2 changes: 1 addition & 1 deletion PopupBridge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
}

dependencies {
implementation 'com.braintreepayments.api:browser-switch:2.0.0-beta1'
implementation 'com.braintreepayments.api:browser-switch:2.0.0-beta2'
implementation 'androidx.appcompat:appcompat:1.2.0'

testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ private void onBrowserSwitchResult(BrowserSwitchResult result) {
+ "}");
return;
} else if (result.getStatus() == BrowserSwitchStatus.SUCCESS) {
if (returnUri == null || !returnUri.getScheme().equals(returnUrlScheme) ||
!returnUri.getHost().equals(POPUP_BRIDGE_URL_HOST)) {
if (returnUri == null || !returnUri.getHost().equals(POPUP_BRIDGE_URL_HOST)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,6 @@ public void onBrowserSwitchResult_whenCancelled_callsPopupBridgeOnCancelMethod()
assertThat(webView.mJavascriptEval, containsString("window.popupBridge.onComplete(null, null)"));
}

@Test
public void onBrowserSwitchResult_whenDifferentScheme_doesNotCallOnComplete() {
BrowserSwitchResult result = mock(BrowserSwitchResult.class);
when(result.getStatus()).thenReturn(BrowserSwitchStatus.SUCCESS);

Uri uri = new Uri.Builder()
.scheme("com.oranges.popupbridge")
.path("mypath")
.build();
when(result.getDeepLinkUrl()).thenReturn(uri);

when(browserSwitchClient.deliverResult(fragmentActivity)).thenReturn(result);

PopupBridgeClient sut =
new PopupBridgeClient(activityRef, webViewRef, "my-custom-url-scheme", browserSwitchClient);
sut.deliverPopupBridgeResult(fragmentActivity);

assertNull(webView.mError);
assertNull(webView.mPayload);
assertNull(webView.mJavascriptEval);
}

@Test
public void onBrowserSwitchResult_whenReturnUrlHasQueryParams_reportsPayloadWithQueryItems()
throws JSONException {
Expand Down

0 comments on commit 1750848

Please sign in to comment.