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; |