From 6501578643062c1eff8c7315565cfd9d991e71cd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 16 Dec 2021 14:33:28 +0100 Subject: Stabilize tst_qwebengineurlrequestinterceptor One of our macOS test machines has become remarkably slower recently. Change-Id: I375c92f9c52054190a79d7793849f2783c98baa8 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 4754121b79ae9129742d141bccf436cf9b30b986) Reviewed-by: Qt Cherry-pick Bot --- .../tst_qwebengineurlrequestinterceptor.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index 94669c4ca..14d045613 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -231,7 +231,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); page.load(QUrl("qrc:///resources/index.html")); - QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); QVariant success = loadSpy.takeFirst().takeFirst(); QVERIFY(success.toBool()); loadSpy.clear(); @@ -247,7 +247,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() interceptor.shouldRedirect = true; page.load(QUrl("qrc:///resources/__placeholder__")); - QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); success = loadSpy.takeFirst().takeFirst(); // The redirection for __placeholder__ should succeed. QVERIFY(success.toBool()); @@ -258,7 +258,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() TestRequestInterceptor observer(/* intercept */ false); profile.setUrlRequestInterceptor(&observer); page.load(QUrl("qrc:///resources/__placeholder__")); - QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); success = loadSpy.takeFirst().takeFirst(); // Since we do not intercept, loading an invalid path should not succeed. QVERIFY(!success.toBool()); @@ -331,7 +331,7 @@ void tst_QWebEngineUrlRequestInterceptor::requestedUrl() page.setUrl(QUrl("qrc:///resources/__placeholder__")); QVERIFY(spy.wait()); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); QVERIFY(interceptor.requestInfos.count() >= 1); QCOMPARE(interceptor.requestInfos.at(0).requestUrl, QUrl("qrc:///resources/content.html")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); @@ -340,14 +340,14 @@ void tst_QWebEngineUrlRequestInterceptor::requestedUrl() interceptor.shouldRedirect = false; page.setUrl(QUrl("qrc:/non-existent.html")); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000); QVERIFY(interceptor.requestInfos.count() >= 3); QCOMPARE(interceptor.requestInfos.at(2).requestUrl, QUrl("qrc:/non-existent.html")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); page.setUrl(QUrl("http://abcdef.abcdef")); - QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 15000); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 20000); QVERIFY(interceptor.requestInfos.count() >= 4); QCOMPARE(interceptor.requestInfos.at(3).requestUrl, QUrl("http://abcdef.abcdef/")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); @@ -444,7 +444,7 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes() QWebEnginePage page(&profile); QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); page.setUrl(requestUrl); - QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); QVERIFY(interceptor.requestInfos.count() >= 1); RequestInfo info = interceptor.requestInfos.at(0); @@ -534,7 +534,7 @@ void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType() QWebEnginePage page(&profile); QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); page.setUrl(firstPartyUrl); - QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); QTRY_COMPARE(interceptor.getUrlRequestForType(static_cast(resourceType)).count(), 1); QList infos = interceptor.getUrlRequestForType(static_cast(resourceType)); @@ -735,7 +735,7 @@ void tst_QWebEngineUrlRequestInterceptor::jsServiceWorker() QVERIFY(loadSync(page.get(), server.url("/sw.html"))); // We expect only one message here, because logging of services workers is not exposed in our API. - QTRY_COMPARE(page->messages.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(page->messages.count(), 1, 20000); QCOMPARE(page->levels.at(0), QWebEnginePage::InfoMessageLevel); QUrl firstPartyUrl = QUrl(server.url().toString() + "sw.js"); @@ -804,7 +804,7 @@ void tst_QWebEngineUrlRequestInterceptor::replaceInterceptor() }); page.setUrl(server.url("/favicon.html")); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000); QTRY_VERIFY(fetchFinished); QString s; QDebug d(&s); @@ -848,7 +848,7 @@ void tst_QWebEngineUrlRequestInterceptor::replaceOnIntercept() }; page.setUrl(server.url("/favicon.html")); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); QTRY_COMPARE(profileInterceptor.requestInfos.size(), 2); // if interceptor for page was replaced on intercept call in profile then, since request first -- cgit v1.2.3 From 1c98e3bd74018d725a958605b21b664041d4e15a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 11 Dec 2021 17:41:19 +0100 Subject: Stabilize tst_QWebEngineCookieStore Centralize and increase the timeout for all QTRY_COMPARE and QTRY_VERIFY to 30s. Change-Id: I582b3694ede65890f2707b50a78d2970e11b3fe8 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 2681f86b2b24440950ea5c254b3d2e2bf8d40688) Reviewed-by: Qt Cherry-pick Bot --- .../tst_qwebenginecookiestore.cpp | 92 +++++++++++----------- 1 file changed, 48 insertions(+), 44 deletions(-) (limited to 'tests') diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp index a712fb288..8b4f17a65 100644 --- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp +++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -35,6 +35,10 @@ #include "httpserver.h" #include "httpreqrep.h" +// locally overwrite the default timeout of QTY_(COMPARE|VERIFY) +#define QWE_TRY_COMPARE(x, y) QTRY_COMPARE_WITH_TIMEOUT(x, y, 30000) +#define QWE_TRY_VERIFY(x) QTRY_VERIFY_WITH_TIMEOUT(x, 30000) + class tst_QWebEngineCookieStore : public QObject { Q_OBJECT @@ -104,22 +108,22 @@ void tst_QWebEngineCookieStore::cookieSignals() page.load(QUrl("qrc:///resources/index.html")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVariant success = loadSpy.takeFirst().takeFirst(); QVERIFY(success.toBool()); - QTRY_COMPARE(cookieAddedSpy.count(), 2); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 2); // 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); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 1); cookieRemovedSpy.clear(); // try removing the other cookie. QNetworkCookie nonSessionCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("CookieWithExpiresField=QtWebEngineCookieTest; path=///resources")).first()); client->deleteCookie(nonSessionCookie, QUrl("qrc:///resources/index.html")); - QTRY_COMPARE(cookieRemovedSpy.count(), 1); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 1); } void tst_QWebEngineCookieStore::setAndDeleteCookie() @@ -140,33 +144,33 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie() client->loadAllCookies(); // /* FIXME remove 'blank' navigation once loadAllCookies api is fixed page.load(QUrl("about:blank")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); // */ // check if pending cookies are set and removed client->setCookie(cookie1); client->setCookie(cookie2); - QTRY_COMPARE(cookieAddedSpy.count(), 2); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 2); client->deleteCookie(cookie1); - QTRY_COMPARE(cookieRemovedSpy.count(), 1); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 1); page.load(QUrl("qrc:///resources/content.html")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 2, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 2); QVariant success = loadSpy.takeFirst().takeFirst(); QVERIFY(success.toBool()); - QTRY_COMPARE(cookieAddedSpy.count(), 2); - QTRY_COMPARE(cookieRemovedSpy.count(), 1); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 2); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 1); cookieAddedSpy.clear(); cookieRemovedSpy.clear(); client->setCookie(cookie3); - QTRY_COMPARE(cookieAddedSpy.count(), 1); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 1); // updating a cookie with an expired 'expires' field should remove the cookie with the same name client->setCookie(expiredCookie3); client->deleteCookie(cookie2); - QTRY_COMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(cookieRemovedSpy.count(), 2); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 1); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 2); } void tst_QWebEngineCookieStore::batchCookieTasks() @@ -185,29 +189,29 @@ void tst_QWebEngineCookieStore::batchCookieTasks() client->loadAllCookies(); // /* FIXME remove 'blank' navigation once loadAllCookies api is fixed page.load(QUrl("about:blank")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); // */ client->setCookie(cookie1); client->setCookie(cookie2); - QTRY_COMPARE(cookieAddedSpy.count(), 2); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 2); page.load(QUrl("qrc:///resources/index.html")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 2, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 2); QVariant success = loadSpy.takeFirst().takeFirst(); QVERIFY(success.toBool()); - QTRY_COMPARE(cookieAddedSpy.count(), 4); - QTRY_COMPARE(cookieRemovedSpy.count(), 0); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 4); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 0); cookieAddedSpy.clear(); cookieRemovedSpy.clear(); client->deleteSessionCookies(); - QTRY_COMPARE(cookieRemovedSpy.count(), 3); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 3); client->deleteAllCookies(); - QTRY_COMPARE(cookieRemovedSpy.count(), 4); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 4); } void tst_QWebEngineCookieStore::basicFilter() @@ -224,19 +228,19 @@ void tst_QWebEngineCookieStore::basicFilter() page.load(QUrl("qrc:///resources/index.html")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); - QTRY_COMPARE(cookieAddedSpy.count(), 2); - QTRY_COMPARE(accessTested.loadAcquire(), 2); // FIXME? + QWE_TRY_COMPARE(cookieAddedSpy.count(), 2); + QWE_TRY_COMPARE(accessTested.loadAcquire(), 2); // FIXME? client->deleteAllCookies(); - QTRY_COMPARE(cookieRemovedSpy.count(), 2); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 2); client->setCookieFilter([&](const QWebEngineCookieStore::FilterRequest &){ ++accessTested; return false; }); page.triggerAction(QWebEnginePage::ReloadAndBypassCache); - QTRY_COMPARE(loadSpy.count(), 1); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); - QTRY_COMPARE(accessTested.loadAcquire(), 4); // FIXME? + QWE_TRY_COMPARE(accessTested.loadAcquire(), 4); // FIXME? // Test cookies are NOT added: QTest::qWait(100); QCOMPARE(cookieAddedSpy.count(), 2); @@ -280,25 +284,25 @@ void tst_QWebEngineCookieStore::basicFilterOverHTTP() QUrl firstPartyUrl = httpServer.url("/test.html"); page.load(firstPartyUrl); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); - QTRY_COMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(accessTested.loadAcquire(), 4); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 1); + QWE_TRY_COMPARE(accessTested.loadAcquire(), 4); QVERIFY(cookieRequestHeader.isEmpty()); - QTRY_COMPARE(serverSpy.count(), 3); + QWE_TRY_COMPARE(serverSpy.count(), 3); page.triggerAction(QWebEnginePage::Reload); - QTRY_COMPARE(loadSpy.count(), 1); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); QVERIFY(!cookieRequestHeader.isEmpty()); - QTRY_COMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(accessTested.loadAcquire(), 6); + QWE_TRY_COMPARE(cookieAddedSpy.count(), 1); + QWE_TRY_COMPARE(accessTested.loadAcquire(), 6); - QTRY_COMPARE(serverSpy.count(), 5); + QWE_TRY_COMPARE(serverSpy.count(), 5); client->deleteAllCookies(); - QTRY_COMPARE(cookieRemovedSpy.count(), 1); + QWE_TRY_COMPARE(cookieRemovedSpy.count(), 1); client->setCookieFilter([&](const QWebEngineCookieStore::FilterRequest &request) { resourceFirstParty.append(qMakePair(request.origin, request.firstPartyUrl)); @@ -306,24 +310,24 @@ void tst_QWebEngineCookieStore::basicFilterOverHTTP() return false; }); page.triggerAction(QWebEnginePage::ReloadAndBypassCache); - QTRY_COMPARE(loadSpy.count(), 1); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); QVERIFY(cookieRequestHeader.isEmpty()); // Test cookies are NOT added: QTest::qWait(100); QCOMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(accessTested.loadAcquire(), 9); + QWE_TRY_COMPARE(accessTested.loadAcquire(), 9); - QTRY_COMPARE(serverSpy.count(), 7); + QWE_TRY_COMPARE(serverSpy.count(), 7); page.triggerAction(QWebEnginePage::Reload); - QTRY_COMPARE(loadSpy.count(), 1); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); QVERIFY(cookieRequestHeader.isEmpty()); QCOMPARE(cookieAddedSpy.count(), 1); // Wait for last GET /favicon.ico - QTRY_COMPARE(serverSpy.count(), 9); + QWE_TRY_COMPARE(serverSpy.count(), 9); (void) httpServer.stop(); QCOMPARE(resourceFirstParty.size(), accessTested.loadAcquire()); @@ -344,17 +348,17 @@ void tst_QWebEngineCookieStore::html5featureFilter() page.load(QUrl("qrc:///resources/content.html")); - QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 30000); + QWE_TRY_COMPARE(loadSpy.count(), 1); QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); QCOMPARE(accessTested.loadAcquire(), 0); // FIXME? QTest::ignoreMessage(QtCriticalMsg, QRegularExpression(".*Uncaught SecurityError.*sessionStorage.*")); page.runJavaScript("sessionStorage.test = 5;"); - QTRY_COMPARE(accessTested.loadAcquire(), 1); + QWE_TRY_COMPARE(accessTested.loadAcquire(), 1); QTest::ignoreMessage(QtCriticalMsg, QRegularExpression(".*Uncaught SecurityError.*sessionStorage.*")); QAtomicInt callbackTriggered = 0; page.runJavaScript("sessionStorage.test", [&](const QVariant &v) { QVERIFY(!v.isValid()); callbackTriggered = 1; }); - QTRY_VERIFY(callbackTriggered); + QWE_TRY_VERIFY(callbackTriggered); } QTEST_MAIN(tst_QWebEngineCookieStore) -- cgit v1.2.3 From 30113ef46fbeb2a063df29ec3ef14bdb0d22fc5b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Sun, 19 Dec 2021 20:32:46 +0100 Subject: Blacklist failing tests on macos Seems to have started failing while the team is on holiday Change-Id: Id47f5c328ae105305c883f9ce00fea36199830d6 Reviewed-by: Jani Heikkinen (cherry picked from commit 4b6d5daf527a565bd659668d63a1d14fad0acb27) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/qwebenginepage/BLACKLIST | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index 0c84b8de1..7eb97b3bb 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -7,3 +7,9 @@ macos # Can't move cursor (QTBUG-76312) [acceptNavigationRequestNavigationType] b2qt arm + +[comboBoxPopupPositionAfterMove] +macos + +[comboBoxPopupPositionAfterChildMove] +macos -- cgit v1.2.3 From bc9677e43afd9a566cce08420c86ac322fb81259 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 22 Dec 2021 11:24:09 +0100 Subject: Increase timeout to help slow CI Change-Id: I5f0dd43e0c1eb6bc43f263227b12ec0e1b9f7a20 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 4cc4f765a9cfc11668c6274dfe77153a68ff1ec5) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/quick/inspectorserver/tst_inspectorserver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp index 7b85c7348..8aa88b34d 100644 --- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp +++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp @@ -121,7 +121,7 @@ void tst_InspectorServer::testPageList() + QLatin1String("/html/basic_page.html")); QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo))); webView()->setUrl(testPageUrl); - QTRY_VERIFY(loadSpy.size() && !webView()->isLoading()); + QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000); // Our page has developerExtrasEnabled and should be the only one in the list. QJsonArray pageList = fetchPageList(); @@ -135,7 +135,7 @@ void tst_InspectorServer::testRemoteDebuggingMessage() + QLatin1String("/html/basic_page.html")); QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo))); webView()->setUrl(testPageUrl); - QTRY_VERIFY(loadSpy.size() && !webView()->isLoading()); + QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000); QJsonArray pageList = fetchPageList(); QCOMPARE(pageList.size(), 1); @@ -170,7 +170,7 @@ void tst_InspectorServer::openRemoteDebuggingSession() + QLatin1String("/html/basic_page.html")); QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo))); webView()->setUrl(testPageUrl); - QTRY_VERIFY(loadSpy.size() && !webView()->isLoading()); + QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000); QJsonArray pageList = fetchPageList(); QCOMPARE(pageList.size(), 1); -- cgit v1.2.3 From 594c8595553ec302a3852e6bf55425023c5897c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Wed, 22 Dec 2021 00:58:52 +0100 Subject: Blacklist tst_InspectorServer::openRemoteDebuggingSession It is causing trouble on some (more) platforms. Might be a regression in qtdeclarative. Change-Id: If0195abe085f1f4cf59864fa89c9611da4f213ec Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/inspectorserver/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/inspectorserver/BLACKLIST b/tests/auto/quick/inspectorserver/BLACKLIST index 076dd5f10..318dae7a5 100644 --- a/tests/auto/quick/inspectorserver/BLACKLIST +++ b/tests/auto/quick/inspectorserver/BLACKLIST @@ -1,2 +1,2 @@ [openRemoteDebuggingSession] -macos +* -- cgit v1.2.3 From 387a5ee0c35364f6b4c9ce3bd3d50f5b825626ca Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Tue, 30 Nov 2021 13:01:39 +0100 Subject: Cleanup code and clang build warnings Fix build noise as reported by clang for issues like api deprecation, unused variables, sign/unsigned mismatch and other non critical issues. Change-Id: I4fba25406eea8170e3283c42e908ae86bd512e3a Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 02d58a067fb5f0db32c254e783170f9f283aeb9d) Reviewed-by: Michal Klocek --- tests/auto/core/origins/tst_origins.cpp | 5 +++-- tests/auto/quick/qmltests/tst_qmltests.cpp | 19 +++++++------------ .../widgets/qwebenginescript/tst_qwebenginescript.cpp | 2 +- .../widgets/qwebengineview/tst_qwebengineview.cpp | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/auto/core/origins/tst_origins.cpp b/tests/auto/core/origins/tst_origins.cpp index ac937037f..1731bee8a 100644 --- a/tests/auto/core/origins/tst_origins.cpp +++ b/tests/auto/core/origins/tst_origins.cpp @@ -200,8 +200,9 @@ private: if (url.path().startsWith("/qtwebchannel/")) pathPrefix = QSL(":"); QString pathSuffix = url.path(); - QFile *file = new QFile(pathPrefix + pathSuffix, job); + auto file = std::make_unique(pathPrefix + pathSuffix, job); if (!file->open(QIODevice::ReadOnly)) { + qWarning() << "Failed to read data for:" << url << file->errorString(); job->fail(QWebEngineUrlRequestJob::RequestFailed); return; } @@ -210,7 +211,7 @@ private: mimeType = QBAL("application/javascript"); else if (pathSuffix.endsWith(QSL(".css"))) mimeType = QBAL("text/css"); - job->reply(mimeType, file); + job->reply(mimeType, file.release()); } QList m_requests; diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 00c6478e9..967cabfec 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -251,22 +251,17 @@ int main(int argc, char **argv) sigaction(SIGSEGV, &sigAction, 0); #endif - QScopedPointer app; + QtWebEngineQuick::initialize(); // Force to use English language for testing due to error message checks QLocale::setDefault(QLocale("en")); static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; - QList w_argv(argc); \ - for (int i = 0; i < argc; ++i) \ - w_argv[i] = argv[i]; \ - for (int i = 0; i < params.size(); ++i) \ - w_argv.append(params[i].data()); \ - int w_argc = w_argv.size(); \ - - if (!QCoreApplication::instance()) { - app.reset(new Application(w_argc, const_cast(w_argv.data()))); - } - QtWebEngineQuick::initialize(); + QList w_argv(argc); + for (int i = 0; i < argc; ++i) w_argv[i] = argv[i]; + for (int i = 0; i < params.size(); ++i) w_argv.append(params[i].data()); + int w_argc = w_argv.size(); + Application app(w_argc, const_cast(w_argv.data())); + QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); qmlRegisterType("Test.util", 1, 0, "TempDir"); qmlRegisterType("Test.util", 1, 0, "TestInputContext"); diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index 5df9f035f..26ba71ae3 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -218,7 +218,7 @@ void tst_QWebEngineScript::loadEvents() // Using window.open from JS QVERIFY(profile.pages.size() == 1); page.load(QUrl("qrc:/resources/test_window_open.html")); - QTRY_COMPARE(profile.pages.size(), 2); + QTRY_COMPARE(profile.pages.size(), 2u); QTRY_COMPARE(profile.pages.front().spy.count(), 1); QTRY_COMPARE(profile.pages.back().spy.count(), 1); QVERIFY(verifyOrder(profile.pages.front().eval("window.log", QWebEngineScript::MainWorld).toStringList())); diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index d6a945e65..bbd1fbd16 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -592,6 +592,7 @@ void tst_QWebEngineView::focusInputTypes() class KeyEventRecordingWidget : public QWidget { public: + ~KeyEventRecordingWidget() { qDeleteAll(pressEvents); qDeleteAll(releaseEvents); } QList pressEvents; QList releaseEvents; void keyPressEvent(QKeyEvent *e) override { pressEvents << e->clone(); } @@ -1676,11 +1677,10 @@ void tst_QWebEngineView::postData() void tst_QWebEngineView::inputFieldOverridesShortcuts() { + QWebEngineView view; bool actionTriggered = false; - QAction *action = new QAction; + QAction *action = new QAction(&view); connect(action, &QAction::triggered, [&actionTriggered] () { actionTriggered = true; }); - - QWebEngineView view; view.addAction(action); QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool))); -- cgit v1.2.3 From 90983b3b673f0af1d862051c542bcb56387eee87 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 Dec 2021 10:58:59 +0100 Subject: QtPdf: add a very rudimentary test for QPdfSelection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as part of tst_QPdfDocument. The smaller QtPdf classes should probably all have their own tests. The existing tests are far from being sufficient. Change-Id: I01ff2b7abbdbe43ee596d682c256001539fde1bf Reviewed-by: Fabian Kosmale Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Shawn Rutledge (cherry picked from commit 154cb38a7744c1cb46e9c2194c696724936beacd) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp index 24c4e988d..a0f73bb88 100644 --- a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp +++ b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp @@ -69,12 +69,23 @@ private slots: void status(); void passwordClearedOnClose(); void metaData(); + +private: + void consistencyCheck(QPdfDocument &doc) const; }; struct TemporaryPdf: public QTemporaryFile { TemporaryPdf(); QPageLayout pageLayout; + + static QString pageText(int page) { + switch (page) { + case 0: return QStringLiteral("Hello Page 1"); + case 1: return QStringLiteral("Hello Page 2"); + default: return {}; + } + } }; @@ -91,9 +102,9 @@ TemporaryPdf::TemporaryPdf() { QPainter painter(&printer); - painter.drawText(100, 100, QStringLiteral("Hello Page 1")); + painter.drawText(100, 100, pageText(0)); printer.newPage(); - painter.drawText(100, 100, QStringLiteral("Hello Page 2")); + painter.drawText(100, 100, pageText(1)); } } @@ -130,6 +141,19 @@ void tst_QPdfDocument::loadFromIODevice() QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); + + consistencyCheck(doc); +} + +void tst_QPdfDocument::consistencyCheck(QPdfDocument &doc) const +{ + for (int i = 0; i < doc.pageCount(); ++i) { + const QString expected = TemporaryPdf::pageText(i); + QPdfSelection page = doc.getAllText(i); + QCOMPARE(page.text(), expected); + auto pageMoved = std::move(page); + QCOMPARE(pageMoved.text(), expected); + } } void tst_QPdfDocument::loadAsync() @@ -153,6 +177,8 @@ void tst_QPdfDocument::loadAsync() QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); + + consistencyCheck(doc); } void tst_QPdfDocument::password() @@ -192,6 +218,10 @@ void tst_QPdfDocument::close() statusChangedSpy.clear(); pageCountChangedSpy.clear(); + consistencyCheck(doc); + if (QTest::currentTestFailed()) + return; + doc.close(); QCOMPARE(statusChangedSpy.count(), 2); QCOMPARE(statusChangedSpy[0][0].value(), QPdfDocument::Unloading); @@ -235,6 +265,8 @@ void tst_QPdfDocument::loadAfterClose() QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); + + consistencyCheck(doc); } void tst_QPdfDocument::closeOnDestroy() -- cgit v1.2.3 From bcb7ab3412275f97d71baa819c1f715a8e225bf1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 5 Jan 2022 14:30:32 +0100 Subject: Add objectName to webengine accessibility objects This requires adding a QObject to represent the backing node. Fixes: QTBUG-99485 Change-Id: I4d8c722a0dfb1f374995f3feab23b93ed5d8752a Reviewed-by: Kirill Burtsev (cherry picked from commit d95f6a6b23e3052c39a32f50d6e604cf17e698e3) Reviewed-by: Qt Cherry-pick Bot --- .../widgets/accessibility/tst_accessibility.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp index 054559f13..4429ff8bf 100644 --- a/tests/auto/widgets/accessibility/tst_accessibility.cpp +++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp @@ -48,6 +48,8 @@ private Q_SLOTS: void value(); void roles_data(); void roles(); + void objectName(); + void crossTreeParent(); }; // This will be called before the first test function is executed. @@ -552,6 +554,57 @@ void tst_Accessibility::roles() QCOMPARE(element->role(), role); } +void tst_Accessibility::objectName() +{ + QWebEngineView webView; + QSignalSpy spyFinished(&webView, &QWebEngineView::loadFinished); + webView.setHtml("

