diff options
Diffstat (limited to 'tests/auto/core')
6 files changed, 134 insertions, 20 deletions
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt new file mode 100644 index 000000000..ee2f010d0 --- /dev/null +++ b/tests/auto/core/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(qwebenginecookiestore) +add_subdirectory(qwebengineurlrequestinterceptor) +if(QT_FEATURE_ssl) + add_subdirectory(qwebengineclientcertificatestore) +endif() diff --git a/tests/auto/core/qwebengineclientcertificatestore/CMakeLists.txt b/tests/auto/core/qwebengineclientcertificatestore/CMakeLists.txt new file mode 100644 index 000000000..18bba2e26 --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/CMakeLists.txt @@ -0,0 +1,21 @@ +qt_internal_add_test(tst_qwebengineclientcertificatestore + SOURCES + tst_qwebengineclientcertificatestore.cpp + LIBRARIES + Qt::WebEngineCore +) + +set(tst_qwebengineclientcertificatestore_resource_files + "resources/certificate.crt" + "resources/certificate1.crt" + "resources/privatekey.key" + "resources/privatekey1.key" +) + +qt_add_resource(tst_qwebengineclientcertificatestore "tst_qwebengineclientcertificatestore" + PREFIX + "/" + FILES + ${tst_qwebengineclientcertificatestore_resource_files} +) + diff --git a/tests/auto/core/qwebenginecookiestore/CMakeLists.txt b/tests/auto/core/qwebenginecookiestore/CMakeLists.txt new file mode 100644 index 000000000..078259ccf --- /dev/null +++ b/tests/auto/core/qwebenginecookiestore/CMakeLists.txt @@ -0,0 +1,23 @@ +include(../../httpserver/httpserver.cmake) +include(../../util/util.cmake) + +qt_internal_add_test(tst_qwebenginecookiestore + SOURCES + tst_qwebenginecookiestore.cpp + LIBRARIES + Qt::WebEngineWidgets + Test::HttpServer + Test::Util +) + +set(tst_qwebenginecookiestore_resource_files + "resources/content.html" + "resources/index.html" +) + +qt_add_resource(tst_qwebenginecookiestore "tst_qwebenginecookiestore" + PREFIX + "/" + FILES + ${tst_qwebenginecookiestore_resource_files} +) diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp index dbd645a83..e056fef8f 100644 --- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp +++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp @@ -26,7 +26,7 @@ ** ****************************************************************************/ -#include "../../widgets/util.h" +#include <util.h> #include <QtTest/QtTest> #include <QtWebEngineCore/qwebenginecallback.h> #include <QtWebEngineCore/qwebenginecookiestore.h> diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/CMakeLists.txt b/tests/auto/core/qwebengineurlrequestinterceptor/CMakeLists.txt new file mode 100644 index 000000000..fa6de9ef5 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/CMakeLists.txt @@ -0,0 +1,41 @@ +include(../../util/util.cmake) +include(../../httpserver/httpserver.cmake) + +qt_internal_add_test(tst_qwebengineurlrequestinterceptor + SOURCES + tst_qwebengineurlrequestinterceptor.cpp + LIBRARIES + Qt::WebEngineWidgets + Test::HttpServer + Test::Util +) + +set(tst_qwebengineurlrequestinterceptor_resource_files + "resources/content.html" + "resources/favicon.html" + "resources/firstparty.html" + "resources/fontawesome.woff" + "resources/icons/favicon.png" + "resources/iframe.html" + "resources/iframe2.html" + "resources/iframe3.html" + "resources/image.html" + "resources/image_in_iframe.html" + "resources/index.html" + "resources/media.html" + "resources/media.mp4" + "resources/media_in_iframe.html" + "resources/resource.html" + "resources/resource_in_iframe.html" + "resources/script.js" + "resources/style.css" + "resources/sw.html" + "resources/sw.js" +) + +qt_add_resource(tst_qwebengineurlrequestinterceptor "tst_qwebengineurlrequestinterceptor" + PREFIX + "/" + FILES + ${tst_qwebengineurlrequestinterceptor_resource_files} +) diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index 34ef111f2..8a6cbb331 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -26,7 +26,7 @@ ** ****************************************************************************/ -#include "../../widgets/util.h" +#include <util.h> #include <QtTest/QtTest> #include <QtWebEngineCore/qwebengineurlrequestinfo.h> #include <QtWebEngineCore/qwebengineurlrequestinterceptor.h> @@ -416,7 +416,8 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl() void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes_data() { - QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/iframe.html")); + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/iframe.html")); QTest::addColumn<QUrl>("requestUrl"); QTest::newRow("ui file") << url; QTest::newRow("ui qrc") << QUrl("qrc:///resources/iframe.html"); @@ -426,8 +427,13 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes() { QFETCH(QUrl, requestUrl); - if (requestUrl.scheme() == "file" && !QDir(TESTS_SOURCE_DIR).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + if (requestUrl.scheme() == "file" + && !QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); QString adjustedUrl = requestUrl.adjusted(QUrl::RemoveFilename).toString(); @@ -461,17 +467,30 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes() void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType_data() { - QUrl firstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/resource_in_iframe.html")); - QUrl styleRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/style.css")); - QUrl scriptRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/script.js")); - QUrl fontRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/fontawesome.woff")); - QUrl xhrRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/test")); - QUrl imageFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/image_in_iframe.html")); - QUrl imageRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/icons/favicon.png")); - QUrl mediaFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/media_in_iframe.html")); - QUrl mediaRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/media.mp4")); - QUrl faviconFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/favicon.html")); - QUrl faviconRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/icons/favicon.png")); + QUrl firstPartyUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/resource_in_iframe.html")); + QUrl styleRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/style.css")); + QUrl scriptRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/script.js")); + QUrl fontRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/fontawesome.woff")); + QUrl xhrRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/test")); + QUrl imageFirstPartyUrl = + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/image_in_iframe.html")); + QUrl imageRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/favicon.png")); + QUrl mediaFirstPartyUrl = + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/media_in_iframe.html")); + QUrl mediaRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/media.mp4")); + QUrl faviconFirstPartyUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon.html")); + QUrl faviconRequestUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/favicon.png")); QTest::addColumn<QUrl>("requestUrl"); QTest::addColumn<QUrl>("firstPartyUrl"); @@ -498,8 +517,12 @@ void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType_data( void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType() { - if (!QDir(TESTS_SOURCE_DIR).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); QFETCH(QUrl, requestUrl); QFETCH(QUrl, firstPartyUrl); QFETCH(int, resourceType); @@ -583,7 +606,8 @@ void tst_QWebEngineUrlRequestInterceptor::customHeaders() { // Create HTTP Server to parse the request. HttpServer httpServer; - httpServer.setResourceDirs({ TESTS_SOURCE_DIR "qwebengineurlrequestinterceptor/resources" }); + httpServer.setResourceDirs({ QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + "/resources" }); QVERIFY(httpServer.start()); QWebEngineProfile profile; @@ -700,7 +724,7 @@ void tst_QWebEngineUrlRequestInterceptor::jsServiceWorker() { HttpServer server; - server.setResourceDirs({ TESTS_SOURCE_DIR "qwebengineurlrequestinterceptor/resources" }); + server.setResourceDirs({ QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/resources" }); QVERIFY(server.start()); QWebEngineProfile profile(QStringLiteral("Test")); |