Commit e4c53ce3 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android] Cleanup ExternalNavigationHandlerTest

This CL:
- Replaces calls to
  ExternalNavigationDelegateImpl#isSpecializedHandlerAvailable() with calls to
  #countSpecializedHandlers() because #isSpecializedHandlerAvailable() has just
  one caller
- Replaces ChromeBrowserTestRule with NativeLibraryTestRule
- Uses a mock context for both ContextUtils#getApplicationContext() and for
  TabRedirectHandler instead of just for TabRedirectHandler
- Makes TestPackageManager#queryIntentActivities() and
  TestExternalNavigationDelegate#queryIntentActivities() use same
  implementation.
- Changes tests to register relevant http:// and https:// handlers at the
  beginning of the test. This is a change of behavior. Previously, most URLs
  would be handled by the "foo" external app
- Changes TestExternalNavigationDelegate#mQueryIntentOverride from tristate to
  boolean. The "true behavior" was nuked but the "false behavior" was
  preserved.

BUG=None

Change-Id: If212afde6e4c12d4f08576c4bd26392b8732bc09
Reviewed-on: https://chromium-review.googlesource.com/891744
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarMaria Khomenko <mariakhomenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532970}
parent a0905fab
...@@ -29,12 +29,6 @@ interface ExternalNavigationDelegate { ...@@ -29,12 +29,6 @@ interface ExternalNavigationDelegate {
*/ */
boolean willChromeHandleIntent(Intent intent); boolean willChromeHandleIntent(Intent intent);
/**
* Search for intent handlers that are specific to this URL aka, specialized apps like
* google maps or youtube
*/
boolean isSpecializedHandlerAvailable(List<ResolveInfo> infos);
/** /**
* Returns true if the current activity is a webapp and {@params url} lies within the scope of * Returns true if the current activity is a webapp and {@params url} lies within the scope of
* that webapp. * that webapp.
......
...@@ -253,11 +253,6 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat ...@@ -253,11 +253,6 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
return willChromeHandleIntent(intent, false); return willChromeHandleIntent(intent, false);
} }
@Override
public boolean isSpecializedHandlerAvailable(List<ResolveInfo> infos) {
return countSpecializedHandlers(infos) > 0;
}
@Override @Override
public boolean isWithinCurrentWebappScope(String url) { public boolean isWithinCurrentWebappScope(String url) {
Context context = getAvailableContext(); Context context = getAvailableContext();
......
...@@ -419,7 +419,7 @@ public class ExternalNavigationHandler { ...@@ -419,7 +419,7 @@ public class ExternalNavigationHandler {
// handlers. If webkit can't handle it internally, we need to call // handlers. If webkit can't handle it internally, we need to call
// startActivityIfNeeded or startActivity. // startActivityIfNeeded or startActivity.
if (!isExternalProtocol) { if (!isExternalProtocol) {
if (!mDelegate.isSpecializedHandlerAvailable(resolvingInfos)) { if (mDelegate.countSpecializedHandlers(resolvingInfos) == 0) {
if (incomingIntentRedirect && mDelegate.maybeLaunchInstantApp( if (incomingIntentRedirect && mDelegate.maybeLaunchInstantApp(
params.getTab(), params.getUrl(), params.getReferrerUrl(), true)) { params.getTab(), params.getUrl(), params.getReferrerUrl(), true)) {
if (DEBUG) Log.i(TAG, "OVERRIDE_WITH_EXTERNAL_INTENT: Instant Apps redirect"); if (DEBUG) Log.i(TAG, "OVERRIDE_WITH_EXTERNAL_INTENT: Instant Apps redirect");
......
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