summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2019-09-18 10:53:38 +0200
committerMichal Klocek <michal.klocek@qt.io>2019-09-26 10:28:20 +0000
commite77ec61b7ba1fb71b397ef358036b5057a0cb39b (patch)
treed92613a60773af306b0c78fbae2622bedacdf8ea /tests/auto
parente31acc86e991d6f83bd56eebb7371914fc9ca5ac (diff)
Unify shared context initialization
Setting shared context on core application object should be done before core application is initialised. This is handled correctly in widgets part but not in qml part. Unify our shared context creation and call WebEngine::initialize() before QCoreaApplication is created. Context has to be set shared before first window's QPlatformOpenGLContext is created and not before window itself is created as documentation claimed. Keep the older code running, but print the warning. Update one test to test new initialization order, but keep the others to check if they still works. [ChangeLog] WebEngine::initialize() has to be called before QCoreApplication is created. Task-number: QTBUG-76391 Change-Id: Iff938493a4d21f360110136192daedb6199584c1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp5
-rw-r--r--tests/auto/quick/shared/util.h12
2 files changed, 15 insertions, 2 deletions
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
index eee6b2bb6..82ea3be37 100644
--- a/tests/auto/quick/dialogs/tst_dialogs.cpp
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -28,6 +28,7 @@
#include "testhandler.h"
#include "server.h"
+#include "util.h"
#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
#include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h>
#include <QQuickWebEngineProfile>
@@ -43,6 +44,7 @@ class tst_Dialogs : public QObject {
public:
tst_Dialogs(){}
+
private slots:
void initTestCase();
void init();
@@ -64,7 +66,6 @@ private:
void tst_Dialogs::initTestCase()
{
- QtWebEngine::initialize();
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler");
m_engine.reset(new QQmlApplicationEngine());
@@ -230,5 +231,5 @@ void tst_Dialogs::javaScriptDialogRequested()
}
#include "tst_dialogs.moc"
-QTEST_MAIN(tst_Dialogs)
+W_QTEST_MAIN(tst_Dialogs)
diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h
index c2e7d3e19..bc5ae445b 100644
--- a/tests/auto/quick/shared/util.h
+++ b/tests/auto/quick/shared/util.h
@@ -36,6 +36,7 @@
#include <QtTest/QtTest>
#include <QtWebEngine/private/qquickwebengineview_p.h>
#include <QtWebEngine/private/qquickwebengineloadrequest_p.h>
+#include <QGuiApplication>
#if !defined(TESTS_SOURCE_DIR)
#define TESTS_SOURCE_DIR ""
@@ -182,4 +183,15 @@ inline QString activeElementId(QQuickWebEngineView *webEngineView)
return arguments.at(1).toString();
}
+#define W_QTEST_MAIN(TestObject) \
+int main(int argc, char *argv[]) \
+{ \
+ QtWebEngine::initialize(); \
+ QGuiApplication app(argc, argv); \
+ app.setAttribute(Qt::AA_Use96Dpi, true); \
+ TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
+ return QTest::qExec(&tc, argc, argv); \
+}
#endif /* UTIL_H */
+