diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-05-19 14:33:48 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2010-05-19 14:39:13 (GMT) |
commit | eea978b9744c24200496af4f8a37d76228a29320 (patch) | |
tree | f00e5228d5ad99c7f10bca6f91aebe496a72ec01 /tests/auto/qmenu/tst_qmenu.cpp | |
parent | 8a97a1cac688d0e6e6aef40bfa396a81d7bfc0b8 (diff) | |
download | Qt-eea978b9744c24200496af4f8a37d76228a29320.zip Qt-eea978b9744c24200496af4f8a37d76228a29320.tar.gz Qt-eea978b9744c24200496af4f8a37d76228a29320.tar.bz2 |
Fixed an assert in QMenu
The code was changed and changed the behaviour. This is
basically a kind of revert.
Reviewed-By: gabi
Task-Number: QTBUG-10735
Diffstat (limited to 'tests/auto/qmenu/tst_qmenu.cpp')
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index e10d7ee..c8dc516 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -51,6 +51,7 @@ #include <QListWidget> #include <QWidgetAction> #include <QDesktopWidget> +#include <qdialog.h> #include <qmenu.h> #include <qstyle.h> @@ -106,6 +107,7 @@ private slots: void pushButtonPopulateOnAboutToShow(); void QTBUG7907_submenus_autoselect(); void QTBUG7411_submenus_activate(); + void QTBUG_10735_crashWithDialog(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -969,5 +971,57 @@ void tst_QMenu::QTBUG7411_submenus_activate() +class MyMenu : public QMenu +{ + Q_OBJECT +public: + MyMenu() : m_currentIndex(0) + { + for (int i = 0; i < 2; ++i) + dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec())); + } + + + void activateAction(int index) + { + m_currentIndex = index; + popup(QPoint()); + QTest::qWaitForWindowShown(this); + setActiveAction(dialogActions[index]); + QTimer::singleShot(0, this, SLOT(checkVisibility())); + QTest::keyClick(this, Qt::Key_Enter); //activation + } + +public slots: + void activateLastAction() + { + activateAction(1); + } + + void checkVisibility() + { + QTRY_VERIFY(dialogs[m_currentIndex].isVisible()); + if (m_currentIndex == 1) { + QApplication::closeAllWindows(); //this is the end of the test + } + } + + +private: + QAction *dialogActions[2]; + QDialog dialogs[2]; + int m_currentIndex; +}; + +void tst_QMenu::QTBUG_10735_crashWithDialog() +{ + MyMenu menu; + + QTimer::singleShot(1000, &menu, SLOT(activateLastAction())); + menu.activateAction(0); + +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" |