Test the three pure MediaProbe helpers, and report the arms no test can bite #92

Merged
JMR-dev merged 3 commits from test/mediaprobe-pure-helpers into main 2026-08-25 04:49:58 +00:00
JMR-dev commented 2026-08-25 03:46:46 +00:00 (Migrated from github.com)

Closes #84.

Three pure helpers in MediaProbe had no test: shortName, isImageFormat and intOr. All
three were private; they are internal now, as #57 did it, with the reason for each function's
shape written into its KDoc rather than left to the reader.

18 tests across three classes — two plain JVM, one Robolectric. MediaFormat.MIMETYPE_* are Java
compile-time String constants, so shortName and isImageFormat need no Android runtime at all;
only intOr does, because it needs a real MediaFormat instance rather than its constants.

The acceptance mutation, and why it is not the one the ticket named

The ticket's literal example stays green, and that is a finding about the code. Deleting
MIMETYPE_VIDEO_HEVC -> "hevc" leaves the whole suite passing — measured, not argued — because
video/hevc falls through to substringAfter('/') and produces hevc anyway. Four arms are like
this:

arm MIME mapped what the fallback gives arm-deletion detectable?
HEVC video/hevc hevc hevc no
OPUS audio/opus opus opus no
FLAC audio/flac flac flac no
VORBIS audio/vorbis vorbis vorbis no
AVC video/avc h264 avc yes
AAC audio/mp4a-latm aac mp4a-latm yes
VP8 / VP9 video/x-vnd.on2.vp* vp8 / vp9 x-vnd.on2.vp* yes
AV1 video/av01 av1 av01 yes
MPEG4 video/mp4v-es mpeg4 mp4v-es yes
RAW audio/raw pcm raw yes

No test can catch the deletion of the top four, by construction. They are not removed here —
they document intent, and their assertions still bite an arm whose mapping changes rather than
one that disappears. The acceptance mutation was run on MIMETYPE_VIDEO_AVC -> "h264" instead.

Mutations run

Delete MediaFormat.MIMETYPE_VIDEO_AVC -> "h264":

MediaProbeMimeNamesTest > an AVC track is reported as h264, which is what everything downstream calls it FAILED
    org.junit.ComparisonFailure at MediaProbeMimeNamesTest.kt:107
org.junit.ComparisonFailure: shortName("video/avc") expected:<[h264]> but was:<[avc]>

Change it.endsWith("_pipe") to it.contains("pipe"):

MediaProbeImageFormatTest > a format that merely contains pipe is not an image FAILED
    java.lang.AssertionError at MediaProbeImageFormatTest.kt:86
java.lang.AssertionError: isImageFormat("yuv4mpegpipe")

Two more, so the third helper and the fallback are not taken on trust either:

  • Drop the runCatching in intOr -> MediaProbeTrackFieldsTest > a frame rate the format carries as a Float gives the fallback rather than throwing FAILED / java.lang.ClassCastException at MediaProbeTrackFieldsTest.kt:69
  • Change else -> mime.substringAfter('/') to else -> mime -> MediaProbeMimeNamesTest > a MIME with no arm of its own falls back to its subtype FAILED / org.junit.ComparisonFailure

And the one that proves the point above: delete MIMETYPE_VIDEO_HEVC -> "hevc" -> 29 tests, 0
failures.

Where the assertions come from

Format names were read back from ffprobe -show_entries format=format_name rather than recalled:
a .png reports png_pipe, a .jpg reports jpeg_pipe, a .y4m reports yuv4mpegpipe, and
image2 appears only when that demuxer is named explicitly. yuv4mpegpipe is why the _pipe half
of the rule has to stay a suffix test — it contains pipe and is raw video. The MIME constants
were read out of android.jar with javap -constants.

image2pipe is noted in the test KDoc and deliberately asserted neither way: it gets a false
answer, but probeWithFFprobe forces no format, and FFprobe only selects that demuxer when it is
named with -f. The name cannot reach this app, so pinning today's answer would be a test about
FFmpeg's command line.

Named exemptions

readMediaInformation, probeWithExtractor, probe, probeWithFFprobe and probeForConcat are
untouched. They are FFprobe- and MediaExtractor-bound and are exercised by RemuxTest,
ConcatEngineTest and RealMediaBenchmark in androidTest, which the JVM coverage report does
not see. Not mocked, deliberately — MediaProbeFormatTest and MediaProbeNativeLoadTest already
cover the parsing and the native-failure edge at the seams that exist.

Also not covered: the four vacuous arms above, at the level of arm deletion, for the reason given.

Gate green locally: assembleDebug, testDebugUnitTest, compileDebugAndroidTestKotlin,
ktlintCheck, detekt, lintDebug.

🤖 Generated with Claude Code

