@@ -885,6 +885,83 @@ void main() {
885885 },
886886 );
887887
888+ test ('setJpegImageQuality() calls CameraPlatform' , () async {
889+ final cameraController = CameraController (
890+ const CameraDescription (
891+ name: 'cam' ,
892+ lensDirection: CameraLensDirection .back,
893+ sensorOrientation: 90 ,
894+ ),
895+ ResolutionPreset .max,
896+ );
897+ await cameraController.initialize ();
898+
899+ await cameraController.setJpegImageQuality (50 );
900+
901+ verify (
902+ CameraPlatform .instance.setJpegImageQuality (cameraController.cameraId, 50 ),
903+ ).called (1 );
904+ });
905+
906+ test (
907+ 'setJpegImageQuality() throws CameraException on PlatformException' ,
908+ () async {
909+ final cameraController = CameraController (
910+ const CameraDescription (
911+ name: 'cam' ,
912+ lensDirection: CameraLensDirection .back,
913+ sensorOrientation: 90 ,
914+ ),
915+ ResolutionPreset .max,
916+ );
917+ await cameraController.initialize ();
918+
919+ when (
920+ CameraPlatform .instance.setJpegImageQuality (
921+ cameraController.cameraId,
922+ 50 ,
923+ ),
924+ ).thenThrow (
925+ PlatformException (
926+ code: 'TEST_ERROR' ,
927+ message: 'This is a test error message' ,
928+ ),
929+ );
930+
931+ expect (
932+ cameraController.setJpegImageQuality (50 ),
933+ throwsA (
934+ isA <CameraException >().having (
935+ (CameraException error) => error.description,
936+ 'TEST_ERROR' ,
937+ 'This is a test error message' ,
938+ ),
939+ ),
940+ );
941+ },
942+ );
943+
944+ test ('setJpegImageQuality() throws ArgumentError for invalid values' , () async {
945+ final cameraController = CameraController (
946+ const CameraDescription (
947+ name: 'cam' ,
948+ lensDirection: CameraLensDirection .back,
949+ sensorOrientation: 90 ,
950+ ),
951+ ResolutionPreset .max,
952+ );
953+ await cameraController.initialize ();
954+
955+ expect (
956+ () => cameraController.setJpegImageQuality (0 ),
957+ throwsA (isA <ArgumentError >()),
958+ );
959+ expect (
960+ () => cameraController.setJpegImageQuality (101 ),
961+ throwsA (isA <ArgumentError >()),
962+ );
963+ });
964+
888965 test ('setExposureMode() calls $CameraPlatform ' , () async {
889966 final cameraController = CameraController (
890967 const CameraDescription (
@@ -4152,6 +4229,12 @@ class MockCameraPlatform extends Mock
41524229 ) async => super .noSuchMethod (
41534230 Invocation .method (#setVideoStabilizationMode, < Object ? > [cameraId, mode]),
41544231 );
4232+
4233+ @override
4234+ Future <void > setJpegImageQuality (int ? cameraId, int ? quality) async =>
4235+ super .noSuchMethod (
4236+ Invocation .method (#setJpegImageQuality, < Object ? > [cameraId, quality]),
4237+ );
41554238}
41564239
41574240class MockCameraDescription extends CameraDescription {
0 commit comments