summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextinput
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-04-06 13:36:17 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-04-12 07:21:33 (GMT)
commitefc80209fb5e6ac9d0343b3c9f6d5a1548cf5556 (patch)
tree28b0cac83c4991b5e6b219c1277197c792fcd3ce /tests/auto/declarative/qdeclarativetextinput
parent3a632cb5f1c1da5c2e72ce167e35a42778867829 (diff)
downloadQt-efc80209fb5e6ac9d0343b3c9f6d5a1548cf5556.zip
Qt-efc80209fb5e6ac9d0343b3c9f6d5a1548cf5556.tar.gz
Qt-efc80209fb5e6ac9d0343b3c9f6d5a1548cf5556.tar.bz2
Add some TextInput properties and methods
Adds the properties -passwordCharacter -displayText And the method -moveCursorSelection(int pos) These just provide a QML way to access existing QLineControl functionality, and are necessary to create desktop style LineEdits (the existing TextInput QML API was designed with a focus on touch input LineEdits) Includes tests and documentation. Task-number: QT-321 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextinput')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml11
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp39
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml b/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml
new file mode 100644
index 0000000..5773cc2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+Rectangle {
+ property var myInput: input
+
+ width: 400; height: 200; color: "green"
+
+ TextInput { id: input; focus: true
+ text: "ABCDefgh"
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index b6f55dd..26d4cb1 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -74,6 +74,7 @@ private slots:
void sendRequestSoftwareInputPanelEvent();
void setHAlignClearCache();
+ void echoMode();
private:
void simulateKey(QDeclarativeView *, int key);
QDeclarativeView *createView(const QString &filename);
@@ -587,6 +588,44 @@ void tst_qdeclarativetextinput::readOnly()
QCOMPARE(input->text(), initial);
}
+void tst_qdeclarativetextinput::echoMode()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ QString initial = input->text();
+ QCOMPARE(initial, QLatin1String("ABCDefgh"));
+ QCOMPARE(input->echoMode(), QDeclarativeTextInput::Normal);
+ QCOMPARE(input->displayText(), input->text());
+ input->setEchoMode(QDeclarativeTextInput::NoEcho);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String(""));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
+ input->setEchoMode(QDeclarativeTextInput::Password);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("********"));
+ input->setPasswordCharacter(QChar('Q'));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(input->text(), QLatin1String("a"));
+ QCOMPARE(input->displayText(), QLatin1String("a"));
+ input->setFocus(false);
+ QCOMPARE(input->displayText(), QLatin1String("Q"));
+}
+
void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key)
{
QKeyEvent press(QKeyEvent::KeyPress, key, 0);