diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-22 04:50:01 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-22 05:28:30 (GMT) |
commit | 0767c2ff719a35c16c72fac97e6ff612e8c71e21 (patch) | |
tree | 1d7d140fc328132dface53d3afae7591661d428d /tests/auto/declarative | |
parent | ddb5e1eef379c7f32a594d91b00ff3514c46b62a (diff) | |
download | Qt-0767c2ff719a35c16c72fac97e6ff612e8c71e21.zip Qt-0767c2ff719a35c16c72fac97e6ff612e8c71e21.tar.gz Qt-0767c2ff719a35c16c72fac97e6ff612e8c71e21.tar.bz2 |
Fix TextEdit text attribute and text stored in the internal QTextDocument having different contents
Task-number: QTBUG-12339
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 93351a8..57a5e29 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -115,6 +115,7 @@ private slots: void navigation(); void readOnly(); void copyAndPaste(); + void textInput(); void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); @@ -882,6 +883,12 @@ void tst_qdeclarativetextedit::copyAndPaste() { QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); QCOMPARE(textEdit->text().length(), 24); + // QTBUG-12339 + // test that document and internal text attribute are in sync + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(textEdit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + QCOMPARE(textEdit->text(), editPrivate->text); + // select word textEdit->setCursorPosition(0); textEdit->selectWord(); @@ -961,6 +968,33 @@ public: bool closeInputPanelReceived; }; +void tst_qdeclarativetextedit::textInput() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QDeclarativeTextEdit edit; + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + edit.setPos(0, 0); + scene.addItem(&edit); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + edit.setFocus(true); + QVERIFY(edit.hasActiveFocus() == true); + + // test that input method event is committed + QInputMethodEvent event; + event.setCommitString( "Hello world!", 0, 0); + QApplication::sendEvent(&view, &event); + QCOMPARE(edit.text(), QString("Hello world!")); + + // QTBUG-12339 + // test that document and internal text attribute are in sync + QCOMPARE(editPrivate->text, QString("Hello world!")); +} + void tst_qdeclarativetextedit::openInputPanelOnClick() { QGraphicsScene scene; |