From f7ed63179fa4f99322d6c7716e17466ec4e3e4ce Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 23 Dec 2017 16:45:31 +0100 Subject: Request filter now properly takes hostlists - hostslist directory is set in browser.filterPath --- lib/adblock/test/filtertest.cpp | 71 ----------------------------------------- lib/adblock/test/filtertest.h | 36 --------------------- lib/adblock/test/main.cpp | 12 ------- 3 files changed, 119 deletions(-) delete mode 100644 lib/adblock/test/filtertest.cpp delete mode 100644 lib/adblock/test/filtertest.h delete mode 100644 lib/adblock/test/main.cpp (limited to 'lib/adblock/test') diff --git a/lib/adblock/test/filtertest.cpp b/lib/adblock/test/filtertest.cpp deleted file mode 100644 index 76e607b..0000000 --- a/lib/adblock/test/filtertest.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "filtertest.h" -#include -#include "../filterrule.h" -#include - -FilterTest::FilterTest(QObject *parent) : QObject(parent) -{ -} - -void FilterTest::initTestCase() -{ - addressRule = new FilterRule("/banner/*/img^"); - QVERIFY(addressRule->isValid() == true); - QVERIFY(addressRule->isException() == false); - - domainRule = new FilterRule("||ads.example.com^"); - QVERIFY(domainRule->isValid() == true); - QVERIFY(domainRule->isException() == false); - - exactAddressRule = new FilterRule("|http://example.com/|"); - QVERIFY(exactAddressRule->isValid() == true); - QVERIFY(exactAddressRule->isException() == false); -} - -void FilterTest::testAddressBlock() -{ - // This rule blocks: - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner/foo/img")) == true); - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner/foo/bar/img?param")) == true); - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner//img/foo")) == true); - - // This rule doesn't block: - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner/img")) == false); - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner/foo/imgraph")) == false); - QVERIFY(addressRule->shouldBlock(QUrl("http://example.com/banner/foo/img.gif")) == false); -} - -void FilterTest::testDomainBlock() -{ - // This rule blocks: - QVERIFY(domainRule->shouldBlock(QUrl("http://ads.example.com/foo.gif")) == true); - QVERIFY(domainRule->shouldBlock(QUrl("http://server1.ads.example.com/foo.gif")) == true); - QVERIFY(domainRule->shouldBlock(QUrl("https://ads.example.com:8000/")) == true); - - // This rule doesn't block: - QVERIFY(domainRule->shouldBlock(QUrl("http://ads.example.com.ua/foo.gif")) == false); - QVERIFY(domainRule->shouldBlock(QUrl("http://example.com/redirect/http://ads.example.com/")) == false); -} - -void FilterTest::testExactAddressBlock() -{ - // This rule blocks: - QVERIFY(exactAddressRule->shouldBlock(QUrl("http://example.com/")) == true); - - // This rule doesn't block: - QVERIFY(exactAddressRule->shouldBlock(QUrl("http://example.com/foo.gif")) == false); - QVERIFY(exactAddressRule->shouldBlock(QUrl("http://example.info/redirect/http://example.com/")) == false); -} - -void FilterTest::cleanupTestCase() -{ - delete addressRule; -} diff --git a/lib/adblock/test/filtertest.h b/lib/adblock/test/filtertest.h deleted file mode 100644 index f91c3dd..0000000 --- a/lib/adblock/test/filtertest.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef FILTERTEST_H -#define FILTERTEST_H - -#include - -class FilterRule; -class FilterTest : public QObject -{ - Q_OBJECT -public: - explicit FilterTest(QObject *parent = nullptr); - -signals: - -private slots: - void initTestCase(); - void testAddressBlock(); - void testDomainBlock(); - void testExactAddressBlock(); - void cleanupTestCase(); - -private: - FilterRule *addressRule; - FilterRule *domainRule; - FilterRule *exactAddressRule; -}; - -#endif // FILTERTEST_H diff --git a/lib/adblock/test/main.cpp b/lib/adblock/test/main.cpp deleted file mode 100644 index b8c9dca..0000000 --- a/lib/adblock/test/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include -#include "filtertest.h" - -QTEST_APPLESS_MAIN(FilterTest) -- cgit v1.2.1