aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/test/options.cpp
blob: d0ad4a09d5a34eb1a66b8662ac550c418e5a326b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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));
        }
    }
}