diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-02-11 10:37:10 -0800 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2016-03-21 08:36:41 +0000 |
commit | e342a2e05f1e73c1a5cc4d029f9316401d07f3d6 (patch) | |
tree | 249380124816caa2878fea3a52417073c2e87555 | |
parent | e9dedb683aaf2474ef202baf56bcaf99e26e7aa7 (diff) |
Add auto-test for crash in QCocoaBackingStore
This issue has been solved some time between 5.6 and 5.6.0.
We just make sure to protect against further regressions.
Change-Id: Ic3fdad901ed5f36792ae04b3d65047da95eea668
Task-number: QTBUG-50561
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 58e85d6b58..27be063333 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -46,6 +46,8 @@ #include <qboxlayout.h> #include <qtabwidget.h> #include <qlabel.h> +#include <qmainwindow.h> +#include <qtoolbar.h> #include <private/qwindow_p.h> static inline void setFrameless(QWidget *w) @@ -99,6 +101,8 @@ private slots: void tst_move_count(); void tst_eventfilter_on_toplevel(); + + void QTBUG_50561_QCocoaBackingStore_paintDevice_crash(); }; void tst_QWidget_window::initTestCase() @@ -795,5 +799,46 @@ void tst_QWidget_window::tst_eventfilter_on_toplevel() QTRY_COMPARE(filter.eventCount, 1); } +class ApplicationStateSaver +{ +public: + ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, true); + QApplication::setQuitOnLastWindowClosed(false); + } + + ~ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, false); + QApplication::setQuitOnLastWindowClosed(true); + } +}; + +void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() +{ + // Keep application state clean if testcase fails + ApplicationStateSaver as; + + QMainWindow w; + w.addToolBar(new QToolBar(&w)); + w.show(); + QTest::qWaitForWindowExposed(&w); + + // Simulate window system close + QCloseEvent *e = new QCloseEvent; + e->accept(); + qApp->postEvent(w.windowHandle(), e); + qApp->processEvents(); + + // Show again + w.show(); + qApp->processEvents(); + + // No crash, all good. + // Wrap up and leave + w.close(); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" |