Fix test to not rely on event processing
QTest's simulation of mouse move events currently uses QCursor::setPos and then processes events. This is unreliable across platforms. This test relies on the event processing and either way has inverted logic in the paint event; the painted region needs to at least include the tab's rect, not the other way around. Also, the mouse move wasn't needed here at all, and some styles don't have a different style for pressed tabs anyway. Pick-to: 6.2 Change-Id: Ib8f6f7be017ff87458e96ec419edcd065dd75b15 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
5ffc744b79
commit
05532a0968
@ -842,9 +842,10 @@ void tst_QTabBar::mouseReleaseOutsideTabBar()
|
||||
QRect rectToBeRepainted;
|
||||
bool eventFilter(QObject *, QEvent *event) override
|
||||
{
|
||||
if (event->type() == QEvent::Paint
|
||||
&& rectToBeRepainted.contains(static_cast<QPaintEvent *>(event)->rect()))
|
||||
if (event->type() == QEvent::Paint &&
|
||||
static_cast<QPaintEvent *>(event)->rect().contains(rectToBeRepainted)) {
|
||||
repainted = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} repaintChecker;
|
||||
@ -859,14 +860,15 @@ void tst_QTabBar::mouseReleaseOutsideTabBar()
|
||||
|
||||
QRect tabRect = tabBar.tabRect(1);
|
||||
QPoint tabCenter = tabRect.center();
|
||||
QTest::mousePress(&tabBar, Qt::LeftButton, {}, tabCenter);
|
||||
QTest::mouseEvent(QTest::MouseMove, &tabBar, Qt::LeftButton, {}, tabCenter + QPoint(tabCenter.x(), tabCenter.y() + tabRect.height()));
|
||||
|
||||
// make sure the holding tab is repainted after releasing the mouse
|
||||
repaintChecker.repainted = false;
|
||||
repaintChecker.rectToBeRepainted = tabRect;
|
||||
// if a press repaints the tab...
|
||||
QTest::mousePress(&tabBar, Qt::LeftButton, {}, tabCenter);
|
||||
const bool pressRepainted = QTest::qWaitFor([&]{ return repaintChecker.repainted; }, 250);
|
||||
|
||||
// ... then releasing the mouse outside the tabbar should repaint it as well
|
||||
repaintChecker.repainted = false;
|
||||
QTest::mouseRelease(&tabBar, Qt::LeftButton, {}, tabCenter + QPoint(tabCenter.x(), tabCenter.y() + tabRect.height()));
|
||||
QTRY_VERIFY(repaintChecker.repainted);
|
||||
QTRY_COMPARE(repaintChecker.repainted, pressRepainted);
|
||||
}
|
||||
|
||||
void tst_QTabBar::checkPositions(const TabBar &tabbar, const QList<int> &positions)
|
||||
|
Loading…
Reference in New Issue
Block a user