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

Unified Diff: test/FilterEngine.cpp

Issue 4756164013195264: Issue 1376 - Add tests for SetFilterChangeCallback (Closed)
Patch Set: Rebased, use GetFilter() Created May 29, 2015, 11:05 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
===================================================================
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -49,6 +49,19 @@
typedef FilterEngineTestGeneric<LazyFileSystem, AdblockPlus::DefaultLogSystem> FilterEngineTest;
typedef FilterEngineTestGeneric<VeryLazyFileSystem, LazyLogSystem> FilterEngineTestNoData;
+ struct MockFilterChangeCallback
+ {
+ MockFilterChangeCallback(int& timesCalled) : timesCalled(timesCalled) {}
+
+ void operator()(const std::string&, const AdblockPlus::JsValuePtr)
+ {
+ timesCalled++;
+ }
+
+ private:
+ int& timesCalled;
+ };
+
class UpdaterTest : public ::testing::Test
{
protected:
@@ -361,6 +374,20 @@
ASSERT_TRUE(filterEngine->IsFirstRun());
}
+TEST_F(FilterEngineTest, SetRemoveFilterChangeCallback)
+{
+ int timesCalled = 0;
+ MockFilterChangeCallback mockFilterChangeCallback(timesCalled);
+
+ filterEngine->SetFilterChangeCallback(mockFilterChangeCallback);
+ filterEngine->GetFilter("foo")->AddToList();
+ ASSERT_EQ(2, timesCalled);
sergei 2015/08/06 08:09:37 Nit: it could be a good practice to use EXPECT_* w
sergei 2015/08/06 08:09:37 It would be also good to test when timesCalled is
Felix Dahlke 2015/08/13 14:17:50 Hm, you're right, I think I should use it more oft
Felix Dahlke 2015/08/13 14:17:50 That's not really possible - it's called two times
+
+ filterEngine->RemoveFilterChangeCallback();
+ filterEngine->GetFilter("foo")->RemoveFromList();
+ ASSERT_EQ(2, timesCalled);
+}
+
TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback)
{
mockWebRequest->response.status = 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld