diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-12-11 01:00:10 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-12-11 14:52:25 +0100 |
commit | 5b193e3dd47704daf56c8817d0157f66363044c3 (patch) | |
tree | 88d81d23ebe62a3decda01c4066599e0c4d81299 /tests/auto/widgets/widgets | |
parent | c3a66baff87e8d231aae06ccd1eb5d623587593d (diff) | |
parent | a4a7c1bcf7595e2645c570d9c824532acf524fdf (diff) |
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 3 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp | 46 |
2 files changed, 46 insertions, 3 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index c2475be8b4..bf31f12958 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -885,9 +885,6 @@ void tst_QLineEdit::hasAcceptableInputMask() qApp->sendEvent(testWidget, &lostFocus); QVERIFY(validInput); - // at the moment we don't strip the blank character if it is valid input, this makes the test between x vs X useless - QEXPECT_FAIL( "Any optional and required", "To eat blanks or not? Known issue. Task 43172", Abort); - // test requiredMask testWidget->setInputMask(requiredMask); validInput = true; diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index 336b6ebfd5..a86784f2ec 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -155,6 +155,7 @@ private slots: #if QT_CONFIG(scrollbar) void updateAfterChangeCenterOnScroll(); #endif + void updateCursorPositionAfterEdit(); private: void createSelection(); @@ -1802,5 +1803,50 @@ void tst_QPlainTextEdit::updateAfterChangeCenterOnScroll() #endif +void tst_QPlainTextEdit::updateCursorPositionAfterEdit() +{ + QPlainTextEdit plaintextEdit; + plaintextEdit.setPlainText("some text some text\nsome text some text"); + + const auto initialPosition = 1; + + // select some text + auto cursor = plaintextEdit.textCursor(); + cursor.setPosition(initialPosition, QTextCursor::MoveAnchor); + cursor.setPosition(initialPosition + 3, QTextCursor::KeepAnchor); + plaintextEdit.setTextCursor(cursor); + QVERIFY(plaintextEdit.textCursor().hasSelection()); + + QTest::keyClick(&plaintextEdit, Qt::Key_Delete); + QTest::keyClick(&plaintextEdit, Qt::Key_Down); + QTest::keyClick(&plaintextEdit, Qt::Key_Up); + + // Moving the cursor down and up should bring it to the initial position + QCOMPARE(plaintextEdit.textCursor().position(), initialPosition); + + // Test the same with backspace + cursor = plaintextEdit.textCursor(); + cursor.setPosition(initialPosition + 3, QTextCursor::KeepAnchor); + plaintextEdit.setTextCursor(cursor); + QVERIFY(plaintextEdit.textCursor().hasSelection()); + + QTest::keyClick(&plaintextEdit, Qt::Key_Backspace); + QTest::keyClick(&plaintextEdit, Qt::Key_Down); + QTest::keyClick(&plaintextEdit, Qt::Key_Up); + + // Moving the cursor down and up should bring it to the initial position + QCOMPARE(plaintextEdit.textCursor().position(), initialPosition); + + // Test insertion + const QString txt("txt"); + QApplication::clipboard()->setText(txt); + plaintextEdit.paste(); + QTest::keyClick(&plaintextEdit, Qt::Key_Down); + QTest::keyClick(&plaintextEdit, Qt::Key_Up); + + // The curser should move back to the end of the copied text + QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.length()); +} + QTEST_MAIN(tst_QPlainTextEdit) #include "tst_qplaintextedit.moc" |