MobVision.SelfTest (mob_vision v0.1.3)

Copy Markdown View Source

The plugin's on-device proof (Mob.Plugin.SelfTest), run by mix mob.selftest and mob_ci for every activated plugin.

One real recognition, no UI, no camera, no permission: the test renders the word LEFT in large block letters into a PNG under Mob.data_dir/0, calls recognize_text/1 on it, waits for the native delivery and deletes the file.

  • {:vision, :text, text} where text reads LEFT (case and whitespace ignored) passes. That answer only comes from the recognizer's success path: on iOS the NIF loaded the file into a CGImage and VNRecognizeTextRequest (Vision, accurate level) ran on it on a background queue; on Android the zig NIF called MobVisionBridge.recognize_text through JNI (so nativeRegister ran and the bootstrap handed the bridge an Activity), InputImage.fromFilePath decoded the file and ML Kit's bundled Latin recognizer read it. Both recognizers run fully on device and offline (Vision ships with iOS, the ML Kit model is in the text-recognition artifact, not a Play services download), so an iOS simulator and an Android emulator are expected to pass like a phone.
  • Any other text, including "", is a failure: the pipeline ran but did not read a clean, high-contrast word.
  • {:vision, :error, reason} is a failure: "no_activity" (Android: the bootstrap never called setActivity), "no_image" (the native side could not open the file the test just wrote) or the recognizer's own error message.
  • {:error, :bridge_not_registered} from the NIF (Android: the bootstrap never called MobVisionBridge.register(), or the method-ID lookup failed) is a failure; so is no answer within 15 s.
  • The host stub's nif_not_loaded is a failure naming the NIF.

There is no skip: the plugin needs no hardware, no permission and no network, so every device can give the full answer.