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 EXPECT instead of ASSERT Created Aug. 13, 2015, 4:52 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 | « dependencies ('k') | 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();
+ EXPECT_EQ(2, timesCalled);
+
+ filterEngine->RemoveFilterChangeCallback();
+ filterEngine->GetFilter("foo")->RemoveFromList();
+ EXPECT_EQ(2, timesCalled);
+}
+
TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback)
{
mockWebRequest->response.status = 0;
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld