This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
packages/camera/camera_platform_interface Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import 'package:camera_platform_interface/camera_platform_interface.dart' ;
2+
3+ /// Parses a string into a corresponding CameraLensDirection.
4+ CameraLensDirection parseCameraLensDirection (String string) {
5+ switch (string) {
6+ case 'front' :
7+ return CameraLensDirection .front;
8+ case 'back' :
9+ return CameraLensDirection .back;
10+ case 'external' :
11+ return CameraLensDirection .external ;
12+ }
13+ throw ArgumentError ('Unknown CameraLensDirection value' );
14+ }
Original file line number Diff line number Diff line change 1+ import 'package:camera_platform_interface/camera_platform_interface.dart' ;
2+ import 'package:camera_platform_interface/src/utils/utils.dart' ;
3+ import 'package:flutter_test/flutter_test.dart' ;
4+
5+ void main () {
6+ group ('Utility methods' , () {
7+ test (
8+ 'Should return CameraLensDirection when valid value is supplied when parsing camera lens direction' ,
9+ () {
10+ expect (
11+ parseCameraLensDirection ('back' ),
12+ CameraLensDirection .back,
13+ );
14+ expect (
15+ parseCameraLensDirection ('front' ),
16+ CameraLensDirection .front,
17+ );
18+ expect (
19+ parseCameraLensDirection ('external' ),
20+ CameraLensDirection .external ,
21+ );
22+ });
23+
24+ test (
25+ 'Should throw ArgumentException when invalid value is supplied when parsing camera lens direction' ,
26+ () {
27+ expect (
28+ () => parseCameraLensDirection ('test' ),
29+ throwsA (isArgumentError),
30+ );
31+ });
32+ });
33+ }
You can’t perform that action at this time.
0 commit comments