summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-22 14:50:01 +1000
committerToby Tomkins <toby.tomkins@nokia.com>2010-07-26 14:11:06 +1000
commit49d1825841a800ac41d15c5bb6e76628c6bb4859 (patch)
treee8677fe68fccdd809986e7e03cb80f3832f3a777 /tests
parentd76f95d30b1c174323bfca982336d96f3a2cebe2 (diff)
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.cpp34
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 f7285c20f5..bc814e559f 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;