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

Side by Side Diff: test/FilterEngineStubs.cpp

Issue 10100009: FilterEngine API improvements (Closed)
Patch Set: Created April 4, 2013, 5:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/FilterEngine.cpp ('K') | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <gtest/gtest.h> 2 #include <gtest/gtest.h>
3 3
4 TEST(FilterEngineStubsTest, AddRemove) 4 TEST(FilterEngineStubsTest, AddRemove)
5 { 5 {
6 AdblockPlus::JsEngine jsEngine(0, 0); 6 AdblockPlus::JsEngine jsEngine(0, 0);
7 AdblockPlus::FilterEngine filterEngine(jsEngine); 7 AdblockPlus::FilterEngine filterEngine(jsEngine);
8 ASSERT_EQ(filterEngine.GetSubscriptions().size(), 0u); 8 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
9 AdblockPlus::Subscription subscription("foo", "bar"); 9 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
10 filterEngine.AddSubscription(subscription); 10 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
11 ASSERT_EQ(filterEngine.GetSubscriptions().size(), 1u); 11 subscription.AddToList();
12 filterEngine.RemoveSubscription(subscription); 12 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u);
13 ASSERT_EQ(filterEngine.GetSubscriptions().size(), 0u); 13 subscription.AddToList();
14 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u);
15 subscription.RemoveFromList();
16 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
17 subscription.RemoveFromList();
18 ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u);
14 } 19 }
15 20
16 TEST(FilterEngineStubsTest, Matches) 21 TEST(FilterEngineStubsTest, Matches)
17 { 22 {
18 AdblockPlus::JsEngine jsEngine(0, 0); 23 AdblockPlus::JsEngine jsEngine(0, 0);
19 AdblockPlus::FilterEngine filterEngine(jsEngine); 24 AdblockPlus::FilterEngine filterEngine(jsEngine);
20 filterEngine.AddSubscription(AdblockPlus::Subscription("foo", "bar")); 25 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
21 ASSERT_FALSE(filterEngine.Matches("http://example.org", "")); 26 subscription.AddToList();
22 ASSERT_TRUE(filterEngine.Matches("http://example.org/adbanner.gif", "")); 27 ASSERT_FALSE(filterEngine.Matches("http://example.org", "", ""));
28 ASSERT_TRUE(filterEngine.Matches("http://example.org/adbanner.gif", "", ""));
23 } 29 }
OLDNEW
« src/FilterEngine.cpp ('K') | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld