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 Change-Id: I02683168216843919e889987a8b0e8a0f1592d3a Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 593ffd3859b2c80c498baf5323906a348de22b80) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
802dfb1879
commit
379649dd8b
@ -606,32 +606,39 @@ void tst_QLabel::mouseEventPropagation_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<const QString>("text");
|
QTest::addColumn<const QString>("text");
|
||||||
QTest::addColumn<const Qt::TextInteractionFlag>("interaction");
|
QTest::addColumn<const Qt::TextInteractionFlag>("interaction");
|
||||||
|
QTest::addColumn<const QList<Qt::MouseButton>>("buttons");
|
||||||
QTest::addColumn<const bool>("expectPropagation");
|
QTest::addColumn<const bool>("expectPropagation");
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("RichText")
|
QTest::newRow("RichText")
|
||||||
<< QString("<b>This is a rich text propagating mouse events</b>")
|
<< QString("<b>This is a rich text propagating mouse events</b>")
|
||||||
<< Qt::LinksAccessibleByMouse
|
<< Qt::LinksAccessibleByMouse
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||||
<< true;
|
<< true;
|
||||||
QTest::newRow("PlainText")
|
QTest::newRow("PlainText")
|
||||||
<< QString("This is a plain text propagating mouse events")
|
<< QString("This is a plain text propagating mouse events")
|
||||||
<< Qt::LinksAccessibleByMouse
|
<< Qt::LinksAccessibleByMouse
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||||
<< true;
|
<< true;
|
||||||
QTest::newRow("PlainTextConsume")
|
QTest::newRow("PlainTextConsume")
|
||||||
<< QString("This is a plain text consuming mouse events")
|
<< QString("This is a plain text consuming mouse events")
|
||||||
<< Qt::TextSelectableByMouse
|
<< Qt::TextSelectableByMouse
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton}
|
||||||
<< false;
|
<< false;
|
||||||
QTest::newRow("RichTextConsume")
|
QTest::newRow("RichTextConsume")
|
||||||
<< QString("<b>This is a rich text consuming mouse events</b>")
|
<< QString("<b>This is a rich text consuming mouse events</b>")
|
||||||
<< Qt::TextSelectableByMouse
|
<< Qt::TextSelectableByMouse
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton}
|
||||||
<< false;
|
<< false;
|
||||||
QTest::newRow("PlainTextNoInteraction")
|
QTest::newRow("PlainTextNoInteraction")
|
||||||
<< QString("This is a text not interacting with mouse")
|
<< QString("This is a text not interacting with mouse")
|
||||||
<< Qt::NoTextInteraction
|
<< Qt::NoTextInteraction
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||||
<< true;
|
<< true;
|
||||||
QTest::newRow("RichTextNoInteraction")
|
QTest::newRow("RichTextNoInteraction")
|
||||||
<< QString("<b>This is a rich text not interacting with mouse</b>")
|
<< QString("<b>This is a rich text not interacting with mouse</b>")
|
||||||
<< Qt::NoTextInteraction
|
<< Qt::NoTextInteraction
|
||||||
|
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||||
<< true;
|
<< true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,21 +668,23 @@ void tst_QLabel::mouseEventPropagation()
|
|||||||
|
|
||||||
QFETCH(const QString, text);
|
QFETCH(const QString, text);
|
||||||
QFETCH(const Qt::TextInteractionFlag, interaction);
|
QFETCH(const Qt::TextInteractionFlag, interaction);
|
||||||
|
QFETCH(const QList<Qt::MouseButton>, buttons);
|
||||||
QFETCH(const bool, expectPropagation);
|
QFETCH(const bool, expectPropagation);
|
||||||
|
|
||||||
MouseEventWidget widget;
|
MouseEventWidget widget;
|
||||||
auto *layout = new QVBoxLayout(&widget);
|
auto *layout = new QVBoxLayout(&widget);
|
||||||
auto *label = new QLabel(text);
|
auto *label = new QLabel(text);
|
||||||
label->setTextInteractionFlags(interaction);
|
label->setTextInteractionFlags(interaction);
|
||||||
const uint count = expectPropagation ? 1 : 0;
|
|
||||||
|
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
widget.show();
|
widget.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&widget));
|
QVERIFY(QTest::qWaitForWindowExposed(&widget));
|
||||||
|
|
||||||
const QPoint labelCenter = label->rect().center();
|
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.pressed(), count);
|
||||||
QTRY_COMPARE(widget.released(), count);
|
QTRY_COMPARE(widget.released(), count);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user