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

Unified Diff: test/WebRequest.cpp

Issue 10260028: Refactor tests, use fixtures and avoid duplication (Closed)
Patch Set: Created April 19, 2013, 4:11 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/JsValue.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/WebRequest.cpp
===================================================================
--- a/test/WebRequest.cpp
+++ b/test/WebRequest.cpp
@@ -4,27 +4,32 @@
#include "../src/Thread.h"
-class TestWebRequest : public AdblockPlus::WebRequest
+// TODO: Use a fixture here
+
+namespace
{
-public:
- AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const
+ class TestWebRequest : public AdblockPlus::WebRequest
{
- AdblockPlus::Sleep(50);
+ public:
+ AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const
+ {
+ AdblockPlus::Sleep(50);
- AdblockPlus::ServerResponse result;
- result.status = NS_OK;
- result.responseStatus = 123;
- result.responseHeaders.push_back(std::pair<std::string, std::string>("Foo", "Bar"));
- result.responseText = url + "\n" + requestHeaders[0].first + "\n" + requestHeaders[0].second;
- return result;
+ AdblockPlus::ServerResponse result;
+ result.status = NS_OK;
+ result.responseStatus = 123;
+ result.responseHeaders.push_back(std::pair<std::string, std::string>("Foo", "Bar"));
+ result.responseText = url + "\n" + requestHeaders[0].first + "\n" + requestHeaders[0].second;
+ return result;
+ }
+ };
+
+ std::string ToString(unsigned int i)
+ {
+ std::stringstream stream;
+ stream << i;
+ return stream.str();
}
-};
-
-std::string ToString(unsigned int i)
-{
- std::stringstream stream;
- stream << i;
- return stream.str();
}
TEST(WebRequestTest, BadCall)
@@ -109,7 +114,6 @@
ASSERT_EQ("{}", jsEngine->Evaluate("JSON.stringify(foo.responseHeaders)")->AsString());
}
-#if !FILTER_ENGINE_STUBS
TEST(WebRequestTest, XMLHttpRequest)
{
AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
@@ -133,6 +137,5 @@
ASSERT_EQ("error", jsEngine->Evaluate("result")->AsString());
ASSERT_TRUE(jsEngine->Evaluate("request.getResponseHeader('Content-Type')")->IsNull());
}
-#endif
#endif
« no previous file with comments | « test/JsValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld