tests/auto/qtextedit/tst_qtextedit.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/tests/auto/qtextedit/tst_qtextedit.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -200,6 +200,7 @@
     void pasteFromQt3RichText();
     void noWrapBackgrounds();
     void preserveCharFormatAfterUnchangingSetPosition();
+    void twoSameInputMethodEvents();
 
 private:
     void createSelection();
@@ -1967,7 +1968,7 @@
     qt_setQtEnableTestFont(true);
     QFont testFont;
     testFont.setFamily("__Qt__Box__Engine__");
-    testFont.setPixelSize(12);
+    testFont.setPixelSize(11);
     testFont.setWeight(QFont::Normal);
     QTextCharFormat cf;
     cf.setFont(testFont);
@@ -2015,7 +2016,7 @@
     qt_setQtEnableTestFont(true);
     QFont testFont;
     testFont.setFamily("__Qt__Box__Engine__");
-    testFont.setPixelSize(12);
+    testFont.setPixelSize(11);
     testFont.setWeight(QFont::Normal);
     QTextCharFormat cf;
     cf.setFont(testFont);
@@ -2183,5 +2184,23 @@
     QCOMPARE(edit.textColor(), color);
 }
 
+// Regression test for QTBUG-4696
+void tst_QTextEdit::twoSameInputMethodEvents()
+{
+    ed->setText("testLine");
+    ed->show();
+    QList<QInputMethodEvent::Attribute> attributes;
+    attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
+                                                   ed->textCursor().position(),
+                                                   0,
+                                                   QVariant()));
+
+    QInputMethodEvent event("PreEditText", attributes);
+    QApplication::sendEvent(ed, &event);
+    QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+    QApplication::sendEvent(ed, &event);
+    QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+}
+
 QTEST_MAIN(tst_QTextEdit)
 #include "tst_qtextedit.moc"