| Index: test/FilterEngine.cpp |
| =================================================================== |
| --- a/test/FilterEngine.cpp |
| +++ b/test/FilterEngine.cpp |
| @@ -48,6 +48,19 @@ |
| typedef FilterEngineTestGeneric<LazyFileSystem, AdblockPlus::DefaultLogSystem> FilterEngineTest; |
| typedef FilterEngineTestGeneric<VeryLazyFileSystem, LazyLogSystem> FilterEngineTestNoData; |
| + |
| + struct MockFilterChangeCallback |
| + { |
| + MockFilterChangeCallback(int& timesCalled) : timesCalled(timesCalled) {} |
|
Felix Dahlke
2014/09/16 09:37:19
It's somewhat unintuitive that the functor doesn't
Wladimir Palant
2014/12/09 21:44:41
Yes, that's a footgun. Should we at least have a c
Felix Dahlke
2015/05/29 23:06:40
It just occurred to me that a shared_ptr should be
|
| + |
| + void operator()(const std::string&, const AdblockPlus::JsValuePtr) |
| + { |
| + timesCalled++; |
| + } |
| + |
| + private: |
| + int& timesCalled; |
| + }; |
| } |
| TEST_F(FilterEngineTest, FilterCreation) |
| @@ -311,3 +324,17 @@ |
| { |
| ASSERT_TRUE(filterEngine->IsFirstRun()); |
| } |
| + |
| +TEST_F(FilterEngineTest, SetRemoveFilterChangeCallback) |
| +{ |
| + int timesCalled = 0; |
| + MockFilterChangeCallback mockFilterChangeCallback(timesCalled); |
| + |
| + filterEngine->SetFilterChangeCallback(mockFilterChangeCallback); |
| + filterEngine->GetSubscription("foo")->AddToList(); |
|
Felix Dahlke
2014/09/16 09:37:19
I tried this with fitlerEngine->GetFilter("foo")->
Wladimir Palant
2014/12/09 21:44:41
Not really, no. If the filter was added it should
Felix Dahlke
2015/05/29 23:06:40
Debugged this a bit. filter.added is actually not
|
| + ASSERT_EQ(1, timesCalled); |
| + |
| + filterEngine->RemoveFilterChangeCallback(); |
| + filterEngine->GetSubscription("foo")->RemoveFromList(); |
| + ASSERT_EQ(1, timesCalled); |
| +} |