aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-03-09 17:40:49 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 06:49:30 +0100
commit7a9cd9d4fedda26a410576bcfa071fcd0d94646e (patch)
tree786d0b18e6027845e4c3219136f9ac6ab54ea0c1 /tests
parent386e56ff336fe956f4d44946edab275b7244a4ca (diff)
Add additional key sequence tests.
Change-Id: Ie77a61a3ea0d1bdccd59dd519346db74bdf59c44 Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp113
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp149
2 files changed, 207 insertions, 55 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index a90b23dfd7..8d346891dc 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -69,6 +69,7 @@
Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
+Q_DECLARE_METATYPE(Qt::Key)
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
@@ -185,7 +186,7 @@ private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
void simulateKeys(QWindow *window, const QKeySequence &sequence);
- void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0);
+ void simulateKey(QWindow *, int key, Qt::KeyboardModifiers modifiers = 0);
QStringList standard;
QStringList richText;
@@ -2155,7 +2156,7 @@ void tst_qquicktextedit::readOnly()
QCOMPARE(edit->cursorPosition(), edit->text().length());
}
-void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers)
+void tst_qquicktextedit::simulateKey(QWindow *view, int key, Qt::KeyboardModifiers modifiers)
{
QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
@@ -3255,63 +3256,118 @@ void tst_qquicktextedit::keySequence_data()
QTest::addColumn<int>("cursorPosition");
QTest::addColumn<QString>("expectedText");
QTest::addColumn<QString>("selectedText");
+ QTest::addColumn<Qt::Key>("layoutDirection");
// standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
QTest::newRow("select all")
<< standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
+ << 44 << standard.at(0) << standard.at(0)
+ << Qt::Key_Direction_L;
+ QTest::newRow("select start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectStartOfLine) << 5 << 5
+ << 0 << standard.at(0) << standard.at(0).mid(0, 5)
+ << Qt::Key_Direction_L;
+ QTest::newRow("select start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectStartOfBlock) << 5 << 5
+ << 0 << standard.at(0) << standard.at(0).mid(0, 5)
+ << Qt::Key_Direction_L;
QTest::newRow("select end of line")
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
+ << 44 << standard.at(0) << standard.at(0).mid(5)
+ << Qt::Key_Direction_L;
QTest::newRow("select end of document")
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 44 << standard.at(0) << standard.at(0).mid(3);
+ << 44 << standard.at(0) << standard.at(0).mid(3)
+ << Qt::Key_Direction_L;
QTest::newRow("select end of block")
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
+ << 44 << standard.at(0) << standard.at(0).mid(18)
+ << Qt::Key_Direction_L;
QTest::newRow("delete end of line")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
+ << 24 << standard.at(0).mid(0, 24) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("move to start of line")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
+ << 0 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("move to start of block")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
+ << 0 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("move to next char")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
+ << 13 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
+ QTest::newRow("move to previous char (ltr)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
+ << 2 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
+ QTest::newRow("move to previous char (rtl)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 4 << standard.at(0) << QString()
+ << Qt::Key_Direction_R;
+ QTest::newRow("move to previous char with selection")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 7
+ << 3 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
+ QTest::newRow("select next char (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1)
+ << Qt::Key_Direction_L;
+ QTest::newRow("select next char (rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
+ << 22 << standard.at(0) << standard.at(0).mid(22, 1)
+ << Qt::Key_Direction_R;
+ QTest::newRow("select previous char (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1)
+ << Qt::Key_Direction_L;
+ QTest::newRow("select previous char (rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
+ << 20 << standard.at(0) << standard.at(0).mid(19, 1)
+ << Qt::Key_Direction_R;
+ QTest::newRow("move to next word (ltr)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
+ << 10 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
+ QTest::newRow("move to next word (rtl)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 4 << standard.at(0) << QString()
+ << Qt::Key_Direction_R;
+ QTest::newRow("move to previous word (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString()
+ << Qt::Key_Direction_L;
+ QTest::newRow("move to previous word (rlt)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
+ << 10 << standard.at(0) << QString()
+ << Qt::Key_Direction_R;
+ QTest::newRow("select next word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextWord) << 11 << 11
+ << 16 << standard.at(0) << standard.at(0).mid(11, 5)
+ << Qt::Key_Direction_L;
QTest::newRow("select previous word")
<< standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1)
+ << Qt::Key_Direction_L;
QTest::newRow("delete (selection)")
<< standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("delete (no selection)")
<< standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("delete end of word")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString()
+ << Qt::Key_Direction_L;
QTest::newRow("delete start of word")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString()
+ << Qt::Key_Direction_L;
}
void tst_qquicktextedit::keySequence()
@@ -3323,6 +3379,7 @@ void tst_qquicktextedit::keySequence()
QFETCH(int, cursorPosition);
QFETCH(QString, expectedText);
QFETCH(QString, selectedText);
+ QFETCH(Qt::Key, layoutDirection);
if (sequence.isEmpty()) {
QSKIP("Key sequence is undefined");
@@ -3341,6 +3398,8 @@ void tst_qquicktextedit::keySequence()
QTest::qWaitForWindowShown(&canvas);
QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+ simulateKey(&canvas, layoutDirection);
+
textEdit->select(selectionStart, selectionEnd);
simulateKeys(&canvas, sequence);
@@ -3466,7 +3525,7 @@ void tst_qquicktextedit::undo_data()
insertString << " unique instance.";
expectedString << "Ensuring a unique instance.";
- expectedString << "Ensuring a "; // ### Not present in TextInput.
+ expectedString << "Ensuring a "; // ### Not present in TextEdit.
expectedString << "Ensuring an instan";
expectedString << "Ensuring instan";
expectedString << "";
@@ -3754,7 +3813,7 @@ void tst_qquicktextedit::undo_keypressevents_data()
<< "ABC";
expectedString << "ABC";
- // ### One operation in TextInput.
+ // ### One operation in TextEdit.
expectedString << "A";
expectedString << "123";
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 9e689a8962..d08890afec 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -63,6 +63,9 @@
#include "../../shared/platforminputcontext.h"
Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
+Q_DECLARE_METATYPE(QQuickTextInput::EchoMode)
+Q_DECLARE_METATYPE(Qt::Key)
+
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
@@ -188,7 +191,7 @@ private slots:
void negativeDimensions();
private:
- void simulateKey(QQuickView *, int key);
+ void simulateKey(QWindow *, int key);
void simulateKeys(QWindow *window, const QList<Key> &keys);
void simulateKeys(QWindow *window, const QKeySequence &sequence);
@@ -2126,7 +2129,7 @@ void tst_qquicktextinput::copyAndPaste() {
// copy and paste
QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());;
+ textInput->select(0, textInput->text().length());
textInput->copy();
QCOMPARE(textInput->selectedText(), QString("Hello world!"));
QCOMPARE(textInput->selectedText().length(), 12);
@@ -2169,7 +2172,7 @@ void tst_qquicktextinput::copyAndPaste() {
QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
textInput->setEchoMode(echoMode);
textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
+ textInput->select(0, textInput->text().length());
textInput->copy();
if (echoMode == QQuickTextInput::Normal) {
QVERIFY(!clipboard->text().isEmpty());
@@ -2246,7 +2249,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence() {
QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
textInput->setEchoMode(echoMode);
textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
+ textInput->select(0, textInput->text().length());
simulateKeys(&canvas, QKeySequence::Copy);
if (echoMode == QQuickTextInput::Normal) {
QVERIFY(!clipboard->text().isEmpty());
@@ -2702,7 +2705,7 @@ void tst_qquicktextinput::passwordEchoDelay()
#endif
-void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
+void tst_qquicktextinput::simulateKey(QWindow *view, int key)
{
QKeyEvent press(QKeyEvent::KeyPress, key, 0);
QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
@@ -4084,63 +4087,135 @@ void tst_qquicktextinput::keySequence_data()
QTest::addColumn<int>("cursorPosition");
QTest::addColumn<QString>("expectedText");
QTest::addColumn<QString>("selectedText");
+ QTest::addColumn<QQuickTextInput::EchoMode>("echoMode");
+ QTest::addColumn<Qt::Key>("layoutDirection");
// standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
QTest::newRow("select all")
<< standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
+ << 44 << standard.at(0) << standard.at(0)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("select start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectStartOfLine) << 5 << 5
+ << 0 << standard.at(0) << standard.at(0).mid(0, 5)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("select start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectStartOfBlock) << 5 << 5
+ << 0 << standard.at(0) << standard.at(0).mid(0, 5)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("select end of line")
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
+ << 44 << standard.at(0) << standard.at(0).mid(5)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("select end of document") // ### Not handled.
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 3 << standard.at(0) << QString();
+ << 3 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("select end of block")
<< standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
+ << 44 << standard.at(0) << standard.at(0).mid(18)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("delete end of line")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
+ << 24 << standard.at(0).mid(0, 24) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("move to start of line")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
+ << 0 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("move to start of block")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
+ << 0 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("move to next char")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
+ << 13 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("move to previous char (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 2 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("move to previous char (rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
+ << 4 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_R;
+ QTest::newRow("move to previous char with selection")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 7
+ << 3 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("select next char (ltr)")
<< standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("select next char (rtl)")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 22 << standard.at(0) << standard.at(0).mid(22, 1)
+ << QQuickTextInput::Normal << Qt::Key_Direction_R;
+ QTest::newRow("select previous char (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("select previous char (rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
+ << 20 << standard.at(0) << standard.at(0).mid(19, 1)
+ << QQuickTextInput::Normal << Qt::Key_Direction_R;
+ QTest::newRow("move to next word (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 10 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("move to next word (rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
+ << 4 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_R;
+ QTest::newRow("move to next word (password,ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 44 << standard.at(0) << QString()
+ << QQuickTextInput::Password << Qt::Key_Direction_L;
+ QTest::newRow("move to next word (password,rtl)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 0 << standard.at(0) << QString()
+ << QQuickTextInput::Password << Qt::Key_Direction_R;
+ QTest::newRow("move to previous word (ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
+ QTest::newRow("move to previous word (rlt)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 10 << standard.at(0) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_R;
+ QTest::newRow("move to previous word (password,ltr)")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 0 << standard.at(0) << QString()
+ << QQuickTextInput::Password << Qt::Key_Direction_L;
+ QTest::newRow("move to previous word (password,rtl)")
<< standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
+ << 44 << standard.at(0) << QString()
+ << QQuickTextInput::Password << Qt::Key_Direction_R;
+ QTest::newRow("select next word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextWord) << 11 << 11
+ << 16 << standard.at(0) << standard.at(0).mid(11, 5)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("select previous word")
<< standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1)
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("delete (selection)")
<< standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("delete (no selection)")
<< standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("delete end of word")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
QTest::newRow("delete start of word")
<< standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString()
+ << QQuickTextInput::Normal << Qt::Key_Direction_L;
}
void tst_qquicktextinput::keySequence()
@@ -4152,6 +4227,8 @@ void tst_qquicktextinput::keySequence()
QFETCH(int, cursorPosition);
QFETCH(QString, expectedText);
QFETCH(QString, selectedText);
+ QFETCH(QQuickTextInput::EchoMode, echoMode);
+ QFETCH(Qt::Key, layoutDirection);
if (sequence.isEmpty()) {
QSKIP("Key sequence is undefined");
@@ -4162,6 +4239,7 @@ void tst_qquicktextinput::keySequence()
textInputComponent.setData(componentStr.toLatin1(), QUrl());
QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
QVERIFY(textInput != 0);
+ textInput->setEchoMode(echoMode);
QQuickCanvas canvas;
textInput->setParentItem(canvas.rootItem());
@@ -4170,6 +4248,8 @@ void tst_qquicktextinput::keySequence()
QTest::qWaitForWindowShown(&canvas);
QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+ simulateKey(&canvas, layoutDirection);
+
textInput->select(selectionStart, selectionEnd);
simulateKeys(&canvas, sequence);
@@ -4583,6 +4663,19 @@ void tst_qquicktextinput::undo_keypressevents_data()
expectedString << "123";
QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys << "123"
+ << QKeySequence::Undo
+ << QKeySequence::Redo;
+
+ expectedString << "123";
+ expectedString << QString();
+
+ QTest::newRow("Insert,undo,redo") << keys << expectedString;
}
}