OLD | NEW |
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 } |
OLD | NEW |