diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-11-26 14:44:08 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-11-26 15:46:40 (GMT) |
commit | bc2b222148648354fe15a6f8da9e01743a1e3e3f (patch) | |
tree | e76b026c32c3189623f9e6a628bfbe54ba16a341 /tests | |
parent | 0cf58948ac9bb9c35835e18a00737c362b08f3c7 (diff) | |
download | Qt-bc2b222148648354fe15a6f8da9e01743a1e3e3f.zip Qt-bc2b222148648354fe15a6f8da9e01743a1e3e3f.tar.gz Qt-bc2b222148648354fe15a6f8da9e01743a1e3e3f.tar.bz2 |
On Mac OS X, QLineEdit should handle MoveToStart/EndOfBlock
On Mac OS X, with a QLineEdit, QKeySequence::MoveToStartOfBlock should
move the cursor to the beginning of the input, and
QKeySequence::MoveToEndOfBlock to the end of the block
Same for selection. The shortcuts also had to be updated.
Task-number: QTBUG-4679
Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index b4dfbba..26294ac 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -261,6 +261,8 @@ private slots: void task241436_passwordEchoOnEditRestoreEchoMode(); void task248948_redoRemovedSelection(); void taskQTBUG_4401_enterKeyClearsPassword(); + void taskQTBUG_4679_moveToStartEndOfBlock(); + void taskQTBUG_4679_selectToStartEndOfBlock(); protected slots: #ifdef QT3_SUPPORT @@ -3548,5 +3550,40 @@ void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword() QTRY_COMPARE(testWidget->text(), password); } +void tst_QLineEdit::taskQTBUG_4679_moveToStartEndOfBlock() +{ +#ifdef Q_OS_MAC + const QString text("there are no blocks for lineEdit"); + testWidget->setText(text); + testWidget->setCursorPosition(5); + QCOMPARE(testWidget->cursorPosition(), 5); + testWidget->setFocus(); + QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier); + QCOMPARE(testWidget->cursorPosition(), 0); + QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier); + QCOMPARE(testWidget->cursorPosition(), text.size()); +#endif // Q_OS_MAC +} + +void tst_QLineEdit::taskQTBUG_4679_selectToStartEndOfBlock() +{ +#ifdef Q_OS_MAC + const QString text("there are no blocks for lineEdit, select all"); + testWidget->setText(text); + testWidget->setCursorPosition(5); + QCOMPARE(testWidget->cursorPosition(), 5); + testWidget->setFocus(); + QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier | Qt::ShiftModifier); + QCOMPARE(testWidget->cursorPosition(), 0); + QVERIFY(testWidget->hasSelectedText()); + QCOMPARE(testWidget->selectedText(), text.mid(0, 5)); + + QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier | Qt::ShiftModifier); + QCOMPARE(testWidget->cursorPosition(), text.size()); + QVERIFY(testWidget->hasSelectedText()); + QCOMPARE(testWidget->selectedText(), text.mid(5)); +#endif // Q_OS_MAC +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" |