Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 22ec1d7

Browse files
committed
Resolved additional feedback
1 parent ab30e1d commit 22ec1d7

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

0 commit comments

Comments
 (0)