diff options
Diffstat (limited to 'staging/adblock/test')
-rw-r--r-- | staging/adblock/test/options.cpp | 17 | ||||
-rw-r--r-- | staging/adblock/test/rule.cpp | 14 |
2 files changed, 16 insertions, 15 deletions
diff --git a/staging/adblock/test/options.cpp b/staging/adblock/test/options.cpp index d0ad4a0..67dc143 100644 --- a/staging/adblock/test/options.cpp +++ b/staging/adblock/test/options.cpp @@ -18,26 +18,25 @@ SCENARIO("parsing adblock options") } } - GIVEN("various options in a QString") + GIVEN("match-case,document,~subdocument") { const QString options = "match-case,document,~subdocument"; - - for(auto &i : splitOptions(&options)) { - REQUIRE(opt.parseAbp(i)); - } + REQUIRE(opt.parseAbp(&options)); WHEN("match-case") { REQUIRE(opt.matchcase); } - WHEN("document") + WHEN("testing set/unset options") { - REQUIRE(opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeMainFrame)); + REQUIRE(opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeMainFrame)); + REQUIRE(!opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeSubFrame)); } - WHEN("~subdocument") + + WHEN("testing other options") { - REQUIRE(!opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeSubFrame)); + REQUIRE(opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeStylesheet)); } } } diff --git a/staging/adblock/test/rule.cpp b/staging/adblock/test/rule.cpp index d192601..31af7d5 100644 --- a/staging/adblock/test/rule.cpp +++ b/staging/adblock/test/rule.cpp @@ -2,11 +2,13 @@ #include "rule.h" #include <catch2/catch.hpp> +using namespace AdblockPlus; + SCENARIO("MatcherRule") { GIVEN("options with case sensitive pattern") { - const AdblockPlus::Options opt { .matchcase=true }; + const Options opt { .matchcase=true }; const QString patternContains("this string contains the pattern in it"); const QString patternBegins("pattern starts this string"); const QString patternEnds("this string ends with pattern"); @@ -14,7 +16,7 @@ SCENARIO("MatcherRule") WHEN("contains") { - AdblockPlus::MatcherRule rule("pattern", opt); + MatcherRule rule("pattern", opt); REQUIRE(rule.shouldBlock()); THEN("pattern is matched anywhere in the URL") @@ -28,7 +30,7 @@ SCENARIO("MatcherRule") WHEN("startsWith") { - AdblockPlus::MatcherRule rule("pattern", opt, AdblockPlus::MatcherRule::UrlStartsWith); + MatcherRule rule("pattern", opt, MatcherRule::UrlStartsWith); REQUIRE(rule.shouldBlock()); THEN("pattern is matched if at the start of the URL") @@ -42,7 +44,7 @@ SCENARIO("MatcherRule") WHEN("endsWith") { - AdblockPlus::MatcherRule rule("pattern", opt, AdblockPlus::MatcherRule::UrlEndsWith); + MatcherRule rule("pattern", opt, MatcherRule::UrlEndsWith); REQUIRE(rule.shouldBlock()); THEN("pattern is matched if at the end of the URL") @@ -60,13 +62,13 @@ SCENARIO("RegexRule") { GIVEN("options with case sensitive pattern") { - const AdblockPlus::Options opt { .matchcase=true }; + const Options opt { .matchcase=true }; const QString patternContains("this string contains the pattern in it"); const QString patternMissing("and this one does not"); WHEN("contains") { - AdblockPlus::RegexRule rule("pattern", opt); + RegexRule rule("pattern", opt); REQUIRE(rule.shouldBlock()); THEN("pattern is matched anywhere in the URL") |