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: removed gradlew.bat - it relates to issue-4324 Created Sept. 16, 2016, 11:27 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..6d86d785f5eac445102156d24e7eb734dee91d01
--- /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.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