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: Created Sept. 16, 2014, 9:34 a.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
@@ -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);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld