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

Unified Diff: test/FilterEngine.cpp

Issue 29442622: Noissue - move (UpdaterTest, SetRemoveUpdateAvailableCallback) to UpdateCheck.cpp (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created May 19, 2017, 4:48 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/UpdateCheck.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
diff --git a/test/FilterEngine.cpp b/test/FilterEngine.cpp
index 28004417bf313874d490de731c3df7229eb68594..98283be7cfd39bd2b5797593346202915978c036 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -69,37 +69,6 @@ namespace
typedef FilterEngineTestGeneric<LazyFileSystem, AdblockPlus::DefaultLogSystem> FilterEngineTest;
typedef FilterEngineTestGeneric<VeryLazyFileSystem, LazyLogSystem> FilterEngineTestNoData;
- class UpdaterTest : public ::testing::Test
- {
- protected:
- class MockWebRequest : public AdblockPlus::WebRequest
- {
- public:
- AdblockPlus::ServerResponse response;
-
- AdblockPlus::ServerResponse GET(const std::string& url,
- const AdblockPlus::HeaderList& requestHeaders) const
- {
- return response;
- }
- };
-
- std::shared_ptr<MockWebRequest> mockWebRequest;
- FilterEnginePtr filterEngine;
-
- void SetUp()
- {
- JsEngineCreationParameters jsEngineParams;
- jsEngineParams.appInfo.name = "test";
- jsEngineParams.appInfo.version = "1.0.1";
- jsEngineParams.timer = CreateDefaultTimer();
- jsEngineParams.fileSystem.reset(new LazyFileSystem());
- AdblockPlus::JsEnginePtr jsEngine = CreateJsEngine(std::move(jsEngineParams));
- jsEngine->SetWebRequest(mockWebRequest = std::make_shared<MockWebRequest>());
- filterEngine = AdblockPlus::FilterEngine::Create(jsEngine);
- }
- };
-
class FilterEngineWithFreshFolder : public ::testing::Test
{
protected:
@@ -621,54 +590,6 @@ TEST_F(FilterEngineTest, SetRemoveFilterChangeCallback)
EXPECT_EQ(1, timesCalled);
}
-TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback)
-{
- mockWebRequest->response.status = 0;
- mockWebRequest->response.responseStatus = 200;
- mockWebRequest->response.responseText = "\
-{\
- \"test\": {\
- \"version\": \"1.0.2\",\
- \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\
- }\
-}";
-
- int timesCalled = 0;
- filterEngine->SetUpdateAvailableCallback([&timesCalled](const std::string&)->void
- {
- ++timesCalled;
- });
- filterEngine->ForceUpdateCheck();
- AdblockPlus::Sleep(100);
- EXPECT_EQ(1, timesCalled);
-
- filterEngine->RemoveUpdateAvailableCallback();
- filterEngine->ForceUpdateCheck();
- AdblockPlus::Sleep(100);
- EXPECT_EQ(1, timesCalled);
-}
-
-TEST_F(UpdaterTest, ForceUpdateCheck)
-{
- mockWebRequest->response.status = 0;
- mockWebRequest->response.responseStatus = 200;
- mockWebRequest->response.responseText = "\
-{\
- \"test\": {\
- \"version\": \"1.0.2\",\
- \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\
- }\
-}";
-
- int called = 0; // 0 - not called; 1 - once, no error; 2 - error
- filterEngine->ForceUpdateCheck([&called](const std::string& error)->void
- {
- called = error.empty() ? 1 : 2;
- });
- AdblockPlus::Sleep(100);
- EXPECT_EQ(1, called);
-}
-
TEST_F(FilterEngineTest, DocumentWhitelisting)
{
filterEngine->GetFilter("@@||example.org^$document").AddToList();
« no previous file with comments | « no previous file | test/UpdateCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld