File tree Expand file tree Collapse file tree 12 files changed +36
-33
lines changed
packages/camera/camera_android_camerax/test Expand file tree Collapse file tree 12 files changed +36
-33
lines changed Original file line number Diff line number Diff line change @@ -16,18 +16,19 @@ import 'test_camerax_library.g.dart';
1616void main () {
1717 TestWidgetsFlutterBinding .ensureInitialized ();
1818
19+ // Mocks the call to clear the native InstanceManager.
20+ TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
21+
1922 group ('Analyzer' , () {
2023 setUp (() {});
2124
2225 tearDown (() {
2326 TestAnalyzerHostApi .setup (null );
24- TestInstanceManagerHostApi .setup (null );
2527 });
2628
2729 test ('HostApi create' , () {
2830 final MockTestAnalyzerHostApi mockApi = MockTestAnalyzerHostApi ();
2931 TestAnalyzerHostApi .setup (mockApi);
30- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
3132
3233 final InstanceManager instanceManager = InstanceManager (
3334 onWeakReferenceRemoved: (_) {},
Original file line number Diff line number Diff line change @@ -98,9 +98,6 @@ void main() {
9898 return cameraClosingEventSent && cameraErrorSent;
9999 }
100100
101- // Mocks the call to clear the native InstanceManager.
102- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
103-
104101 test ('Should fetch CameraDescription instances for available cameras' ,
105102 () async {
106103 // Arrange
Original file line number Diff line number Diff line change @@ -7,17 +7,17 @@ import 'package:camera_android_camerax/src/instance_manager.dart';
77import 'package:flutter_test/flutter_test.dart' ;
88import 'package:mockito/annotations.dart' ;
99
10+ import 'camera_state_error_test.mocks.dart' ;
1011import 'test_camerax_library.g.dart' ;
1112
1213@GenerateMocks (< Type > [TestInstanceManagerHostApi ])
1314void main () {
1415 TestWidgetsFlutterBinding .ensureInitialized ();
1516
16- group ('CameraStateError' , () {
17- tearDown (() {
18- TestInstanceManagerHostApi .setup (null );
19- });
17+ // Mocks the call to clear the native InstanceManager.
18+ TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
2019
20+ group ('CameraStateError' , () {
2121 test (
2222 'FlutterAPI create makes call to create CameraStateError instance with expected identifier' ,
2323 () {
Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ void main() {
2020 TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
2121
2222 group ('CameraState' , () {
23- tearDown (() {
24- TestInstanceManagerHostApi .setup (null );
25- });
26-
2723 test (
2824 'FlutterAPI create makes call to create CameraState instance with expected identifier' ,
2925 () {
Original file line number Diff line number Diff line change @@ -26,14 +26,12 @@ void main() {
2626
2727 tearDown (() {
2828 TestImageAnalysisHostApi .setup (null );
29- TestInstanceManagerHostApi .setup (null );
3029 });
3130
3231 test ('HostApi create' , () {
3332 final MockTestImageAnalysisHostApi mockApi =
3433 MockTestImageAnalysisHostApi ();
3534 TestImageAnalysisHostApi .setup (mockApi);
36- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
3735
3836 final InstanceManager instanceManager = InstanceManager (
3937 onWeakReferenceRemoved: (_) {},
Original file line number Diff line number Diff line change @@ -12,10 +12,13 @@ import 'package:mockito/mockito.dart';
1212import 'image_capture_test.mocks.dart' ;
1313import 'test_camerax_library.g.dart' ;
1414
15- @GenerateMocks (< Type > [TestImageCaptureHostApi ])
15+ @GenerateMocks (< Type > [TestImageCaptureHostApi , TestInstanceManagerHostApi ])
1616void main () {
1717 TestWidgetsFlutterBinding .ensureInitialized ();
1818
19+ // Mocks the call to clear the native InstanceManager.
20+ TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
21+
1922 group ('ImageCapture' , () {
2023 tearDown (() => TestImageCaptureHostApi .setup (null ));
2124
Original file line number Diff line number Diff line change 1- // Mocks generated by Mockito 5.4.0 from annotations
1+ // Mocks generated by Mockito 5.4.1 from annotations
22// in camera_android_camerax/test/image_capture_test.dart.
33// Do not manually edit this file.
44
5+ // @dart=2.19
6+
57// ignore_for_file: no_leading_underscores_for_library_prefixes
68import 'dart:async' as _i4;
79
@@ -71,3 +73,22 @@ class MockTestImageCaptureHostApi extends _i1.Mock
7173 returnValue: _i4.Future <String >.value ('' ),
7274 ) as _i4.Future <String >);
7375}
76+
77+ /// A class which mocks [TestInstanceManagerHostApi] .
78+ ///
79+ /// See the documentation for Mockito's code generation for more information.
80+ class MockTestInstanceManagerHostApi extends _i1.Mock
81+ implements _i2.TestInstanceManagerHostApi {
82+ MockTestInstanceManagerHostApi () {
83+ _i1.throwOnMissingStub (this );
84+ }
85+
86+ @override
87+ void clear () => super .noSuchMethod (
88+ Invocation .method (
89+ #clear,
90+ [],
91+ ),
92+ returnValueForMissingStub: null ,
93+ );
94+ }
Original file line number Diff line number Diff line change @@ -22,11 +22,8 @@ void main() {
2222 TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
2323
2424 group ('ImageProxy' , () {
25- setUp (() {});
26-
2725 tearDown (() {
2826 TestImageProxyHostApi .setup (null );
29- TestInstanceManagerHostApi .setup (null );
3027 });
3128
3229 test ('getPlanes' , () async {
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ void main() {
2424 group ('LiveData' , () {
2525 tearDown (() {
2626 TestLiveDataHostApi .setup (null );
27- TestInstanceManagerHostApi .setup (null );
2827 });
2928
3029 test ('observe makes call to add observer to LiveData instance' , () async {
@@ -103,7 +102,6 @@ void main() {
103102 test ('getValue returns expected value' , () async {
104103 final MockTestLiveDataHostApi mockApi = MockTestLiveDataHostApi ();
105104 TestLiveDataHostApi .setup (mockApi);
106- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
107105
108106 final InstanceManager instanceManager = InstanceManager (
109107 onWeakReferenceRemoved: (_) {},
Original file line number Diff line number Diff line change @@ -17,16 +17,17 @@ import 'test_camerax_library.g.dart';
1717void main () {
1818 TestWidgetsFlutterBinding .ensureInitialized ();
1919
20+ // Mocks the call to clear the native InstanceManager.
21+ TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
22+
2023 group ('Observer' , () {
2124 tearDown (() {
2225 TestObserverHostApi .setup (null );
23- TestInstanceManagerHostApi .setup (null );
2426 });
2527
2628 test ('HostApi create makes call to create Observer instance' , () {
2729 final MockTestObserverHostApi mockApi = MockTestObserverHostApi ();
2830 TestObserverHostApi .setup (mockApi);
29- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
3031
3132 final InstanceManager instanceManager = InstanceManager (
3233 onWeakReferenceRemoved: (_) {},
@@ -47,7 +48,6 @@ void main() {
4748 () {
4849 final MockTestObserverHostApi mockApi = MockTestObserverHostApi ();
4950 TestObserverHostApi .setup (mockApi);
50- TestInstanceManagerHostApi .setup (MockTestInstanceManagerHostApi ());
5151
5252 final Observer <String > cameraStateObserver =
5353 Observer <String >.detached (onChanged: (Object value) {});
You can’t perform that action at this time.
0 commit comments