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

Unified Diff: test/FilterEngine.cpp

Issue 29366747: Issue 4657 - Add Acceptable Ads API (Closed)
Patch Set: Created Dec. 2, 2016, 4:27 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
« src/FilterEngine.cpp ('K') | « 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 0900e69b38173bf6d4595f817d4699e6b8efcab5..77c0149b745b501c4f4be2801d74293d47d428b0 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -598,23 +598,21 @@ TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun)
auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine));
const auto subscriptions = filterEngine->GetListedSubscriptions();
ASSERT_EQ(2u, subscriptions.size());
- const auto aaUrl = filterEngine->GetPref("subscriptions_exceptionsurl")->AsString();
SubscriptionPtr aaSubscription;
SubscriptionPtr langSubscription;
- if (subscriptions[0]->GetProperty("url")->AsString() == aaUrl)
+ if (subscriptions[0]->IsAA())
{
aaSubscription = subscriptions[0];
langSubscription = subscriptions[1];
- }
- else if (subscriptions[1]->GetProperty("url")->AsString() == aaUrl)
+ } else if (subscriptions[1]->IsAA())
{
aaSubscription = subscriptions[1];
langSubscription = subscriptions[0];
}
ASSERT_NE(nullptr, aaSubscription);
ASSERT_NE(nullptr, langSubscription);
- EXPECT_EQ(aaUrl, aaSubscription->GetProperty("url")->AsString());
EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString());
+ EXPECT_TRUE(filterEngine->IsAAEnabled());
}
TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
@@ -625,4 +623,25 @@ TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine, preSettings));
const auto subscriptions = filterEngine->GetListedSubscriptions();
EXPECT_EQ(0u, subscriptions.size());
+ EXPECT_FALSE(filterEngine->IsAAEnabled());
}
+
+TEST_F(FilterEngineTest, IsAAEnabled)
+{
+ // no subscription (because of preconfigured prefs.json and patterns.ini)
+ EXPECT_FALSE(filterEngine->IsAAEnabled());
+ // add subscription and enable
+ filterEngine->SetAAEnabled(true);
+ EXPECT_TRUE(filterEngine->IsAAEnabled());
+ // disable
+ filterEngine->SetAAEnabled(false);
+ EXPECT_FALSE(filterEngine->IsAAEnabled());
+ // only enable already existing disabled
+ filterEngine->SetAAEnabled(true);
+ EXPECT_TRUE(filterEngine->IsAAEnabled());
+ // remove
+ filterEngine->GetSubscription(filterEngine->GetAAURL())->RemoveFromList();
+ EXPECT_FALSE(filterEngine->IsAAEnabled());
+ // no subscription
+ EXPECT_FALSE(filterEngine->IsAAEnabled());
+}
Eric 2016/12/05 14:40:58 This is a bunch of unit tests all combined into on
sergei 2017/03/17 15:55:25 Added more tests and they run in each separate tes
« src/FilterEngine.cpp ('K') | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld