diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-04-25 12:41:28 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-09 10:31:40 +0000 |
commit | b129388fe21f8af0fde9420fbcd6a130f64503ae (patch) | |
tree | 41def397bcf4280027c45883557106526199b58e | |
parent | 89de72f370157aaf4e5c9f7a6fe24ecd83e9df09 (diff) |
Android: re-enable tst_QQuickPopup
This patch udpated tst_QQuickPopup::orientation() to also consider
the cases when Android the window (or screen) size has odd width
or height. The expected popup position calculations need to be
adjusted for such cases because of the way we round float pixel
positions.
This allows to re-enable the test that was previously #ifdef'ed out
because androidtestrunner failed to parse its output.
With the recent changes to androidtestrunner, that should not be a
problem anymore.
This commit amends dd04e55a624ad58a25e44b7a824dbf407009cfdb
Fixes: QTBUG-101005
Change-Id: I63fcb0cb129e6ba3aeaa4bc6cd9ab6cf415757bd
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 52aaf0a4e78a197b1c12189db7d7bf5681946df5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tests/auto/quickcontrols2/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp | 35 |
2 files changed, 25 insertions, 12 deletions
diff --git a/tests/auto/quickcontrols2/CMakeLists.txt b/tests/auto/quickcontrols2/CMakeLists.txt index ac67bbe31b..0428406c79 100644 --- a/tests/auto/quickcontrols2/CMakeLists.txt +++ b/tests/auto/quickcontrols2/CMakeLists.txt @@ -30,9 +30,7 @@ add_subdirectory(qquickmenu) endif() add_subdirectory(qquickmenubar) add_subdirectory(qquickninepatchimage) -if(NOT ANDROID) # QTBUG-101005 add_subdirectory(qquickpopup) -endif() add_subdirectory(qquickstyle) add_subdirectory(qquickuniversalstyle) add_subdirectory(qquickuniversalstyleconf) diff --git a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp index 4b1dbbacdb..87667989a2 100644 --- a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp @@ -1269,18 +1269,33 @@ void tst_QQuickPopup::orientation_data() #endif const int width = availableSize.width(); const int height = availableSize.height(); + + // The width & height might be odd numbers, so we calculate center in a way + // similar to anchors.centerIn. + // Also note that when we emulate the screen orientation change (by calling + // window->reportContentOrientationChange() in the test), these values need + // to be adjusted, because the "logical" (0, 0) of the screen changes. + const int widthCenter = (width % 2) ? (width + 1) / 2 : width / 2; + const int heightCenter = (height % 2) ? (height + 1) / 2 : height / 2; + // 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); + // (rectangle.width, rectangle.height) + QTest::newRow("Portrait") << Qt::PortraitOrientation + << QPointF(widthCenter - 30 + 60, heightCenter - 15 + 30); + // in landscape orientation the top left corner of physical screen + // (not rotated) becomes (0, 0), so we need to adjust our widthCenter + QTest::newRow("Landscape") << Qt::LandscapeOrientation + << QPointF(heightCenter - 15 + 30, (width - widthCenter) + 30 - 60); + // In inverted portrait orientation the bottom right corner of physical + // screen (not rotated) becomes (0, 0), so we need to adjust both + // widthCenter and heightCenter + QTest::newRow("InvertedPortrait") << Qt::InvertedPortraitOrientation + << QPointF((width - widthCenter) + 30 - 60, (height - heightCenter) + 15 - 30); + // In inverted landscape orientation the bottom right corner of physical + // screen (not rotated) becomes (0, 0), so we need to adjust heightCenter + QTest::newRow("InvertedLandscape") << Qt::InvertedLandscapeOrientation + << QPointF((height - heightCenter) + 15 - 30, widthCenter - 30 + 60); } void tst_QQuickPopup::orientation() |