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 6.9.0 6.8 Task-number: QTBUG-132311 Change-Id: I178265b02878206ba95c8f83507963ce0bd0d732 Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
This commit is contained in:
parent
6b361119ef
commit
1f3c5f8f90
@ -25,6 +25,7 @@ Q_DECLARE_JNI_CLASS(Window, "android/view/Window")
|
|||||||
Q_DECLARE_JNI_CLASS(WindowInsets, "android/view/WindowInsets")
|
Q_DECLARE_JNI_CLASS(WindowInsets, "android/view/WindowInsets")
|
||||||
Q_DECLARE_JNI_CLASS(WindowManager, "android/view/WindowManager")
|
Q_DECLARE_JNI_CLASS(WindowManager, "android/view/WindowManager")
|
||||||
Q_DECLARE_JNI_CLASS(WindowMetrics, "android/view/WindowMetrics")
|
Q_DECLARE_JNI_CLASS(WindowMetrics, "android/view/WindowMetrics")
|
||||||
|
Q_DECLARE_JNI_CLASS(ApplicationInfo, "android/content/pm/ApplicationInfo")
|
||||||
|
|
||||||
class tst_Android : public QObject
|
class tst_Android : public QObject
|
||||||
{
|
{
|
||||||
@ -249,27 +250,41 @@ void tst_Android::testFullScreenDimensions()
|
|||||||
// available geometry == app size (system bars visible and removed from available geometry)
|
// available geometry == app size (system bars visible and removed from available geometry)
|
||||||
widget.showNormal();
|
widget.showNormal();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
QJniObject window = activity.callMethod<QtJniTypes::Window>("getWindow");
|
|
||||||
QVERIFY(window.isValid());
|
|
||||||
|
|
||||||
QJniObject decorView = window.callMethod<QtJniTypes::View>("getDecorView");
|
int expectedWidth;
|
||||||
QVERIFY(decorView.isValid());
|
int expectedHeight;
|
||||||
|
|
||||||
QJniObject insets = decorView.callMethod<QtJniTypes::WindowInsets>("getRootWindowInsets");
|
const auto appContext = activity.callMethod<QtJniTypes::Context>("getApplicationContext");
|
||||||
QVERIFY(insets.isValid());
|
const auto appInfo = appContext.callMethod<QtJniTypes::ApplicationInfo>("getApplicationInfo");
|
||||||
|
const int targetSdkVersion = appInfo.getField<jint>("targetSdkVersion");
|
||||||
|
const int sdkVersion = QNativeInterface::QAndroidApplication::sdkVersion();
|
||||||
|
|
||||||
int insetRight = insets.callMethod<jint>("getSystemWindowInsetRight");
|
if (sdkVersion >= __ANDROID_API_V__ && targetSdkVersion >= __ANDROID_API_V__) {
|
||||||
int insetLeft = insets.callMethod<jint>("getSystemWindowInsetLeft");
|
expectedWidth = appSize.width();
|
||||||
int insetsWidth = insetRight + insetLeft;
|
expectedHeight = appSize.height();
|
||||||
|
} else {
|
||||||
|
QJniObject window = activity.callMethod<QtJniTypes::Window>("getWindow");
|
||||||
|
QVERIFY(window.isValid());
|
||||||
|
|
||||||
int insetTop = insets.callMethod<jint>("getSystemWindowInsetTop");
|
QJniObject decorView = window.callMethod<QtJniTypes::View>("getDecorView");
|
||||||
int insetBottom = insets.callMethod<jint>("getSystemWindowInsetBottom");
|
QVERIFY(decorView.isValid());
|
||||||
int insetsHeight = insetTop + insetBottom;
|
|
||||||
|
auto insets = decorView.callMethod<QtJniTypes::WindowInsets>("getRootWindowInsets");
|
||||||
|
QVERIFY(insets.isValid());
|
||||||
|
|
||||||
|
int insetRight = insets.callMethod<jint>("getSystemWindowInsetRight");
|
||||||
|
int insetLeft = insets.callMethod<jint>("getSystemWindowInsetLeft");
|
||||||
|
int insetsWidth = insetRight + insetLeft;
|
||||||
|
|
||||||
|
int insetTop = insets.callMethod<jint>("getSystemWindowInsetTop");
|
||||||
|
int insetBottom = insets.callMethod<jint>("getSystemWindowInsetBottom");
|
||||||
|
int insetsHeight = insetTop + insetBottom;
|
||||||
|
|
||||||
|
expectedWidth = appSize.width() - insetsWidth;
|
||||||
|
expectedHeight = appSize.height() - insetsHeight;
|
||||||
|
}
|
||||||
|
|
||||||
int expectedWidth = appSize.width() - insetsWidth;
|
|
||||||
QTRY_COMPARE(screen->availableGeometry().width(), expectedWidth);
|
QTRY_COMPARE(screen->availableGeometry().width(), expectedWidth);
|
||||||
|
|
||||||
int expectedHeight = appSize.height() - insetsHeight;
|
|
||||||
QTRY_COMPARE(screen->availableGeometry().height(), expectedHeight);
|
QTRY_COMPARE(screen->availableGeometry().height(), expectedHeight);
|
||||||
|
|
||||||
QTRY_COMPARE(screen->geometry().width(), realSize.getField<jint>("x"));
|
QTRY_COMPARE(screen->geometry().width(), realSize.getField<jint>("x"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user