summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-12-02 19:38:33 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-01-15 22:06:53 +0000
commit09ff58b1a91a1472b4aa4c644686fb2e46a3b1ca (patch)
treed3c77a3034e4ddc349150f5e38a686fd569457dd /tests
parent50c423267ee54020a7ddbe3a0f56ddca4653c40a (diff)
Remove callback functions from qwebenginecookiestore
Remove all callback api calls, rename getAllCookies to loadCookies, update documentation. New function name reflects the fact the cookieAdded signal is always emitted when cookies are loaded from the store. Change-Id: Iab7bb04871c7396d2e23306a10084d425426a19f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
index 9436b093e..7cf55427e 100644
--- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
+++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
@@ -95,6 +95,7 @@ void tst_QWebEngineCookieStore::cookieSignals()
{
QWebEngineView view;
QWebEngineCookieStore *client = view.page()->profile()->cookieStore();
+ client->deleteAllCookies();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
@@ -110,6 +111,7 @@ void tst_QWebEngineCookieStore::cookieSignals()
// try whether updating a cookie to be expired results in that cookie being removed.
QNetworkCookie expiredCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
client->setCookie(expiredCookie, QUrl("qrc:///resources/index.html"));
+
QTRY_COMPARE(cookieRemovedSpy.count(), 1);
cookieRemovedSpy.clear();
@@ -123,6 +125,7 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie()
{
QWebEngineView view;
QWebEngineCookieStore *client = view.page()->profile()->cookieStore();
+ client->deleteAllCookies();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
@@ -134,8 +137,10 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie()
QNetworkCookie expiredCookie3(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
// check if pending cookies are set and removed
- client->setCookieWithCallback(cookie1, [](bool success) { QVERIFY(success); });
- client->setCookieWithCallback(cookie2, [](bool success) { QVERIFY(success); });
+ client->setCookie(cookie1);
+ QTRY_COMPARE(cookieAddedSpy.count(),1);
+ client->setCookie(cookie2);
+ QTRY_COMPARE(cookieAddedSpy.count(),2);
client->deleteCookie(cookie1);
view.load(QUrl("qrc:///resources/content.html"));
@@ -148,9 +153,10 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie()
cookieAddedSpy.clear();
cookieRemovedSpy.clear();
- client->setCookieWithCallback(cookie3, [](bool success) { QVERIFY(success); });
+ client->setCookie(cookie3);
+ QTRY_COMPARE(cookieAddedSpy.count(), 1);
// updating a cookie with an expired 'expires' field should remove the cookie with the same name
- client->setCookieWithCallback(expiredCookie3, [](bool success) { QVERIFY(success); });
+ client->setCookie(expiredCookie3);
client->deleteCookie(cookie2);
QTRY_COMPARE(cookieAddedSpy.count(), 1);
QTRY_COMPARE(cookieRemovedSpy.count(), 2);
@@ -160,6 +166,7 @@ void tst_QWebEngineCookieStore::batchCookieTasks()
{
QWebEngineView view;
QWebEngineCookieStore *client = view.page()->profile()->cookieStore();
+ client->deleteAllCookies();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
@@ -168,10 +175,10 @@ void tst_QWebEngineCookieStore::batchCookieTasks()
QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first());
QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first());
- int capture = 0;
-
- client->setCookieWithCallback(cookie1, [&capture](bool success) { QVERIFY(success); ++capture; });
- client->setCookieWithCallback(cookie2, [&capture](bool success) { QVERIFY(success); ++capture; });
+ client->setCookie(cookie1);
+ QTRY_COMPARE(cookieAddedSpy.count(), 1);
+ client->setCookie(cookie2);
+ QTRY_COMPARE(cookieAddedSpy.count(), 2);
view.load(QUrl("qrc:///resources/index.html"));
@@ -180,28 +187,15 @@ void tst_QWebEngineCookieStore::batchCookieTasks()
QVERIFY(success.toBool());
QTRY_COMPARE(cookieAddedSpy.count(), 4);
QTRY_COMPARE(cookieRemovedSpy.count(), 0);
- QTRY_COMPARE(capture, 2);
- capture = 0;
cookieAddedSpy.clear();
cookieRemovedSpy.clear();
- client->getAllCookies([&capture](const QByteArray& cookieLine) {
- ++capture;
- QCOMPARE(QNetworkCookie::parseCookies(cookieLine).count(), 4);
- });
-
- client->deleteSessionCookiesWithCallback([&capture](int numDeleted) {
- ++capture;
- QCOMPARE(numDeleted, 3);
- });
-
- client->deleteAllCookiesWithCallback([&capture](int numDeleted) {
- ++capture;
- QCOMPARE(numDeleted, 1);
- });
+ client->deleteSessionCookies();
+ QTRY_COMPARE(cookieRemovedSpy.count(), 3);
- QTRY_COMPARE(capture, 3);
+ client->deleteAllCookies();
+ QTRY_COMPARE(cookieRemovedSpy.count(), 4);
}
QTEST_MAIN(tst_QWebEngineCookieStore)