From 3c5b3a36af4e3d9dca5e6fbc9b95ddad74f747d3 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 24 Mar 2022 11:27:17 +0100 Subject: [PATCH] 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 --- src/testlib/qtesthelpers_p.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/testlib/qtesthelpers_p.h b/src/testlib/qtesthelpers_p.h index 1995bb4873..67150419bf 100644 --- a/src/testlib/qtesthelpers_p.h +++ b/src/testlib/qtesthelpers_p.h @@ -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