camera_facing_test.dart
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile_scanner/src/enums/camera_facing.dart';
void main() {
group('$CameraFacing tests', () {
test('can be created from raw value', () {
const values = <int, CameraFacing>{
0: CameraFacing.front,
1: CameraFacing.back,
};
for (final MapEntry<int, CameraFacing> entry in values.entries) {
final CameraFacing result = CameraFacing.fromRawValue(entry.key);
expect(result, entry.value);
}
});
test('invalid raw value throws argument error', () {
const int negative = -1;
const int outOfRange = 2;
expect(() => CameraFacing.fromRawValue(negative), throwsArgumentError);
expect(() => CameraFacing.fromRawValue(outOfRange), throwsArgumentError);
});
test('can be converted to raw value', () {
const values = <CameraFacing, int>{
CameraFacing.front: 0,
CameraFacing.back: 1,
};
for (final MapEntry<CameraFacing, int> entry in values.entries) {
final int result = entry.key.rawValue;
expect(result, entry.value);
}
});
});
}