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

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

Issue 2727483002: Instant Apps: refactor logic to encapsulate in the Instant Apps Handler. (Closed)
Patch Set: Fix findbugs issue. Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.externalnav; 5 package org.chromium.chrome.browser.externalnav;
6 6
7 import android.content.IntentFilter; 7 import android.content.IntentFilter;
8 import android.content.pm.ActivityInfo; 8 import android.content.pm.ActivityInfo;
9 import android.content.pm.ResolveInfo; 9 import android.content.pm.ResolveInfo;
10 import android.support.test.filters.SmallTest; 10 import android.support.test.filters.SmallTest;
11 11
12 import org.chromium.chrome.browser.ChromeActivity; 12 import org.chromium.chrome.browser.ChromeActivity;
13 import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
13 import org.chromium.chrome.test.ChromeActivityTestCaseBase; 14 import org.chromium.chrome.test.ChromeActivityTestCaseBase;
14 15
15 import java.util.ArrayList; 16 import java.util.ArrayList;
16 import java.util.Arrays; 17 import java.util.Arrays;
17 import java.util.List; 18 import java.util.List;
18 19
19 /** 20 /**
20 * Instrumentation tests for {@link ExternalNavigationHandler}. 21 * Instrumentation tests for {@link ExternalNavigationHandler}.
21 */ 22 */
22 public class ExternalNavigationDelegateImplTest extends ChromeActivityTestCaseBa se<ChromeActivity> { 23 public class ExternalNavigationDelegateImplTest extends ChromeActivityTestCaseBa se<ChromeActivity> {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 resolveInfos, packageName).size()); 96 resolveInfos, packageName).size());
96 } 97 }
97 98
98 @SmallTest 99 @SmallTest
99 public void testIsPackageSpecializeHandler_withEphemeralResolver() { 100 public void testIsPackageSpecializeHandler_withEphemeralResolver() {
100 String packageName = ""; 101 String packageName = "";
101 ResolveInfo info = new ResolveInfo(); 102 ResolveInfo info = new ResolveInfo();
102 info.filter = new IntentFilter(); 103 info.filter = new IntentFilter();
103 info.filter.addDataPath("somepath", 2); 104 info.filter.addDataPath("somepath", 2);
104 info.activityInfo = new ActivityInfo(); 105 info.activityInfo = new ActivityInfo();
105 info.activityInfo.name = ExternalNavigationDelegateImpl.EPHEMERAL_INSTAL LER_CLASS; 106 info.activityInfo.name = InstantAppsHandler.EPHEMERAL_INSTALLER_CLASS;
106 info.activityInfo.packageName = "com.google.android.gms"; 107 info.activityInfo.packageName = "com.google.android.gms";
107 List<ResolveInfo> resolveInfos = makeResolveInfos(info); 108 List<ResolveInfo> resolveInfos = makeResolveInfos(info);
108 // Ephemeral resolver is not counted as a specialized handler. 109 // Ephemeral resolver is not counted as a specialized handler.
109 assertEquals(0, ExternalNavigationDelegateImpl.getSpecializedHandlersWit hFilter( 110 assertEquals(0, ExternalNavigationDelegateImpl.getSpecializedHandlersWit hFilter(
110 resolveInfos, packageName).size()); 111 resolveInfos, packageName).size());
111 } 112 }
112 113
113 @SmallTest 114 @SmallTest
114 public void testIsDownload_noSystemDownloadManager() throws Exception { 115 public void testIsDownload_noSystemDownloadManager() throws Exception {
115 ExternalNavigationDelegateImpl delegate = new ExternalNavigationDelegate Impl( 116 ExternalNavigationDelegateImpl delegate = new ExternalNavigationDelegate Impl(
116 getActivity().getActivityTab()); 117 getActivity().getActivityTab());
117 assertTrue("pdf should be a download, no viewer in Android Chrome", 118 assertTrue("pdf should be a download, no viewer in Android Chrome",
118 delegate.isPdfDownload("http://somesampeleurldne.com/file.pdf")) ; 119 delegate.isPdfDownload("http://somesampeleurldne.com/file.pdf")) ;
119 assertFalse("URL is not a file, but web page", 120 assertFalse("URL is not a file, but web page",
120 delegate.isPdfDownload("http://somesampleurldne.com/index.html") ); 121 delegate.isPdfDownload("http://somesampleurldne.com/index.html") );
121 assertFalse("URL is not a file url", 122 assertFalse("URL is not a file url",
122 delegate.isPdfDownload("http://somesampeleurldne.com/not.a.real. extension")); 123 delegate.isPdfDownload("http://somesampeleurldne.com/not.a.real. extension"));
123 assertFalse("URL is an image, can be viewed in Chrome", 124 assertFalse("URL is an image, can be viewed in Chrome",
124 delegate.isPdfDownload("http://somesampleurldne.com/image.jpg")) ; 125 delegate.isPdfDownload("http://somesampleurldne.com/image.jpg")) ;
125 assertFalse("URL is a text file can be viewed in Chrome", 126 assertFalse("URL is a text file can be viewed in Chrome",
126 delegate.isPdfDownload("http://somesampleurldne.com/copy.txt")); 127 delegate.isPdfDownload("http://somesampleurldne.com/copy.txt"));
127 } 128 }
128 129
129 @Override 130 @Override
130 public void startMainActivity() throws InterruptedException { 131 public void startMainActivity() throws InterruptedException {
131 startMainActivityOnBlankPage(); 132 startMainActivityOnBlankPage();
132 } 133 }
133 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698