summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkcookiejar
diff options
context:
space:
mode:
authorJani Hautakangas <jani.hautakangas@nokia.com>2011-06-22 11:38:32 (GMT)
committerJani Hautakangas <jani.hautakangas@nokia.com>2011-06-22 11:38:32 (GMT)
commit14f10211e72f2d04fa7f4e0faa430eb94c1f8f83 (patch)
tree1e8d1e2f758c1090a15123cbcb8f615d867caa47 /tests/auto/qnetworkcookiejar
parente4cce8849bf45be9a111072e3fca7bdf67364e8a (diff)
parent5e80b137d195625c0d57c1c27e5e8464d1ccfa33 (diff)
downloadQt-14f10211e72f2d04fa7f4e0faa430eb94c1f8f83.zip
Qt-14f10211e72f2d04fa7f4e0faa430eb94c1f8f83.tar.gz
Qt-14f10211e72f2d04fa7f4e0faa430eb94c1f8f83.tar.bz2
Merge remote branch 'origin/4.7' into qt-4.8-from-4.7
Conflicts: src/opengl/qgl.cpp src/opengl/qpixmapdata_symbiangl.cpp src/opengl/qwindowsurface_gl.cpp
Diffstat (limited to 'tests/auto/qnetworkcookiejar')
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 1b4256b..d1c376a 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -52,6 +52,7 @@ private slots:
void getterSetter();
void setCookiesFromUrl_data();
void setCookiesFromUrl();
+ void setCookiesFromUrl_50CookiesLimitPerDomain();
void cookiesForUrl_data();
void cookiesForUrl();
void effectiveTLDs_data();
@@ -251,6 +252,46 @@ void tst_QNetworkCookieJar::setCookiesFromUrl()
QVERIFY2(result.isEmpty(), QTest::toString(result));
}
+static bool findCookieName(const QList<QNetworkCookie> &cookieList, const QString &name)
+{
+ foreach(QNetworkCookie cookie, cookieList)
+ if (cookie.name() == name)
+ return true;
+ return false;
+}
+
+void tst_QNetworkCookieJar::setCookiesFromUrl_50CookiesLimitPerDomain()
+{
+ QNetworkCookie cookie;
+ cookie.setValue("value");
+ MyCookieJar jar;
+ QUrl url("http://a.b.c.com");
+
+ for (int i = 0; i < 20; ++i) {
+ // Add a list of 3 domain-matched cookies on each iteration for a total of 60 cookies.
+ QList<QNetworkCookie> cookieList;
+ cookie.setName(QString("CookieNo%1").arg(i*3+1).toAscii());
+ cookie.setDomain("a.b.c.com");
+ cookieList += cookie;
+ cookie.setName(QString("CookieNo%1").arg(i*3+2).toAscii());
+ cookie.setDomain(".b.c.com");
+ cookieList += cookie;
+ cookie.setName(QString("CookieNo%1").arg(i*3+3).toAscii());
+ cookie.setDomain(".c.com");
+ cookieList += cookie;
+ jar.setCookiesFromUrl(cookieList, url);
+
+ int expectedNumCookies = std::min((i+1)*3, 50);
+ QCOMPARE(jar.allCookies().size(), expectedNumCookies);
+ }
+
+ // Verify that the oldest cookies were the ones overwritten.
+ QVERIFY(!findCookieName(jar.allCookies(), "CookieNo1"));
+ QVERIFY(!findCookieName(jar.allCookies(), "CookieNo10"));
+ QVERIFY(findCookieName(jar.allCookies(), "CookieNo11"));
+ QVERIFY(findCookieName(jar.allCookies(), "CookieNo60"));
+}
+
void tst_QNetworkCookieJar::cookiesForUrl_data()
{
QTest::addColumn<QList<QNetworkCookie> >("allCookies");