From e0780b7779d5ac7e47fcd80e3734d254e1d27d3d Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 6 Mar 2014 17:07:58 +0100 Subject: [PATCH] [CookiesTest] Make the test pass after last commit --- src/lib/cookies/cookiejar.h | 6 ++++-- tests/autotests/cookiestest.cpp | 18 +++++++++++++++--- tests/autotests/cookiestest.h | 26 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/lib/cookies/cookiejar.h b/src/lib/cookies/cookiejar.h index d860214ca..6d82d8734 100644 --- a/src/lib/cookies/cookiejar.h +++ b/src/lib/cookies/cookiejar.h @@ -49,11 +49,13 @@ public: private slots: void saveCookies(); -private: - bool rejectCookie(const QString &domain, const QNetworkCookie &cookie) const; +protected: bool matchDomain(QString cookieDomain, QString siteDomain) const; bool listMatchesDomain(const QStringList &list, const QString &cookieDomain) const; +private: + bool rejectCookie(const QString &domain, const QNetworkCookie &cookie) const; + bool m_allowCookies; bool m_filterTrackingCookie; bool m_blockThirdParty; diff --git a/tests/autotests/cookiestest.cpp b/tests/autotests/cookiestest.cpp index cef64ec47..1cc4ea43f 100644 --- a/tests/autotests/cookiestest.cpp +++ b/tests/autotests/cookiestest.cpp @@ -16,9 +16,21 @@ * along with this program. If not, see . * ============================================================ */ #include "cookiestest.h" -#include "cookiejar.h" +#include "settings.h" #include +#include + +void CookiesTest::initTestCase() +{ + Settings::createSettings(QDir::tempPath() + "/QupZilla-test.ini"); + m_cookieJar = new CookieJar_Tst; +} + +void CookiesTest::cleanupTestCase() +{ + delete m_cookieJar; +} void CookiesTest::domainMatchingTest_data() { @@ -50,7 +62,7 @@ void CookiesTest::domainMatchingTest() QFETCH(QString, siteDomain); QFETCH(bool, result); - QCOMPARE(CookieJar::matchDomain(cookieDomain, siteDomain), result); + QCOMPARE(m_cookieJar->matchDomain(cookieDomain, siteDomain), result); } void CookiesTest::listMatchesDomainTest_data() @@ -82,5 +94,5 @@ void CookiesTest::listMatchesDomainTest() QFETCH(QString, cookieDomain); QFETCH(bool, result); - QCOMPARE(CookieJar::listMatchesDomain(list, cookieDomain), result); + QCOMPARE(m_cookieJar->listMatchesDomain(list, cookieDomain), result); } diff --git a/tests/autotests/cookiestest.h b/tests/autotests/cookiestest.h index 4bd06bcf7..d19f9b9ac 100644 --- a/tests/autotests/cookiestest.h +++ b/tests/autotests/cookiestest.h @@ -20,17 +20,43 @@ #include +#include "cookiejar.h" + +class CookieJar_Tst : public CookieJar +{ +public: + explicit CookieJar_Tst() + : CookieJar(QString()) + { + } + + bool matchDomain(QString cookieDomain, QString siteDomain) const + { + return CookieJar::matchDomain(cookieDomain, siteDomain); + } + + bool listMatchesDomain(const QStringList &list, const QString &cookieDomain) const + { + return CookieJar::listMatchesDomain(list, cookieDomain); + } +}; + class CookiesTest : public QObject { Q_OBJECT private slots: + void initTestCase(); + void cleanupTestCase(); + void domainMatchingTest_data(); void domainMatchingTest(); void listMatchesDomainTest_data(); void listMatchesDomainTest(); +private: + CookieJar_Tst *m_cookieJar; }; #endif // COOKIESTEST_H