TestWidgetsFlutterBinding should dispose old RestorationManager on reset. (#133999)
This commit is contained in:
parent
e08173e767
commit
0d30546c74
@ -244,6 +244,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
|||||||
/// If [registerTestTextInput] returns true when this method is called,
|
/// If [registerTestTextInput] returns true when this method is called,
|
||||||
/// the [testTextInput] is configured to simulate the keyboard.
|
/// the [testTextInput] is configured to simulate the keyboard.
|
||||||
void reset() {
|
void reset() {
|
||||||
|
_restorationManager?.dispose();
|
||||||
_restorationManager = null;
|
_restorationManager = null;
|
||||||
resetGestureBinding();
|
resetGestureBinding();
|
||||||
testTextInput.reset();
|
testTextInput.reset();
|
||||||
|
20
packages/flutter_test/test/bindings_reset_test.dart
Normal file
20
packages/flutter_test/test/bindings_reset_test.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Disposes restoration manager on reset.', () {
|
||||||
|
final AutomatedTestWidgetsFlutterBinding binding = AutomatedTestWidgetsFlutterBinding();
|
||||||
|
int oldCounter = 0;
|
||||||
|
final TestRestorationManager oldRestorationManager = binding.restorationManager;
|
||||||
|
oldRestorationManager.addListener(() => oldCounter++);
|
||||||
|
|
||||||
|
oldRestorationManager.notifyListeners();
|
||||||
|
expect(oldCounter, 1);
|
||||||
|
|
||||||
|
binding.reset();
|
||||||
|
expect(oldRestorationManager.notifyListeners, throwsA((Object e) => e.toString().contains('disposed')));
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user