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

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

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 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
new file mode 100644
index 0000000000000000000000000000000000000000..a9dfd4cb57724fd7e345290a834d7e69b16dbe46
--- /dev/null
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UtilsTest.java
@@ -0,0 +1,55 @@
+package org.adblockplus.libadblockplus.tests;
+
+import org.adblockplus.libadblockplus.android.Utils;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Test for Utils
+ */
+public class UtilsTest extends BaseJsTest
+{
+ @Test
+ public void testJson_null()
+ {
+ final List<String> list = null;
+ String json = Utils.stringListToJsonArray(list);
+ assertEquals("[]", json);
+ }
+
+ @Test
+ public void testJson_single()
+ {
+ final List<String> list = Arrays.asList("string1");
+ String json = Utils.stringListToJsonArray(list);
+ assertEquals("[\"string1\"]", json);
+ }
+
+ @Test
+ public void testJson_multiple()
+ {
+ final List<String> list = Arrays.asList("string1", "string2");
+ String json = Utils.stringListToJsonArray(list);
+ assertEquals("[\"string1\",\"string2\"]", json);
+ }
+
+ @Test
+ public void testJson_multipleWithNull()
+ {
+ final List<String> list = Arrays.asList("string1", null, "string2");
+ String json = Utils.stringListToJsonArray(list);
+ assertEquals("[\"string1\",\"string2\"]", json);
+ }
+
+ @Test
+ public void testJson_singleWithNull()
+ {
+ final List<String> list = new LinkedList<String>();
+ list.add(null);
+ String json = Utils.stringListToJsonArray(list);
+ assertEquals("[]", json);
+ }
+}

Powered by Google App Engine
This is Rietveld