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(); |
+ EXPECT_EQ(2, timesCalled); |
+ |
+ filterEngine->RemoveFilterChangeCallback(); |
+ filterEngine->GetFilter("foo")->RemoveFromList(); |
+ EXPECT_EQ(2, timesCalled); |
+} |
+ |
TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback) |
{ |
mockWebRequest->response.status = 0; |