Closes #84. Three pure helpers in `MediaProbe` had no test: `shortName`, `isImageFormat` and `intOr`. All three were `private`; they are `internal` now, as #57 did it, with the reason for each function's shape written into its KDoc rather than left to the reader. 18 tests across three classes — two plain JVM, one Robolectric. `MediaFormat.MIMETYPE_*` are Java compile-time String constants, so `shortName` and `isImageFormat` need no Android runtime at all; only `intOr` does, because it needs a real `MediaFormat` instance rather than its constants. ## The acceptance mutation, and why it is not the one the ticket named **The ticket's literal example stays green, and that is a finding about the code.** Deleting `MIMETYPE_VIDEO_HEVC -> "hevc"` leaves the whole suite passing — measured, not argued — because `video/hevc` falls through to `substringAfter('/')` and produces `hevc` anyway. Four arms are like this: | arm | MIME | mapped | what the fallback gives | arm-deletion detectable? | |---|---|---|---|---| | HEVC | `video/hevc` | `hevc` | `hevc` | **no** | | OPUS | `audio/opus` | `opus` | `opus` | **no** | | FLAC | `audio/flac` | `flac` | `flac` | **no** | | VORBIS | `audio/vorbis` | `vorbis` | `vorbis` | **no** | | AVC | `video/avc` | `h264` | `avc` | yes | | AAC | `audio/mp4a-latm` | `aac` | `mp4a-latm` | yes | | VP8 / VP9 | `video/x-vnd.on2.vp*` | `vp8` / `vp9` | `x-vnd.on2.vp*` | yes | | AV1 | `video/av01` | `av1` | `av01` | yes | | MPEG4 | `video/mp4v-es` | `mpeg4` | `mp4v-es` | yes | | RAW | `audio/raw` | `pcm` | `raw` | yes | No test can catch the deletion of the top four, by construction. They are **not** removed here — they document intent, and their assertions still bite an arm whose *mapping* changes rather than one that disappears. The acceptance mutation was run on `MIMETYPE_VIDEO_AVC -> "h264"` instead. ## Mutations run **Delete `MediaFormat.MIMETYPE_VIDEO_AVC -> "h264"`:** ``` MediaProbeMimeNamesTest > an AVC track is reported as h264, which is what everything downstream calls it FAILED org.junit.ComparisonFailure at MediaProbeMimeNamesTest.kt:107 org.junit.ComparisonFailure: shortName("video/avc") expected:<[h264]> but was:<[avc]> ``` **Change `it.endsWith("_pipe")` to `it.contains("pipe")`:** ``` MediaProbeImageFormatTest > a format that merely contains pipe is not an image FAILED java.lang.AssertionError at MediaProbeImageFormatTest.kt:86 java.lang.AssertionError: isImageFormat("yuv4mpegpipe") ``` Two more, so the third helper and the fallback are not taken on trust either: - Drop the `runCatching` in `intOr` -> `MediaProbeTrackFieldsTest > a frame rate the format carries as a Float gives the fallback rather than throwing FAILED / java.lang.ClassCastException at MediaProbeTrackFieldsTest.kt:69` - Change `else -> mime.substringAfter('/')` to `else -> mime` -> `MediaProbeMimeNamesTest > a MIME with no arm of its own falls back to its subtype FAILED / org.junit.ComparisonFailure` And the one that proves the point above: **delete `MIMETYPE_VIDEO_HEVC -> "hevc"` -> 29 tests, 0 failures.** ## Where the assertions come from Format names were read back from `ffprobe -show_entries format=format_name` rather than recalled: a `.png` reports `png_pipe`, a `.jpg` reports `jpeg_pipe`, a `.y4m` reports `yuv4mpegpipe`, and `image2` appears only when that demuxer is named explicitly. `yuv4mpegpipe` is why the `_pipe` half of the rule has to stay a suffix test — it contains `pipe` and is raw video. The MIME constants were read out of `android.jar` with `javap -constants`. `image2pipe` is noted in the test KDoc and deliberately asserted neither way: it gets a false answer, but `probeWithFFprobe` forces no format, and FFprobe only selects that demuxer when it is named with `-f`. The name cannot reach this app, so pinning today's answer would be a test about FFmpeg's command line. ## Named exemptions `readMediaInformation`, `probeWithExtractor`, `probe`, `probeWithFFprobe` and `probeForConcat` are untouched. They are FFprobe- and `MediaExtractor`-bound and are exercised by `RemuxTest`, `ConcatEngineTest` and `RealMediaBenchmark` in `androidTest`, which the JVM coverage report does not see. Not mocked, deliberately — `MediaProbeFormatTest` and `MediaProbeNativeLoadTest` already cover the parsing and the native-failure edge at the seams that exist. Also not covered: the four vacuous arms above, at the level of arm deletion, for the reason given. Gate green locally: `assembleDebug`, `testDebugUnitTest`, `compileDebugAndroidTestKotlin`, `ktlintCheck`, `detekt`, `lintDebug`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.