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

Unified Diff: test/UpdateCheck.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 | « test/FilterEngine.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
diff --git a/test/UpdateCheck.cpp b/test/UpdateCheck.cpp
index c6036395f22c21040fa5802487ad18d43d88e2c6..22653ba47ba215e7a7b1f7468ce69b2bbe7d2a12 100644
--- a/test/UpdateCheck.cpp
+++ b/test/UpdateCheck.cpp
@@ -262,3 +262,48 @@ TEST_F(UpdateCheckTest, WrongURL)
ASSERT_TRUE(updateCallbackCalled);
ASSERT_FALSE(updateError.empty());
}
+
+TEST_F(UpdateCheckTest, SetRemoveUpdateAvailableCallback)
+{
+ webRequestResponse.status = 0;
+ webRequestResponse.responseStatus = 200;
+ webRequestResponse.responseText = "\
+{\
+ \"test\": {\
+ \"version\": \"1.0.2\",\
+ \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\
+ }\
+}";
+
+ appInfo.name = "test";
+ appInfo.version = "1.0.1";
+ CreateFilterEngine();
+
+ int timesCalled = 0;
+ filterEngine->SetUpdateAvailableCallback([&timesCalled](const std::string&)->void
+ {
+ ++timesCalled;
+ });
+ ForceUpdateCheck();
+
+ // ensure that the was the corresponding request
+ EXPECT_FALSE(ProcessPendingUpdateWebRequest().empty());
+
+ EXPECT_EQ(1, timesCalled);
+
+ // filterEngine->SetUpdateAvailableCallback overriddes previously installed on JsEngine
+ // handler for "updateAvailable" event.
+ EXPECT_FALSE(eventCallbackCalled);
+
+ filterEngine->RemoveUpdateAvailableCallback();
+ ForceUpdateCheck();
+
+ // ensure that the was the corresponding request
+ EXPECT_FALSE(ProcessPendingUpdateWebRequest().empty());
+
+ EXPECT_FALSE(eventCallbackCalled);
+ EXPECT_EQ(1, timesCalled);
+
+ // previous handler is not restored
+ EXPECT_FALSE(eventCallbackCalled);
+}
« no previous file with comments | « test/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld