diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/platform/android/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/corelib/platform/android/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/corelib/platform/android/tst_android.cpp | 26 |
3 files changed, 24 insertions, 5 deletions
diff --git a/tests/auto/corelib/platform/android/BLACKLIST b/tests/auto/corelib/platform/android/BLACKLIST deleted file mode 100644 index 8b5c0990f1..0000000000 --- a/tests/auto/corelib/platform/android/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[orientationChange] -android diff --git a/tests/auto/corelib/platform/android/CMakeLists.txt b/tests/auto/corelib/platform/android/CMakeLists.txt index 0f9f670cb0..6b7e9b2901 100644 --- a/tests/auto/corelib/platform/android/CMakeLists.txt +++ b/tests/auto/corelib/platform/android/CMakeLists.txt @@ -18,6 +18,7 @@ qt_internal_add_test(tst_android Qt::CorePrivate Qt::Gui Qt::GuiPrivate + Qt::Widgets ) if(ANDROID) diff --git a/tests/auto/corelib/platform/android/tst_android.cpp b/tests/auto/corelib/platform/android/tst_android.cpp index 9a503fafc5..02204abcb5 100644 --- a/tests/auto/corelib/platform/android/tst_android.cpp +++ b/tests/auto/corelib/platform/android/tst_android.cpp @@ -12,6 +12,8 @@ #include <qpa/qplatformscreen.h> #include <qpa/qplatformnativeinterface.h> #include <QtCore/qdiriterator.h> +#include <QWidget> +#include <QSignalSpy> using namespace Qt::StringLiterals; @@ -305,19 +307,37 @@ void tst_Android::orientationChange_data() { QTest::addColumn<int>("nativeOrientation"); QTest::addColumn<Qt::ScreenOrientation>("expected"); + QTest::addColumn<QSize>("screenSize"); - QTest::newRow("Landscape") << 0 << Qt::LandscapeOrientation; - QTest::newRow("Portrait") << 1 << Qt::PortraitOrientation; + const QSize portraitSize = QGuiApplication::primaryScreen()->size(); + const QSize landscapeSize = QSize(portraitSize.height(), portraitSize.width()); + + QTest::newRow("InvertedLandscape") << 8 << Qt::InvertedLandscapeOrientation << landscapeSize; + QTest::newRow("InvertedPortrait") << 9 << Qt::InvertedPortraitOrientation << portraitSize; + QTest::newRow("Landscape") << 0 << Qt::LandscapeOrientation << landscapeSize; + // Leave Portrait till the end + QTest::newRow("Portrait") << 1 << Qt::PortraitOrientation << portraitSize; } void tst_Android::orientationChange() { QFETCH(int, nativeOrientation); QFETCH(Qt::ScreenOrientation, expected); + QFETCH(QSize, screenSize); + + // For QTBUG-94459 to check that the widget size are consistent after orientation changes + QWidget widget; + widget.show(); auto context = QNativeInterface::QAndroidApplication::context(); context.callMethod<void>("setRequestedOrientation", nativeOrientation); - QTRY_COMPARE(qGuiApp->primaryScreen()->orientation(), expected); + + QScreen *screen = QGuiApplication::primaryScreen(); + QSignalSpy orientationSpy(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation))); + QTRY_COMPARE(screen->orientation(), expected); + QCOMPARE(orientationSpy.size(), 1); + QCOMPARE(screen->size(), screenSize); + QCOMPARE(widget.size(), screen->availableSize()); } QTEST_MAIN(tst_Android) |