Skip to content

Add tests for DeviceInfoModule.getWindowDisplayMetrics edge-to-edge branches#56632

Open
zoontek wants to merge 1 commit intofacebook:mainfrom
zoontek:add-device-info-module-test
Open

Add tests for DeviceInfoModule.getWindowDisplayMetrics edge-to-edge branches#56632
zoontek wants to merge 1 commit intofacebook:mainfrom
zoontek:add-device-info-module-test

Conversation

@zoontek
Copy link
Copy Markdown
Contributor

@zoontek zoontek commented Apr 28, 2026

Summary:

This PR adds two focused unit tests for DeviceInfoModule.getWindowDisplayMetrics() that attach a mocked Activity, swap in a fake WindowMetricsCalculator via WindowMetricsCalculator.overrideDecorator() and verify both branches of isEdgeToEdgeFeatureFlagOn:

  • edge-to-edge on -> WindowMetrics.bounds are used directly.
  • edge-to-edge off -> bounds minus systemBars | displayCutout insets.

To make this testable without reflection or @SuppressLint("RestrictedApi") outside the production code, three small visibility tweaks:

  • DeviceInfoModule.getWindowDisplayMetrics() and getDisplayMetricsWritableMap(): privateinternal + @VisibleForTesting
  • WindowUtilKt.isEdgeToEdgeFeatureFlagOn setter: private set@VisibleForTesting internal set

Changelog:

[INTERNAL] [ADDED] - Add unit tests for DeviceInfoModule.getWindowDisplayMetrics covering both edge-to-edge branches

Test Plan:

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
  --tests com.facebook.react.modules.deviceinfo.DeviceInfoModuleTest

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 28, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant