tests/auto/qtextedit/tst_qtextedit.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
--- a/tests/auto/qtextedit/tst_qtextedit.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -201,6 +201,9 @@
     void noWrapBackgrounds();
     void preserveCharFormatAfterUnchangingSetPosition();
     void twoSameInputMethodEvents();
+#ifndef QT_NO_CONTEXTMENU
+    void taskQTBUG_7902_contextMenuCrash();
+#endif
 
 private:
     void createSelection();
@@ -2202,5 +2205,24 @@
     QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
 }
 
+#ifndef QT_NO_CONTEXTMENU
+void tst_QTextEdit::taskQTBUG_7902_contextMenuCrash()
+{
+    QTextEdit *w = new QTextEdit;
+    w->show();
+    QTest::qWaitForWindowShown(w);
+
+    QTimer ti;
+    w->connect(&ti, SIGNAL(timeout()), w, SLOT(deleteLater()));
+    ti.start(200);
+
+    QContextMenuEvent *cme = new QContextMenuEvent(QContextMenuEvent::Mouse, w->rect().center());
+    qApp->postEvent(w->viewport(), cme);
+
+    QTest::qWait(300);
+    // No crash, it's allright.
+}
+#endif
+
 QTEST_MAIN(tst_QTextEdit)
 #include "tst_qtextedit.moc"