Repository navigation
Commit 2df16e5
authored
Test that ReactAndroid ships the ExifInterface Fresco needs
## Summary:
#60371 made ReactAndroid depend on `androidx.exifinterface`, which Fresco 3.9.0 uses to read a HEIF image's EXIF orientation but does not declare. No test failed if that dependency was removed.
The new `HeifExifOrientationTest` calls Fresco's `HeifExifUtil.getOrientation`, the method that crashed, on a stream that holds an EXIF orientation tag, and expects that orientation back. It goes through Fresco instead of loading the class by name, so it checks what an app needs: if a later Fresco stops using ExifInterface, the test passes without the dependency.
The stream is a JPEG with no image data, the smallest file ExifInterface reads: `HeifExifUtil` passes the stream to `ExifInterface` without checking its format, and parsing a real HEIF goes through `MediaMetadataRetriever`, which Robolectric only stubs.
## Changelog:
[INTERNAL] [ADDED] - Test that ReactAndroid provides the ExifInterface class Fresco uses for HEIF images
## Test Plan:
```sh
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.modules.fresco.HeifExifOrientationTest -Preact.internal.useHermesStable=true --console=plain
```
The test passes. With `implementation(libs.androidx.exifinterface)` removed from `ReactAndroid/build.gradle.kts` it fails as an app did before #60371:
```
java.lang.NoClassDefFoundError: androidx/exifinterface/media/ExifInterface
at com.facebook.imageutils.HeifExifUtil.getOrientation(HeifExifUtil.kt:31)
```
ktfmt is clean.
Differential Revision: D135308452
Pull Request resolved: #604201 parent e83162a commit 2df16e5
1 file changed
Lines changed: 84 additions & 0 deletions
File tree
- packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/fresco
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
0 commit comments