LEFT | RIGHT |
(no file at all) | |
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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 typedef std::shared_ptr<MockLogSystem> MockLogSystemPtr; | 38 typedef std::shared_ptr<MockLogSystem> MockLogSystemPtr; |
39 | 39 |
40 class ConsoleJsObjectTest : public BaseJsTest | 40 class ConsoleJsObjectTest : public BaseJsTest |
41 { | 41 { |
42 protected: | 42 protected: |
43 MockLogSystemPtr mockLogSystem; | 43 MockLogSystemPtr mockLogSystem; |
44 | 44 |
45 void SetUp() | 45 void SetUp() |
46 { | 46 { |
47 BaseJsTest::SetUp(); | 47 BaseJsTest::SetUp(); |
48 mockLogSystem = MockLogSystemPtr(new MockLogSystem); | 48 mockLogSystem = std::make_shared<MockLogSystem>(); |
49 jsEngine->SetLogSystem(mockLogSystem); | 49 jsEngine->SetLogSystem(mockLogSystem); |
| 50 } |
| 51 |
| 52 void TearDown() |
| 53 { |
| 54 mockLogSystem.reset(); |
| 55 BaseJsTest::TearDown(); |
50 } | 56 } |
51 }; | 57 }; |
52 } | 58 } |
53 | 59 |
54 TEST_F(ConsoleJsObjectTest, ConsoleLogCall) | 60 TEST_F(ConsoleJsObjectTest, ConsoleLogCall) |
55 { | 61 { |
56 jsEngine->Evaluate("\n\nconsole.log('foo', 'bar');\n\n", "eval"); | 62 jsEngine->Evaluate("\n\nconsole.log('foo', 'bar');\n\n", "eval"); |
57 ASSERT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_LOG, mockLogSystem->lastLogLevel); | 63 ASSERT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_LOG, mockLogSystem->lastLogLevel); |
58 ASSERT_EQ("foo bar", mockLogSystem->lastMessage); | 64 ASSERT_EQ("foo bar", mockLogSystem->lastMessage); |
59 ASSERT_EQ("eval:3", mockLogSystem->lastSource); | 65 ASSERT_EQ("eval:3", mockLogSystem->lastSource); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 })();\n\ | 107 })();\n\ |
102 }\n\ | 108 }\n\ |
103 foo();", "eval"); | 109 foo();", "eval"); |
104 ASSERT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, mockLogSystem->lastLogLevel
); | 110 ASSERT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, mockLogSystem->lastLogLevel
); |
105 ASSERT_EQ("\ | 111 ASSERT_EQ("\ |
106 1: /* anonymous */() at eval:5\n\ | 112 1: /* anonymous */() at eval:5\n\ |
107 2: foo() at eval:6\n\ | 113 2: foo() at eval:6\n\ |
108 3: /* anonymous */() at eval:8\n", mockLogSystem->lastMessage); | 114 3: /* anonymous */() at eval:8\n", mockLogSystem->lastMessage); |
109 ASSERT_EQ("", mockLogSystem->lastSource); | 115 ASSERT_EQ("", mockLogSystem->lastSource); |
110 } | 116 } |
LEFT | RIGHT |