Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 package org.mozilla.gecko.background.sync;
6 import java.util.Arrays;
8 import org.mozilla.gecko.background.helpers.AndroidSyncTestCase;
9 import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
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 }
19 public String find(String[] strings) {
20 return new WebURLFinder(Arrays.asList(strings)).bestWebURL();
21 }
23 public void testNoEmail() {
24 assertNull(find("test@test.com"));
25 }
27 public void testSchemeFirst() {
28 assertEquals("http://scheme.com", find("test.com http://scheme.com"));
29 }
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 }
35 public void testNoScheme() {
36 assertEquals("noscheme.com", find("noscheme.com"));
37 }
39 public void testNoBadScheme() {
40 assertNull(find("file:///test javascript:///test.js"));
41 }
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 }