tests/auto/qtextedit/tst_qtextedit.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
--- a/tests/auto/qtextedit/tst_qtextedit.cpp	Mon Jun 21 22:38:13 2010 +0100
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp	Thu Jul 22 16:41:55 2010 +0100
@@ -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"