tests/auto/qmenu/tst_qmenu.cpp
changeset 29 b72c6db6890b
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/tests/auto/qmenu/tst_qmenu.cpp	Fri Jun 11 14:24:45 2010 +0300
+++ b/tests/auto/qmenu/tst_qmenu.cpp	Wed Jun 23 19:07:03 2010 +0300
@@ -51,6 +51,7 @@
 #include <QListWidget>
 #include <QWidgetAction>
 #include <QDesktopWidget>
+#include <qdialog.h>
 
 #include <qmenu.h>
 #include <qstyle.h>
@@ -104,6 +105,7 @@
     void setFixedWidth();
     void deleteActionInTriggered();
     void pushButtonPopulateOnAboutToShow();
+    void QTBUG_10735_crashWithDialog();
 protected slots:
     void onActivated(QAction*);
     void onHighlighted(QAction*);
@@ -932,5 +934,57 @@
 }
 
 
+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(500, 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"