Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java

Issue 29411633: Issue 5136 - Add test for AndroidWebRequestResourceWrapper (Closed)
Patch Set: added "static final" for the test impls Created April 28, 2017, 6:09 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java
index a9dfd4cb57724fd7e345290a834d7e69b16dbe46..88aad760e1e03b2b5187ada99d7831c9fae8475c 100644
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java
@@ -52,4 +52,75 @@ public class UtilsTest extends BaseJsTest
String json = Utils.stringListToJsonArray(list);
assertEquals("[]", json);
}
+
+ @Test
+ public void testUrlWithoutParams_null()
+ {
+ try
+ {
+ Utils.getUrlWithoutParams(null);
+ fail();
+ }
+ catch (IllegalArgumentException ignored)
+ {
+ // ignored
+ }
+ }
+
+ @Test
+ public void testUrlWithoutParams_empty()
+ {
+ String url = Utils.getUrlWithoutParams("https://www.google.com?");
+ assertNotNull(url);
+ assertEquals("https://www.google.com", url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_withoutParams()
+ {
+ final String originalUrl = "http://www.google.com";
+ String url = Utils.getUrlWithoutParams(originalUrl);
+ assertNotNull(url);
+ assertEquals(originalUrl, url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_ok()
+ {
+ String url = Utils.getUrlWithoutParams("https://www.google.com?q=adblockplus");
+ assertNotNull(url);
+ assertEquals("https://www.google.com", url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_multipleParams()
+ {
+ String url = Utils.getUrlWithoutParams("https://www.google.com?q=adblockplus&gws_rd=cr");
+ assertNotNull(url);
+ assertEquals("https://www.google.com", url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_language()
+ {
+ String url = Utils.getUrlWithoutParams("http://почта.рф?q=myemail"); // non-English characters in URL
+ assertNotNull(url);
+ assertEquals("http://почта.рф", url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_digits()
+ {
+ String url = Utils.getUrlWithoutParams("https://www.google.com?q=123");
+ assertNotNull(url);
+ assertEquals("https://www.google.com", url);
+ }
+
+ @Test
+ public void testUrlWithoutParams_multipleQuestionMarks()
+ {
+ String url = Utils.getUrlWithoutParams("https://www.google.com?q=123?t=123"); // invalid URL
+ assertNotNull(url);
+ assertEquals("https://www.google.com", url);
+ }
}

Powered by Google App Engine
This is Rietveld