summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-11-19 05:28:48 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-11-19 05:28:48 (GMT)
commit3e52973f552391a5159b27d6252a81f6a1d52d8c (patch)
treee68619fc74c46563fe5d847943d19ddd9c0c5c48 /tests
parent678c03f5cfecc6448af6474c52c116644f9f54f9 (diff)
downloadQt-3e52973f552391a5159b27d6252a81f6a1d52d8c.zip
Qt-3e52973f552391a5159b27d6252a81f6a1d52d8c.tar.gz
Qt-3e52973f552391a5159b27d6252a81f6a1d52d8c.tar.bz2
Extend tests for TextInput
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/masks.qml7
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml7
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp44
3 files changed, 49 insertions, 9 deletions
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml b/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml
new file mode 100644
index 0000000..08a857c
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+TextInput{
+ focus: true
+ objectName: "myInput"
+ inputMask: "HHHHhhhh; "
+}
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml b/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml
new file mode 100644
index 0000000..7cbeadd
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+TextInput{
+ focus: true
+ objectName: "myInput"
+ maximumLength: 10
+}
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
index d84623f..0eba11b 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
@@ -328,27 +328,53 @@ void tst_qmlgraphicstextinput::selection()
void tst_qmlgraphicstextinput::maxLength()
{
- QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
- QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
+ //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QmlView *canvas = createView(SRCDIR "/data/maxLength.qml");
+ canvas->execute();
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->root() != 0);
+ QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root());
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->text().isEmpty());
+ QVERIFY(textinputObject->maxLength() == 10);
foreach(const QString &str, standard){
QVERIFY(textinputObject->text().length() <= 10);
textinputObject->setText(str);
QVERIFY(textinputObject->text().length() <= 10);
}
- //TODO: Simulated keypress input adding 11 chars at a time
+
+ textinputObject->setText("");
+ QTRY_VERIFY(textinputObject->hasFocus() == true);
+ for(int i=0; i<20; i++){
+ QCOMPARE(textinputObject->text().length(), qMin(i,10));
+ //simulateKey(canvas, Qt::Key_A);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ }
}
void tst_qmlgraphicstextinput::masks()
{
- QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
- QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
+ //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
+ //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }";
+ QmlView *canvas = createView(SRCDIR "/data/masks.qml");
+ canvas->execute();
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->root() != 0);
+ QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root());
QVERIFY(textinputObject != 0);
-
- //TODO: Me
+ QTRY_VERIFY(textinputObject->hasFocus() == true);
+ QVERIFY(textinputObject->text().length() == 0);
+ QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
+ for(int i=0; i<10; i++){
+ QCOMPARE(qMin(i,8), textinputObject->text().length());
+ QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
+ //simulateKey(canvas, Qt::Key_A);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ }
}
void tst_qmlgraphicstextinput::validators()