From 566abfa99120652fb1e9190d791fdbbba64d2e0d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 16 Nov 2018 16:26:22 +0100 Subject: Add adblockrule_parse --- test/adblock/adblocktest.cpp | 6 +++++- test/hostlist/hostlisttest.cpp | 4 ++-- test/meson.build | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/adblock/adblocktest.cpp b/test/adblock/adblocktest.cpp index f4d9ce2..871b7ca 100644 --- a/test/adblock/adblocktest.cpp +++ b/test/adblock/adblocktest.cpp @@ -1,11 +1,15 @@ #include "adblocktest.h" #include #include "formats/adblockrule.h" +#include "formats/adblockrule_parse.h" void AdBlockTest::parseRule() { - FilterLeaf *rule = loadRule("spamdomain"); + auto *rule = loadRule("/spamdomain/$domain=spamdomain.com,image"); QCOMPARE(rule != nullptr, true); + QCOMPARE(rule->match(QUrl::fromUserInput("subdomain.spamdomain.com")), true); + QCOMPARE(rule->action().first == FilterLeaf::Block, true); + QCOMPARE(rule->option(QWebEngineUrlRequestInfo::ResourceTypeImage).value(), true); } /*void AdBlockTest::parseList() diff --git a/test/hostlist/hostlisttest.cpp b/test/hostlist/hostlisttest.cpp index 5270118..7f5c954 100644 --- a/test/hostlist/hostlisttest.cpp +++ b/test/hostlist/hostlisttest.cpp @@ -39,9 +39,9 @@ void HostlistTest::checkRules() auto result = tree.match(domain, request); QCOMPARE(result.length(), matches); if(matches > 0) - QCOMPARE(result.constFirst()->action(), action); + QCOMPARE(result.constFirst()->action().first, action); if(action == FilterLeaf::Redirect) - QCOMPARE(result.constFirst()->redirect(), QLatin1Literal("127.0.0.1")); + QCOMPARE(result.constFirst()->action().second, QLatin1Literal("127.0.0.1")); } void HostlistTest::benchmark_parse() diff --git a/test/meson.build b/test/meson.build index 9be99c9..df6a9c9 100644 --- a/test/meson.build +++ b/test/meson.build @@ -3,14 +3,14 @@ adblock = executable('AdblockTest', dependencies: [dep_qt5, dep_urlfilter], sources: ['adblock/adblocktest.cpp', qt5.preprocess(moc_headers: 'adblock/adblocktest.h', dependencies: dep_qt5)] ) -test('urlfilter-adblock', adblock) +test('urlfilter-adblock', adblock, workdir: meson.current_source_dir()) # Hostlist parsing test hostlist = executable('HostlistTest', dependencies: [dep_qt5, dep_urlfilter], sources: ['hostlist/hostlisttest.cpp', qt5.preprocess(moc_headers: 'hostlist/hostlisttest.h', dependencies: dep_qt5)] ) -test('urlfilter-hostlist', hostlist) +test('urlfilter-hostlist', hostlist, workdir: meson.current_source_dir()) # matching algorithms benchmark matcherbenchmark = executable('MatcherBenchmark', -- cgit v1.2.1