Introduce QTestPrivate::androidCompatibleShow() helper function

This function should be used in QWidget-related test cases instead of
QWidget::show() when you need to move or resize the widget and then
compare its position or geometry with the expected value.
The reason for introducing it is that on Android QWidget::show() is
showing the widget maximized by default, so its position and size
can't be changed.

Task-number: QTBUG-87668
Pick-to: 6.3 6.2
Change-Id: I8ec5c07b73968b98d924a41e5d41ddb4d7be1ced
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Ivan Solovev 2022-03-24 11:27:17 +01:00
parent 2a893db480
commit 3c5b3a36af

View File

@ -104,6 +104,19 @@ static inline void setFrameless(QWidget *w)
| Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
static inline void androidCompatibleShow(QWidget *widget)
{
// On Android QWidget::show() shows the widget maximized, so if we need
// to move or resize the widget, we need to explicitly call
// QWidget::setVisible(true) instead, because that's what show() actually
// does on desktop platforms.
#ifdef Q_OS_ANDROID
widget->setVisible(true);
#else
widget->show();
#endif
}
#endif // QT_WIDGETS_LIB
} // namespace QTestPrivate