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

Side by Side Diff: test/JsEngine.cpp

Issue 29442722: Issue 3593 - stop sharing v8::Isolate among tests (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: address comments and rebase Created May 24, 2017, 4:20 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/BaseJsTest.cpp ('k') | no next file » | 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 TEST(NewJsEngineTest, GlobalPropertyTest) 182 TEST(NewJsEngineTest, GlobalPropertyTest)
183 { 183 {
184 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); 184 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
185 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); 185 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar"));
186 auto foo = jsEngine->Evaluate("foo"); 186 auto foo = jsEngine->Evaluate("foo");
187 ASSERT_TRUE(foo.IsString()); 187 ASSERT_TRUE(foo.IsString());
188 ASSERT_EQ(foo.AsString(), "bar"); 188 ASSERT_EQ(foo.AsString(), "bar");
189 } 189 }
190 190
191 TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences)
192 {
193 std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine;
194 {
195 weakJsEngine = AdblockPlus::JsEngine::New();
196 }
197 EXPECT_FALSE(weakJsEngine.lock());
198 }
199
200 #if UINTPTR_MAX == UINT32_MAX // detection of 32-bit platform
sergei 2017/05/24 16:22:32 Although it might seem hacky, on practice it turne
hub 2017/05/24 16:31:40 We could do something like #if UINTPTR_MAX == UI
sergei 2017/05/24 17:05:51 Since in this case it will still run, so not disab
hub 2017/05/24 18:18:07 According to this, the test will be disabled (buil
sergei 2017/05/26 10:56:43 That's a cool feature of gtest I was not aware of.
201 TEST(NewJsEngineTest, MemoryLeak_NoLeak)
202 {
203 static_assert(sizeof(intptr_t) == 4, "It should be 32bit platform");
204 // v8::Isolate by default requires 32MB (depends on platform), so if there is
205 // a memory leak than we will run out of memory on 32 bit platform because it
206 // will allocate 32000 MB which is less than 2GB where it reaches out of
207 // memory. Even on android where it allocates initially 16MB, the test still
208 // makes sense.
209 for (int i = 0; i < 1000; ++i)
210 {
211 AdblockPlus::JsEngine::New();
212 }
213 }
214 #endif
OLDNEW
« no previous file with comments | « test/BaseJsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld