Index: test/FilterEngineStubs.cpp |
=================================================================== |
--- a/test/FilterEngineStubs.cpp |
+++ b/test/FilterEngineStubs.cpp |
@@ -28,36 +28,36 @@ class DummyFileSystem : public AdblockPl |
StatResult Stat(const std::string& path) const |
{ |
throw std::runtime_error("Not implemented"); |
} |
}; |
TEST(FilterEngineStubsTest, FilterCreation) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::FilterPtr filter1 = filterEngine.GetFilter("foo"); |
ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetProperty("type", -1)); |
AdblockPlus::FilterPtr filter2 = filterEngine.GetFilter("@@foo"); |
ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter2->GetProperty("type", -1)); |
AdblockPlus::FilterPtr filter3 = filterEngine.GetFilter("example.com##foo"); |
ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE, filter3->GetProperty("type", -1)); |
AdblockPlus::FilterPtr filter4 = filterEngine.GetFilter("example.com#@#foo"); |
ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION, filter4->GetProperty("type", -1)); |
AdblockPlus::FilterPtr filter5 = filterEngine.GetFilter(" foo "); |
ASSERT_EQ(*filter1, *filter5); |
} |
TEST(FilterEngineStubsTest, FilterProperties) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::FilterPtr filter = filterEngine.GetFilter("foo"); |
ASSERT_EQ("x", filter->GetProperty("stringFoo", "x")); |
ASSERT_EQ(42, filter->GetProperty("intFoo", 42)); |
ASSERT_FALSE(filter->GetProperty("boolFoo", false)); |
filter->SetProperty("stringFoo", "y"); |
@@ -65,18 +65,18 @@ TEST(FilterEngineStubsTest, FilterProper |
filter->SetProperty("boolFoo", true); |
ASSERT_EQ("y", filter->GetProperty("stringFoo", "x")); |
ASSERT_EQ(24, filter->GetProperty("intFoo", 42)); |
ASSERT_TRUE(filter->GetProperty("boolFoo", false)); |
} |
TEST(FilterEngineStubsTest, AddRemoveFilters) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
AdblockPlus::FilterPtr filter = filterEngine.GetFilter("foo"); |
ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
filter->AddToList(); |
ASSERT_EQ(1u, filterEngine.GetListedFilters().size()); |
ASSERT_EQ(*filter, *filterEngine.GetListedFilters()[0]); |
filter->AddToList(); |
@@ -85,18 +85,18 @@ TEST(FilterEngineStubsTest, AddRemoveFil |
filter->RemoveFromList(); |
ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
filter->RemoveFromList(); |
ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
} |
TEST(FilterEngineStubsTest, SubscriptionProperties) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
ASSERT_EQ("x", subscription->GetProperty("stringFoo", "x")); |
ASSERT_EQ(42, subscription->GetProperty("intFoo", 42)); |
ASSERT_FALSE(subscription->GetProperty("boolFoo", false)); |
subscription->SetProperty("stringFoo", "y"); |
@@ -104,18 +104,18 @@ TEST(FilterEngineStubsTest, Subscription |
subscription->SetProperty("boolFoo", true); |
ASSERT_EQ("y", subscription->GetProperty("stringFoo", "x")); |
ASSERT_EQ(24, subscription->GetProperty("intFoo", 42)); |
ASSERT_TRUE(subscription->GetProperty("boolFoo", false)); |
} |
TEST(FilterEngineStubsTest, AddRemoveSubscriptions) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
subscription->AddToList(); |
ASSERT_EQ(1u, filterEngine.GetListedSubscriptions().size()); |
ASSERT_EQ(*subscription, *filterEngine.GetListedSubscriptions()[0]); |
subscription->AddToList(); |
@@ -124,30 +124,30 @@ TEST(FilterEngineStubsTest, AddRemoveSub |
subscription->RemoveFromList(); |
ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
subscription->RemoveFromList(); |
ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
} |
TEST(FilterEngineStubsTest, SubscriptionUpdates) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
ASSERT_FALSE(subscription->IsUpdating()); |
//TODO: This currently crashes due to errors reported on a different thread |
//subscription->UpdateFilters(); |
} |
TEST(FilterEngineStubsTest, Matches) |
{ |
- AdblockPlus::JsEngine jsEngine; |
- jsEngine.SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
+ AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
+ jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new DummyFileSystem())); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
filterEngine.GetFilter("adbanner.gif")->AddToList(); |
filterEngine.GetFilter("@@notbanner.gif")->AddToList(); |
AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org/foobar.gif", "IMAGE", ""); |
ASSERT_FALSE(match1); |