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

Delta Between Two Patch Sets: test/FilterEngineStubs.cpp

Issue 10100009: FilterEngine API improvements (Closed)
Left Patch Set: Addressed review comments Created April 8, 2013, 1:51 p.m.
Right Patch Set: Changed filter type enum Created April 9, 2013, 5:55 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/FilterEngine.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <gtest/gtest.h> 2 #include <gtest/gtest.h>
3 3
4 TEST(FilterEngineStubsTest, FilterCreation) 4 TEST(FilterEngineStubsTest, FilterCreation)
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 8
9 AdblockPlus::Filter& filter1 = filterEngine.GetFilter("foo"); 9 AdblockPlus::Filter& filter1 = filterEngine.GetFilter("foo");
10 ASSERT_EQ(filter1.GetProperty("type", -1), AdblockPlus::BLOCKING_RULE); 10 ASSERT_EQ(filter1.GetProperty("type", -1), AdblockPlus::Filter::TYPE_BLOCKING) ;
11 AdblockPlus::Filter& filter2 = filterEngine.GetFilter("@@foo"); 11 AdblockPlus::Filter& filter2 = filterEngine.GetFilter("@@foo");
12 ASSERT_EQ(filter2.GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE); 12 ASSERT_EQ(filter2.GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION );
13 AdblockPlus::Filter& filter3 = filterEngine.GetFilter("example.com##foo"); 13 AdblockPlus::Filter& filter3 = filterEngine.GetFilter("example.com##foo");
14 ASSERT_EQ(filter3.GetProperty("type", -1), AdblockPlus::ELEMHIDE_RULE); 14 ASSERT_EQ(filter3.GetProperty("type", -1), AdblockPlus::Filter::TYPE_ELEMHIDE) ;
15 AdblockPlus::Filter& filter4 = filterEngine.GetFilter("example.com#@#foo"); 15 AdblockPlus::Filter& filter4 = filterEngine.GetFilter("example.com#@#foo");
16 ASSERT_EQ(filter4.GetProperty("type", -1), AdblockPlus::ELEMHIDE_EXCEPTION_RUL E); 16 ASSERT_EQ(filter4.GetProperty("type", -1), AdblockPlus::Filter::TYPE_ELEMHIDE_ EXCEPTION);
17 AdblockPlus::Filter& filter5 = filterEngine.GetFilter(" foo "); 17 AdblockPlus::Filter& filter5 = filterEngine.GetFilter(" foo ");
18 ASSERT_EQ(&filter5, &filter1); 18 ASSERT_EQ(&filter5, &filter1);
19 } 19 }
20 20
21 TEST(FilterEngineStubsTest, FilterProperties) 21 TEST(FilterEngineStubsTest, FilterProperties)
22 { 22 {
23 AdblockPlus::JsEngine jsEngine(0, 0); 23 AdblockPlus::JsEngine jsEngine(0, 0);
24 AdblockPlus::FilterEngine filterEngine(jsEngine); 24 AdblockPlus::FilterEngine filterEngine(jsEngine);
25 AdblockPlus::Filter& filter = filterEngine.GetFilter("foo"); 25 AdblockPlus::Filter& filter = filterEngine.GetFilter("foo");
26 26
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AdblockPlus::JsEngine jsEngine(0, 0); 97 AdblockPlus::JsEngine jsEngine(0, 0);
98 AdblockPlus::FilterEngine filterEngine(jsEngine); 98 AdblockPlus::FilterEngine filterEngine(jsEngine);
99 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo"); 99 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription("foo");
100 subscription.AddToList(); 100 subscription.AddToList();
101 101
102 AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org", "", ""); 102 AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org", "", "");
103 ASSERT_FALSE(match1); 103 ASSERT_FALSE(match1);
104 104
105 AdblockPlus::FilterPtr match2 = filterEngine.Matches("http://example.org/adban ner.gif", "", ""); 105 AdblockPlus::FilterPtr match2 = filterEngine.Matches("http://example.org/adban ner.gif", "", "");
106 ASSERT_TRUE(match2); 106 ASSERT_TRUE(match2);
107 ASSERT_EQ(match2->GetProperty("type", -1), AdblockPlus::BLOCKING_RULE); 107 ASSERT_EQ(match2->GetProperty("type", -1), AdblockPlus::Filter::TYPE_BLOCKING) ;
108 108
109 AdblockPlus::FilterPtr match3 = filterEngine.Matches("http://example.org/notba nner.gif", "", ""); 109 AdblockPlus::FilterPtr match3 = filterEngine.Matches("http://example.org/notba nner.gif", "", "");
110 ASSERT_TRUE(match3); 110 ASSERT_TRUE(match3);
111 ASSERT_EQ(match3->GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE); 111 ASSERT_EQ(match3->GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION );
112 112
113 AdblockPlus::FilterPtr match4 = filterEngine.Matches("http://example.org/notba nner.gif", "", ""); 113 AdblockPlus::FilterPtr match4 = filterEngine.Matches("http://example.org/notba nner.gif", "", "");
114 ASSERT_TRUE(match4); 114 ASSERT_TRUE(match4);
115 ASSERT_EQ(match4->GetProperty("type", -1), AdblockPlus::EXCEPTION_RULE); 115 ASSERT_EQ(match4->GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION );
116 } 116 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld