summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qfxtextinput
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-10-15 04:07:24 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-10-15 04:07:24 (GMT)
commit0f97a4fbcab5972f47a8a6cc3b501446df94bedb (patch)
tree2f481fb4dab033b42649c9453b0409d0825a1792 /tests/auto/declarative/qfxtextinput
parent25f5008d6bc6788e68e34f24af196f12de052567 (diff)
downloadQt-0f97a4fbcab5972f47a8a6cc3b501446df94bedb.zip
Qt-0f97a4fbcab5972f47a8a6cc3b501446df94bedb.tar.gz
Qt-0f97a4fbcab5972f47a8a6cc3b501446df94bedb.tar.bz2
Add cursorDelegate test to QFxTextInput autotests
Also cleaned up the QFxTextEdit version, and fixed a bug the new test uncovered.
Diffstat (limited to 'tests/auto/declarative/qfxtextinput')
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index 81b4ac8..069574c 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -330,7 +330,30 @@ void tst_qfxtextinput::navigation()
void tst_qfxtextinput::cursorDelegate()
{
- //TODO:Get the QFxTextEdit test passing first
+ QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->execute();
+ view->show();
+ view->setFocus();
+ QFxTextInput *textInputObject = view->root()->findChild<QFxTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QFxItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QFxItem* delegateObject = textInputObject->findChild<QFxItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textInputObject->text().length(); i++){
+ textInputObject->setCursorPosition(i);
+ //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
+ QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QFxItem*>("cursorInstance"));
}
void tst_qfxtextinput::simulateKey(QmlView *view, int key)