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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java

Issue 2880413002: Constrain ShortcutSource to valid values (Closed)
Patch Set: Merge branch 'master' into webapk_source Created 3 years, 7 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/webapps/WebappInfo.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
index aba6f20baa2756074f6f6d013421ef118e6c3381..f1ccc06de71f495f7c83ae39d499ffb9a0e5700a 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
@@ -225,4 +225,24 @@ public class WebApkInfoTest {
WebApkInfo info = WebApkInfo.create(intent);
Assert.assertTrue(info.shouldForceNavigation());
}
+
+ /**
+ * Test that {@link WebApkInfo#source()} returns {@link ShortcutSource#UNKNOWN} if the source
+ * in the launch intent > {@link ShortcutSource#COUNT}. This can occur if the user is using a
+ * new WebAPK and an old version of Chrome.
+ */
+ @Test
+ public void testOutOfBoundsSource() {
+ Bundle bundle = new Bundle();
+ bundle.putString(WebApkMetaDataKeys.START_URL, START_URL);
+ WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME, bundle);
+
+ Intent intent = new Intent();
+ intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, WEBAPK_PACKAGE_NAME);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, START_URL);
+ intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.COUNT + 1);
+
+ WebApkInfo info = WebApkInfo.create(intent);
+ Assert.assertEquals(ShortcutSource.UNKNOWN, info.source());
+ }
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698