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

Unified Diff: test/UpdateCheck.cpp

Issue 29370977: Issue #3593 - Stop sharing a single isolate amongst all unit tests
Patch Set: Created Jan. 10, 2017, 6:52 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
« no previous file with comments | « test/Prefs.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/UpdateCheck.cpp
===================================================================
--- a/test/UpdateCheck.cpp
+++ b/test/UpdateCheck.cpp
@@ -18,6 +18,7 @@
#include <functional>
#include "BaseJsTest.h"
+#include "../src/JsEngineTransition.h"
namespace
{
@@ -46,10 +47,30 @@
class UpdateCheckTest : public ::testing::Test
{
+ void Construct()
+ {
+ jsEngine = CreateJsEngine(appInfo);
+ jsEngine->SetLogSystem(std::make_shared<LazyLogSystem>());
+ jsEngine->SetFileSystem(std::make_shared<LazyFileSystem>());
+ jsEngine->SetWebRequest(webRequest);
+ jsEngine->SetEventCallback("updateAvailable",
+ std::bind(&UpdateCheckTest::EventCallback, this, std::placeholders::_1));
+
+ filterEngine = std::make_shared<AdblockPlus::FilterEngine>(jsEngine);
+ }
+
+ void Destroy()
+ {
+ webRequest->Cancel();
+ filterEngine.reset();
+ ToInternal(jsEngine)->WaitForQuietScheduler();
+ jsEngine.reset();
+ ASSERT_EQ(0, jsEngine.use_count());
+ }
+
protected:
AdblockPlus::AppInfo appInfo;
- TestWebRequest* webRequest;
- AdblockPlus::WebRequestPtr webRequestPtr;
+ std::shared_ptr<TestWebRequest> webRequest;
AdblockPlus::JsEnginePtr jsEngine;
FilterEnginePtr filterEngine;
@@ -60,29 +81,22 @@
void SetUp()
{
- webRequest = new TestWebRequest();
- webRequestPtr.reset(webRequest);
-
+ webRequest = std::make_shared<TestWebRequest>();
eventCallbackCalled = false;
updateCallbackCalled = false;
- Reset();
+ Construct();
}
void TearDown()
{
- webRequest->Cancel();
+ Destroy();
+ webRequest.reset();
}
void Reset()
{
- jsEngine = CreateJsEngine(appInfo);
- jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem));
- jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem));
- jsEngine->SetWebRequest(webRequestPtr);
- jsEngine->SetEventCallback("updateAvailable",
- std::bind(&UpdateCheckTest::EventCallback, this, std::placeholders::_1));
-
- filterEngine.reset(new AdblockPlus::FilterEngine(jsEngine));
+ Destroy();
+ Construct();
}
void ForceUpdateCheck()
« no previous file with comments | « test/Prefs.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld