summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-03-24 11:27:17 +0100
committerIvan Solovev <ivan.solovev@qt.io>2022-03-29 13:56:14 +0100
commit3c5b3a36af4e3d9dca5e6fbc9b95ddad74f747d3 (patch)
tree7c11736eec2820f97642d4a784ef8307e2e4427c /src/testlib
parent2a893db48017a850044156442b93d935c78e941d (diff)
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>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtesthelpers_p.h13
1 files changed, 13 insertions, 0 deletions
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