From 8d5516b58541b2ad63497437271f0a4e36ed311d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 11 Jun 2015 12:11:22 +0200 Subject: [PATCH] Add check for top level widget leaks in kernel test of QtWidgets. Add a cleanup function for the check and disable animations in tst_qwidgetaction to prevent effect widgets from interfering (vista style animations). Change-Id: I043ecb131c8dcd07b6ef10bc75c9e010ab569e85 Reviewed-by: Frederik Gladhorn --- .../kernel/qactiongroup/tst_qactiongroup.cpp | 1 + .../kernel/qdesktopwidget/tst_qdesktopwidget.cpp | 1 + tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | 1 + .../widgets/kernel/qshortcut/tst_qshortcut.cpp | 1 + .../kernel/qsizepolicy/tst_qsizepolicy.cpp | 1 + .../kernel/qwidgetaction/tst_qwidgetaction.cpp | 15 +++++++++++++++ 6 files changed, 20 insertions(+) diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 8ce9941238..5e5d15841a 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -42,6 +42,7 @@ class tst_QActionGroup : public QObject Q_OBJECT private slots: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void enabledPropagation(); void visiblePropagation(); void exclusive(); diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp index b717c1deb1..e94dfa5754 100644 --- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp +++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp @@ -73,6 +73,7 @@ void tst_QDesktopWidget::init() void tst_QDesktopWidget::cleanup() { + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QDesktopWidget::numScreens() diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index d661c074ac..3bdd335fa6 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -66,6 +66,7 @@ public: virtual ~tst_QLayout(); private slots: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void getSetCheck(); void geometry(); void smartMaxSize(); diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 7b9eaa418f..f206a5fe9a 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -108,6 +108,7 @@ public slots: public slots: void initTestCase(); void cleanupTestCase(); + void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); } private slots: void number_data(); diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index d6bc580bb3..0f8c9d1c9e 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -44,6 +44,7 @@ class tst_QSizePolicy : public QObject Q_OBJECT private Q_SLOTS: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void qtest(); void defaultValues(); void getSetCheck_data() { data(); } diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp index df54d22a2f..d10ce054b0 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp @@ -55,6 +55,8 @@ class tst_QWidgetAction : public QObject { Q_OBJECT private slots: + void initTestCase(); + void cleanup(); void defaultWidget(); void visibilityUpdate(); void customWidget(); @@ -65,6 +67,19 @@ private slots: void releaseWidgetCrash(); }; +void tst_QWidgetAction::initTestCase() +{ + // Disable menu/combo animations to prevent the alpha widgets from getting in the + // way in popup(), failing the top level leak check in cleanup(). + QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); +} + +void tst_QWidgetAction::cleanup() +{ + QVERIFY(QApplication::topLevelWidgets().isEmpty()); +} + void tst_QWidgetAction::defaultWidget() { {