From 593ffd3859b2c80c498baf5323906a348de22b80 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Mon, 23 Jan 2023 11:15:38 +0100 Subject: [PATCH] Add right and middle mouse button to tst_QLabel::mouseEventPropagation The test function used only the left button to test mouse event propagation. This patch adds the right and middle buttons to the test data. Task-number: QTBUG-110055 Pick-to: 6.5 6.4 Change-Id: I02683168216843919e889987a8b0e8a0f1592d3a Reviewed-by: Doris Verria --- tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index 77613341dd..2775e2c683 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -608,32 +608,39 @@ void tst_QLabel::mouseEventPropagation_data() { QTest::addColumn("text"); QTest::addColumn("interaction"); + QTest::addColumn>("buttons"); QTest::addColumn("expectPropagation"); QTest::newRow("RichText") << QString("This is a rich text propagating mouse events") << Qt::LinksAccessibleByMouse + << QList{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton} << true; QTest::newRow("PlainText") << QString("This is a plain text propagating mouse events") << Qt::LinksAccessibleByMouse + << QList{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton} << true; QTest::newRow("PlainTextConsume") << QString("This is a plain text consuming mouse events") << Qt::TextSelectableByMouse + << QList{Qt::LeftButton} << false; QTest::newRow("RichTextConsume") << QString("This is a rich text consuming mouse events") << Qt::TextSelectableByMouse + << QList{Qt::LeftButton} << false; QTest::newRow("PlainTextNoInteraction") << QString("This is a text not interacting with mouse") << Qt::NoTextInteraction + << QList{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton} << true; QTest::newRow("RichTextNoInteraction") << QString("This is a rich text not interacting with mouse") << Qt::NoTextInteraction + << QList{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton} << true; } @@ -663,21 +670,23 @@ void tst_QLabel::mouseEventPropagation() QFETCH(const QString, text); QFETCH(const Qt::TextInteractionFlag, interaction); + QFETCH(const QList, buttons); QFETCH(const bool, expectPropagation); MouseEventWidget widget; auto *layout = new QVBoxLayout(&widget); auto *label = new QLabel(text); label->setTextInteractionFlags(interaction); - const uint count = expectPropagation ? 1 : 0; layout->addWidget(label); widget.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); const QPoint labelCenter = label->rect().center(); - QTest::mouseClick(label, Qt::LeftButton, Qt::KeyboardModifiers(), labelCenter); + for (Qt::MouseButton mouseButton : buttons) + QTest::mouseClick(label, mouseButton, Qt::KeyboardModifiers(), labelCenter); + const uint count = expectPropagation ? buttons.count() : 0; QTRY_COMPARE(widget.pressed(), count); QTRY_COMPARE(widget.released(), count); }