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

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

Issue 29678581: Issue 6000 - Rename "libadblockplus-android" (Closed)
Patch Set: Created Jan. 24, 2018, 6:53 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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 package org.adblockplus.libadblockplus.tests;
19
20 import org.adblockplus.libadblockplus.LogSystem;
21 import org.adblockplus.libadblockplus.MockLogSystem;
22
23 import org.junit.Test;
24
25 public class ConsoleJsObjectTest extends BaseJsEngineTest
26 {
27 protected MockLogSystem mockLogSystem;
28
29 @Override
30 protected LogSystem createLogSystem()
31 {
32 return mockLogSystem = new MockLogSystem();
33 }
34
35 @Test
36 public void testConsoleLogCall()
37 {
38 jsEngine.evaluate("\n\nconsole.log('foo', 'bar');\n\n", "eval");
39 assertEquals(LogSystem.LogLevel.LOG, mockLogSystem.getLastLogLevel());
40 assertEquals("foo bar", mockLogSystem.getLastMessage());
41 assertEquals("eval:3", mockLogSystem.getLastSource());
42 }
43
44 @Test
45 public void testConsoleDebugCall()
46 {
47 jsEngine.evaluate("console.debug('foo', 'bar')");
48 assertEquals(LogSystem.LogLevel.LOG, mockLogSystem.getLastLogLevel());
49 assertEquals("foo bar", mockLogSystem.getLastMessage());
50 assertEquals(":1", mockLogSystem.getLastSource());
51 }
52
53 @Test
54 public void testConsoleInfoCall()
55 {
56 jsEngine.evaluate("console.info('foo', 'bar')");
57 assertEquals(LogSystem.LogLevel.INFO, mockLogSystem.getLastLogLevel());
58 assertEquals("foo bar", mockLogSystem.getLastMessage());
59 assertEquals(":1", mockLogSystem.getLastSource());
60 }
61
62 @Test
63 public void testConsoleWarnCall()
64 {
65 jsEngine.evaluate("console.warn('foo', 'bar')");
66 assertEquals(LogSystem.LogLevel.WARN, mockLogSystem.getLastLogLevel());
67 assertEquals("foo bar", mockLogSystem.getLastMessage());
68 assertEquals(":1", mockLogSystem.getLastSource());
69 }
70
71 @Test
72 public void testConsoleErrorCall()
73 {
74 jsEngine.evaluate("console.error('foo', 'bar')");
75 assertEquals(LogSystem.LogLevel.ERROR, mockLogSystem.getLastLogLevel());
76 assertEquals("foo bar", mockLogSystem.getLastMessage());
77 assertEquals(":1", mockLogSystem.getLastSource());
78 }
79
80 @Test
81 public void testConsoleTraceCall()
82 {
83 jsEngine.evaluate(
84 "\n" +
85 "function foo()\n" +
86 "{\n" +
87 " (function() {\n" +
88 " console.trace();\n" +
89 " })();\n" +
90 "}\n" +
91 "foo();", "eval");
92 assertEquals(LogSystem.LogLevel.TRACE, mockLogSystem.getLastLogLevel());
93 assertEquals(
94 "1: /* anonymous */() at eval:5\n" +
95 "2: foo() at eval:6\n" +
96 "3: /* anonymous */() at eval:8\n", mockLogSystem.getLastMessage());
97 assertEquals("", mockLogSystem.getLastSource());
98 }
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld