Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java

Issue 1786813003: Fix bug in specialized handler logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3fb510c8fc3f93aa7d37a9968e7cdb5e483dec32
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java
@@ -0,0 +1,92 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.externalnav;
+
+import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ResolveInfo;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+
+/**
+ * Instrumentation tests for {@link ExternalNavigationHandler}.
+ */
+public class ExternalNavigationDelegateImplTest extends InstrumentationTestCase {
+
+ private static List<ResolveInfo> makeResolveInfos(ResolveInfo... infos) {
+ return Arrays.asList(infos);
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_NoResolveInfo() {
+ String packageName = "";
+ List<ResolveInfo> resolveInfos = new ArrayList<ResolveInfo>();
+ assertFalse(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_NoPathOrAuthority() {
+ String packageName = "";
+ ResolveInfo info = new ResolveInfo();
+ info.filter = new IntentFilter();
+ List<ResolveInfo> resolveInfos = makeResolveInfos(info);
+ assertFalse(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_WithPath() {
+ String packageName = "";
+ ResolveInfo info = new ResolveInfo();
+ info.filter = new IntentFilter();
+ info.filter.addDataPath("somepath", 2);
+ List<ResolveInfo> resolveInfos = makeResolveInfos(info);
+ assertTrue(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_WithAuthority() {
+ String packageName = "";
+ ResolveInfo info = new ResolveInfo();
+ info.filter = new IntentFilter();
+ info.filter.addDataAuthority("http://www.google.com", "80");
+ List<ResolveInfo> resolveInfos = makeResolveInfos(info);
+ assertTrue(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_WithTargetPackage_Matching() {
+ String packageName = "com.android.chrome";
+ ResolveInfo info = new ResolveInfo();
+ info.filter = new IntentFilter();
+ info.filter.addDataAuthority("http://www.google.com", "80");
+ info.activityInfo = new ActivityInfo();
+ info.activityInfo.packageName = packageName;
+ List<ResolveInfo> resolveInfos = makeResolveInfos(info);
+ assertTrue(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+
+ @SmallTest
+ public void testIsPackageSpecializedHandler_WithTargetPackage_NotMatching() {
+ String packageName = "com.android.chrome";
+ ResolveInfo info = new ResolveInfo();
+ info.filter = new IntentFilter();
+ info.filter.addDataAuthority("http://www.google.com", "80");
+ info.activityInfo = new ActivityInfo();
+ info.activityInfo.packageName = "com.foo.bar";
+ List<ResolveInfo> resolveInfos = makeResolveInfos(info);
+ assertFalse(ExternalNavigationDelegateImpl
+ .isPackageSpecializedHandler(resolveInfos, packageName));
+ }
+}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698