diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index efecf31d66f19ec26e81fab23b69a819882001b0..60e358232e3b592eeefb9c9f69033674ba6f26d5 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -41,12 +41,7 @@
 #include <private/qeventloop_p.h>
 #include <private/qthread_p.h>
 
-#ifdef QT_GUI_LIB
-#include <QtGui/QGuiApplication>
-typedef QGuiApplication TestApplication;
-#else
 typedef QCoreApplication TestApplication;
-#endif
 
 class EventSpy : public QObject
 {
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 19365bffdd9dcc8eb651910de986b5c09f2984f3..d573d974955901d46a3314091e5f32ea435cedc3 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -60,6 +60,7 @@ class tst_QGuiApplication: public tst_QCoreApplication
     Q_OBJECT
 
 private slots:
+    void initTestCase();
     void cleanup();
     void displayName();
     void firstWindowTitle();
@@ -84,6 +85,21 @@ private slots:
     void settableStyleHints(); // Needs to run last as it changes style hints.
 };
 
+void tst_QGuiApplication::initTestCase()
+{
+#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
+    if ((QString::compare(QStringLiteral(QT_QPA_DEFAULT_PLATFORM_NAME),
+         QStringLiteral("eglfs"), Qt::CaseInsensitive) == 0) ||
+        (QString::compare(QString::fromLatin1(qgetenv("QT_QPA_PLATFORM")),
+         QStringLiteral("eglfs"), Qt::CaseInsensitive) == 0)) {
+        // Set env variables to disable input and cursor because eglfs is single fullscreen window
+        // and trying to initialize input and cursor will crash test.
+        qputenv("QT_QPA_EGLFS_DISABLE_INPUT", "1");
+        qputenv("QT_QPA_EGLFS_HIDECURSOR", "1");
+    }
+#endif
+}
+
 void tst_QGuiApplication::cleanup()
 {
     QVERIFY(QGuiApplication::allWindows().isEmpty());