@@ -10,7 +10,6 @@ import 'package:local_auth_platform_interface/default_method_channel_platform.da
10
10
import 'package:local_auth_platform_interface/local_auth_platform_interface.dart' ;
11
11
import 'package:local_auth_platform_interface/types/auth_messages.dart' ;
12
12
import 'package:local_auth_platform_interface/types/auth_options.dart' ;
13
- import 'package:local_auth_platform_interface/types/biometric_type.dart' ;
14
13
15
14
void main () {
16
15
TestWidgetsFlutterBinding .ensureInitialized ();
@@ -19,9 +18,13 @@ void main() {
19
18
'plugins.flutter.io/local_auth' ,
20
19
);
21
20
22
- final List <MethodCall > log = < MethodCall > [] ;
21
+ late List <MethodCall > log;
23
22
late LocalAuthPlatform localAuthentication;
24
23
24
+ setUp (() async {
25
+ log = < MethodCall > [];
26
+ });
27
+
25
28
test (
26
29
'DefaultLocalAuthPlatform is registered as the default platform implementation' ,
27
30
() async {
@@ -32,10 +35,9 @@ void main() {
32
35
test ('getAvailableBiometrics' , () async {
33
36
channel.setMockMethodCallHandler ((MethodCall methodCall) {
34
37
log.add (methodCall);
35
- return Future <dynamic >.value (< BiometricType > []);
38
+ return Future <dynamic >.value (< String > []);
36
39
});
37
40
localAuthentication = DefaultLocalAuthPlatform ();
38
- log.clear ();
39
41
await localAuthentication.getEnrolledBiometrics ();
40
42
expect (
41
43
log,
@@ -45,14 +47,36 @@ void main() {
45
47
);
46
48
});
47
49
50
+ test ('deviceSupportsBiometrics handles special sentinal value' , () async {
51
+ // The pre-federation implementation of the platform channels, which the
52
+ // default implementation retains compatibility with for the benefit of any
53
+ // existing unendorsed implementations, used 'undefined' as a special
54
+ // return value from `getAvailableBiometrics` to indicate that nothing was
55
+ // enrolled, but that the hardware does support biometrics.
56
+ channel.setMockMethodCallHandler ((MethodCall methodCall) {
57
+ log.add (methodCall);
58
+ return Future <dynamic >.value (< String > ['undefined' ]);
59
+ });
60
+
61
+ localAuthentication = DefaultLocalAuthPlatform ();
62
+ final bool supportsBiometrics =
63
+ await localAuthentication.deviceSupportsBiometrics ();
64
+ expect (supportsBiometrics, true );
65
+ expect (
66
+ log,
67
+ < Matcher > [
68
+ isMethodCall ('getAvailableBiometrics' , arguments: null ),
69
+ ],
70
+ );
71
+ });
72
+
48
73
group ('Boolean returning methods' , () {
49
74
setUp (() {
50
75
channel.setMockMethodCallHandler ((MethodCall methodCall) {
51
76
log.add (methodCall);
52
77
return Future <dynamic >.value (true );
53
78
});
54
79
localAuthentication = DefaultLocalAuthPlatform ();
55
- log.clear ();
56
80
});
57
81
58
82
test ('isDeviceSupported' , () async {
0 commit comments