diff --git a/autotests/adblocktest.cpp b/autotests/adblocktest.cpp index 24158ae60..44ecc7351 100644 --- a/autotests/adblocktest.cpp +++ b/autotests/adblocktest.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2013 David Rosca +* Copyright (C) 2013-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ * ============================================================ */ #include "adblocktest.h" #include "adblockrule.h" +#include "adblocksubscription.h" #include @@ -108,4 +109,16 @@ void AdBlockTest::parseRegExpFilterTest() QCOMPARE(rule_test.parseRegExpFilter(parsedFilter), result); } +void AdBlockTest::ignoreEmptyLinesInSubscriptionTest() +{ + AdBlockSubscription subscription("test-subscription"); + subscription.setFilePath(":autotests/data/adblock_empty_lines.txt"); + subscription.loadSubscription({}); + + QCOMPARE(subscription.allRules().count(), 3); + QCOMPARE(subscription.allRules().at(0)->filter(), QString("filter.com")); + QCOMPARE(subscription.allRules().at(1)->filter(), QString("test")); + QCOMPARE(subscription.allRules().at(2)->isComment(), true); +} + QTEST_GUILESS_MAIN(AdBlockTest) diff --git a/autotests/adblocktest.h b/autotests/adblocktest.h index 304716724..e88759550 100644 --- a/autotests/adblocktest.h +++ b/autotests/adblocktest.h @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2013-2014 David Rosca +* Copyright (C) 2013-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,10 +27,10 @@ class AdBlockTest : public QObject private slots: void isMatchingCookieTest_data(); void isMatchingCookieTest(); - void parseRegExpFilterTest_data(); void parseRegExpFilterTest(); + void ignoreEmptyLinesInSubscriptionTest(); }; #endif // ADBLOCKTEST_H diff --git a/autotests/autotests.qrc b/autotests/autotests.qrc index 20cbc5a25..86b3b7b8b 100644 --- a/autotests/autotests.qrc +++ b/autotests/autotests.qrc @@ -2,5 +2,6 @@ data/basic_page.html data/basic_page2.html + data/adblock_empty_lines.txt diff --git a/autotests/data/adblock_empty_lines.txt b/autotests/data/adblock_empty_lines.txt new file mode 100644 index 000000000..cdcd838c3 --- /dev/null +++ b/autotests/data/adblock_empty_lines.txt @@ -0,0 +1,8 @@ +Title: Empty Lines List +Url: https://kde.org +[Adblock Plus 2.0] + +filter.com +test + +! Comment