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

Unified Diff: test/FilterEngineStubs.cpp

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Addressed review comments Created April 8, 2013, 1:51 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
« include/AdblockPlus/FilterEngine.h ('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
@@ -2,23 +2,23 @@
#include <gtest/gtest.h>
TEST(FilterEngineStubsTest, FilterCreation)
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
AdblockPlus::Filter& filter1 = filterEngine.GetFilter("foo");
- ASSERT_EQ(filter1.GetProperty("type", ""), "blocking");
+ ASSERT_EQ(filter1.GetProperty("type", -1), AdblockPlus::BLOCKING_RULE);
AdblockPlus::Filter& filter2 = filterEngine.GetFilter("@@foo");
- ASSERT_EQ(filter2.GetProperty("type", ""), "exception");
+ ASSERT_EQ(filter2.GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE);
AdblockPlus::Filter& filter3 = filterEngine.GetFilter("example.com##foo");
- ASSERT_EQ(filter3.GetProperty("type", ""), "elemhide");
+ ASSERT_EQ(filter3.GetProperty("type", -1), AdblockPlus::ELEMHIDE_RULE);
AdblockPlus::Filter& filter4 = filterEngine.GetFilter("example.com#@#foo");
- ASSERT_EQ(filter4.GetProperty("type", ""), "elemhideexception");
+ ASSERT_EQ(filter4.GetProperty("type", -1), AdblockPlus::ELEMHIDE_EXCEPTION_RULE);
AdblockPlus::Filter& filter5 = filterEngine.GetFilter(" foo ");
ASSERT_EQ(&filter5, &filter1);
}
TEST(FilterEngineStubsTest, FilterProperties)
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
@@ -40,20 +40,20 @@ TEST(FilterEngineStubsTest, AddRemoveFil
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u);
AdblockPlus::Filter& filter = filterEngine.GetFilter("foo");
ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u);
filter.AddToList();
ASSERT_EQ(filterEngine.GetListedFilters().size(), 1u);
- ASSERT_EQ(filterEngine.GetListedFilters()[0], &filter);
+ ASSERT_EQ(filterEngine.GetListedFilters()[0].get(), &filter);
filter.AddToList();
ASSERT_EQ(filterEngine.GetListedFilters().size(), 1u);
- ASSERT_EQ(filterEngine.GetListedFilters()[0], &filter);
+ ASSERT_EQ(filterEngine.GetListedFilters()[0].get(), &filter);
filter.RemoveFromList();
ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u);
filter.RemoveFromList();
ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u);
}
TEST(FilterEngineStubsTest, SubscriptionProperties)
{
@@ -77,36 +77,40 @@ TEST(FilterEngineStubsTest, AddRemoveSub
{
AdblockPlus::JsEngine jsEngine(0, 0);
AdblockPlus::FilterEngine filterEngine(jsEngine);
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);
- ASSERT_EQ(filterEngine.GetListedSubscriptions()[0], &subscription);
+ ASSERT_EQ(filterEngine.GetListedSubscriptions()[0].get(), &subscription);
subscription.AddToList();
ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u);
- ASSERT_EQ(filterEngine.GetListedSubscriptions()[0], &subscription);
+ ASSERT_EQ(filterEngine.GetListedSubscriptions()[0].get(), &subscription);
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);
AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
subscription.AddToList();
- AdblockPlus::Filter* match1 = filterEngine.Matches("http://example.org", "", "");
+ AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org", "", "");
ASSERT_FALSE(match1);
- AdblockPlus::Filter* match2 = filterEngine.Matches("http://example.org/adbanner.gif", "", "");
+ AdblockPlus::FilterPtr match2 = filterEngine.Matches("http://example.org/adbanner.gif", "", "");
ASSERT_TRUE(match2);
- ASSERT_EQ(match2->GetProperty("type", ""), "blocking");
+ ASSERT_EQ(match2->GetProperty("type", -1), AdblockPlus::BLOCKING_RULE);
- AdblockPlus::Filter* match3 = filterEngine.Matches("http://example.org/notbanner.gif", "", "");
+ AdblockPlus::FilterPtr match3 = filterEngine.Matches("http://example.org/notbanner.gif", "", "");
ASSERT_TRUE(match3);
- ASSERT_EQ(match3->GetProperty("type", ""), "exception");
+ ASSERT_EQ(match3->GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE);
+
+ AdblockPlus::FilterPtr match4 = filterEngine.Matches("http://example.org/notbanner.gif", "", "");
+ ASSERT_TRUE(match4);
+ ASSERT_EQ(match4->GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE);
}
« include/AdblockPlus/FilterEngine.h ('K') | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld