summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-23 17:01:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-25 14:16:44 +0000
commit33403f2c79d678afc5b76add2c517d99b9708c32 (patch)
tree796fb3e1607a14b9e9e7f00a2e35a326ec083ba6 /tests
parent7bbde34ee012bbe90c4ce76736c6f71b16e64215 (diff)
Fix crash when accessing QStyleHints before QGuiApplication is constructed.
Make styleHints a static member variable of QGuiApplicationPrivate and fix accessor accordingly. Extend tst_QApplication::settableStyleHints() to run without QApplication instance as well and add a similar test to QGuiApplication. Task-number: QTBUG-44499 Change-Id: I42b92ef38f7dd512d08d70accfa7dd4f09a22f01 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp25
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp14
2 files changed, 38 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 35f441c605..3cf7803cfb 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -37,7 +37,9 @@
#include <QtGui/QWindow>
#include <QtGui/QScreen>
#include <QtGui/QCursor>
+#include <QtGui/QFont>
#include <QtGui/QPalette>
+#include <QtGui/QStyleHints>
#include <qpa/qwindowsysteminterface.h>
#include <qgenericplugin.h>
@@ -74,6 +76,9 @@ private slots:
void genericPluginsAndWindowSystemEvents();
void layoutDirection();
void globalShareContext();
+
+ void settableStyleHints_data();
+ void settableStyleHints(); // Needs to run last as it changes style hints.
};
void tst_QGuiApplication::cleanup()
@@ -961,4 +966,24 @@ void tst_QGuiApplication::globalShareContext()
#endif
}
+void tst_QGuiApplication::settableStyleHints_data()
+{
+ QTest::addColumn<bool>("appInstance");
+ QTest::newRow("app") << true;
+ QTest::newRow("no-app") << false;
+}
+
+void tst_QGuiApplication::settableStyleHints()
+{
+ QFETCH(bool, appInstance);
+ int argc = 0;
+ QScopedPointer<QGuiApplication> app;
+ if (appInstance)
+ app.reset(new QGuiApplication(argc, 0));
+
+ const int keyboardInputInterval = 555;
+ QGuiApplication::styleHints()->setKeyboardInputInterval(keyboardInputInterval);
+ QCOMPARE(QGuiApplication::styleHints()->keyboardInputInterval(), keyboardInputInterval);
+}
+
QTEST_APPLESS_MAIN(tst_QGuiApplication)
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 7e950b33c1..bab3337c0c 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -172,6 +172,7 @@ private slots:
void abortQuitOnShow();
+ void settableStyleHints_data();
void settableStyleHints(); // Needs to run last as it changes style hints.
};
@@ -2298,10 +2299,21 @@ void tst_QApplication::abortQuitOnShow()
QCOMPARE(app.exec(), 1);
}
+void tst_QApplication::settableStyleHints_data()
+{
+ QTest::addColumn<bool>("appInstance");
+ QTest::newRow("app") << true;
+ QTest::newRow("no-app") << false;
+}
+
void tst_QApplication::settableStyleHints()
{
+ QFETCH(bool, appInstance);
int argc = 0;
- QApplication app(argc, 0);
+ QScopedPointer<QApplication> app;
+ if (appInstance)
+ app.reset(new QApplication(argc, 0));
+
QApplication::setCursorFlashTime(437);
QCOMPARE(QApplication::cursorFlashTime(), 437);
QApplication::setDoubleClickInterval(128);