"); + webView.show(); + QVERIFY(spyFinished.wait()); + QAccessibleInterface *view = QAccessible::queryAccessibleInterface(&webView); + QAccessibleInterface *document = view->child(0); + QTRY_COMPARE(document->childCount(), 1); + QAccessibleInterface *p = document->child(0); + QVERIFY(p); + QVERIFY(p->object()); + QCOMPARE(p->role(), QAccessible::Paragraph); + QCOMPARE(p->object()->objectName(), QStringLiteral("my_id")); +} + +void tst_Accessibility::crossTreeParent() +{ + QWebEngineView webView; + QSignalSpy spyFinished(&webView, &QWebEngineView::loadFinished); + webView.setHtml(""); + webView.show(); + QVERIFY(spyFinished.wait()); + QAccessibleInterface *view = QAccessible::queryAccessibleInterface(&webView); + QAccessibleInterface *document = view->child(0); + QCOMPARE(document->role(), QAccessible::WebDocument); + QTRY_COMPARE(document->childCount(), 1); + QAccessibleInterface *p = document->child(0); + QVERIFY(p); + QCOMPARE(p->parent(), document); + p = p->child(0); + QVERIFY(p); + QCOMPARE(p->role(), QAccessible::WebDocument); + QCOMPARE(p->parent()->parent(), document); + QTRY_COMPARE(p->childCount(), 1); + p = p->child(0); + QVERIFY(p); + QAccessibleInterface *subdocument = p; + QCOMPARE(p->role(), QAccessible::WebDocument); + QCOMPARE(p->parent()->parent()->parent(), document); + p = p->child(0); + QVERIFY(p); + QVERIFY(p->object()); + QCOMPARE(p->role(), QAccessible::Paragraph); + QCOMPARE(p->parent(), subdocument); + QCOMPARE(p->parent()->parent()->parent()->parent(), document); + QCOMPARE(p->parent()->parent()->parent()->parent()->parent(), view); + QCOMPARE(p->object()->objectName(), QStringLiteral("my_id")); +} + static QByteArrayList params = QByteArrayList() << "--force-renderer-accessibility" << "--enable-features=AccessibilityExposeARIAAnnotations"; -- cgit v1.2.3 From 077c5dcb7088b694cdc03b21bb7201a46b12ce43 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Wed, 17 Nov 2021 15:08:14 +0100 Subject: Widgets: Add FileSelectionMode::FileSelectSave Now we have an example to trigger this type of dialog, we can expose this as public API. Change-Id: If0964d07a532daaff5e798dac63dc02ec7781d4d Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 99b46c0959ec6280ee51c0d9ef8df432fd96a5bc) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index c86e89b42..d95c246fc 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -4758,6 +4758,8 @@ void tst_QWebEnginePage::testChooseFilesParameters_data() << QWebEnginePage::FileSelectOpenMultiple << QStringList(); QTest::addRow("Folder upload") << QString("multiple webkitdirectory") << QString() << QWebEnginePage::FileSelectUploadFolder << QStringList(); + QTest::addRow("Save file") << QString("") << QString() + << QWebEnginePage::FileSelectSave << QStringList(); mimeTypes = QStringList() << "audio/*"; QTest::addRow("MIME type: audio") << QString() << QString("accept='%1'").arg(mimeTypes.join(',')) << QWebEnginePage::FileSelectOpen << mimeTypes; @@ -4791,9 +4793,16 @@ void tst_QWebEnginePage::testChooseFilesParameters() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - page.setHtml(QString("" - "" - "").arg(uploadAttribute, mimeTypeAttribute)); + if (expectedFileSelectionMode != QWebEnginePage::FileSelectSave) { + page.setHtml(QString("" + "" + "").arg(uploadAttribute, mimeTypeAttribute)); + } else { + page.setHtml(QString("" + "