tests/auto/qtextedit/tst_qtextedit.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   198     void cursorRect();
   198     void cursorRect();
   199     void setDocumentPreservesPalette();
   199     void setDocumentPreservesPalette();
   200     void pasteFromQt3RichText();
   200     void pasteFromQt3RichText();
   201     void noWrapBackgrounds();
   201     void noWrapBackgrounds();
   202     void preserveCharFormatAfterUnchangingSetPosition();
   202     void preserveCharFormatAfterUnchangingSetPosition();
       
   203     void twoSameInputMethodEvents();
   203 
   204 
   204 private:
   205 private:
   205     void createSelection();
   206     void createSelection();
   206     int blockCount() const;
   207     int blockCount() const;
   207     bool nativeClipboardWorking();
   208     bool nativeClipboardWorking();
  1965 
  1966 
  1966     // use the test font so we always know where stuff will end up.
  1967     // use the test font so we always know where stuff will end up.
  1967     qt_setQtEnableTestFont(true);
  1968     qt_setQtEnableTestFont(true);
  1968     QFont testFont;
  1969     QFont testFont;
  1969     testFont.setFamily("__Qt__Box__Engine__");
  1970     testFont.setFamily("__Qt__Box__Engine__");
  1970     testFont.setPixelSize(12);
  1971     testFont.setPixelSize(11);
  1971     testFont.setWeight(QFont::Normal);
  1972     testFont.setWeight(QFont::Normal);
  1972     QTextCharFormat cf;
  1973     QTextCharFormat cf;
  1973     cf.setFont(testFont);
  1974     cf.setFont(testFont);
  1974     cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
  1975     cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
  1975     cursor.setCharFormat(cf);
  1976     cursor.setCharFormat(cf);
  2013 
  2014 
  2014     // use the test font so we always know where stuff will end up.
  2015     // use the test font so we always know where stuff will end up.
  2015     qt_setQtEnableTestFont(true);
  2016     qt_setQtEnableTestFont(true);
  2016     QFont testFont;
  2017     QFont testFont;
  2017     testFont.setFamily("__Qt__Box__Engine__");
  2018     testFont.setFamily("__Qt__Box__Engine__");
  2018     testFont.setPixelSize(12);
  2019     testFont.setPixelSize(11);
  2019     testFont.setWeight(QFont::Normal);
  2020     testFont.setWeight(QFont::Normal);
  2020     QTextCharFormat cf;
  2021     QTextCharFormat cf;
  2021     cf.setFont(testFont);
  2022     cf.setFont(testFont);
  2022     cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
  2023     cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
  2023     cursor.setCharFormat(cf);
  2024     cursor.setCharFormat(cf);
  2181     edit.setTextCursor(c);
  2182     edit.setTextCursor(c);
  2182 
  2183 
  2183     QCOMPARE(edit.textColor(), color);
  2184     QCOMPARE(edit.textColor(), color);
  2184 }
  2185 }
  2185 
  2186 
       
  2187 // Regression test for QTBUG-4696
       
  2188 void tst_QTextEdit::twoSameInputMethodEvents()
       
  2189 {
       
  2190     ed->setText("testLine");
       
  2191     ed->show();
       
  2192     QList<QInputMethodEvent::Attribute> attributes;
       
  2193     attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
       
  2194                                                    ed->textCursor().position(),
       
  2195                                                    0,
       
  2196                                                    QVariant()));
       
  2197 
       
  2198     QInputMethodEvent event("PreEditText", attributes);
       
  2199     QApplication::sendEvent(ed, &event);
       
  2200     QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
       
  2201     QApplication::sendEvent(ed, &event);
       
  2202     QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
       
  2203 }
       
  2204 
  2186 QTEST_MAIN(tst_QTextEdit)
  2205 QTEST_MAIN(tst_QTextEdit)
  2187 #include "tst_qtextedit.moc"
  2206 #include "tst_qtextedit.moc"