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

Side by Side Diff: test/FilterEngine.cpp

Issue 11021064: Fixed: domain options aren`t treated correctly by the matcher (Closed)
Patch Set: Created July 5, 2013, 12:39 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
« no previous file with comments | « lib/api.js ('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 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ASSERT_FALSE(subscription->IsUpdating()); 148 ASSERT_FALSE(subscription->IsUpdating());
149 subscription->UpdateFilters(); 149 subscription->UpdateFilters();
150 } 150 }
151 151
152 TEST_F(FilterEngineTest, Matches) 152 TEST_F(FilterEngineTest, Matches)
153 { 153 {
154 filterEngine->GetFilter("adbanner.gif")->AddToList(); 154 filterEngine->GetFilter("adbanner.gif")->AddToList();
155 filterEngine->GetFilter("@@notbanner.gif")->AddToList(); 155 filterEngine->GetFilter("@@notbanner.gif")->AddToList();
156 filterEngine->GetFilter("tpbanner.gif$third-party")->AddToList(); 156 filterEngine->GetFilter("tpbanner.gif$third-party")->AddToList();
157 filterEngine->GetFilter("fpbanner.gif$~third-party")->AddToList(); 157 filterEngine->GetFilter("fpbanner.gif$~third-party")->AddToList();
158 filterEngine->GetFilter("combanner.gif$domain=example.com")->AddToList();
159 filterEngine->GetFilter("orgbanner.gif$domain=~example.com")->AddToList();
158 160
159 AdblockPlus::FilterPtr match1 = filterEngine->Matches("http://example.org/foob ar.gif", "IMAGE", ""); 161 AdblockPlus::FilterPtr match1 = filterEngine->Matches("http://example.org/foob ar.gif", "IMAGE", "");
160 ASSERT_FALSE(match1); 162 ASSERT_FALSE(match1);
161 163
162 AdblockPlus::FilterPtr match2 = filterEngine->Matches("http://example.org/adba nner.gif", "IMAGE", ""); 164 AdblockPlus::FilterPtr match2 = filterEngine->Matches("http://example.org/adba nner.gif", "IMAGE", "");
163 ASSERT_TRUE(match2); 165 ASSERT_TRUE(match2);
164 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match2->GetType()); 166 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match2->GetType());
165 167
166 AdblockPlus::FilterPtr match3 = filterEngine->Matches("http://example.org/notb anner.gif", "IMAGE", ""); 168 AdblockPlus::FilterPtr match3 = filterEngine->Matches("http://example.org/notb anner.gif", "IMAGE", "");
167 ASSERT_TRUE(match3); 169 ASSERT_TRUE(match3);
168 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match3->GetType()); 170 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match3->GetType());
169 171
170 AdblockPlus::FilterPtr match4 = filterEngine->Matches("http://example.org/notb anner.gif", "IMAGE", ""); 172 AdblockPlus::FilterPtr match4 = filterEngine->Matches("http://example.org/notb anner.gif", "IMAGE", "");
171 ASSERT_TRUE(match4); 173 ASSERT_TRUE(match4);
172 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match4->GetType()); 174 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match4->GetType());
173 175
174 AdblockPlus::FilterPtr match5 = filterEngine->Matches("http://example.org/tpba nner.gif", "IMAGE", "http://example.org/"); 176 AdblockPlus::FilterPtr match5 = filterEngine->Matches("http://example.org/tpba nner.gif", "IMAGE", "http://example.org/");
175 ASSERT_FALSE(match5); 177 ASSERT_FALSE(match5);
176 178
177 AdblockPlus::FilterPtr match6 = filterEngine->Matches("http://example.org/fpba nner.gif", "IMAGE", "http://example.org/"); 179 AdblockPlus::FilterPtr match6 = filterEngine->Matches("http://example.org/fpba nner.gif", "IMAGE", "http://example.org/");
178 ASSERT_TRUE(match6); 180 ASSERT_TRUE(match6);
179 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); 181 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType());
180 182
181 AdblockPlus::FilterPtr match7 = filterEngine->Matches("http://example.org/tpba nner.gif", "IMAGE", "http://example.com/"); 183 AdblockPlus::FilterPtr match7 = filterEngine->Matches("http://example.org/tpba nner.gif", "IMAGE", "http://example.com/");
182 ASSERT_TRUE(match7); 184 ASSERT_TRUE(match7);
183 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); 185 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match7->GetType());
184 186
185 AdblockPlus::FilterPtr match8 = filterEngine->Matches("http://example.org/fpba nner.gif", "IMAGE", "http://example.com/"); 187 AdblockPlus::FilterPtr match8 = filterEngine->Matches("http://example.org/fpba nner.gif", "IMAGE", "http://example.com/");
186 ASSERT_FALSE(match8); 188 ASSERT_FALSE(match8);
189
190 AdblockPlus::FilterPtr match9 = filterEngine->Matches("http://example.org/comb anner.gif", "IMAGE", "http://example.com/");
191 ASSERT_TRUE(match9);
192 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match9->GetType());
193
194 AdblockPlus::FilterPtr match10 = filterEngine->Matches("http://example.org/com banner.gif", "IMAGE", "http://example.org/");
195 ASSERT_FALSE(match10);
196
197 AdblockPlus::FilterPtr match11 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.com/");
198 ASSERT_FALSE(match11);
199
200 AdblockPlus::FilterPtr match12 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.org/");
201 ASSERT_TRUE(match12);
202 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match12->GetType());
187 } 203 }
188 204
189 TEST_F(FilterEngineTest, FirstRunFlag) 205 TEST_F(FilterEngineTest, FirstRunFlag)
190 { 206 {
191 ASSERT_FALSE(filterEngine->IsFirstRun()); 207 ASSERT_FALSE(filterEngine->IsFirstRun());
192 } 208 }
193 209
194 TEST_F(FilterEngineTestNoData, FirstRunFlag) 210 TEST_F(FilterEngineTestNoData, FirstRunFlag)
195 { 211 {
196 ASSERT_FALSE(filterEngine->IsFirstRun()); 212 ASSERT_FALSE(filterEngine->IsFirstRun());
197 } 213 }
OLDNEW
« no previous file with comments | « lib/api.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld