Closed
Bug 2037911
Opened 6 months ago
Closed 6 months ago
Refactor tests and code to prevent using Robolectric ReflectionHelpers
Categories
(Firefox for Android :: Tooling, task)
Tracking
()
RESOLVED
FIXED
152 Branch
| Tracking | Status | |
|---|---|---|
| firefox152 | --- | fixed |
People
(Reporter: mcarare, Assigned: mcarare)
References
Details
(Whiteboard: [fxdroid][group6] )
Attachments
(1 external file)
https://developer.android.com/about/versions/17/behavior-changes-17#static-final-fields
Apps running on Android 17 or higher that target Android 17 (API level 37) or higher cannot change static final fields. If an app attempts to change a static final field by using reflection, it will cause an IllegalAccessException. Attempting to modify one of these fields through JNI APIs (such as SetStaticLongField()) will cause the app to crash.
Multiple tests (e.g., WindowTest.kt, AdaptiveIconProcessorTest.kt) use Robolectric's ReflectionHelpers.setStaticField to mock Build.VERSION.SDK_INT. These tests will likely fail when executed against an Android 17 runtime environment.
Updated•6 months ago
|
| Assignee | ||
Comment 1•6 months ago
|
||
- Removed manual reflection-based overrides of
Build.VERSION.SDK_INTand associated setup/teardown methods. - Adjusted
WindowTestto properly initializeSTATUS_BAR_COLORand mockWindowInsetsControllerfor API 29 compatibility. - Updated exception handling assertions in
MediaSessionServiceDelegateTestto reflect realistic behaviors for different SDK levels.
Pushed by mcarare@mozilla.com:
https://github.com/mozilla-firefox/firefox/commit/4f5b9474d688
https://hg.mozilla.org/integration/autoland/rev/a0cd53d60e84
Refactor unit tests to use Robolectric's `@Config(sdk = ...)` annotation instead of manually mocking `Build.VERSION.SDK_INT`. r=android-reviewers,giorga
Comment 3•6 months ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
status-firefox152:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•