mobile/android/tests/background/junit3/src/sync/TestWebURLFinder.java

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:87f215eb64f7
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 package org.mozilla.gecko.background.sync;
5
6 import java.util.Arrays;
7
8 import org.mozilla.gecko.background.helpers.AndroidSyncTestCase;
9 import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
10
11 /**
12 * These tests are on device because the WebKit APIs are stubs on desktop.
13 */
14 public class TestWebURLFinder extends AndroidSyncTestCase {
15 public String find(String string) {
16 return new WebURLFinder(string).bestWebURL();
17 }
18
19 public String find(String[] strings) {
20 return new WebURLFinder(Arrays.asList(strings)).bestWebURL();
21 }
22
23 public void testNoEmail() {
24 assertNull(find("test@test.com"));
25 }
26
27 public void testSchemeFirst() {
28 assertEquals("http://scheme.com", find("test.com http://scheme.com"));
29 }
30
31 public void testFullURL() {
32 assertEquals("http://scheme.com:8080/inner#anchor&arg=1", find("test.com http://scheme.com:8080/inner#anchor&arg=1"));
33 }
34
35 public void testNoScheme() {
36 assertEquals("noscheme.com", find("noscheme.com"));
37 }
38
39 public void testNoBadScheme() {
40 assertNull(find("file:///test javascript:///test.js"));
41 }
42
43 public void testStrings() {
44 assertEquals("http://test.com", find(new String[] { "http://test.com", "noscheme.com" }));
45 assertEquals("http://test.com", find(new String[] { "noschemefirst.com", "http://test.com" }));
46 assertEquals("http://test.com/inner#test", find(new String[] { "noschemefirst.com", "http://test.com/inner#test", "http://second.org/fark" }));
47 assertEquals("http://test.com", find(new String[] { "javascript:///test.js", "http://test.com" }));
48 }
49 }

mercurial