Skip to content

Commit

Permalink
Fix UriOverrider::isTargetUri with different paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinrob committed Jan 25, 2024
1 parent b811d56 commit 833d614
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private boolean isTargetUri(Uri destinationUri) {
String destinationPath = destinationUri.getPath();

String targetHost = target.getHost();
String targetPath = destinationUri.getPath();
String targetPath = target.getPath();

return destinationHost.equalsIgnoreCase(targetHost)
&& destinationPath.equals(targetPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,44 @@ protected void onSessionRestart() {
verify(webView.getContext()).startActivity(argument.capture());
}

@Test
public void givenUserIsNavigatingToOtherPathThenLoadShouldBeCancelledAndIntentShouldBeStarted() {
UriOverrider testObj = new UriOverrider();
testObj.setQueue(Uri.parse("https://useraccount.queue-it.net/app/enqueue"));
testObj.setTarget(Uri.parse("https://www.qoqa.ch/"));
WebView webView = getMockedWebview();
final AtomicBoolean queuePassed = new AtomicBoolean(false);
ArgumentCaptor<Intent> argument = ArgumentCaptor.forClass(Intent.class);
String otherPage = "https://www.qoqa.ch/concept";

boolean loadCancelled = testObj.handleNavigationRequest(otherPage, webView, new UriOverrideWrapper() {
@Override
protected void onQueueUrlChange(String uri) {
System.out.print(uri);
}

@Override
protected void onPassed(String queueItToken) {
queuePassed.set(true);
}

@Override
protected void onCloseClicked() {

}

@Override
protected void onSessionRestart() {

}
});

assertTrue(loadCancelled);
assertFalse(queuePassed.get());

verify(webView.getContext()).startActivity(argument.capture());
}

@Test
public void givenAppUserIsRedirectedToDeepLinkThenLoadShouldBeCancelled() {
UriOverrider testObj = new UriOverrider();
Expand Down

0 comments on commit 833d614

Please sign in to comment.