From f70031c17b9724d8918420a3ab7342b62c061485 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Jul 2014 15:11:27 +0200 Subject: [PATCH] Add checks for widget/window leaks to kernel tests. Change-Id: I52af87279e37e49ce2206c5c823fe8fb4caef338 Reviewed-by: Oliver Wolff --- .../gui/kernel/qguiapplication/tst_qguiapplication.cpp | 6 ++++++ tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 6 ++++++ .../auto/widgets/kernel/qapplication/tst_qapplication.cpp | 1 + .../widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 8 +++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 9a6b9f488b..232231b005 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -64,6 +64,7 @@ class tst_QGuiApplication: public tst_QCoreApplication Q_OBJECT private slots: + void cleanup(); void displayName(); void firstWindowTitle(); void windowIcon(); @@ -80,6 +81,11 @@ private slots: void layoutDirection(); }; +void tst_QGuiApplication::cleanup() +{ + QVERIFY(QGuiApplication::allWindows().isEmpty()); +} + void tst_QGuiApplication::displayName() { int argc = 1; diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 9517264e55..3fa02ebaa3 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -101,11 +101,17 @@ private slots: touchDevice->setType(QTouchDevice::TouchScreen); QWindowSystemInterface::registerTouchDevice(touchDevice); } + void cleanup(); private: QTouchDevice *touchDevice; }; +void tst_QWindow::cleanup() +{ + QVERIFY(QGuiApplication::allWindows().isEmpty()); +} + void tst_QWindow::mapGlobal() { QWindow a; diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index a170430ef6..6c1e67a049 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -260,6 +260,7 @@ void tst_QApplication::cleanup() { // TODO: Add cleanup code here. // This will be executed immediately after each test is run. + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QApplication::staticSetup() 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 1809cdc16a..8084d50fbe 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -61,7 +61,7 @@ static inline void setFrameless(QWidget *w) w->setWindowFlags(flags); } -class tst_QWidget_window : public QWidget +class tst_QWidget_window : public QObject { Q_OBJECT @@ -71,6 +71,7 @@ public: public slots: void initTestCase(); void cleanupTestCase(); + void cleanup(); private slots: void tst_min_max_size(); @@ -106,6 +107,11 @@ void tst_QWidget_window::cleanupTestCase() { } +void tst_QWidget_window::cleanup() +{ + QVERIFY(QApplication::topLevelWidgets().isEmpty()); +} + /* Test if the maximum/minimum size constraints * are propagated from the widget to the QWidgetWindow * independently of whether they were set before or after