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

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

Issue 1845233002: Store standalone web app data in WebappDataStorage as well as the homescreen intent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-deep-linking
Patch Set: Final nit Created 4 years, 8 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
Index: chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5cb75eed1447feb9a26e7a4365007d3a0c1792f7
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java
@@ -0,0 +1,56 @@
+// 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;
+
+import static org.junit.Assert.assertEquals;
+
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+/**
+ * Unit tests for {@link org.chromium.chrome.browser.ShortcutHelper}.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ShortcutHelperTest {
+
+ /**
+ * Test method for {@link ShortcutHelper#getScopeFromUrl.}
+ */
+ @Test
+ public void testGetScopeFromUrl() {
+ String url1 = "https://www.google.com";
+ String url2 = "https://www.google.com/";
+ String url3 = "https://www.google.com/maps";
+ String url4 = "https://www.google.com/maps/";
+ String url5 = "https://www.google.com/index.html";
+ String url6 = "https://www.google.com/index.html?q=maps";
+ String url7 = "https://www.google.com/index.html#maps/";
+ String url8 = "https://www.google.com/maps/au/index.html";
+ String url9 = "https://www.google.com/maps/au/north";
+ String url10 = "https://www.google.com/maps/au/north/";
+ String url11 = "https://www.google.com/maps/au/index.html?q=maps#fragment/";
+ String url12 = "http://www.google.com:8000/maps/au/index.html?q=maps#fragment/";
+
+ String url2_scope = "https://www.google.com/";
+ String url8_scope = "https://www.google.com/maps/au/";
+ String url12_scope = "http://www.google.com:8000/maps/au/";
+
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url1));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url2));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url3));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url4));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url5));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url6));
+ assertEquals(url2_scope, ShortcutHelper.getScopeFromUrl(url7));
+ assertEquals(url8_scope, ShortcutHelper.getScopeFromUrl(url8));
+ assertEquals(url8_scope, ShortcutHelper.getScopeFromUrl(url9));
+ assertEquals(url8_scope, ShortcutHelper.getScopeFromUrl(url10));
+ assertEquals(url8_scope, ShortcutHelper.getScopeFromUrl(url11));
+ assertEquals(url12_scope, ShortcutHelper.getScopeFromUrl(url12));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698