summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-02-17 12:42:50 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2023-03-15 23:45:00 +0100
commit09c3cd8503102c70c7d5bf41c0b662b2c86b4ad0 (patch)
tree4936d13bbbc05c32fbbbdd6d33992a29e1abcf91 /tests/auto/widgets
parent99975ec07feb6b1a9f6be9e0d392a35e40f9550a (diff)
QPlainTextEdit: Don't block signals on page step
Signals of the vertical scroll bar were blocked when scrolling with pageUp/pageDown keys or clicking on the scroll range outside the scroll bar. This has lead to inconsistent signal emissions: The vertical scroll bar's valueChanged signal was emitted only on single steps and when the scroll bar was moved with the mouse. When it was moved in page steps by clicking on the scroll range or pressing pageUp/pageDown, it was not emitted. This patch removes the signal blocker for page step movements, which was added in 94fd108ea42a99dacefa819bc3fd4363fb95e886 to replace explicit calls to blockSignals(), which were added in c14d442b08ac81327b173b0a220c7b1840667899. The patch also adds test function to tst_QPlainTextEdit to check if the valueChanged signal is emitted correctly. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-8682 Fixes: QTBUG-25365 Change-Id: I4385a5387c91497f623978e35bbbe3e06f473afe Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index e3ccc58867..ed68c735d4 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -132,6 +132,7 @@ private slots:
void appendTextWhenInvisible();
void placeholderVisibility_data();
void placeholderVisibility();
+ void scrollBarSignals();
private:
void createSelection();
@@ -1919,5 +1920,30 @@ void tst_QPlainTextEdit::placeholderVisibility()
QTRY_VERIFY(plainTextEdit_d->placeholderVisible == placeholderVisible);
}
+
+void tst_QPlainTextEdit::scrollBarSignals()
+{
+ QPlainTextEdit plainTextEdit;
+ QString longText;
+ for (uint i = 0; i < 500; ++i)
+ longText += "This is going to be a very long text for scroll signal testing.\n";
+ plainTextEdit.setPlainText(longText);
+ QScrollBar *vbar = plainTextEdit.verticalScrollBar();
+ plainTextEdit.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&plainTextEdit));
+ QSignalSpy spy(vbar, &QScrollBar::valueChanged);
+
+ QTest::keyClick(vbar, Qt::Key_Down);
+ QTRY_COMPARE(spy.count(), 1);
+ QTest::keyClick(vbar, Qt::Key_PageDown);
+ QTRY_COMPARE(spy.count(), 2);
+ QTest::keyClick(vbar, Qt::Key_PageDown);
+ QTRY_COMPARE(spy.count(), 3);
+ QTest::keyClick(vbar, Qt::Key_Up);
+ QTRY_COMPARE(spy.count(), 4);
+ QTest::keyClick(vbar, Qt::Key_PageUp);
+ QTRY_COMPARE(spy.count(), 5);
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"