aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-04-08 14:58:53 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-11 17:37:26 +0000
commit9df9bd9e481d1fcafb68948e9a219913a4d631cf (patch)
tree91131c736d65414d8b88bf4ecb5ba781a713997b
parentb6316097cca5ca0ede4b59ac6510b31c242dd791 (diff)
Android: enable tst_qquickpopup::orientation
The test was failing because the expected positions were calculated based on hardcoded window size (600x300). Android emulator has a smaller display, so the actual window size was different. This patch replaces the hardcoded values with runtime calculation. Fixes: QTBUG-100253 Change-Id: Icb6e9acce34b62e40c6cf2c3ec37efbf2a5966a6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit dd04e55a624ad58a25e44b7a824dbf407009cfdb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/BLACKLIST4
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp27
2 files changed, 23 insertions, 8 deletions
diff --git a/tests/auto/quickcontrols2/qquickpopup/BLACKLIST b/tests/auto/quickcontrols2/qquickpopup/BLACKLIST
index ae18e97546..4aa2bfeb6e 100644
--- a/tests/auto/quickcontrols2/qquickpopup/BLACKLIST
+++ b/tests/auto/quickcontrols2/qquickpopup/BLACKLIST
@@ -15,7 +15,3 @@ opensuse-leap
[cursorShape]
opensuse-leap
-
-# QTBUG-100253
-[orientation]
-android
diff --git a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
index 08e98fcb50..6263661b0f 100644
--- a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
@@ -1260,10 +1260,29 @@ void tst_QQuickPopup::orientation_data()
QTest::addColumn<Qt::ScreenOrientation>("orientation");
QTest::addColumn<QPointF>("position");
- QTest::newRow("Portrait") << Qt::PortraitOrientation << QPointF(330, 165);
- QTest::newRow("Landscape") << Qt::LandscapeOrientation << QPointF(165, 270);
- QTest::newRow("InvertedPortrait") << Qt::InvertedPortraitOrientation << QPointF(270, 135);
- QTest::newRow("InvertedLandscape") << Qt::InvertedLandscapeOrientation << QPointF(135, 330);
+ // On Android the screen size will usually be smaller than the 600x300
+ // size of a Window in orientation.qml
+ // Because of that we need to calculate proper positions at runtime.
+#ifndef Q_OS_ANDROID
+ QQuickControlsApplicationHelper helper(this, "orientation.qml");
+ const QSize availableSize = helper.window->size();
+#else
+ const QSize availableSize = QGuiApplication::primaryScreen()->availableSize();
+#endif
+ const int width = availableSize.width();
+ const int height = availableSize.height();
+ // Rectangle is (60x30); popup is (30x60).
+ // Rectangle is using "anchors.centerIn: parent", and popup is positioned at
+ // (rectangle.width, rectangle.height) so we need the "/ 2 - x" part to
+ // calculate expected popup's position.
+ QTest::newRow("Portrait")
+ << Qt::PortraitOrientation << QPointF(width / 2 - 30 + 60, height / 2 - 15 + 30);
+ QTest::newRow("Landscape")
+ << Qt::LandscapeOrientation << QPointF(height / 2 - 15 + 30, width / 2 + 30 - 60);
+ QTest::newRow("InvertedPortrait")
+ << Qt::InvertedPortraitOrientation << QPointF(width / 2 + 30 - 60, height / 2 + 15 - 30);
+ QTest::newRow("InvertedLandscape")
+ << Qt::InvertedLandscapeOrientation << QPointF(height / 2 + 15 - 30, width / 2 - 30 + 60);
}
void tst_QQuickPopup::orientation()