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 <doris.verria@qt.io>
This commit is contained in:
parent
1fad7aa73e
commit
593ffd3859
@ -608,32 +608,39 @@ void tst_QLabel::mouseEventPropagation_data()
|
||||
{
|
||||
QTest::addColumn<const QString>("text");
|
||||
QTest::addColumn<const Qt::TextInteractionFlag>("interaction");
|
||||
QTest::addColumn<const QList<Qt::MouseButton>>("buttons");
|
||||
QTest::addColumn<const bool>("expectPropagation");
|
||||
|
||||
|
||||
QTest::newRow("RichText")
|
||||
<< QString("<b>This is a rich text propagating mouse events</b>")
|
||||
<< Qt::LinksAccessibleByMouse
|
||||
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||
<< true;
|
||||
QTest::newRow("PlainText")
|
||||
<< QString("This is a plain text propagating mouse events")
|
||||
<< Qt::LinksAccessibleByMouse
|
||||
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||
<< true;
|
||||
QTest::newRow("PlainTextConsume")
|
||||
<< QString("This is a plain text consuming mouse events")
|
||||
<< Qt::TextSelectableByMouse
|
||||
<< QList<Qt::MouseButton>{Qt::LeftButton}
|
||||
<< false;
|
||||
QTest::newRow("RichTextConsume")
|
||||
<< QString("<b>This is a rich text consuming mouse events</b>")
|
||||
<< Qt::TextSelectableByMouse
|
||||
<< QList<Qt::MouseButton>{Qt::LeftButton}
|
||||
<< false;
|
||||
QTest::newRow("PlainTextNoInteraction")
|
||||
<< QString("This is a text not interacting with mouse")
|
||||
<< Qt::NoTextInteraction
|
||||
<< QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
|
||||
<< true;
|
||||
QTest::newRow("RichTextNoInteraction")
|
||||
<< QString("<b>This is a rich text not interacting with mouse</b>")
|
||||
<< Qt::NoTextInteraction
|
||||
<< QList<Qt::MouseButton>{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<Qt::MouseButton>, 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user