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

Side by Side Diff: test/JsEngine.cpp

Issue 29498576: Issue 4832 - remove API allowing changing of LogSystem after Initialization of JsEngine (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: address comment Created July 26, 2017, 4:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/ConsoleJsObject.cpp ('k') | test/WebRequest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 jsEngine->Evaluate("_triggerEvent('barfoo')"); 155 jsEngine->Evaluate("_triggerEvent('barfoo')");
156 ASSERT_FALSE(callbackCalled); 156 ASSERT_FALSE(callbackCalled);
157 157
158 // Remove callback 158 // Remove callback
159 jsEngine->RemoveEventCallback("foobar"); 159 jsEngine->RemoveEventCallback("foobar");
160 callbackCalled = false; 160 callbackCalled = false;
161 jsEngine->Evaluate("_triggerEvent('foobar')"); 161 jsEngine->Evaluate("_triggerEvent('foobar')");
162 ASSERT_FALSE(callbackCalled); 162 ASSERT_FALSE(callbackCalled);
163 } 163 }
164 164
165 TEST(NewJsEngineTest, CallbackGetSet)
166 {
167 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
168
169 ASSERT_TRUE(jsEngine->GetLogSystem());
170 ASSERT_ANY_THROW(jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr()));
171 AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem());
172 jsEngine->SetLogSystem(logSystem);
173 ASSERT_EQ(logSystem, jsEngine->GetLogSystem());
174 }
175
176 TEST(NewJsEngineTest, GlobalPropertyTest) 165 TEST(NewJsEngineTest, GlobalPropertyTest)
177 { 166 {
178 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); 167 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
179 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); 168 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar"));
180 auto foo = jsEngine->Evaluate("foo"); 169 auto foo = jsEngine->Evaluate("foo");
181 ASSERT_TRUE(foo.IsString()); 170 ASSERT_TRUE(foo.IsString());
182 ASSERT_EQ(foo.AsString(), "bar"); 171 ASSERT_EQ(foo.AsString(), "bar");
183 } 172 }
184 173
185 TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences) 174 TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences)
(...skipping 15 matching lines...) Expand all
201 // v8::Isolate by default requires 32MB (depends on platform), so if there is 190 // v8::Isolate by default requires 32MB (depends on platform), so if there is
202 // a memory leak than we will run out of memory on 32 bit platform because it 191 // a memory leak than we will run out of memory on 32 bit platform because it
203 // will allocate 32000 MB which is less than 2GB where it reaches out of 192 // will allocate 32000 MB which is less than 2GB where it reaches out of
204 // memory. Even on android where it allocates initially 16MB, the test still 193 // memory. Even on android where it allocates initially 16MB, the test still
205 // makes sense. 194 // makes sense.
206 for (int i = 0; i < 1000; ++i) 195 for (int i = 0; i < 1000; ++i)
207 { 196 {
208 AdblockPlus::JsEngine::New(); 197 AdblockPlus::JsEngine::New();
209 } 198 }
210 } 199 }
OLDNEW
« no previous file with comments | « test/ConsoleJsObject.cpp ('k') | test/WebRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld