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

Delta Between Two Patch Sets: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AppInfoJsObjectTest.java

Issue 29344967: Issue 4031 - Implement tests for libadblockplus-android (Closed)
Left Patch Set: Created May 27, 2016, 1:38 p.m.
Right Patch Set: fix typo ".. file[s]" Created Sept. 15, 2016, 10:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.libadblockplus.tests; 18 package org.adblockplus.libadblockplus.tests;
19 19
20 import org.adblockplus.libadblockplus.AppInfo; 20 import org.adblockplus.libadblockplus.AppInfo;
21 import org.adblockplus.libadblockplus.JsEngine; 21 import org.adblockplus.libadblockplus.JsEngine;
22 22
23 import org.junit.Test; 23 import org.junit.Test;
24 24
25 public class AppInfoJsObjectTest extends BaseJsTest { 25 public class AppInfoJsObjectTest extends BaseJsTest
26 {
27 @Test
28 public void testAllProperties()
29 {
30 AppInfo appInfo = AppInfo
31 .builder()
32 .setVersion("1")
33 .setName("3")
34 .setApplication("4")
35 .setApplicationVersion("5")
36 .setLocale("2")
37 .setDevelopmentBuild(true)
38 .build();
26 39
27 @Test 40 JsEngine jsEngine = new JsEngine(appInfo);
28 public void testAllProperties() { 41 assertEquals("1", jsEngine.evaluate("_appInfo.version").asString());
29 AppInfo appInfo = AppInfo 42 assertEquals("3", jsEngine.evaluate("_appInfo.name").asString());
30 .builder() 43 assertEquals("4", jsEngine.evaluate("_appInfo.application").asString());
31 .setVersion("1") 44 assertEquals("5", jsEngine.evaluate("_appInfo.applicationVersion").asString( ));
32 .setName("3") 45 assertEquals("2", jsEngine.evaluate("_appInfo.locale").asString());
33 .setApplication("4") 46 assertTrue(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
34 .setApplicationVersion("5") 47 }
35 .setLocale("2")
36 .setDevelopmentBuild(true)
37 .build();
38 48
39 JsEngine jsEngine = new JsEngine(appInfo); 49 @Test
40 assertEquals("1", jsEngine.evaluate("_appInfo.version").asString()); 50 public void testDefaultPropertyValues()
41 assertEquals("3", jsEngine.evaluate("_appInfo.name").asString()); 51 {
42 assertEquals("4", jsEngine.evaluate("_appInfo.application").asString()); 52 AppInfo appInfo = AppInfo
43 assertEquals("5", jsEngine.evaluate("_appInfo.applicationVersion").asStr ing()); 53 .builder()
44 assertEquals("2", jsEngine.evaluate("_appInfo.locale").asString()); 54 .build();
45 assertTrue(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
46 }
47 55
48 @Test 56 JsEngine jsEngine = new JsEngine(appInfo);
49 public void testDefaultPropertyValues() { 57 assertEquals("0", jsEngine.evaluate("_appInfo.version").asString());
50 AppInfo appInfo = AppInfo 58 assertEquals("adblockplusandroid", jsEngine.evaluate("_appInfo.name").asStri ng());
51 .builder() 59 assertEquals("android", jsEngine.evaluate("_appInfo.application").asString() );
52 .build(); 60 assertEquals("0", jsEngine.evaluate("_appInfo.applicationVersion").asString( ));
53 61 assertEquals("en_US", jsEngine.evaluate("_appInfo.locale").asString());
54 JsEngine jsEngine = new JsEngine(appInfo); 62 assertFalse(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
55 assertEquals("0", jsEngine.evaluate("_appInfo.version").asString()); 63 }
56 assertEquals("adblockplusandroid", jsEngine.evaluate("_appInfo.name").as String());
57 assertEquals("android", jsEngine.evaluate("_appInfo.application").asStri ng());
58 assertEquals("0", jsEngine.evaluate("_appInfo.applicationVersion").asStr ing());
59 assertEquals("en_US", jsEngine.evaluate("_appInfo.locale").asString());
60 assertFalse(jsEngine.evaluate("_appInfo.developmentBuild").asBoolean());
61 }
62 } 64 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld