Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/FilterEngine.cpp

Issue 29424648: Issue 5123 - add Subscription::IsDisabled (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created April 28, 2017, 9:44 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 | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
diff --git a/test/FilterEngine.cpp b/test/FilterEngine.cpp
index 3244d42f4218e56fb63f2668f4503cb633e79cb9..a9491bb5822738cc7a0b042924d0ee7f0f5894ee 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -330,6 +330,47 @@ TEST_F(FilterEngineTest, SubscriptionProperties)
ASSERT_TRUE(subscription.GetProperty("boolFoo").AsBool());
}
+TEST_F(FilterEngineTest, AddedSubscriptionIsEnabled)
+{
+ AdblockPlus::Subscription subscription = filterEngine->GetSubscription("foo");
+ EXPECT_FALSE(subscription.IsDisabled());
+}
+
+TEST_F(FilterEngineTest, DisablingSubscriptionDisablesItAndFiresEvent)
+{
+ AdblockPlus::Subscription subscription = filterEngine->GetSubscription("foo");
+ int eventFiredCounter = 0;
+ filterEngine->SetFilterChangeCallback([&eventFiredCounter](const std::string& eventName, JsValue&& subscriptionObject)
+ {
+ if (eventName != "subscription.disabled" || subscriptionObject.GetProperty("url").AsString() != "foo")
+ return;
+ ++eventFiredCounter;
+ });
+ EXPECT_FALSE(subscription.IsDisabled());
+ subscription.SetDisabled(true);
+ EXPECT_EQ(1, eventFiredCounter);
+ EXPECT_TRUE(subscription.IsDisabled());
+}
+
+TEST_F(FilterEngineTest, EnablingSubscriptionEnablesItAndFiresEvent)
+{
+ AdblockPlus::Subscription subscription = filterEngine->GetSubscription("foo");
+ EXPECT_FALSE(subscription.IsDisabled());
+ subscription.SetDisabled(true);
+ EXPECT_TRUE(subscription.IsDisabled());
+
+ int eventFiredCounter = 0;
+ filterEngine->SetFilterChangeCallback([&eventFiredCounter](const std::string& eventName, JsValue&& subscriptionObject)
+ {
+ if (eventName != "subscription.disabled" || subscriptionObject.GetProperty("url").AsString() != "foo")
+ return;
+ ++eventFiredCounter;
+ });
+ subscription.SetDisabled(false);
+ EXPECT_EQ(1, eventFiredCounter);
+ EXPECT_FALSE(subscription.IsDisabled());
+}
+
TEST_F(FilterEngineTest, AddRemoveSubscriptions)
{
ASSERT_EQ(0u, filterEngine->GetListedSubscriptions().size());
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld