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); |
+ } |
} |