Skip to content

Commit bac8747

Browse files
Added pubspec update, changelog update, and added test to dir
1 parent 1bb6ab5 commit bac8747

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

packages/camera/camera_web/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.3.5+3
2+
3+
* Fixes camera initialization failure on Safari by fixing a null check operator error using
4+
a nullable getter and null safe practices.
5+
16
## 0.3.5+2
27

38
* Fixes camera initialization failure on Firefox Android by using `{video: true}` instead

packages/camera/camera_web/example/integration_test/camera_service_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,29 @@ void main() {
708708

709709
expect(facingMode, isNull);
710710
});
711+
712+
testWidgets('returns null '
713+
'when the facing mode setting is empty and '
714+
'the facingMode capability is null', (WidgetTester tester) async {
715+
mockVideoTrack.getSettings = () {
716+
return web.MediaTrackSettings(facingMode: '');
717+
}.toJS;
718+
mockVideoTrack.getCapabilities = () {
719+
// Use the fake class that has no facingMode property
720+
return createJSInteropWrapper(FakeMediaTrackCapabilities())
721+
as web.MediaTrackCapabilities;
722+
}.toJS;
723+
724+
when(
725+
jsUtil.hasProperty(videoTrack, 'getCapabilities'.toJS),
726+
).thenReturn(true);
727+
728+
final String? facingMode = cameraService.getFacingModeForVideoTrack(
729+
videoTrack,
730+
);
731+
732+
expect(facingMode, isNull);
733+
});
711734
});
712735
});
713736

packages/camera/camera_web/example/integration_test/helpers/mocks.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'dart:ui';
1111
// ignore_for_file: implementation_imports
1212
import 'package:camera_web/src/camera.dart';
1313
import 'package:camera_web/src/camera_service.dart';
14+
import 'package:camera_web/src/pkg_web_tweaks.dart';
1415
import 'package:camera_web/src/shims/dart_js_util.dart';
1516
import 'package:camera_web/src/types/types.dart';
1617
import 'package:mockito/annotations.dart';
@@ -284,3 +285,14 @@ class MockEventStreamProvider<T extends web.Event> extends Mock
284285
as ElementStream<T>;
285286
}
286287
}
288+
289+
/// A fake [web.MediaTrackCapabilities] where facingMode is null/undefined.
290+
///
291+
/// Used to test null-safe handling when the browser doesn't provide
292+
/// the facingMode capability.
293+
@JSExport()
294+
class FakeMediaTrackCapabilities {
295+
296+
// Dummy property required by @JSExport
297+
bool get dummy => true;
298+
}

packages/camera/camera_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_web
22
description: A Flutter plugin for getting information about and controlling the camera on Web.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.3.5+2
5+
version: 0.3.5+3
66

77
environment:
88
sdk: ^3.8.0

0 commit comments

Comments
 (0)