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

Unified Diff: chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java

Issue 2954933002: WebApk needs to be restarted to notice that host browser was uninstalled. (Closed)
Patch Set: Nits. Created 3 years, 6 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 | « no previous file | chrome/android/webapk/shell_apk/shell_apk_version.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java
diff --git a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java
index 548f7cbc4e85a329618e8251e60e3fe6f5356c26..9517d18e0110e2eafbbeb835a95884a0c471434f 100644
--- a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java
+++ b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java
@@ -171,6 +171,40 @@ public class WebApkUtilsTest {
Assert.assertNull(hostBrowser);
}
+ /**
+ * Tests that {@link WebApkUtils#getHostBrowserPackageName(Context)} doesn't return the current
+ * host browser which is cached in the {@link WebApkUtils#sHostPackage} and uninstalled.
+ */
+ @Test
+ public void testDoesNotReturnTheCurrentHostBrowserAfterUninstall() {
+ String currentHostBrowser = BROWSER_INSTALLED_SUPPORTING_WEBAPKS;
+ mockInstallBrowsers(ANOTHER_BROWSER_INSTALLED_SUPPORTING_WEBAPKS);
+ setHostBrowserInMetadata(null);
+ setHostBrowserInSharedPreferences(currentHostBrowser);
+
+ String hostBrowser = WebApkUtils.getHostBrowserPackageName(mContext);
+ Assert.assertEquals(currentHostBrowser, hostBrowser);
+
+ uninstallBrowser(currentHostBrowser);
+ hostBrowser = WebApkUtils.getHostBrowserPackageName(mContext);
+ Assert.assertNotEquals(currentHostBrowser, hostBrowser);
+ }
+
+ /**
+ * Uninstall a browser. Note: this function only works for uninstalling the non default browser.
+ */
+ private void uninstallBrowser(String packageName) {
+ Intent intent = null;
+ try {
+ intent = Intent.parseUri("http://", Intent.URI_INTENT_SCHEME);
+ } catch (Exception e) {
+ Assert.fail();
+ return;
+ }
+ mPackageManager.removeResolveInfosForIntent(intent, packageName);
+ mPackageManager.removePackage(packageName);
+ }
+
private static ResolveInfo newResolveInfo(String packageName) {
ActivityInfo activityInfo = new ActivityInfo();
activityInfo.packageName = packageName;
« no previous file with comments | « no previous file | chrome/android/webapk/shell_apk/shell_apk_version.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698