aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/test/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'staging/adblock/test/options.cpp')
-rw-r--r--staging/adblock/test/options.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/staging/adblock/test/options.cpp b/staging/adblock/test/options.cpp
new file mode 100644
index 0000000..d0ad4a0
--- /dev/null
+++ b/staging/adblock/test/options.cpp
@@ -0,0 +1,43 @@
+#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("various options in a QString")
+ {
+ const QString options = "match-case,document,~subdocument";
+
+ for(auto &i : splitOptions(&options)) {
+ REQUIRE(opt.parseAbp(i));
+ }
+
+ WHEN("match-case")
+ {
+ REQUIRE(opt.matchcase);
+ }
+
+ WHEN("document")
+ {
+ REQUIRE(opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeMainFrame));
+ }
+ WHEN("~subdocument")
+ {
+ REQUIRE(!opt.resource_options.value(QWebEngineUrlRequestInfo::ResourceTypeSubFrame));
+ }
+ }
+}