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

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

Issue 29344967: Issue 4031 - Implement tests for libadblockplus-android (Closed)
Patch Set: fix typo ".. file[s]" Created Sept. 15, 2016, 10:44 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/AppInfoJsObjectTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AppInfoJsObjectTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AppInfoJsObjectTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..96095dd0fea3b9fd41d9fb1976cc226de6a0048e
--- /dev/null
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AppInfoJsObjectTest.java
@@ -0,0 +1,64 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.libadblockplus.tests;
+
+import org.adblockplus.libadblockplus.AppInfo;
+import org.adblockplus.libadblockplus.JsEngine;
+
+import org.junit.Test;
+
+public class AppInfoJsObjectTest extends BaseJsTest
+{
+ @Test
+ public void testAllProperties()
+ {
+ AppInfo appInfo = AppInfo
+ .builder()
+ .setVersion("1")
+ .setName("3")
+ .setApplication("4")
+ .setApplicationVersion("5")
+ .setLocale("2")
+ .setDevelopmentBuild(true)
+ .build();
+
+ JsEngine jsEngine = new JsEngine(appInfo);
+ assertEquals("1", jsEngine.evaluate("_appInfo.version").asString());
+ assertEquals("3", jsEngine.evaluate("_appInfo.name").asString());
+ assertEquals("4", jsEngine.evaluate("_appInfo.application").asString());
+ assertEquals("5", jsEngine.evaluate("_appInfo.applicationVersion").asString());
+ assertEquals("2", jsEngine.evaluate("_appInfo.locale").asString());
+ assertTrue(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
+ }
+
+ @Test
+ public void testDefaultPropertyValues()
+ {
+ AppInfo appInfo = AppInfo
+ .builder()
+ .build();
+
+ JsEngine jsEngine = new JsEngine(appInfo);
+ assertEquals("0", jsEngine.evaluate("_appInfo.version").asString());
+ assertEquals("adblockplusandroid", jsEngine.evaluate("_appInfo.name").asString());
+ assertEquals("android", jsEngine.evaluate("_appInfo.application").asString());
+ assertEquals("0", jsEngine.evaluate("_appInfo.applicationVersion").asString());
+ assertEquals("en_US", jsEngine.evaluate("_appInfo.locale").asString());
+ assertFalse(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
+ }
+}

Powered by Google App Engine
This is Rietveld