diff options
Diffstat (limited to 'tests/auto/qlineedit')
-rw-r--r-- | tests/auto/qlineedit/qlineedit.pro | 1 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qlineedit/qlineedit.pro b/tests/auto/qlineedit/qlineedit.pro index f00a2d8..1f862b4 100644 --- a/tests/auto/qlineedit/qlineedit.pro +++ b/tests/auto/qlineedit/qlineedit.pro @@ -1,4 +1,5 @@ load(qttest_p4) +contains(QT_CONFIG,qt3support) QT += qt3support SOURCES += tst_qlineedit.cpp diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 6dc2c82..b34e559 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -276,6 +276,11 @@ private slots: #endif void taskQTBUG_7395_readOnlyShortcut(); +#ifdef QT3_SUPPORT + void validateAndSet_data(); + void validateAndSet(); +#endif + protected slots: #ifdef QT3_SUPPORT void lostFocus(); @@ -1491,6 +1496,34 @@ void tst_QLineEdit::lostFocus() { editingFinished(); } + +void tst_QLineEdit::validateAndSet_data() +{ + QTest::addColumn<QString>("newText"); + QTest::addColumn<int>("newPos"); + QTest::addColumn<int>("newMarkAnchor"); + QTest::addColumn<int>("newMarkDrag"); + + QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5; + QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5; +} + +void tst_QLineEdit::validateAndSet() +{ + QFETCH(QString, newText); + QFETCH(int, newPos); + QFETCH(int, newMarkAnchor); + QFETCH(int, newMarkDrag); + + QLineEdit e; + e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag); + QCOMPARE(e.text(), newText); + QCOMPARE(e.cursorPosition(), newPos); + QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor)); +} + + + #endif void tst_QLineEdit::editingFinished() { |