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

Unified Diff: test/GlobalJsObject.cpp

Issue 29500602: Issue 5450 - introduce the Platform class (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 28, 2017, 12:40 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/GlobalJsObject.cpp
diff --git a/test/GlobalJsObject.cpp b/test/GlobalJsObject.cpp
index 1ee9074cf2ba69a6a820be896e2920987220b345..575f76a2536cc87fcdda929864cdd404e5421e20 100644
--- a/test/GlobalJsObject.cpp
+++ b/test/GlobalJsObject.cpp
@@ -23,13 +23,15 @@ namespace
class GlobalJsObjectTest : public ::testing::Test
{
protected:
+ std::unique_ptr<AdblockPlus::Platform> platform;
AdblockPlus::JsEnginePtr jsEngine;
void SetUp() override
{
- JsEngineCreationParameters jsEngineParams;
- jsEngineParams.timer = AdblockPlus::CreateDefaultTimer();
- jsEngine = CreateJsEngine(std::move(jsEngineParams));
+ ThrowingPlatformCreationParameters params;
+ params.timer = AdblockPlus::CreateDefaultTimer();
+ platform.reset(new AdblockPlus::Platform(std::move(params)));
+ jsEngine = platform->GetJsEngine();
}
};
}
@@ -68,9 +70,11 @@ TEST_F(GlobalJsObjectTest, SetMultipleTimeouts)
TEST_F(GlobalJsObjectTest, TimeoutDoesNotKeepJsEngine)
{
jsEngine->Evaluate("setTimeout(function() {}, 50000)");
- EXPECT_EQ(1u, jsEngine.use_count()); // check that counter is still 1
+ // 1 reference is held by platform and yet one by the test fixture class.
+ EXPECT_EQ(2u, jsEngine.use_count());
AdblockPlus::Sleep(200);
std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine = jsEngine;
jsEngine.reset();
+ platform.reset();
EXPECT_FALSE(weakJsEngine.lock());
}
« include/AdblockPlus/JsEngine.h ('K') | « test/FilterEngine.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld