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

Side by Side Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/GlobalJsObjectTest.java

Issue 29348972: Issue 4239 - Change indentation to reflect our coding style (Closed)
Patch Set: Created Aug. 2, 2016, 10:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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.AdblockPlusException; 20 import org.adblockplus.libadblockplus.AdblockPlusException;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 23
24 public class GlobalJsObjectTest extends BaseJsTest 24 public class GlobalJsObjectTest extends BaseJsTest
25 { 25 {
26 @Test 26 @Test
27 public void testSetTimeout() throws InterruptedException 27 public void testSetTimeout() throws InterruptedException
28 {
29 jsEngine.evaluate("setTimeout(function() {foo = 'bar';}, 100)");
30 assertTrue(jsEngine.evaluate("this.foo").isUndefined());
31 Thread.sleep(200);
32 assertEquals("bar", jsEngine.evaluate("this.foo").asString());
33 }
34
35 @Test
36 public void testSetTimeoutWithArgs() throws InterruptedException
37 {
38 jsEngine.evaluate("setTimeout(function(s) {foo = s;}, 100, 'foobar')");
39 assertTrue(jsEngine.evaluate("this.foo").isUndefined());
40 Thread.sleep(200);
41 assertEquals("foobar", jsEngine.evaluate("this.foo").asString());
42 }
43
44 @Test
45 public void testSetTimeoutWithInvalidArgs()
46 {
47 try
28 { 48 {
29 jsEngine.evaluate("setTimeout(function() {foo = 'bar';}, 100)"); 49 jsEngine.evaluate("setTimeout()");
30 assertTrue(jsEngine.evaluate("this.foo").isUndefined()); 50 fail();
31 Thread.sleep(200); 51 } catch (AdblockPlusException e)
32 assertEquals("bar", jsEngine.evaluate("this.foo").asString()); 52 {
53 // ignored
33 } 54 }
34 55
35 @Test 56 try
36 public void testSetTimeoutWithArgs() throws InterruptedException
37 { 57 {
38 jsEngine.evaluate("setTimeout(function(s) {foo = s;}, 100, 'foobar')"); 58 jsEngine.evaluate("setTimeout('', 1)");
39 assertTrue(jsEngine.evaluate("this.foo").isUndefined()); 59 fail();
40 Thread.sleep(200); 60 } catch (AdblockPlusException e)
41 assertEquals("foobar", jsEngine.evaluate("this.foo").asString()); 61 {
62 // ignored
42 } 63 }
64 }
43 65
44 @Test 66 @Test
45 public void testSetTimeoutWithInvalidArgs() 67 public void testSetMultipleTimeouts() throws InterruptedException
46 { 68 {
47 try 69 jsEngine.evaluate("foo = []");
48 { 70 jsEngine.evaluate("setTimeout(function(s) {foo.push('1');}, 100)");
49 jsEngine.evaluate("setTimeout()"); 71 jsEngine.evaluate("setTimeout(function(s) {foo.push('2');}, 150)");
50 fail(); 72 Thread.sleep(200);
51 } catch (AdblockPlusException e) 73 assertEquals("1,2", jsEngine.evaluate("this.foo").asString());
52 { 74 }
53 // ignored
54 }
55
56 try
57 {
58 jsEngine.evaluate("setTimeout('', 1)");
59 fail();
60 } catch (AdblockPlusException e)
61 {
62 // ignored
63 }
64 }
65
66 @Test
67 public void testSetMultipleTimeouts() throws InterruptedException
68 {
69 jsEngine.evaluate("foo = []");
70 jsEngine.evaluate("setTimeout(function(s) {foo.push('1');}, 100)");
71 jsEngine.evaluate("setTimeout(function(s) {foo.push('2');}, 150)");
72 Thread.sleep(200);
73 assertEquals("1,2", jsEngine.evaluate("this.foo").asString());
74 }
75 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld