Android: account for edge-to-edge in tst_android
When running on Android 15 with target sdk set to 35 (Android 15), the new edge-to-edge behavior is enforced, so the test needs to account for that and take the full screen size instead of deducting the insects. Pick-to: 6.9.0 6.8 Task-number: QTBUG-132311 Change-Id: I178265b02878206ba95c8f83507963ce0bd0d732 Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io> (cherry picked from commit 1f3c5f8f9025057f9a7f6b6143f33a529583ab19) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
07f088d340
commit
a6e68f636e
@ -25,6 +25,7 @@ Q_DECLARE_JNI_CLASS(Window, "android/view/Window")
|
||||
Q_DECLARE_JNI_CLASS(WindowInsets, "android/view/WindowInsets")
|
||||
Q_DECLARE_JNI_CLASS(WindowManager, "android/view/WindowManager")
|
||||
Q_DECLARE_JNI_CLASS(WindowMetrics, "android/view/WindowMetrics")
|
||||
Q_DECLARE_JNI_CLASS(ApplicationInfo, "android/content/pm/ApplicationInfo")
|
||||
|
||||
class tst_Android : public QObject
|
||||
{
|
||||
@ -249,13 +250,26 @@ void tst_Android::testFullScreenDimensions()
|
||||
// available geometry == app size (system bars visible and removed from available geometry)
|
||||
widget.showNormal();
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
int expectedWidth;
|
||||
int expectedHeight;
|
||||
|
||||
const auto appContext = activity.callMethod<QtJniTypes::Context>("getApplicationContext");
|
||||
const auto appInfo = appContext.callMethod<QtJniTypes::ApplicationInfo>("getApplicationInfo");
|
||||
const int targetSdkVersion = appInfo.getField<jint>("targetSdkVersion");
|
||||
const int sdkVersion = QNativeInterface::QAndroidApplication::sdkVersion();
|
||||
|
||||
if (sdkVersion >= __ANDROID_API_V__ && targetSdkVersion >= __ANDROID_API_V__) {
|
||||
expectedWidth = appSize.width();
|
||||
expectedHeight = appSize.height();
|
||||
} else {
|
||||
QJniObject window = activity.callMethod<QtJniTypes::Window>("getWindow");
|
||||
QVERIFY(window.isValid());
|
||||
|
||||
QJniObject decorView = window.callMethod<QtJniTypes::View>("getDecorView");
|
||||
QVERIFY(decorView.isValid());
|
||||
|
||||
QJniObject insets = decorView.callMethod<QtJniTypes::WindowInsets>("getRootWindowInsets");
|
||||
auto insets = decorView.callMethod<QtJniTypes::WindowInsets>("getRootWindowInsets");
|
||||
QVERIFY(insets.isValid());
|
||||
|
||||
int insetRight = insets.callMethod<jint>("getSystemWindowInsetRight");
|
||||
@ -266,10 +280,11 @@ void tst_Android::testFullScreenDimensions()
|
||||
int insetBottom = insets.callMethod<jint>("getSystemWindowInsetBottom");
|
||||
int insetsHeight = insetTop + insetBottom;
|
||||
|
||||
int expectedWidth = appSize.width() - insetsWidth;
|
||||
QTRY_COMPARE(screen->availableGeometry().width(), expectedWidth);
|
||||
expectedWidth = appSize.width() - insetsWidth;
|
||||
expectedHeight = appSize.height() - insetsHeight;
|
||||
}
|
||||
|
||||
int expectedHeight = appSize.height() - insetsHeight;
|
||||
QTRY_COMPARE(screen->availableGeometry().width(), expectedWidth);
|
||||
QTRY_COMPARE(screen->availableGeometry().height(), expectedHeight);
|
||||
|
||||
QTRY_COMPARE(screen->geometry().width(), realSize.getField<jint>("x"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user