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

Unified Diff: test/FilterEngine.cpp

Issue 29331737: Issue 3363 - Implement IsDocumentWhitelisted and IsElemhideWhitelisted (Closed)
Patch Set: Reverted a whitespace removal Created Dec. 3, 2015, 8:39 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
diff --git a/test/FilterEngine.cpp b/test/FilterEngine.cpp
index 9c2facf0a9ad66b28b4c6f360a424e119ebfbe77..92579c23ee392f218687248f56e913290db138f2 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -413,3 +413,61 @@ TEST_F(UpdaterTest, SetRemoveUpdateAvailableCallback)
AdblockPlus::Sleep(100);
ASSERT_EQ(1, timesCalled);
}
+
+TEST_F(FilterEngineTest, DocumentWhitelisting)
+{
+ filterEngine->GetFilter("@@||example.org^$document")->AddToList();
+ filterEngine->GetFilter("@@||example.com^$document,domain=example.de")->AddToList();
+
+ ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
+ "http://example.org",
+ std::vector<std::string>()));
+
+ ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
+ "http://example.co.uk",
+ std::vector<std::string>()));
+
+ ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
+ "http://example.com",
+ std::vector<std::string>()));
+
+ std::vector<std::string> documentUrls1;
+ documentUrls1.push_back("http://example.de");
+
+ ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
+ "http://example.com",
+ documentUrls1));
+
+ ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
+ "http://example.co.uk",
+ documentUrls1));
+}
+
+TEST_F(FilterEngineTest, ElemhideWhitelisting)
+{
+ filterEngine->GetFilter("@@||example.org^$elemhide")->AddToList();
+ filterEngine->GetFilter("@@||example.com^$elemhide,domain=example.de")->AddToList();
+
+ ASSERT_TRUE(filterEngine->IsElemhideWhitelisted(
+ "http://example.org",
+ std::vector<std::string>()));
+
+ ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
+ "http://example.co.uk",
+ std::vector<std::string>()));
+
+ ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
+ "http://example.com",
+ std::vector<std::string>()));
+
+ std::vector<std::string> documentUrls1;
+ documentUrls1.push_back("http://example.de");
+
+ ASSERT_TRUE(filterEngine->IsElemhideWhitelisted(
+ "http://example.com",
+ documentUrls1));
+
+ ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
+ "http://example.co.uk",
+ documentUrls1));
+}
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld