1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

AdBlockTest: Add ignoreEmptyLinesInSubscriptionTest

This commit is contained in:
David Rosca 2018-02-14 09:13:10 +01:00
parent a3409d2e8f
commit 99eb9c8089
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
4 changed files with 25 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2013 David Rosca <nowrep@gmail.com> * Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +17,7 @@
* ============================================================ */ * ============================================================ */
#include "adblocktest.h" #include "adblocktest.h"
#include "adblockrule.h" #include "adblockrule.h"
#include "adblocksubscription.h"
#include <QtTest/QtTest> #include <QtTest/QtTest>
@ -108,4 +109,16 @@ void AdBlockTest::parseRegExpFilterTest()
QCOMPARE(rule_test.parseRegExpFilter(parsedFilter), result); 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) QTEST_GUILESS_MAIN(AdBlockTest)

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com> * Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,10 +27,10 @@ class AdBlockTest : public QObject
private slots: private slots:
void isMatchingCookieTest_data(); void isMatchingCookieTest_data();
void isMatchingCookieTest(); void isMatchingCookieTest();
void parseRegExpFilterTest_data(); void parseRegExpFilterTest_data();
void parseRegExpFilterTest(); void parseRegExpFilterTest();
void ignoreEmptyLinesInSubscriptionTest();
}; };
#endif // ADBLOCKTEST_H #endif // ADBLOCKTEST_H

View File

@ -2,5 +2,6 @@
<qresource prefix="/autotests"> <qresource prefix="/autotests">
<file>data/basic_page.html</file> <file>data/basic_page.html</file>
<file>data/basic_page2.html</file> <file>data/basic_page2.html</file>
<file>data/adblock_empty_lines.txt</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,8 @@
Title: Empty Lines List
Url: https://kde.org
[Adblock Plus 2.0]
filter.com
test
! Comment