Allow building without ONNX Runtime

flutter_onnxruntime downloads ORT natively at build time, and the Linux and
Windows downloads from github.com/microsoft/onnxruntime are unavailable.
scripts/onnx.sh off swaps in a pure-Dart stub via pubspec_overrides.yaml, so no
platform pulls ORT; image messages then show as unavailable, as on web. Linux
CI builds use this mode for now.
This commit is contained in:
zjs81 committed 2026-11-20 16:38:09 -07:00
1 parent 34ea0cb7ca
commit d7fff0533e
12 files changed
+215 -13

No files matched your search

@@ -0,0 +1,35 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/models/image_codec_support.dart';
import 'package:meshcore_open/services/app_settings_service.dart';
import 'package:meshcore_open/services/image_codec_backend.dart';
import 'package:meshcore_open/services/image_codec_service.dart';
import 'package:meshcore_open/services/image_codec_settings_store.dart';
import 'package:meshcore_open/widgets/image_send_codec_binding.dart';
/// Runs in both build modes; each half skips in the other (`scripts/onnx.sh`).
void main() {
ImageCodecService newService() {
final service = ImageCodecService(
AppSettingsService(),
settingsStore: InMemoryImageCodecSettingsStore(
const ImageCodecPreferences(enabled: true),
),
);
addTearDown(service.dispose);
return service;
}
test('ONNX-free build reports the image codec unavailable', () {
final service = newService();
expect(createImageCodecBackend(), isNull);
expect(service.availability, ImageCodecAvailability.unavailable);
expect(service.unavailableReason, contains('without ONNX Runtime'));
expect(service.canRunInference, isFalse);
}, skip: imageCodecRuntimeAvailable ? 'ONNX Runtime is compiled in' : false);
test('ONNX build has a codec backend', () {
final service = newService();
expect(createImageCodecBackend(), isA<OnnxImageCodecBackend>());
expect(service.unavailableReason, isNull);
}, skip: imageCodecRuntimeAvailable ? false : 'built without ONNX Runtime');
}