aboutsummaryrefslogtreecommitdiff
path: root/plugins/AdblockFilter/test/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdblockFilter/test/options.cpp')
-rw-r--r--plugins/AdblockFilter/test/options.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/AdblockFilter/test/options.cpp b/plugins/AdblockFilter/test/options.cpp
new file mode 100644
index 0000000..67dc143
--- /dev/null
+++ b/plugins/AdblockFilter/test/options.cpp
@@ -0,0 +1,42 @@
+#define CATCH_CONFIG_MAIN
+#include "options.h"
+#include <catch2/catch.hpp>
+
+using namespace AdblockPlus;
+
+SCENARIO("parsing adblock options")
+{
+ Options opt;
+
+ GIVEN("an unknown option")
+ {
+ const QString unknown = "unknown";
+ THEN("the option is not parsed")
+ {
+ QStringRef unknown_ref(&unknown);
+ REQUIRE(!opt.parseAbp(unknown_ref));
+ }
+ }
+
+ GIVEN("match-case,document,~subdocument")
+ {
+ const QString options = "match-case,document,~subdocument";
+ REQUIRE(opt.parseAbp(&options));
+
+ WHEN("match-case")
+ {
+ REQUIRE(opt.matchcase);
+ }
+
+ WHEN("testing set/unset options")
+ {
+ REQUIRE(opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeMainFrame));
+ REQUIRE(!opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeSubFrame));
+ }
+
+ WHEN("testing other options")
+ {
+ REQUIRE(opt.matchesType(QWebEngineUrlRequestInfo::ResourceTypeStylesheet));
+ }
+ }
+}