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

Unified Diff: test/FilterEngineStubs.cpp

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Created April 4, 2013, 5:04 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/FilterEngineStubs.cpp
===================================================================
--- a/test/FilterEngineStubs.cpp
+++ b/test/FilterEngineStubs.cpp
@@ -1,23 +1,29 @@
#include <AdblockPlus.h>
#include <gtest/gtest.h>
TEST(FilterEngineStubsTest, AddRemove)
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
- ASSERT_EQ(filterEngine.GetSubscriptions().size(), 0u);
- AdblockPlus::Subscription subscription("foo", "bar");
- filterEngine.AddSubscription(subscription);
- ASSERT_EQ(filterEngine.GetSubscriptions().size(), 1u);
- filterEngine.RemoveSubscription(subscription);
- ASSERT_EQ(filterEngine.GetSubscriptions().size(), 0u);
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
+ AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
+ subscription.AddToList();
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u);
+ subscription.AddToList();
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u);
+ subscription.RemoveFromList();
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
+ subscription.RemoveFromList();
+ ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
}
TEST(FilterEngineStubsTest, Matches)
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
- filterEngine.AddSubscription(AdblockPlus::Subscription("foo", "bar"));
- ASSERT_FALSE(filterEngine.Matches("http://example.org", ""));
- ASSERT_TRUE(filterEngine.Matches("http://example.org/adbanner.gif", ""));
+ AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
+ subscription.AddToList();
+ ASSERT_FALSE(filterEngine.Matches("http://example.org", "", ""));
+ ASSERT_TRUE(filterEngine.Matches("http://example.org/adbanner.gif", "", ""));
}
« src/FilterEngine.cpp ('K') | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld