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

Unified Diff: test/BaseJsTest.h

Issue 10291009: Disable side-effects in filter engine tests (Closed)
Patch Set: Fixed the other TODO in tests Created April 26, 2013, 12:44 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 | « no previous file | test/FilterEngine.cpp » ('j') | test/WebRequest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/BaseJsTest.h
===================================================================
--- a/test/BaseJsTest.h
+++ b/test/BaseJsTest.h
@@ -1,13 +1,14 @@
#ifndef MOCKS_H
#define MOCKS_H
#include <AdblockPlus.h>
#include <gtest/gtest.h>
+#include "../src/Thread.h"
class ThrowingErrorCallback : public AdblockPlus::ErrorCallback
{
public:
void operator()(const std::string& message)
{
throw std::runtime_error("Unexpected error: " + message);
}
@@ -45,16 +46,63 @@ class ThrowingFileSystem : public Adbloc
class ThrowingWebRequest : public AdblockPlus::WebRequest
{
AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const
{
throw std::runtime_error("Unexpected GET: " + url);
}
};
+class LazyFileSystem : public AdblockPlus::FileSystem
+{
+ std::tr1::shared_ptr<std::istream> Read(const std::string& path) const
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ return std::tr1::shared_ptr<std::istream>();
+ }
+
+ void Write(const std::string& path,
+ std::tr1::shared_ptr<std::ostream> content)
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ }
+
+ void Move(const std::string& fromPath, const std::string& toPath)
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ }
+
+ void Remove(const std::string& path)
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ }
+
+ StatResult Stat(const std::string& path) const
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ return StatResult();
+ }
+};
+
+class LazyWebRequest : public AdblockPlus::WebRequest
+{
+ AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const
+ {
+ while (true)
+ AdblockPlus::Sleep(100000);
+ return AdblockPlus::ServerResponse();
+ }
+};
+
+
class BaseJsTest : public ::testing::Test
{
protected:
AdblockPlus::JsEnginePtr jsEngine;
virtual void SetUp()
{
jsEngine = AdblockPlus::JsEngine::New();
« no previous file with comments | « no previous file | test/FilterEngine.cpp » ('j') | test/WebRequest.cpp » ('J')

Powered by Google App Engine
This is Rietveld