summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-02-11 10:03:24 +0100
committerMichal Klocek <michal.klocek@qt.io>2021-05-22 14:10:10 +0200
commit97dcbd4019456b9a1c567faddb0521b7505d80fc (patch)
tree9c77c5640b1563d853c79898cd64d87252fe8c41 /tests/auto/widgets
parentdd523573f2981cc58d4da0ec6e2b061a6172a8eb (diff)
Add tests to the cmake build
Use QT_TESTCASE_SOURCEDIR instead of TESTS_SOURCE_DIR. Introduce Test::HttpServer and Test::Util targets. Query shared data location from server. Clean up "shared" resources. Note QT_TESTCASE_SOURCEDIR must be turned into the canonical form since the user can call on windows: "cmake \path\to\foo" instead of "cmake c:\path\to\foo" which will break all file:// urls. Note this patch breaks qmake builds. Task-number: QTBUG-91760 Change-Id: Ibc1f904ac9acd375d1ff70ff80f0c533497e3f20 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/CMakeLists.txt36
-rw-r--r--tests/auto/widgets/accessibility/CMakeLists.txt9
-rw-r--r--tests/auto/widgets/accessibility/tst_accessibility.cpp2
-rw-r--r--tests/auto/widgets/certificateerror/CMakeLists.txt23
-rw-r--r--tests/auto/widgets/certificateerror/resources/cert.pem64
-rw-r--r--tests/auto/widgets/certificateerror/resources/key.pem27
-rw-r--r--tests/auto/widgets/certificateerror/tst_certificateerror.cpp2
-rw-r--r--tests/auto/widgets/defaultsurfaceformat/CMakeLists.txt20
-rw-r--r--tests/auto/widgets/defaultsurfaceformat/tst_defaultsurfaceformat.cpp2
-rw-r--r--tests/auto/widgets/devtools/CMakeLists.txt7
-rw-r--r--tests/auto/widgets/faviconmanager/CMakeLists.txt29
-rw-r--r--tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp118
-rw-r--r--tests/auto/widgets/loadsignals/CMakeLists.txt60
-rw-r--r--tests/auto/widgets/loadsignals/tst_loadsignals.cpp6
-rw-r--r--tests/auto/widgets/offscreen/CMakeLists.txt22
-rw-r--r--tests/auto/widgets/origins/CMakeLists.txt45
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp85
-rw-r--r--tests/auto/widgets/printing/CMakeLists.txt34
-rw-r--r--tests/auto/widgets/printing/tst_printing.cpp6
-rw-r--r--tests/auto/widgets/proxy/CMakeLists.txt9
-rw-r--r--tests/auto/widgets/proxy/proxy_server.cpp102
-rw-r--r--tests/auto/widgets/proxy/proxy_server.h64
-rw-r--r--tests/auto/widgets/proxypac/CMakeLists.txt46
-rw-r--r--tests/auto/widgets/proxypac/tst_proxypac.cpp8
-rw-r--r--tests/auto/widgets/qwebenginedownloadrequest/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp2
-rw-r--r--tests/auto/widgets/qwebenginehistory/CMakeLists.txt26
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp2
-rw-r--r--tests/auto/widgets/qwebenginepage/CMakeLists.txt61
-rw-r--r--tests/auto/widgets/qwebenginepage/resources/image2.png (renamed from tests/auto/widgets/resources/image2.png)bin14743 -> 14743 bytes
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp28
-rw-r--r--tests/auto/widgets/qwebengineprofile/CMakeLists.txt11
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp4
-rw-r--r--tests/auto/widgets/qwebenginescript/CMakeLists.txt26
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp2
-rw-r--r--tests/auto/widgets/qwebenginesettings/CMakeLists.txt9
-rw-r--r--tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp2
-rw-r--r--tests/auto/widgets/qwebengineview/CMakeLists.txt29
-rw-r--r--tests/auto/widgets/qwebengineview/resources/test.swf (renamed from tests/auto/widgets/resources/test.swf)bin10085 -> 10085 bytes
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp19
-rw-r--r--tests/auto/widgets/schemes/CMakeLists.txt7
-rw-r--r--tests/auto/widgets/shutdown/CMakeLists.txt6
-rw-r--r--tests/auto/widgets/touchinput/CMakeLists.txt10
-rw-r--r--tests/auto/widgets/touchinput/tst_touchinput.cpp2
-rw-r--r--tests/auto/widgets/util.h242
45 files changed, 820 insertions, 505 deletions
diff --git a/tests/auto/widgets/CMakeLists.txt b/tests/auto/widgets/CMakeLists.txt
new file mode 100644
index 000000000..7072329c3
--- /dev/null
+++ b/tests/auto/widgets/CMakeLists.txt
@@ -0,0 +1,36 @@
+if(NOT boot2qt)
+ add_subdirectory(defaultsurfaceformat)
+ add_subdirectory(devtools)
+ add_subdirectory(qwebenginepage)
+ add_subdirectory(qwebengineprofile)
+ add_subdirectory(qwebengineview)
+endif()
+add_subdirectory(faviconmanager)
+add_subdirectory(loadsignals)
+add_subdirectory(origins)
+add_subdirectory(proxy)
+add_subdirectory(proxypac)
+add_subdirectory(schemes)
+add_subdirectory(shutdown)
+add_subdirectory(qwebenginedownloadrequest)
+add_subdirectory(qwebenginehistory)
+add_subdirectory(qwebenginescript)
+add_subdirectory(qwebenginesettings)
+if(LINUX)
+ add_subdirectory(offscreen)
+endif()
+if(NOT MACOS)
+ add_subdirectory(touchinput)
+endif()
+if(QT_FEATURE_accessibility AND NOT boot2qt)
+ add_subdirectory(accessibility)
+endif()
+if(QT_FEATURE_webengine_printing_and_pdf)
+ add_subdirectory(printing)
+endif()
+if(QT_FEATURE_ssl)
+ add_subdirectory(certificateerror)
+endif()
+if(QT_FEATURE_webengine_spellchecker AND NOT CMAKE_CROSSCOMPILING AND NOT QT_FEATURE_webengine_native_spellchecker)
+# add_subdirectory(spellchecking)
+endif()
diff --git a/tests/auto/widgets/accessibility/CMakeLists.txt b/tests/auto/widgets/accessibility/CMakeLists.txt
new file mode 100644
index 000000000..9653ef1c0
--- /dev/null
+++ b/tests/auto/widgets/accessibility/CMakeLists.txt
@@ -0,0 +1,9 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_accessibility
+ SOURCES
+ tst_accessibility.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp
index 46d26e6c6..429a40f4d 100644
--- a/tests/auto/widgets/accessibility/tst_accessibility.cpp
+++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp
@@ -18,7 +18,7 @@
*/
#include <qtest.h>
-#include "../util.h"
+#include <util.h>
#include <QHBoxLayout>
#include <QMainWindow>
diff --git a/tests/auto/widgets/certificateerror/CMakeLists.txt b/tests/auto/widgets/certificateerror/CMakeLists.txt
new file mode 100644
index 000000000..71721e8f5
--- /dev/null
+++ b/tests/auto/widgets/certificateerror/CMakeLists.txt
@@ -0,0 +1,23 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_certificateerror
+ SOURCES
+ tst_certificateerror.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
+
+set(tst_certificateerror_resource_files
+ "resources/cert.pem"
+ "resources/key.pem"
+)
+
+qt_internal_add_resource(tst_certificateerror "tst_certificateerror"
+ PREFIX
+ "/"
+ FILES
+ ${tst_certificateerror_resource_files}
+)
diff --git a/tests/auto/widgets/certificateerror/resources/cert.pem b/tests/auto/widgets/certificateerror/resources/cert.pem
new file mode 100644
index 000000000..3aaaf289c
--- /dev/null
+++ b/tests/auto/widgets/certificateerror/resources/cert.pem
@@ -0,0 +1,64 @@
+-----BEGIN CERTIFICATE-----
+MIIEpDCCAoygAwIBAgIUO90aty9AMjvBvzfUhr1WwdBrKkMwDQYJKoZIhvcNAQEL
+BQAwfzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
+DVNhbiBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEyMDAGA1UEAwwpQmFkU1NM
+IEludGVybWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTkwODI2MTQ0
+NDIxWhcNMTkwODI3MTQ0NDIxWjBjMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2Fs
+aWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEPMA0GA1UECgwGQmFkU1NM
+MRYwFAYDVQQDDA0qLmJhZHNzbC50ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
+MIIBCgKCAQEAkybT/L4zJCqefpd+eYT6aQ0PtobQfFgP+n+z5wWoUxIAJnjb5ZW4
+7IJxka/2/ggzJOfrUBur54LkTfFQ+yX85eKYCuH0GLz+Rve50LDn0ya6qSgmEhDG
+0bend2tMZY+Nl3B+5Ane1vua8hdJjv3ZO3e5UgpQwysL54eYyhEWWlbFWF11LhEd
+MYp953UGLqoV4Mlw+Li8TmFwdKQx6icgBTuloXLzk9aUU+b6NbXdadNXkmzg09IC
+sb8pnMXiF2P9Xm5rK0IoiRkSHxVnU12nQXh65Ns/2Dj5DcbHmVdvallfr4wnLeFP
+UotysZnvFmE7FLMSr/eQfkTG+Jlb7ZhoGwIDAQABozQwMjAJBgNVHRMEAjAAMCUG
+A1UdEQQeMByCDSouYmFkc3NsLnRlc3SCC2JhZHNzbC50ZXN0MA0GCSqGSIb3DQEB
+CwUAA4ICAQA7Yc+QQzqSK15ibmaYrkqq+cumggsWLCprW8jvzhpWBt9IjToP5nsy
+sKinYPoZR8jvZ1YVotcts7uQT7DkqeWkB+l+88c7gQdgujvBo6v9/g+jrXFKgsJD
+IBmkho8hpd63Slqv2Yp4bYT20O5EvR9CQvwSkwTs+ylBNEs1Q+AbekxmBjuYUxHn
+9xL4/GZ6ufoNv676iCoXo4mnDrCD8e8MRiZoU9Lq4G41HGiLWV0tM/M6BdVJYGzl
+FcBg0ZKnQT9OCWEPRe3zyRS6a+MivPAzxS8z/kYaRN+C7H68Mib3xPDsEETz1MnO
+uzGAPHAAgtYWYJi+CaaNWkgAv4n+UIQa0oyqPn4z5hLcsO+nMBws2Sg0mkQLilBX
+N1ciCdVMi7sHKuLa7GVksq/RQrXnZcQhoYQRrZAaAHKbxyo/M2pNqmDiFJppdH7a
+6Rj2vYf6ig/FXAzDGsDvf/tsGCxgJTFzGly+GsWVe40vyjfWHxWWDU/eGjfGO05k
+Xzjm+kYGJnH2hfiIlX1Jeu/jjIodiSy31F0hvuKlJu8PfaQ7oo5neRzwRO6Wq9rR
+7DMsQN6OtXGnnA+ogC0korA+aXev6wzbwYUhzMf1YTzEjrFNIXeIHsQSzq6lPcIE
+JOly5wjyO/eNF7mpHyDX8brY6Hn+bgyDeKAmsUvhOCEXgaPpKlP4gQ==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIGeTCCBGGgAwIBAgIUbVL7tFc7sgPIYnt+REVc0wiHdBcwDQYJKoZIhvcNAQEL
+BQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
+DVNhbiBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEqMCgGA1UEAwwhQmFkU1NM
+IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTE5MDgyNjE0NDQyMFoXDTI5
+MDgyMzE0NDQyMFowfzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
+FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEyMDAGA1UE
+AwwpQmFkU1NMIEludGVybWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIi
+MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgoU4q43DJEUyoAOeK31uyEgLn
+s5CCd6XFmGp6wln0yupwmYRaDiCoSJ1qpmjYt+gIHpDAFS2ZzR4TbZORFirjY0cQ
+6+IWwpBEQR0hOluWN99CqjdCxfuZwiTvTV3FQv1IJZ13g23Uh2xRbnrzC2muDHzT
+4ZNM3aayvziMGY6n33aksEc6WMZb3p/Qn2OepeC7EzZiy4tXKPf9OaOPbae5aJWZ
+bOzzydFLkV4UqZb5FfySt8toIivPeIlRCiPodWLb2y5DYUXyWBk1dpbIcVa/LusV
+vsBELeJ+BFDRH1NHtwOrhOkZHKMr3SQ1YRlNDEeHUVmQkori397j9JjpPzScQJ6r
+d/W4mGyzgRmguIy9IpKMbxX5/1A6c6l5q0HqMgPv84GWxlhav4xwsOf90iT2vLPZ
+yllVCgCsCfvLEyVFhER18HAo8mTkQqKL7ZO96xXHgugA7dFN/C3BdC9kYP/GbAwd
+J0R6qKrfSiyyk1VbjWfFdFH/G/bT9H0nrjMj5tCT4q/zDCb5HkBp3BOoyUKb9yyt
+a1Cht/Iu3f1SlQzsrDBt9iMMCjXoNNAJcV7ZZ6HCxcWwfAwxgylQgq8UG60shxhn
+CBPhcA8JM+mk2nghTU2pxwY/KpAd0H4/a79b0DE97dCOnNHzyP3tqP8RenG549B0
+gsNO60aG01k6P9jFuQIDAQABo4H0MIHxMB0GA1UdDgQWBBQgvWmDuYqQ6xX7y8xc
+cgky1FO7jzCBtAYDVR0jBIGsMIGpgBTUGo+svIaoSMF/shILSbeiQ1zAQKF7pHkw
+dzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNh
+biBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEqMCgGA1UEAwwhQmFkU1NMIFJv
+b3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5ghR1qCPxzkfCSCwMFHm98245f0pk0zAM
+BgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAnGr6
+t1+KNGZV9hmAE3SyMzHRpgwtqIG4kl94A7Pz3CbA8+q7u7DW8l1GdaNx2J2wo+R5
+rJi02V5e7TNa7ZS5S9WGYHZ2y6QOjXuT28VMAPX+3HAgxk3RMxocpLpkPp8hhD/9
+S5KxA6AQDUN6av8E3xeuuWYWmTvAXNHK5ABXDFxxTp902ozNnZaSk2DxAUqcsOD4
+ago0IhRdkFGe1Q7F8gOxtlUL5owNL4uhRP8BbwOja2Gopn2+kA9CNqdwPI4Ipjlr
+yo61oCqzy3RAXOUct8WAvybacADmJODAxDq9O5fAZuYZScjjj1ASowmbyDH/Wb9z
++WfiKKH4BfgOIukzK3I1M9wiSDefIodCFfEVXbdNudZj8f9Gw4RrZwkUuxDLeRWG
+ReDtzAWq7G0Diw3uX40S4jaj3MeS6oHp2Nrj/VyjSRiYTeN/pnA9N0M5VuCYYvXD
+f50rrigjQfOgb4TmnyJAjXWVkXW7Fa+ooLsbvlfr8wP8f31y1cgWPHTVIv6Kmug7
+Bg88k3x5gLTXmutDjseORonhGMRdAxHgJVf5aKfzdRpwXZTDZJXhsAz9OdlOhNZd
+UrYo680QugA0V3H5D8Egbr2AUUSMDkn133COjeOIDknFxX3qDqeTzqLZCAEBIoKn
+Adpix0jvG1Ys4Ayq6K2wQFdGFjtl6LsiGC7pWWU=
+-----END CERTIFICATE-----
diff --git a/tests/auto/widgets/certificateerror/resources/key.pem b/tests/auto/widgets/certificateerror/resources/key.pem
new file mode 100644
index 000000000..89922679a
--- /dev/null
+++ b/tests/auto/widgets/certificateerror/resources/key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAkybT/L4zJCqefpd+eYT6aQ0PtobQfFgP+n+z5wWoUxIAJnjb
+5ZW47IJxka/2/ggzJOfrUBur54LkTfFQ+yX85eKYCuH0GLz+Rve50LDn0ya6qSgm
+EhDG0bend2tMZY+Nl3B+5Ane1vua8hdJjv3ZO3e5UgpQwysL54eYyhEWWlbFWF11
+LhEdMYp953UGLqoV4Mlw+Li8TmFwdKQx6icgBTuloXLzk9aUU+b6NbXdadNXkmzg
+09ICsb8pnMXiF2P9Xm5rK0IoiRkSHxVnU12nQXh65Ns/2Dj5DcbHmVdvallfr4wn
+LeFPUotysZnvFmE7FLMSr/eQfkTG+Jlb7ZhoGwIDAQABAoIBADRXy3BL98UVo+tD
+2ClBtBFKJBy5N9ADQyvH4SZ8TLO/423L7+xqpaz7eYppHWKfaBHorTuBnFRtquhO
+vo+Xo63iPFMirMFf+NMlq2MgilYBoMQrE9+5N//BZECGWlaGCcekrH5RRIMUXLlg
+rzm98lfE7pbQNIo39bQV97NpAJqBWPuoIvCrbRCysGoA5j7ptZ/EhSlC00eA7ybD
+CeYHmh8NrsapKOTGb5u1v3paV8X/mH6vKmsVs7n6LC0opBxzM8eAHEAQ6h8rmz9H
+y99FWDYha3lOS4SLkTnuRnNHOMLJajPq3Isu+BgzLWuRGnKZ3rmuUFwPNkCZTvsV
+dTdBE4ECgYEAw6jBEil0e8Pc9sGqnz93e8qrYE9wSPso4q3BNJgTbN48kon6mqh7
+gQVgEP/75Th5YrJUrY9Pd/8H9uoMOxbDXgOXG/xNnhC0L+7aM8nhKlxCLndY1e56
+/YymYYH4+D9ZD2u526mK/nmCg2QGOkCVYYp7NXe/mA0g34drKjefmj8CgYEAwIhq
+rZhlfAvQThSOqQA9zA7NXPDh4KzIjr8htVu5YvVcv5W2uhsni9DXFaloPnhuLdJ7
+MnPF2WqzQ9YqFrGn/9/OTqeE23f60ed04qLGM4BApb45y5Kw6sCPnWu7dMYfny9i
+XeZA2A+ODmqVkrU+ZNVzqzS1krYyUP3exd1voyUCgYEAqPRARH6np3gqhqoVvA4C
+D1OjSTdPrrWzSIriG5h2rbv6ck/Tp1l1zKPnoMZrrjRmHWQA2x61cNk4926DwUKW
+0cgn5HKqU6P49Ks8oRvi48FnJNjKTXHxoqChy/GAHF4Xecl8ZMKy06v5l5v4BLVg
+SSpb2n/dYl9z05IMaBhAKeECgYBKB2n1S6ah1q0GiLL92mDoiDyAYwKG8AjBkk40
+vIsAuNUruTYkQvKmuOsqohO6CXZb2hWSpZ9KZNN+3ucaCL9PDE/4QEM+W9iuQu/X
+gLzy6npxAD6avtGVweq2ncjbMp7QB1ksP69pJDn74xGV8miGPuiVyNOUEMgyChtR
+Oz6EnQKBgEth0w80CBg6b3NKuASoc/vC08njZQvWpe5xrzY2DL8epVKb1qf6+8SE
+eX34cIcSaonEZ2g67MAeIG6jtmPwxWk4EYAsO1u4XiyziABkoNyLKVH4hZg61BsV
+jL7R5UrUvBbhKLFOwkcB4Kwdwu7COB/UKa5XJBTMbuw1UTyxlUeI
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
index 9865162cb..2f03c3275 100644
--- a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
+++ b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
@@ -86,7 +86,7 @@ void tst_CertificateError::handleError_data()
void tst_CertificateError::handleError()
{
- HttpsServer server;
+ HttpsServer server(":/resources/cert.pem",":/resources/key.pem");
server.setExpectError(true);
QVERIFY(server.start());
diff --git a/tests/auto/widgets/defaultsurfaceformat/CMakeLists.txt b/tests/auto/widgets/defaultsurfaceformat/CMakeLists.txt
new file mode 100644
index 000000000..871c92350
--- /dev/null
+++ b/tests/auto/widgets/defaultsurfaceformat/CMakeLists.txt
@@ -0,0 +1,20 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_defaultsurfaceformat
+ SOURCES
+ tst_defaultsurfaceformat.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
+
+set(tst_defaultsurfaceformat_resource_files
+ "resources/index.html"
+)
+
+qt_add_resource(tst_defaultsurfaceformat "tst_defaultsurfaceformat"
+ PREFIX
+ "/"
+ FILES
+ ${tst_defaultsurfaceformat_resource_files}
+)
diff --git a/tests/auto/widgets/defaultsurfaceformat/tst_defaultsurfaceformat.cpp b/tests/auto/widgets/defaultsurfaceformat/tst_defaultsurfaceformat.cpp
index 697ed3d08..7a52a372a 100644
--- a/tests/auto/widgets/defaultsurfaceformat/tst_defaultsurfaceformat.cpp
+++ b/tests/auto/widgets/defaultsurfaceformat/tst_defaultsurfaceformat.cpp
@@ -27,7 +27,7 @@
****************************************************************************/
#include <qtest.h>
-#include "../util.h"
+#include <util.h>
#include <QSurfaceFormat>
#include <QTimer>
diff --git a/tests/auto/widgets/devtools/CMakeLists.txt b/tests/auto/widgets/devtools/CMakeLists.txt
new file mode 100644
index 000000000..2ef09df12
--- /dev/null
+++ b/tests/auto/widgets/devtools/CMakeLists.txt
@@ -0,0 +1,7 @@
+qt_internal_add_test(tst_devtools
+ SOURCES
+ tst_devtools.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+)
+
diff --git a/tests/auto/widgets/faviconmanager/CMakeLists.txt b/tests/auto/widgets/faviconmanager/CMakeLists.txt
new file mode 100644
index 000000000..89bee5a2a
--- /dev/null
+++ b/tests/auto/widgets/faviconmanager/CMakeLists.txt
@@ -0,0 +1,29 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_faviconmanager
+ SOURCES
+ tst_faviconmanager.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
+
+set(tst_faviconmanager_resource_files
+ "resources/favicon-misc.html"
+ "resources/favicon-multi.html"
+ "resources/favicon-shortcut.html"
+ "resources/favicon-single.html"
+ "resources/favicon-touch.html"
+ "resources/favicon-unavailable.html"
+ "resources/icons/qt144.png"
+ "resources/icons/qt32.ico"
+ "resources/icons/qtmulti.ico"
+ "resources/test1.html"
+)
+
+qt_add_resource(tst_faviconmanager "tst_faviconmanager"
+ PREFIX
+ "/"
+ FILES
+ ${tst_faviconmanager_resource_files}
+)
diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp
index 46038cdc6..8e9bb2470 100644
--- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp
+++ b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp
@@ -27,7 +27,7 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include "../util.h"
+#include <util.h>
#include <qwebenginepage.h>
#include <qwebengineprofile.h>
@@ -97,14 +97,19 @@ void tst_FaviconManager::cleanup()
void tst_FaviconManager::faviconLoad()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-single.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-single.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -113,7 +118,9 @@ void tst_FaviconManager::faviconLoad()
QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
QCOMPARE(iconUrl, m_page->iconUrl());
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qt32.ico")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qt32.ico")));
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
@@ -150,14 +157,20 @@ void tst_FaviconManager::faviconLoadFromResources()
void tst_FaviconManager::faviconLoadEncodedUrl()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QString urlString = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-single.html")).toString();
+ QString urlString = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-single.html"))
+ .toString();
QUrl url(urlString + QLatin1String("?favicon=load should work with#whitespace!"));
m_page->load(url);
@@ -167,7 +180,9 @@ void tst_FaviconManager::faviconLoadEncodedUrl()
QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
QCOMPARE(m_page->iconUrl(), iconUrl);
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qt32.ico")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qt32.ico")));
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
@@ -179,14 +194,19 @@ void tst_FaviconManager::faviconLoadEncodedUrl()
void tst_FaviconManager::noFavicon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/test1.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/test1.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -216,14 +236,19 @@ void tst_FaviconManager::aboutBlank()
void tst_FaviconManager::unavailableFavicon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-unavailable.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-unavailable.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -274,8 +299,12 @@ void tst_FaviconManager::errorPageDisabled()
void tst_FaviconManager::bestFavicon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
@@ -285,7 +314,8 @@ void tst_FaviconManager::bestFavicon()
QIcon icon;
QSize iconSize;
- url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-misc.html"));
+ url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-misc.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -295,7 +325,9 @@ void tst_FaviconManager::bestFavicon()
iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
QCOMPARE(iconUrl, m_page->iconUrl());
// Touch icon is ignored
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qt32.ico")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qt32.ico")));
icon = m_page->icon();
QVERIFY(!icon.isNull());
@@ -308,7 +340,8 @@ void tst_FaviconManager::bestFavicon()
iconUrlChangedSpy.clear();
iconChangedSpy.clear();
- url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-shortcut.html"));
+ url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-shortcut.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -326,7 +359,9 @@ void tst_FaviconManager::bestFavicon()
}
QCOMPARE(iconUrl, m_page->iconUrl());
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qt144.png")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qt144.png")));
icon = m_page->icon();
QVERIFY(!icon.isNull());
@@ -337,14 +372,19 @@ void tst_FaviconManager::bestFavicon()
void tst_FaviconManager::touchIcon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-touch.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-touch.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -357,14 +397,19 @@ void tst_FaviconManager::touchIcon()
void tst_FaviconManager::multiIcon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-multi.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-multi.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -373,7 +418,9 @@ void tst_FaviconManager::multiIcon()
QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
QCOMPARE(m_page->iconUrl(), iconUrl);
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qtmulti.ico")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qtmulti.ico")));
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
@@ -385,14 +432,19 @@ void tst_FaviconManager::multiIcon()
void tst_FaviconManager::candidateIcon()
{
- 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);
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon)));
- QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-shortcut.html"));
+ QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/favicon-shortcut.html"));
m_page->load(url);
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
@@ -401,7 +453,9 @@ void tst_FaviconManager::candidateIcon()
QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
QCOMPARE(m_page->iconUrl(), iconUrl);
- QCOMPARE(iconUrl, QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/icons/qt144.png")));
+ QCOMPARE(iconUrl,
+ QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/resources/icons/qt144.png")));
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
diff --git a/tests/auto/widgets/loadsignals/CMakeLists.txt b/tests/auto/widgets/loadsignals/CMakeLists.txt
new file mode 100644
index 000000000..f648cf6d3
--- /dev/null
+++ b/tests/auto/widgets/loadsignals/CMakeLists.txt
@@ -0,0 +1,60 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_loadsignals
+ SOURCES
+ tst_loadsignals.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
+
+get_target_property(sharedData Test::HttpServer SHARED_DATA)
+
+set_source_files_properties("${sharedData}/loadprogress/downloadable.tar.gz"
+ PROPERTIES QT_RESOURCE_ALIAS "downloadable.tar.gz"
+)
+set_source_files_properties("${sharedData}/loadprogress/page1.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page1.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page2.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page2.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page3.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page3.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page4.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page4.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page5.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page5.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page6.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page6.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page7.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page7.html"
+)
+set_source_files_properties("${sharedData}/loadprogress/page8.html"
+ PROPERTIES QT_RESOURCE_ALIAS "page8.html"
+)
+
+set(tst_loadsignals_resource_files
+ "${sharedData}/loadprogress/downloadable.tar.gz"
+ "${sharedData}/loadprogress/page1.html"
+ "${sharedData}/loadprogress/page2.html"
+ "${sharedData}/loadprogress/page3.html"
+ "${sharedData}/loadprogress/page4.html"
+ "${sharedData}/loadprogress/page5.html"
+ "${sharedData}/loadprogress/page6.html"
+ "${sharedData}/loadprogress/page7.html"
+ "${sharedData}/loadprogress/page8.html"
+)
+
+qt_add_resource(tst_loadsignals "tst_loadsignals"
+ PREFIX
+ "/resources"
+ FILES
+ ${tst_loadsignals_resource_files}
+)
diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
index fe01bede4..12a497dd9 100644
--- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
+++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
@@ -29,7 +29,7 @@
#include <QtTest/QtTest>
#include "httpserver.h"
-#include "../util.h"
+#include <util.h>
#include "qdebug.h"
#include "qwebenginepage.h"
#include "qwebengineprofile.h"
@@ -276,7 +276,7 @@ void tst_LoadSignals::rejectNavigationRequest()
void tst_LoadSignals::monotonicity()
{
HttpServer server;
- server.setResourceDirs({ TESTS_SHARED_DATA_DIR });
+ server.setResourceDirs({ server.sharedDataDir() });
connect(&server, &HttpServer::newRequest, [] (HttpReqRep *) {
QTest::qWait(250); // just add delay to trigger some progress for every sub resource
});
@@ -376,7 +376,7 @@ void tst_LoadSignals::numberOfStartedAndFinishedSignalsIsSame()
QFETCH(QString, imageResourceUrl);
HttpServer server;
- server.setResourceDirs({ TESTS_SOURCE_DIR "/qwebengineprofile/resources" });
+ server.setResourceDirs({ server.sharedDataDir() });
QVERIFY(server.start());
QUrl serverImage = server.url("/hedgehog.png");
diff --git a/tests/auto/widgets/offscreen/CMakeLists.txt b/tests/auto/widgets/offscreen/CMakeLists.txt
new file mode 100644
index 000000000..1ba5a1e6a
--- /dev/null
+++ b/tests/auto/widgets/offscreen/CMakeLists.txt
@@ -0,0 +1,22 @@
+qt_internal_add_test(tst_offscreen
+ SOURCES
+ tst_offscreen.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+)
+
+set(tst_offscreen_resource_files
+ "test.html"
+)
+
+set_tests_properties(tst_offscreen PROPERTIES
+ ENVIRONMENT QT_QPA_PLATFORM=offscreen
+)
+
+qt_add_resource(tst_offscreen "tst_offscreen"
+ PREFIX
+ "/"
+ FILES
+ ${tst_offscreen_resource_files}
+)
+
diff --git a/tests/auto/widgets/origins/CMakeLists.txt b/tests/auto/widgets/origins/CMakeLists.txt
new file mode 100644
index 000000000..5ba017052
--- /dev/null
+++ b/tests/auto/widgets/origins/CMakeLists.txt
@@ -0,0 +1,45 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_origins
+ SOURCES
+ tst_origins.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
+
+set(tst_origins_resource_files
+ "resources/createObjectURL.html"
+ "resources/dedicatedWorker.html"
+ "resources/dedicatedWorker.js"
+ "resources/mixedSchemes.html"
+ "resources/mixedSchemesWithCsp.html"
+ "resources/mixedSchemes_frame.html"
+ "resources/mixedXHR.html"
+ "resources/mixedXHR.txt"
+ "resources/serviceWorker.html"
+ "resources/serviceWorker.js"
+ "resources/sharedWorker.html"
+ "resources/sharedWorker.js"
+ "resources/subdir/frame2.html"
+ "resources/subdir/index.html"
+ "resources/subdir_frame1.html"
+ "resources/viewSource.html"
+ "resources/websocket.html"
+)
+
+qt_add_resource(tst_origins "tst_origins"
+ PREFIX
+ "/"
+ FILES
+ ${tst_origins_resource_files}
+)
+
+qt_extend_target(tst_origins CONDITION QT_FEATURE_webengine_webchannel AND TARGET Qt::WebSockets
+ DEFINES
+ WEBSOCKETS
+ LIBRARIES
+ Qt::WebSockets
+)
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index b9385516f..a834110b5 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "../util.h"
+#include <util.h>
#include "httpserver.h"
#include <QtCore/qfile.h>
@@ -47,7 +47,6 @@
#define QSL QStringLiteral
#define QBAL QByteArrayLiteral
-#define THIS_DIR TESTS_SOURCE_DIR "origins/"
void registerSchemes()
{
@@ -185,7 +184,7 @@ private:
return;
}
- QString pathPrefix = QSL(THIS_DIR);
+ QString pathPrefix = QDir(QT_TESTCASE_SOURCEDIR).canonicalPath();
QString pathSuffix = url.path();
QFile *file = new QFile(pathPrefix + pathSuffix, job);
if (!file->open(QIODevice::ReadOnly)) {
@@ -460,7 +459,8 @@ void tst_Origins::subdirWithAccess()
{
ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessFileUrls, true);
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/subdir/index.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/subdir/index.html"));
QCOMPARE(eval(QSL("msg[0]")), QVariant(QSL("hello")));
QCOMPARE(eval(QSL("msg[1]")), QVariant(QSL("world")));
@@ -488,7 +488,8 @@ void tst_Origins::subdirWithoutAccess()
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/subdir/index.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/subdir/index.html"));
QCOMPARE(eval(QSL("msg[0]")), QVariant());
QCOMPARE(eval(QSL("msg[1]")), QVariant());
@@ -513,14 +514,15 @@ void tst_Origins::fileAccessRemoteUrl()
QFETCH(bool, EnableAccess);
HttpServer server;
- server.setResourceDirs({ THIS_DIR "resources" });
+ server.setResourceDirs({ QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/resources" });
QVERIFY(server.start());
ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessRemoteUrls, EnableAccess);
if (!EnableAccess)
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("blocked by CORS policy")));
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedXHR.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html"));
eval("sendXHR('" + server.url("/mixedXHR.txt").toString() + "')");
QTRY_COMPARE(eval("result"), (EnableAccess ? QString("ok") : QString("error")));
@@ -536,8 +538,10 @@ void tst_Origins::fileAccessRemoteUrl()
// file: scheme.
void tst_Origins::mixedSchemes()
{
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedSchemes.html")));
- eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedSchemes.html"));
+ eval("setIFrameUrl('file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedSchemes_frame.html')");
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
@@ -548,7 +552,8 @@ void tst_Origins::mixedSchemes()
QVERIFY(verifyLoad(QSL("qrc:/resources/mixedSchemes.html")));
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
- eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
+ eval("setIFrameUrl('file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedSchemes_frame.html')");
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
@@ -558,7 +563,8 @@ void tst_Origins::mixedSchemes()
QVERIFY(verifyLoad(QSL("tst:/resources/mixedSchemes.html")));
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Not allowed to load local resource")));
- eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
+ eval("setIFrameUrl('file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedSchemes_frame.html')");
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("cannotLoad")));
QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
@@ -644,24 +650,32 @@ void tst_Origins::mixedXHR_data()
QTest::addColumn<QString>("url");
QTest::addColumn<QString>("command");
QTest::addColumn<QVariant>("result");
- QTest::newRow("file->file") << QString("file:" THIS_DIR "resources/mixedXHR.html")
- << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ QTest::newRow("file->file") << QString("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html")
+ << QString("sendXHR('file:"
+ + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.txt')")
<< QVariant(QString("ok"));
- QTest::newRow("file->qrc") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ QTest::newRow("file->qrc") << QString("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html")
<< QString("sendXHR('qrc:/resources/mixedXHR.txt')")
<< QVariant(QString("error"));
- QTest::newRow("file->tst") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ QTest::newRow("file->tst") << QString("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html")
<< QString("sendXHR('tst:/resources/mixedXHR.txt')")
<< QVariant(QString("error"));
- QTest::newRow("file->data") << QString("file:" THIS_DIR "resources/mixedXHR.html")
- << QString("sendXHR('data:,ok')")
- << QVariant(QString("ok"));
- QTest::newRow("file->cors") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ QTest::newRow("file->data") << QString("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html")
+ << QString("sendXHR('data:,ok')") << QVariant(QString("ok"));
+ QTest::newRow("file->cors") << QString("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.html")
<< QString("sendXHR('cors:/resources/mixedXHR.txt')")
<< QVariant(QString("ok"));
QTest::newRow("qrc->file") << QString("qrc:/resources/mixedXHR.html")
- << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ << QString("sendXHR('file:"
+ + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.txt')")
<< QVariant(QString("ok"));
QTest::newRow("qrc->qrc") << QString("qrc:/resources/mixedXHR.html")
<< QString("sendXHR('qrc:/resources/mixedXHR.txt')")
@@ -676,9 +690,10 @@ void tst_Origins::mixedXHR_data()
<< QString("sendXHR('cors:/resources/mixedXHR.txt')")
<< QVariant(QString("ok"));
-
QTest::newRow("tst->file") << QString("tst:/resources/mixedXHR.html")
- << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ << QString("sendXHR('file:"
+ + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/mixedXHR.txt')")
<< QVariant(QString("error"));
QTest::newRow("tst->qrc") << QString("tst:/resources/mixedXHR.html")
<< QString("sendXHR('qrc:/resources/mixedXHR.txt')")
@@ -760,7 +775,8 @@ void tst_Origins::webSocket()
m_page->setWebChannel(&channel);
QVERIFY(echoServer.listen());
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/websocket.html")));
+ QVERIFY(verifyLoad(
+ QSL("file:" QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() "/resources/websocket.html")));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
QVERIFY(verifyLoad(QSL("qrc:/resources/websocket.html")));
@@ -779,7 +795,8 @@ void tst_Origins::webSocket()
// one page, there is not much need for security restrictions.
void tst_Origins::dedicatedWorker()
{
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/dedicatedWorker.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/dedicatedWorker.html"));
QTRY_VERIFY(eval(QSL("done")).toBool());
QCOMPARE(eval(QSL("result")), QVariant(42));
@@ -810,7 +827,8 @@ void tst_Origins::sharedWorker()
{
{
ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessFileUrls, false);
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/sharedWorker.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/sharedWorker.html"));
QTRY_VERIFY_WITH_TIMEOUT(eval(QSL("done")).toBool(), 10000);
QVERIFY(eval(QSL("error")).toString()
.contains(QSL("cannot be accessed from origin 'null'")));
@@ -818,7 +836,8 @@ void tst_Origins::sharedWorker()
{
ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessFileUrls, true);
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/sharedWorker.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/sharedWorker.html"));
QTRY_VERIFY_WITH_TIMEOUT(eval(QSL("done")).toBool(), 10000);
QCOMPARE(eval(QSL("result")), QVariant(42));
}
@@ -842,7 +861,8 @@ void tst_Origins::sharedWorker()
// Service workers have to be explicitly enabled for a scheme.
void tst_Origins::serviceWorker()
{
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/serviceWorker.html")));
+ QVERIFY(verifyLoad("file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/serviceWorker.html"));
QTRY_VERIFY(eval(QSL("done")).toBool());
QVERIFY(eval(QSL("error")).toString()
.contains(QSL("The URL protocol of the current origin ('file://') is not supported.")));
@@ -885,11 +905,16 @@ void tst_Origins::serviceWorker()
// Support for view-source must be enabled explicitly.
void tst_Origins::viewSource()
{
- QVERIFY(verifyLoad(QSL("view-source:file:" THIS_DIR "resources/viewSource.html")));
+ QVERIFY(verifyLoad("view-source:file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/viewSource.html"));
#ifdef Q_OS_WIN
- QCOMPARE(m_page->requestedUrl().toString(), QSL("file:///" THIS_DIR "resources/viewSource.html"));
+ QCOMPARE(m_page->requestedUrl().toString(),
+ "file:///" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/viewSource.html");
#else
- QCOMPARE(m_page->requestedUrl().toString(), QSL("file://" THIS_DIR "resources/viewSource.html"));
+ QCOMPARE(m_page->requestedUrl().toString(),
+ "file://" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + "/resources/viewSource.html");
#endif
QVERIFY(verifyLoad(QSL("view-source:qrc:/resources/viewSource.html")));
diff --git a/tests/auto/widgets/printing/CMakeLists.txt b/tests/auto/widgets/printing/CMakeLists.txt
new file mode 100644
index 000000000..4c06a1b38
--- /dev/null
+++ b/tests/auto/widgets/printing/CMakeLists.txt
@@ -0,0 +1,34 @@
+include(../../util/util.cmake)
+
+find_package(PkgConfig)
+if(PkgConfig_FOUND)
+ pkg_check_modules(POPPLER_CPP poppler-cpp IMPORTED_TARGET)
+endif()
+
+qt_internal_add_test(tst_printing
+ SOURCES
+ tst_printing.cpp
+ PUBLIC_LIBRARIES
+ Qt::WebEngineWidgets
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineCorePrivate
+ Test::Util
+)
+
+qt_internal_extend_target(tst_printing
+ CONDITION POPPLER_CPP_FOUND
+ DEFINES
+ POPPLER_CPP
+ LIBRARIES
+ PkgConfig::POPPLER_CPP
+)
+
+set(tst_printing_resource_files
+ "resources/basic_printing_page.html"
+)
+
+qt_add_resource(tst_printing "tst_printing"
+ PREFIX "/"
+ FILES ${tst_printing_resource_files}
+)
diff --git a/tests/auto/widgets/printing/tst_printing.cpp b/tests/auto/widgets/printing/tst_printing.cpp
index 380fb65ff..d1542af23 100644
--- a/tests/auto/widgets/printing/tst_printing.cpp
+++ b/tests/auto/widgets/printing/tst_printing.cpp
@@ -33,7 +33,7 @@
#include <QSignalSpy>
#include <util.h>
-#if QT_CONFIG(webengine_poppler_cpp)
+#if defined(POPPLER_CPP)
#include <poppler-document.h>
#include <poppler-page.h>
#endif
@@ -44,7 +44,7 @@ class tst_Printing : public QObject
private slots:
void printToPdfBasic();
void printRequest();
-#if QT_CONFIG(webengine_poppler_cpp) && defined(Q_OS_LINUX) && defined(__GLIBCXX__)
+#if defined(POPPLER_CPP) && defined(Q_OS_LINUX) && defined(__GLIBCXX__)
void printToPdfPoppler();
#endif
};
@@ -108,7 +108,7 @@ void tst_Printing::printRequest()
QVERIFY(data.length() > 0);
}
-#if QT_CONFIG(webengine_poppler_cpp) && defined(Q_OS_LINUX) && defined(__GLIBCXX__)
+#if defined(POPPLER_CPP) && defined(Q_OS_LINUX) && defined(__GLIBCXX__)
void tst_Printing::printToPdfPoppler()
{
// check if generated pdf is correct by searching for a know string on the page
diff --git a/tests/auto/widgets/proxy/CMakeLists.txt b/tests/auto/widgets/proxy/CMakeLists.txt
new file mode 100644
index 000000000..0929c050c
--- /dev/null
+++ b/tests/auto/widgets/proxy/CMakeLists.txt
@@ -0,0 +1,9 @@
+include(../../httpserver/httpserver.cmake)
+
+qt_internal_add_test(tst_proxy
+ SOURCES
+ tst_proxy.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+)
diff --git a/tests/auto/widgets/proxy/proxy_server.cpp b/tests/auto/widgets/proxy/proxy_server.cpp
deleted file mode 100644
index 3e52de4f2..000000000
--- a/tests/auto/widgets/proxy/proxy_server.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "proxy_server.h"
-#include <QDataStream>
-#include <QTcpSocket>
-#include <QDebug>
-
-ProxyServer::ProxyServer(QObject *parent) : QObject(parent)
-{
- connect(&m_server, &QTcpServer::newConnection, this, &ProxyServer::handleNewConnection);
-}
-
-void ProxyServer::setCredentials(const QByteArray &user, const QByteArray password)
-{
- m_auth.append(user);
- m_auth.append(':');
- m_auth.append(password);
- m_auth = m_auth.toBase64();
- m_authenticate = true;
-}
-
-void ProxyServer::setCookie(const QByteArray &cookie)
-{
- m_cookie.append(QByteArrayLiteral("Cookie: "));
- m_cookie.append(cookie);
-}
-
-
-bool ProxyServer::isListening()
-{
- return m_server.isListening();
-}
-
-void ProxyServer::run()
-{
- if (!m_server.listen(QHostAddress::LocalHost, 5555))
- qFatal("Could not start the test server");
-}
-
-void ProxyServer::handleNewConnection()
-{
- // do one connection at the time
- Q_ASSERT(m_data.isEmpty());
- QTcpSocket *socket = m_server.nextPendingConnection();
- Q_ASSERT(socket);
- connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
- connect(socket, &QAbstractSocket::readyRead, this, &ProxyServer::handleReadReady);
-}
-
-void ProxyServer::handleReadReady()
-{
- QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender());
- Q_ASSERT(socket);
-
- m_data.append(socket->readAll());
-
- if (!m_data.endsWith("\r\n\r\n"))
- return;
-
- if (m_authenticate && !m_data.contains(QByteArrayLiteral("Proxy-Authorization: Basic"))) {
- socket->write("HTTP/1.1 407 Proxy Authentication Required\nProxy-Authenticate: "
- "Basic realm=\"Proxy requires authentication\"\r\n"
- "content-length: 0\r\n"
- "\r\n");
- return;
- }
-
- if (m_authenticate && m_data.contains(m_auth)) {
- emit authenticationSuccess();
- }
-
- if (m_data.contains(m_cookie)) {
- emit cookieMatch();
- }
- m_data.clear();
-}
diff --git a/tests/auto/widgets/proxy/proxy_server.h b/tests/auto/widgets/proxy/proxy_server.h
deleted file mode 100644
index 7bc7b100b..000000000
--- a/tests/auto/widgets/proxy/proxy_server.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PROXY_SERVER_H
-#define PROXY_SERVER_H
-
-#include <QObject>
-#include <QTcpServer>
-
-class ProxyServer : public QObject
-{
- Q_OBJECT
-
-public:
- explicit ProxyServer(QObject *parent = nullptr);
- void setCredentials(const QByteArray &user, const QByteArray password);
- void setCookie(const QByteArray &cookie);
- bool isListening();
-
-public slots:
- void run();
-
-private slots:
- void handleNewConnection();
- void handleReadReady();
-
-signals:
- void authenticationSuccess();
- void cookieMatch();
-
-private:
- QByteArray m_data;
- QTcpServer m_server;
- QByteArray m_auth;
- QByteArray m_cookie;
- bool m_authenticate = false;
-};
-
-#endif // PROXY_SERVER_H
diff --git a/tests/auto/widgets/proxypac/CMakeLists.txt b/tests/auto/widgets/proxypac/CMakeLists.txt
new file mode 100644
index 000000000..25d754cf7
--- /dev/null
+++ b/tests/auto/widgets/proxypac/CMakeLists.txt
@@ -0,0 +1,46 @@
+include(../../httpserver/httpserver.cmake)
+
+qt_internal_add_test(tst_proxypac_file
+ SOURCES
+ tst_proxypac.cpp
+ LIBRARIES
+ Qt::WebEngineCore
+ Test::HttpServer
+)
+
+if(WIN32)
+ set(fileEnvArg "--proxy-pac-url=\"file:///${CMAKE_CURRENT_LIST_DIR}/proxy.pac\"")
+elseif(boot2qt)
+ set(fileEnvArg "--single-process --no-sandbox --proxy-pac-url=\"file://${CMAKE_CURRENT_LIST_DIR}/proxy.pac\"")
+else()
+ set(fileEnvArg "--proxy-pac-url=\"file://${CMAKE_CURRENT_LIST_DIR}/proxy.pac\"")
+endif()
+
+set_tests_properties(tst_proxypac_file PROPERTIES
+ ENVIRONMENT QTWEBENGINE_CHROMIUM_FLAGS=${fileEnvArg}
+)
+
+qt_internal_add_test(tst_proxypac_qrc
+ SOURCES
+ tst_proxypac.cpp
+ LIBRARIES
+ Qt::WebEngineCore
+ Test::HttpServer
+)
+
+if(boot2qt)
+ set(qrcEnvArg "--single-process --no-sandbox --proxy-pac-url=\"qrc:///proxy.pac\"")
+else()
+ set(qrcEnvArg "--proxy-pac-url=\"qrc:///proxy.pac\"")
+endif()
+
+set_tests_properties(tst_proxypac_qrc PROPERTIES
+ ENVIRONMENT QTWEBENGINE_CHROMIUM_FLAGS=${qrcEnvArg}
+)
+
+qt_add_resource(tst_proxypac_qrc "proxypac"
+ PREFIX
+ "/"
+ FILES
+ "proxy.pac"
+)
diff --git a/tests/auto/widgets/proxypac/tst_proxypac.cpp b/tests/auto/widgets/proxypac/tst_proxypac.cpp
index 26f9b8aa3..223c995e0 100644
--- a/tests/auto/widgets/proxypac/tst_proxypac.cpp
+++ b/tests/auto/widgets/proxypac/tst_proxypac.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "proxyserver.h"
+#include "proxy_server.h"
#include <QTest>
#include <QSignalSpy>
#include <QWebEngineProfile>
@@ -47,17 +47,17 @@ void tst_ProxyPac::proxypac()
{
const QString fromEnv = qEnvironmentVariable("QTWEBENGINE_CHROMIUM_FLAGS");
if (!fromEnv.contains("--proxy-pac-url"))
- qFatal("--proxy-pac-url argument is not passed.");
+ qFatal("--proxy-pac-url argument is not passed. Use ctest or set QTWEBENGINE_CHROMIUM_FLAGS");
ProxyServer proxyServer1;
+ QSignalSpy proxySpy1(&proxyServer1, &ProxyServer::requestReceived);
proxyServer1.setPort(5551);
proxyServer1.run();
- QSignalSpy proxySpy1(&proxyServer1, &ProxyServer::requestReceived);
ProxyServer proxyServer2;
+ QSignalSpy proxySpy2(&proxyServer2, &ProxyServer::requestReceived);
proxyServer2.setPort(5552);
proxyServer2.run();
- QSignalSpy proxySpy2(&proxyServer2, &ProxyServer::requestReceived);
QTRY_VERIFY2(proxyServer1.isListening(), "Could not setup proxy server 1");
QTRY_VERIFY2(proxyServer2.isListening(), "Could not setup proxy server 2");
diff --git a/tests/auto/widgets/qwebenginedownloadrequest/CMakeLists.txt b/tests/auto/widgets/qwebenginedownloadrequest/CMakeLists.txt
new file mode 100644
index 000000000..3a8244c0f
--- /dev/null
+++ b/tests/auto/widgets/qwebenginedownloadrequest/CMakeLists.txt
@@ -0,0 +1,11 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebenginedownloadrequest
+ SOURCES
+ tst_qwebenginedownloadrequest.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
diff --git a/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp
index a69ceaed0..f95c4ab33 100644
--- a/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp
+++ b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "../util.h"
+#include <util.h>
#include <QCoreApplication>
#include <QSignalSpy>
diff --git a/tests/auto/widgets/qwebenginehistory/CMakeLists.txt b/tests/auto/widgets/qwebenginehistory/CMakeLists.txt
new file mode 100644
index 000000000..b91281a45
--- /dev/null
+++ b/tests/auto/widgets/qwebenginehistory/CMakeLists.txt
@@ -0,0 +1,26 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebenginehistory
+ SOURCES
+ tst_qwebenginehistory.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
+
+set(tst_qwebenginehistory_resource_files
+ "resources/page1.html"
+ "resources/page2.html"
+ "resources/page3.html"
+ "resources/page4.html"
+ "resources/page5.html"
+ "resources/page6.html"
+)
+
+qt_internal_add_resource(tst_qwebenginehistory "tst_qwebenginehistory"
+ PREFIX
+ "/"
+ FILES
+ ${tst_qwebenginehistory_resource_files}
+)
+
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index 72a45379b..f67c2e03d 100644
--- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
+++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
@@ -20,7 +20,7 @@
#include <QtTest/QtTest>
#include <QAction>
-#include "../util.h"
+#include <util.h>
#include "qwebenginepage.h"
#include "qwebengineview.h"
#include "qwebenginehistory.h"
diff --git a/tests/auto/widgets/qwebenginepage/CMakeLists.txt b/tests/auto/widgets/qwebenginepage/CMakeLists.txt
new file mode 100644
index 000000000..bb31d9a97
--- /dev/null
+++ b/tests/auto/widgets/qwebenginepage/CMakeLists.txt
@@ -0,0 +1,61 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebenginepage
+ SOURCES
+ tst_qwebenginepage.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
+
+get_target_property(sharedData Test::HttpServer SHARED_DATA)
+
+set(tst_qwebenginepage_resource_files
+ "resources/redirect.html"
+ "resources/bar.txt"
+ "resources/content.html"
+ "resources/dynamicFrame.html"
+ "resources/foo.txt"
+ "resources/frame_a.html"
+ "resources/frame_c.html"
+ "resources/framedindex.html"
+ "resources/fullscreen.html"
+ "resources/iframe.html"
+ "resources/iframe2.html"
+ "resources/iframe3.html"
+ "resources/image.png"
+ "resources/index.html"
+ "resources/lifecycle.html"
+ "resources/pasteimage.html"
+ "resources/path with spaces.txt"
+ "resources/reload.html"
+ "resources/script.html"
+ "resources/style.css"
+ "resources/test1.html"
+ "resources/test2.html"
+ "resources/testiframe.html"
+ "resources/testiframe2.html"
+ "resources/user.css"
+)
+
+qt_internal_add_resource(tst_qwebenginepage "tst_qwebenginepage"
+ PREFIX
+ "/"
+ FILES
+ ${tst_qwebenginepage_resource_files}
+)
+set_source_files_properties("${sharedData}/notification.html"
+ PROPERTIES QT_RESOURCE_ALIAS "notification.html"
+)
+set(tst_qwebenginepage1_resource_files
+ "${sharedData}/notification.html"
+)
+
+qt_internal_add_resource(tst_qwebenginepage "tst_qwebenginepage1"
+ PREFIX
+ "/shared"
+ FILES
+ ${tst_qwebenginepage1_resource_files}
+)
diff --git a/tests/auto/widgets/resources/image2.png b/tests/auto/widgets/qwebenginepage/resources/image2.png
index 8d703640c..8d703640c 100644
--- a/tests/auto/widgets/resources/image2.png
+++ b/tests/auto/widgets/qwebenginepage/resources/image2.png
Binary files differ
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index a8d0e1ac8..fecda7c47 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -19,7 +19,7 @@
Boston, MA 02110-1301, USA.
*/
-#include "../util.h"
+#include <util.h>
#include <QtWebEngineCore/qtwebenginecore-config.h>
#include <QByteArray>
#include <QClipboard>
@@ -2245,10 +2245,15 @@ void tst_QWebEnginePage::setHtmlWithBaseURL()
// This tests if baseUrl is indeed affecting the relative paths from resources.
// As we are using a local file as baseUrl, its security origin should be able to load local resources.
- 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);
- QDir::setCurrent(TESTS_SOURCE_DIR);
+ QDir::setCurrent(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath());
+ qDebug()<<QDir::current();
QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>");
@@ -2257,7 +2262,9 @@ void tst_QWebEnginePage::setHtmlWithBaseURL()
// in few seconds, the image should be completey loaded
QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
- page.setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
+ page.setHtml(html,
+ QUrl::fromLocalFile(
+ QString("%1/foo.html").arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath())));
QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished);
QVERIFY(spyFinished.wait());
QCOMPARE(spy.count(), 1);
@@ -3187,7 +3194,8 @@ void tst_QWebEnginePage::viewSourceURL_data()
QTest::newRow("view-source:") << QUrl("view-source:") << true << QUrl("view-source:") << QUrl("about:blank") << QString("view-source:");
QTest::newRow("view-source:about:blank") << QUrl("view-source:about:blank") << true << QUrl("view-source:about:blank") << QUrl("about:blank") << QString("view-source:about:blank");
- QString localFilePath = QString("%1qwebenginepage/resources/test1.html").arg(TESTS_SOURCE_DIR);
+ QString localFilePath =
+ QString("%1/resources/test1.html").arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath());
QUrl testLocalUrl = QUrl(QString("view-source:%1").arg(QUrl::fromLocalFile(localFilePath).toString()));
QUrl testLocalUrlWithoutScheme = QUrl(QString("view-source:%1").arg(localFilePath));
QTest::newRow(testLocalUrl.toString().toStdString().c_str()) << testLocalUrl << true << testLocalUrl << QUrl::fromLocalFile(localFilePath) << QString("test1.html");
@@ -3203,8 +3211,12 @@ void tst_QWebEnginePage::viewSourceURL_data()
void tst_QWebEnginePage::viewSourceURL()
{
- 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, userInputUrl);
QFETCH(bool, loadSucceed);
diff --git a/tests/auto/widgets/qwebengineprofile/CMakeLists.txt b/tests/auto/widgets/qwebengineprofile/CMakeLists.txt
new file mode 100644
index 000000000..744f44405
--- /dev/null
+++ b/tests/auto/widgets/qwebengineprofile/CMakeLists.txt
@@ -0,0 +1,11 @@
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebengineprofile
+ SOURCES
+ tst_qwebengineprofile.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::HttpServer
+ Test::Util
+)
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index eb692f351..64c763693 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "../util.h"
+#include <util.h>
#include <QtCore/qbuffer.h>
#include <QtCore/qmimedatabase.h>
#include <QtTest/QtTest>
@@ -198,7 +198,7 @@ public:
private:
void onNewRequest(HttpReqRep *rr)
{
- const QDir resourceDir(TESTS_SOURCE_DIR "qwebengineprofile/resources");
+ const QDir resourceDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/resources");
QString path = rr->requestPath();
path.remove(0, 1);
diff --git a/tests/auto/widgets/qwebenginescript/CMakeLists.txt b/tests/auto/widgets/qwebenginescript/CMakeLists.txt
new file mode 100644
index 000000000..2e93894d9
--- /dev/null
+++ b/tests/auto/widgets/qwebenginescript/CMakeLists.txt
@@ -0,0 +1,26 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebenginescript
+ SOURCES
+ tst_qwebenginescript.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
+
+set(tst_qwebenginescript_resource_files
+ "resources/test_iframe_inner.html"
+ "resources/test_iframe_main.html"
+ "resources/test_iframe_outer.html"
+ "resources/test_window_open.html"
+ "resources/title_a.html"
+ "resources/title_b.html"
+ "resources/webChannelWithBadString.html"
+)
+
+qt_add_resource(tst_qwebenginescript "tst_qwebenginescript"
+ PREFIX
+ "/"
+ FILES
+ ${tst_qwebenginescript_resource_files}
+)
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index c141c0754..ca2f0cab9 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -25,7 +25,7 @@
#include <qwebenginescriptcollection.h>
#include <qwebenginesettings.h>
#include <qwebengineview.h>
-#include "../util.h"
+#include <util.h>
#if QT_CONFIG(webengine_webchannel)
#include <QWebChannel>
#endif
diff --git a/tests/auto/widgets/qwebenginesettings/CMakeLists.txt b/tests/auto/widgets/qwebenginesettings/CMakeLists.txt
new file mode 100644
index 000000000..f5ec3441e
--- /dev/null
+++ b/tests/auto/widgets/qwebenginesettings/CMakeLists.txt
@@ -0,0 +1,9 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebenginesettings
+ SOURCES
+ tst_qwebenginesettings.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Test::Util
+)
diff --git a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
index a7c3ccb3c..77e46b0bf 100644
--- a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
+++ b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
@@ -17,7 +17,7 @@
Boston, MA 02110-1301, USA.
*/
-#include "../util.h"
+#include <util.h>
#include <QtTest/QtTest>
diff --git a/tests/auto/widgets/qwebengineview/CMakeLists.txt b/tests/auto/widgets/qwebengineview/CMakeLists.txt
new file mode 100644
index 000000000..0f4fe9327
--- /dev/null
+++ b/tests/auto/widgets/qwebengineview/CMakeLists.txt
@@ -0,0 +1,29 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qwebengineview
+ SOURCES
+ tst_qwebengineview.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Qt::WebEngineCorePrivate
+ Qt::GuiPrivate
+ Qt::QuickWidgets
+ Test::Util
+)
+
+set(tst_qwebengineview_resource_files
+ "resources/dummy.html"
+ "resources/frame_a.html"
+ "resources/image2.png"
+ "resources/index.html"
+ "resources/input_types.html"
+ "resources/keyboardEvents.html"
+ "resources/scrolltest_page.html"
+)
+
+qt_add_resource(tst_qwebengineview "tst_qwebengineview"
+ PREFIX
+ "/"
+ FILES
+ ${tst_qwebengineview_resource_files}
+)
diff --git a/tests/auto/widgets/resources/test.swf b/tests/auto/widgets/qwebengineview/resources/test.swf
index 895298271..895298271 100644
--- a/tests/auto/widgets/resources/test.swf
+++ b/tests/auto/widgets/qwebengineview/resources/test.swf
Binary files differ
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 284f84d9f..2673c0d33 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -18,10 +18,9 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
+#include <QtWebEngineCore/private/qtwebenginecore-config_p.h>
#include <qtest.h>
-#include "../util.h"
-
+#include <util.h>
#include <private/qinputmethod_p.h>
#include <qpainter.h>
#include <qpagelayout.h>
@@ -363,17 +362,21 @@ void tst_QWebEngineView::reusePage_data()
void tst_QWebEngineView::reusePage()
{
- 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);
- QDir::setCurrent(TESTS_SOURCE_DIR);
+ QDir::setCurrent(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath());
QFETCH(QString, html);
QWebEngineView* view1 = new QWebEngineView;
QPointer<QWebEnginePage> page = new QWebEnginePage;
view1->setPage(page.data());
page.data()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- page->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
+ page->setHtml(html, QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()));
if (html.contains("</embed>")) {
// some reasonable time for the PluginStream to feed test.swf to flash and start painting
QSignalSpy spyFinished(view1, &QWebEngineView::loadFinished);
@@ -3193,8 +3196,10 @@ void tst_QWebEngineView::webUIURLs_data()
QTest::newRow("usb-internals") << QUrl("chrome://usb-internals") << false;
QTest::newRow("user-actions") << QUrl("chrome://user-actions") << true;
QTest::newRow("version") << QUrl("chrome://version") << false;
+#if QT_CONFIG(webengine_webrtc)
QTest::newRow("webrtc-internals") << QUrl("chrome://webrtc-internals") << true;
QTest::newRow("webrtc-logs") << QUrl("chrome://webrtc-logs") << true;
+#endif
}
void tst_QWebEngineView::webUIURLs()
diff --git a/tests/auto/widgets/schemes/CMakeLists.txt b/tests/auto/widgets/schemes/CMakeLists.txt
new file mode 100644
index 000000000..446ae5751
--- /dev/null
+++ b/tests/auto/widgets/schemes/CMakeLists.txt
@@ -0,0 +1,7 @@
+qt_internal_add_test(tst_schemes
+ SOURCES
+ tst_schemes.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+)
+
diff --git a/tests/auto/widgets/shutdown/CMakeLists.txt b/tests/auto/widgets/shutdown/CMakeLists.txt
new file mode 100644
index 000000000..12ca27c3d
--- /dev/null
+++ b/tests/auto/widgets/shutdown/CMakeLists.txt
@@ -0,0 +1,6 @@
+qt_internal_add_test(tst_shutdown
+ SOURCES
+ tst_shutdown.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+)
diff --git a/tests/auto/widgets/touchinput/CMakeLists.txt b/tests/auto/widgets/touchinput/CMakeLists.txt
new file mode 100644
index 000000000..82e3fca4a
--- /dev/null
+++ b/tests/auto/widgets/touchinput/CMakeLists.txt
@@ -0,0 +1,10 @@
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_touchinput
+ SOURCES
+ tst_touchinput.cpp
+ LIBRARIES
+ Qt::WebEngineWidgets
+ Qt::GuiPrivate
+ Test::Util
+)
diff --git a/tests/auto/widgets/touchinput/tst_touchinput.cpp b/tests/auto/widgets/touchinput/tst_touchinput.cpp
index 359b11eb2..d60fd1d7b 100644
--- a/tests/auto/widgets/touchinput/tst_touchinput.cpp
+++ b/tests/auto/widgets/touchinput/tst_touchinput.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "../util.h"
+#include <util.h>
#include <QtGui/qpa/qwindowsysteminterface.h>
#include <QSignalSpy>
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
deleted file mode 100644
index 3be9a91b9..000000000
--- a/tests/auto/widgets/util.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Functions and macros that really need to be in QTestLib
-
-#if 0
-#pragma qt_no_master_include
-#endif
-
-#include <QEventLoop>
-#include <QSignalSpy>
-#include <QTimer>
-#include <qwebenginepage.h>
-#include <qwebengineview.h>
-
-#if !defined(TESTS_SOURCE_DIR)
-#define TESTS_SOURCE_DIR ""
-#endif
-
-// Disconnect signal on destruction.
-class ScopedConnection
-{
-public:
- ScopedConnection(QMetaObject::Connection connection) : m_connection(std::move(connection)) { }
- ~ScopedConnection() { QObject::disconnect(m_connection); }
-
-private:
- QMetaObject::Connection m_connection;
-};
-
-/**
- * Just like QSignalSpy but facilitates sync and async
- * signal emission. For example if you want to verify that
- * page->foo() emitted a signal, it could be that the
- * implementation decides to emit the signal asynchronously
- * - in which case we want to spin a local event loop until
- * emission - or that the call to foo() emits it right away.
- */
-class SignalBarrier : private QSignalSpy
-{
-public:
- SignalBarrier(const QObject* obj, const char* aSignal)
- : QSignalSpy(obj, aSignal)
- { }
-
- bool ensureSignalEmitted()
- {
- bool result = count() > 0;
- if (!result)
- result = wait();
- clear();
- return result;
- }
-};
-
-template<typename T, typename R>
-struct CallbackWrapper {
- QPointer<R> p;
- void operator()(const T& result) {
- if (p)
- (*p)(result);
- }
-};
-
-template<typename T>
-class CallbackSpy: public QObject {
-public:
- CallbackSpy() : called(false) {
- timeoutTimer.setSingleShot(true);
- QObject::connect(&timeoutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
- }
-
- T waitForResult(int timeout = 20000) {
- const int step = 1000;
- int elapsed = 0;
- while (elapsed < timeout && !called) {
- timeoutTimer.start(step);
- eventLoop.exec();
- elapsed += step;
- }
- return result;
- }
-
- bool wasCalled() const {
- return called;
- }
-
- void operator()(const T &result) {
- this->result = result;
- called = true;
- eventLoop.quit();
- }
-
- CallbackWrapper<T, CallbackSpy<T> > ref()
- {
- CallbackWrapper<T, CallbackSpy<T> > wrapper = {this};
- return wrapper;
- }
-
-private:
- Q_DISABLE_COPY(CallbackSpy)
- bool called;
- QTimer timeoutTimer;
- QEventLoop eventLoop;
- T result;
-};
-
-static inline QString toPlainTextSync(QWebEnginePage *page)
-{
- CallbackSpy<QString> spy;
- page->toPlainText(spy.ref());
- return spy.waitForResult();
-}
-
-static inline QString toHtmlSync(QWebEnginePage *page)
-{
- CallbackSpy<QString> spy;
- page->toHtml(spy.ref());
- return spy.waitForResult();
-}
-
-static inline bool findTextSync(QWebEnginePage *page, const QString &subString)
-{
- CallbackSpy<bool> spy;
- page->findText(subString, {}, spy.ref());
- return spy.waitForResult();
-}
-
-static inline QVariant evaluateJavaScriptSync(QWebEnginePage *page, const QString &script)
-{
- CallbackSpy<QVariant> spy;
- page->runJavaScript(script, spy.ref());
- return spy.waitForResult();
-}
-
-static inline QVariant evaluateJavaScriptSyncInWorld(QWebEnginePage *page, const QString &script, int worldId)
-{
- CallbackSpy<QVariant> spy;
- page->runJavaScript(script, worldId, spy.ref());
- return spy.waitForResult();
-}
-
-static inline QUrl baseUrlSync(QWebEnginePage *page)
-{
- CallbackSpy<QVariant> spy;
- page->runJavaScript("document.baseURI", spy.ref());
- return spy.waitForResult().toUrl();
-}
-
-static inline bool loadSync(QWebEnginePage *page, const QUrl &url, bool ok = true)
-{
- QSignalSpy spy(page, &QWebEnginePage::loadFinished);
- page->load(url);
- return (!spy.empty() || spy.wait(20000)) && (spy.front().value(0).toBool() == ok);
-}
-
-static inline bool loadSync(QWebEngineView *view, const QUrl &url, bool ok = true)
-{
- return loadSync(view->page(), url, ok);
-}
-
-static inline QPoint elementCenter(QWebEnginePage *page, const QString &id)
-{
- const QString jsCode(
- "(function(){"
- " var elem = document.getElementById('" + id + "');"
- " var rect = elem.getBoundingClientRect();"
- " return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
- "})()");
- QVariantList rectList = evaluateJavaScriptSync(page, jsCode).toList();
-
- if (rectList.count() != 2) {
- qWarning("elementCenter failed.");
- return QPoint();
- }
-
- return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
-}
-
-static inline QRect elementGeometry(QWebEnginePage *page, const QString &id)
-{
- const QString jsCode(
- "(function() {"
- " var elem = document.getElementById('" + id + "');"
- " var rect = elem.getBoundingClientRect();"
- " return [rect.left, rect.top, rect.right, rect.bottom];"
- "})()");
- QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList();
-
- if (coords.count() != 4) {
- qWarning("elementGeometry faield.");
- return QRect();
- }
-
- return QRect(coords[0].toInt(), coords[1].toInt(), coords[2].toInt(), coords[3].toInt());
-}
-
-
-#define W_QSKIP(a, b) QSKIP(a)
-
-#define W_QTEST_MAIN(TestObject, params) \
-int main(int argc, char *argv[]) \
-{ \
- QList<const char *> 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(); \
- \
- QApplication app(w_argc, const_cast<char **>(w_argv.data())); \
- app.setAttribute(Qt::AA_Use96Dpi, true); \
- QTEST_DISABLE_KEYPAD_NAVIGATION \
- TestObject tc; \
- QTEST_SET_MAIN_SOURCE_PATH \
- return QTest::qExec(&tc, argc, argv); \
-}