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

Unified Diff: test/WebRequest.cpp

Issue 29428650: Issue 5180 - introduce asynchronous web request (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created May 3, 2017, 2:21 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/UpdateCheck.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
diff --git a/test/WebRequest.cpp b/test/WebRequest.cpp
index 8ee5806beab6db5b6896ce99a2260b89d274668f..9e9b0b790284f9c6a757ae7a424dcc46ba6d0106 100644
--- a/test/WebRequest.cpp
+++ b/test/WebRequest.cpp
@@ -44,7 +44,7 @@ namespace
AdblockPlus::Sleep(50);
AdblockPlus::ServerResponse result;
- result.status = NS_OK;
+ result.status = IWebRequest::NS_OK;
result.responseStatus = 123;
result.responseHeaders.push_back(std::pair<std::string, std::string>("Foo", "Bar"));
result.responseText = url + "\n";
@@ -92,7 +92,7 @@ namespace
};
typedef WebRequestTest<MockWebRequest> MockWebRequestTest;
- typedef WebRequestTest<AdblockPlus::DefaultWebRequest> DefaultWebRequestTest;
+ typedef WebRequestTest<AdblockPlus::DefaultWebRequestSync> DefaultWebRequestTest;
typedef WebRequestTest<MockWebRequest> XMLHttpRequestTest;
// we return the url of the XHR.
@@ -142,7 +142,7 @@ TEST_F(MockWebRequestTest, SuccessfulRequest)
jsEngine->Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function(result) {foo = result;} )");
ASSERT_TRUE(jsEngine->Evaluate("this.foo").IsUndefined());
AdblockPlus::Sleep(200);
- ASSERT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status").AsInt());
+ ASSERT_EQ(IWebRequest::NS_OK, jsEngine->Evaluate("foo.status").AsInt());
ASSERT_EQ(123, jsEngine->Evaluate("foo.responseStatus").AsInt());
ASSERT_EQ("http://example.com/\nX\nY", jsEngine->Evaluate("foo.responseText").AsString());
ASSERT_EQ("{\"Foo\":\"Bar\"}", jsEngine->Evaluate("JSON.stringify(foo.responseHeaders)").AsString());
@@ -156,7 +156,7 @@ TEST_F(DefaultWebRequestTest, RealWebRequest)
jsEngine->Evaluate("_webRequest.GET('https://easylist-downloads.adblockplus.org/easylist.txt', {}, function(result) {foo = result;} )");
WaitForVariable("this.foo", jsEngine);
ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'].substr(0, 10)").AsString());
- ASSERT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status").AsInt());
+ ASSERT_EQ(IWebRequest::NS_OK, jsEngine->Evaluate("foo.status").AsInt());
ASSERT_EQ(200, jsEngine->Evaluate("foo.responseStatus").AsInt());
ASSERT_EQ("[Adblock Plus ", jsEngine->Evaluate("foo.responseText.substr(0, 14)").AsString());
ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'].substr(0, 10)").AsString());
@@ -176,7 +176,7 @@ TEST_F(DefaultWebRequestTest, XMLHttpRequest)
request.setRequestHeader('X2', 'Y2');\
request.send(null);");
WaitForVariable("result", jsEngine);
- ASSERT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("request.channel.status").AsInt());
+ ASSERT_EQ(IWebRequest::NS_OK, jsEngine->Evaluate("request.channel.status").AsInt());
ASSERT_EQ(200, jsEngine->Evaluate("request.status").AsInt());
ASSERT_EQ("[Adblock Plus ", jsEngine->Evaluate("result.substr(0, 14)").AsString());
ASSERT_EQ("text/plain", jsEngine->Evaluate("request.getResponseHeader('Content-Type').substr(0, 10)").AsString());
@@ -190,7 +190,7 @@ TEST_F(DefaultWebRequestTest, DummyWebRequest)
{
jsEngine->Evaluate("_webRequest.GET('https://easylist-downloads.adblockplus.org/easylist.txt', {}, function(result) {foo = result;} )");
WaitForVariable("this.foo", jsEngine);
- ASSERT_EQ(AdblockPlus::WebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("foo.status").AsInt());
+ ASSERT_EQ(IWebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("foo.status").AsInt());
ASSERT_EQ(0, jsEngine->Evaluate("foo.responseStatus").AsInt());
ASSERT_EQ("", jsEngine->Evaluate("foo.responseText").AsString());
ASSERT_EQ("{}", jsEngine->Evaluate("JSON.stringify(foo.responseHeaders)").AsString());
@@ -205,7 +205,7 @@ TEST_F(DefaultWebRequestTest, XMLHttpRequest)
request.setRequestHeader('X', 'Y');\
request.send(null);");
WaitForVariable("result", jsEngine);
- ASSERT_EQ(AdblockPlus::WebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("request.channel.status").AsInt());
+ ASSERT_EQ(IWebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("request.channel.status").AsInt());
ASSERT_EQ(0, jsEngine->Evaluate("request.status").AsInt());
ASSERT_EQ("error", jsEngine->Evaluate("result").AsString());
ASSERT_TRUE(jsEngine->Evaluate("request.getResponseHeader('Content-Type')").IsNull());
« no previous file with comments | « test/UpdateCheck.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld