Source code
Revision control
Copy as Markdown
Other Tools
/* Any copyright is dedicated to the Public Domain.
package org.mozilla.gecko.util;
import static org.junit.Assert.*;
import android.net.Uri;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
@SmallTest
public class IntentUtilsTest {
@Test
public void shouldNormalizeUri() {
final Uri normUri = IntentUtils.normalizeUri(uri);
}
@Test
public void safeHttpUri() {
assertTrue(IntentUtils.isUriSafeForScheme(uri));
}
@Test
public void safeIntentUri() {
assertTrue(IntentUtils.isUriSafeForScheme(uri));
}
@Test
public void unsafeIntentUri() {
assertFalse(IntentUtils.isUriSafeForScheme(uri));
}
@Test
public void safeTelUri() {
final String uri = "tel:12345678";
assertTrue(IntentUtils.isUriSafeForScheme(uri));
}
@Test
public void unsafeTelUri() {
final String uri = "tel:#12345678";
assertFalse(IntentUtils.isUriSafeForScheme(uri));
}
@Test
public void unsafeHtmlEncodedTelUri() {
assertFalse(IntentUtils.isUriSafeForScheme("tel:*%2306%23"));
assertFalse(IntentUtils.isUriSafeForScheme("tel:%2A%2306%23"));
}
@Test
public void intentDataWithoutScheme() {
final String uri = "intent:non_scheme_intent#Intent;end";
assertTrue(IntentUtils.isUriSafeForScheme(uri));
}
}