diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-22 04:50:01 (GMT) |
---|---|---|
committer | Toby Tomkins <toby.tomkins@nokia.com> | 2010-07-26 04:11:06 (GMT) |
commit | 49d1825841a800ac41d15c5bb6e76628c6bb4859 (patch) | |
tree | e8677fe68fccdd809986e7e03cb80f3832f3a777 /tests | |
parent | d76f95d30b1c174323bfca982336d96f3a2cebe2 (diff) | |
download | Qt-49d1825841a800ac41d15c5bb6e76628c6bb4859.zip Qt-49d1825841a800ac41d15c5bb6e76628c6bb4859.tar.gz Qt-49d1825841a800ac41d15c5bb6e76628c6bb4859.tar.bz2 |
Fix TextEdit text attribute and text stored in the internal QTextDocument having different contents
Task-number: QTBUG-12339
Reviewed-by: Martin Jones
(cherry picked from commit 0767c2ff719a35c16c72fac97e6ff612e8c71e21)
Diffstat (limited to 'tests')
-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 f7285c2..bc814e5 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -97,6 +97,7 @@ private slots: void navigation(); void readOnly(); void copyAndPaste(); + void textInput(); void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); @@ -862,6 +863,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(); @@ -941,6 +948,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; |