diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2023-11-15 10:47:39 +0200 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2023-11-15 22:52:23 +0200 |
commit | d6861926a12e3ee8eb3e1c8c90e9c6483b997d45 (patch) | |
tree | a0539cdf6a5546b938083400c7c4ae5aa6c5e8bd /tests/auto/corelib/platform/android/tst_android.cpp | |
parent | 2c96f517714eb67a9af821141a90eed68b8714ed (diff) |
Android: set displayManager listener after QtLayout is initialized
the QtDisplayManager listener uses m_layout but it can be called
before m_layout is actually initialized, so set the listener after
the layout has been initialized.
Task-number: QTBUG-118077
Fixes: QTBUG-119007
Fixes: QTBUG-119134
Change-Id: Icebc350f09210c12dbd011f86ce88a90b6f27d12
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Diffstat (limited to 'tests/auto/corelib/platform/android/tst_android.cpp')
-rw-r--r-- | tests/auto/corelib/platform/android/tst_android.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/platform/android/tst_android.cpp b/tests/auto/corelib/platform/android/tst_android.cpp index 8d0bf1e72c..9a503fafc5 100644 --- a/tests/auto/corelib/platform/android/tst_android.cpp +++ b/tests/auto/corelib/platform/android/tst_android.cpp @@ -26,6 +26,8 @@ private slots: void testAndroidActivity(); void testRunOnAndroidMainThread(); void testFullScreenDimensions(); + void orientationChange_data(); + void orientationChange(); }; void tst_Android::assetsRead() @@ -299,6 +301,25 @@ void tst_Android::testFullScreenDimensions() } } +void tst_Android::orientationChange_data() +{ + QTest::addColumn<int>("nativeOrientation"); + QTest::addColumn<Qt::ScreenOrientation>("expected"); + + QTest::newRow("Landscape") << 0 << Qt::LandscapeOrientation; + QTest::newRow("Portrait") << 1 << Qt::PortraitOrientation; +} + +void tst_Android::orientationChange() +{ + QFETCH(int, nativeOrientation); + QFETCH(Qt::ScreenOrientation, expected); + + auto context = QNativeInterface::QAndroidApplication::context(); + context.callMethod<void>("setRequestedOrientation", nativeOrientation); + QTRY_COMPARE(qGuiApp->primaryScreen()->orientation(), expected); +} + QTEST_MAIN(tst_Android) #include "tst_android.moc" |