OLD | NEW |
1 #include "BaseJsTest.h" | 1 #include "BaseJsTest.h" |
2 | 2 |
3 namespace | 3 namespace |
4 { | 4 { |
5 typedef std::tr1::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr; | 5 typedef std::tr1::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr; |
6 | 6 |
7 class FilterEngineTest : public BaseJsTest | 7 class FilterEngineTest : public BaseJsTest |
8 { | 8 { |
9 protected: | 9 protected: |
10 FilterEnginePtr filterEngine; | 10 FilterEnginePtr filterEngine; |
11 | 11 |
12 void SetUp() | 12 void SetUp() |
13 { | 13 { |
14 BaseJsTest::SetUp(); | 14 BaseJsTest::SetUp(); |
15 // TODO: Don't use the default ErrorCallback/WebRequest | 15 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem)); |
| 16 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new LazyWebRequest)); |
16 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new AdblockPlus::
DefaultErrorCallback)); | 17 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new AdblockPlus::
DefaultErrorCallback)); |
17 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new AdblockPlus::Defaul
tWebRequest)); | |
18 filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)); | 18 filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)); |
19 } | 19 } |
20 }; | 20 }; |
21 } | 21 } |
22 | 22 |
23 TEST_F(FilterEngineTest, FilterCreation) | 23 TEST_F(FilterEngineTest, FilterCreation) |
24 { | 24 { |
25 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo"); | 25 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo"); |
26 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType()); | 26 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType()); |
27 AdblockPlus::FilterPtr filter2 = filterEngine->GetFilter("@@foo"); | 27 AdblockPlus::FilterPtr filter2 = filterEngine->GetFilter("@@foo"); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ASSERT_TRUE(match6); | 136 ASSERT_TRUE(match6); |
137 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); | 137 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); |
138 | 138 |
139 AdblockPlus::FilterPtr match7 = filterEngine->Matches("http://example.org/tpba
nner.gif", "IMAGE", "http://example.com/"); | 139 AdblockPlus::FilterPtr match7 = filterEngine->Matches("http://example.org/tpba
nner.gif", "IMAGE", "http://example.com/"); |
140 ASSERT_TRUE(match7); | 140 ASSERT_TRUE(match7); |
141 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); | 141 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match6->GetType()); |
142 | 142 |
143 AdblockPlus::FilterPtr match8 = filterEngine->Matches("http://example.org/fpba
nner.gif", "IMAGE", "http://example.com/"); | 143 AdblockPlus::FilterPtr match8 = filterEngine->Matches("http://example.org/fpba
nner.gif", "IMAGE", "http://example.com/"); |
144 ASSERT_FALSE(match8); | 144 ASSERT_FALSE(match8); |
145 } | 145 } |
OLD | NEW |