From 3c6eb1d5a1344bd60e9fc812b999695957d7028a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 13 Jan 2016 15:30:15 +0100 Subject: Fix tst_QQuickWebEngineViewGraphics::showHideShow for OS X Defer the TestView::exposeChanged signal. On OS X exposeEvent is called directly by view->show(). Thus exposeChanged was emitted before signalSpy.wait() was called and the check on wait consequently failed. Change-Id: Ie318f8ddc0d1bcc35a14c73e615798b3e164739c Reviewed-by: Allan Sandfeld Jensen --- .../tst_qquickwebengineviewgraphics.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp index a969993ff..eacd1f87e 100644 --- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp +++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp @@ -52,12 +52,19 @@ class TestView : public QQuickView { Q_OBJECT public: + TestView() + { + connect(this, &TestView::_q_exposeChanged, this, &TestView::exposeChanged, + Qt::QueuedConnection); + } + virtual void exposeEvent(QExposeEvent *e) Q_DECL_OVERRIDE { QQuickView::exposeEvent(e); - emit exposeChanged(); + emit _q_exposeChanged(); } Q_SIGNALS: + void _q_exposeChanged(); void exposeChanged(); }; -- cgit v1.2.3 From 09ff58b1a91a1472b4aa4c644686fb2e46a3b1ca Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 2 Dec 2015 19:38:33 +0100 Subject: 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 --- .../tst_qwebenginecookiestore.cpp | 44 ++++++++++------------ 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'tests') 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) -- cgit v1.2.3 From 7ae7b58955b018aa7294aa07d6ff7754af336f4c Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 3 Dec 2015 15:29:48 +0100 Subject: Remove FilterRequest from qwebenginecookiestore OnCanSetCookie and OnCanGetCookies should both be mapped to API. Since the other call is missing (filter cookies which should be send) remove existing one from 5.6 Change-Id: I4f42c4a1fee6add7a5efffaf4c38877a1f35ce61 Reviewed-by: Allan Sandfeld Jensen --- tests/quicktestbrowser/BrowserWindow.qml | 8 -------- tests/quicktestbrowser/main.cpp | 8 +------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml index 3fcca4aab..cf583c60d 100644 --- a/tests/quicktestbrowser/BrowserWindow.qml +++ b/tests/quicktestbrowser/BrowserWindow.qml @@ -79,7 +79,6 @@ ApplicationWindow { property alias javaScriptEnabled: javaScriptEnabled.checked; property alias errorPageEnabled: errorPageEnabled.checked; property alias pluginsEnabled: pluginsEnabled.checked; - property alias thirdPartyCookiesEnabled: thirdPartyCookiesEnabled.checked; } // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. @@ -254,13 +253,6 @@ ApplicationWindow { checkable: true checked: true } - MenuItem { - id: thirdPartyCookiesEnabled - text: "Third party cookies enabled" - checkable: true - checked: true - onToggled: applicationRoot.thirdPartyCookiesEnabled = checked - } MenuItem { id: offTheRecordEnabled text: "Off The Record" diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp index 61977a018..85a02ab34 100644 --- a/tests/quicktestbrowser/main.cpp +++ b/tests/quicktestbrowser/main.cpp @@ -86,15 +86,9 @@ int main(int argc, char **argv) QObject *rootObject = appEngine.rootObjects().first(); QQuickWebEngineProfile *profile = new QQuickWebEngineProfile(rootObject); - QWebEngineCookieStore *client = profile->cookieStore(); const QMetaObject *rootMeta = rootObject->metaObject(); - int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled"); - Q_ASSERT(index != -1); - QMetaProperty thirdPartyCookiesProperty = rootMeta->property(index); - client->setCookieFilter([rootObject,&thirdPartyCookiesProperty](const QWebEngineCookieStore::FilterRequest&){ return thirdPartyCookiesProperty.read(rootObject).toBool(); }); - - index = rootMeta->indexOfProperty("testProfile"); + int index = rootMeta->indexOfProperty("testProfile"); Q_ASSERT(index != -1); QMetaProperty profileProperty = rootMeta->property(index); profileProperty.write(rootObject, qVariantFromValue(profile)); -- cgit v1.2.3