File tree 5 files changed +23
-7
lines changed 5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -391,11 +391,12 @@ mixin SchedulerBinding on BindingBase {
391
391
AppLifecycleState ? get lifecycleState => _lifecycleState;
392
392
AppLifecycleState ? _lifecycleState;
393
393
394
- /// Allows the test framework to reset the lifecycle state back to its
395
- /// initial value .
394
+ /// Allows the test framework to reset the lifecycle state and framesEnabled
395
+ /// back to their initial values .
396
396
@visibleForTesting
397
- void resetLifecycleState () {
397
+ void resetInternalState () {
398
398
_lifecycleState = null ;
399
+ _framesEnabled = true ;
399
400
}
400
401
401
402
/// Called when the application lifecycle state changes.
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
10
10
void main () {
11
11
testWidgets ('initialLifecycleState is used to init state paused' , (WidgetTester tester) async {
12
12
final TestWidgetsFlutterBinding binding = tester.binding;
13
- binding.resetLifecycleState ();
13
+ binding.resetInternalState ();
14
14
// Use paused as the initial state.
15
15
binding.platformDispatcher.initialLifecycleStateTestValue = 'AppLifecycleState.paused' ;
16
16
binding.readTestInitialLifecycleStateFromNativeWindow (); // Re-attempt the initialization.
@@ -22,7 +22,7 @@ void main() {
22
22
testWidgets ('Handles all of the allowed states of AppLifecycleState' , (WidgetTester tester) async {
23
23
final TestWidgetsFlutterBinding binding = tester.binding;
24
24
for (final AppLifecycleState state in AppLifecycleState .values) {
25
- binding.resetLifecycleState ();
25
+ binding.resetInternalState ();
26
26
binding.platformDispatcher.initialLifecycleStateTestValue = state.toString ();
27
27
binding.readTestInitialLifecycleStateFromNativeWindow ();
28
28
expect (ServicesBinding .instance.lifecycleState.toString (), equals (state.toString ()));
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ void main() {
43
43
listener? .dispose ();
44
44
listener = null ;
45
45
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding .instance;
46
- binding.resetLifecycleState ();
46
+ binding.resetInternalState ();
47
47
binding.platformDispatcher.resetInitialLifecycleState ();
48
48
assert (TestAppLifecycleListener .registerCount == 0 ,
49
49
'There were ${TestAppLifecycleListener .registerCount } listeners that were not disposed of in tests.' );
Original file line number Diff line number Diff line change @@ -397,6 +397,21 @@ void main() {
397
397
await tester.pump ();
398
398
});
399
399
400
+ testWidgets ('resetInternalState resets lifecycleState and framesEnabled to initial state' , (WidgetTester tester) async {
401
+ // Initial state
402
+ expect (tester.binding.lifecycleState, isNull);
403
+ expect (tester.binding.framesEnabled, isTrue);
404
+
405
+ tester.binding.handleAppLifecycleStateChanged (AppLifecycleState .paused);
406
+ expect (tester.binding.lifecycleState, AppLifecycleState .paused);
407
+ expect (tester.binding.framesEnabled, isFalse);
408
+
409
+ tester.binding.resetInternalState ();
410
+
411
+ expect (tester.binding.lifecycleState, isNull);
412
+ expect (tester.binding.framesEnabled, isTrue);
413
+ });
414
+
400
415
testWidgets ('scheduleFrameCallback error control test' , (WidgetTester tester) async {
401
416
late FlutterError error;
402
417
try {
Original file line number Diff line number Diff line change @@ -1177,7 +1177,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
1177
1177
// ignore: invalid_use_of_visible_for_testing_member
1178
1178
RendererBinding .instance.initMouseTracker ();
1179
1179
// ignore: invalid_use_of_visible_for_testing_member
1180
- ServicesBinding .instance.resetLifecycleState ();
1180
+ ServicesBinding .instance.resetInternalState ();
1181
1181
}
1182
1182
}
1183
1183
You can’t perform that action at this time.
0 commit comments