Bug 1431456 - Pre: junit4-ify weburlfinder tests, add a few extra test cases r=nalexander draft
authorGrigory Kruglov <gkruglov@mozilla.com>
Mon, 22 Jan 2018 16:56:45 -0500
changeset 723322 c391076899cb2f78713bca6369ab20392e84fe80
parent 721495 4e429d313fd2e0f9202271ee8f3fb798817ec3e7
child 723323 eb3b169a1ee471abb676737a0b25ea01f3460b07
push id96390
push userbmo:gkruglov@mozilla.com
push dateMon, 22 Jan 2018 21:58:41 +0000
reviewersnalexander
bugs1431456
milestone59.0a1
Bug 1431456 - Pre: junit4-ify weburlfinder tests, add a few extra test cases r=nalexander MozReview-Commit-ID: 6y4zlcvBolW
mobile/android/services/src/androidTest/java/org/mozilla/gecko/background/sync/TestWebURLFinder.java
mobile/android/services/src/test/java/org/mozilla/gecko/sync/setup/activities/WebURLFinderTest.java
deleted file mode 100644
--- a/mobile/android/services/src/androidTest/java/org/mozilla/gecko/background/sync/TestWebURLFinder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-package org.mozilla.gecko.background.sync;
-
-import java.util.Arrays;
-
-import org.mozilla.gecko.background.helpers.AndroidSyncTestCase;
-import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
-
-/**
- * These tests are on device because the WebKit APIs are stubs on desktop.
- */
-public class TestWebURLFinder extends AndroidSyncTestCase {
-  public String find(String string) {
-    return new WebURLFinder(string).bestWebURL();
-  }
-
-  public String find(String[] strings) {
-    return new WebURLFinder(Arrays.asList(strings)).bestWebURL();
-  }
-
-  public void testNoEmail() {
-    assertNull(find("test@test.com"));
-  }
-
-  public void testSchemeFirst() {
-    assertEquals("http://scheme.com", find("test.com http://scheme.com"));
-  }
-
-  public void testFullURL() {
-    assertEquals("http://scheme.com:8080/inner#anchor&arg=1", find("test.com http://scheme.com:8080/inner#anchor&arg=1"));
-  }
-
-  public void testNoScheme() {
-    assertEquals("noscheme.com", find("noscheme.com"));
-  }
-
-  public void testNoBadScheme() {
-    assertNull(find("file:///test javascript:///test.js"));
-  }
-
-  public void testStrings() {
-    assertEquals("http://test.com", find(new String[] { "http://test.com", "noscheme.com" }));
-    assertEquals("http://test.com", find(new String[] { "noschemefirst.com", "http://test.com" }));
-    assertEquals("http://test.com/inner#test", find(new String[] { "noschemefirst.com", "http://test.com/inner#test", "http://second.org/fark" }));
-    assertEquals("http://test.com", find(new String[] { "javascript:///test.js", "http://test.com" }));
-  }
-}
new file mode 100644
--- /dev/null
+++ b/mobile/android/services/src/test/java/org/mozilla/gecko/sync/setup/activities/WebURLFinderTest.java
@@ -0,0 +1,58 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+package org.mozilla.gecko.sync.setup.activities;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mozilla.gecko.background.testhelpers.TestRunner;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.*;
+
+@RunWith(TestRunner.class)
+public class WebURLFinderTest {
+    public String find(String string) {
+        return new WebURLFinder(string).bestWebURL();
+    }
+
+    public String find(String[] strings) {
+        return new WebURLFinder(Arrays.asList(strings)).bestWebURL();
+    }
+
+    public void testNoEmail() {
+        assertNull(find("test@test.com"));
+    }
+
+    @Test
+    public void testSchemeFirst() {
+        assertEquals("http://scheme.com", find("test.com http://scheme.com"));
+    }
+
+    @Test
+    public void testFullURL() {
+        assertEquals("http://scheme.com:8080/inner#anchor&arg=1", find("test.com http://scheme.com:8080/inner#anchor&arg=1"));
+        assertEquals("http://s-scheme.com:8080/inner#anchor&arg=1", find("test.com http://s-scheme.com:8080/inner#anchor&arg=1"));
+        assertEquals("http://t-example:8080/appversion-1.0.0/f/action.xhtml", find("test.com http://t-example:8080/appversion-1.0.0/f/action.xhtml"));
+        assertEquals("http://t-example:8080/appversion-1.0.0/f/action.xhtml", find("http://t-example:8080/appversion-1.0.0/f/action.xhtml"));
+    }
+
+    @Test
+    public void testNoScheme() {
+        assertEquals("noscheme.com", find("noscheme.com"));
+    }
+
+    @Test
+    public void testNoBadScheme() {
+        assertNull(find("file:///test javascript:///test.js"));
+    }
+
+    @Test
+    public void testStrings() {
+        assertEquals("http://test.com", find(new String[] { "http://test.com", "noscheme.com" }));
+        assertEquals("http://test.com", find(new String[] { "noschemefirst.com", "http://test.com" }));
+        assertEquals("http://test.com/inner#test", find(new String[] { "noschemefirst.com", "http://test.com/inner#test", "http://second.org/fark" }));
+        assertEquals("http://test.com", find(new String[] { "javascript:///test.js", "http://test.com" }));
+    }
+}
\ No newline at end of file