Unverified Commit 0d30546c authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

TestWidgetsFlutterBinding should dispose old RestorationManager on reset. (#133999)

parent e08173e7
......@@ -244,6 +244,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// If [registerTestTextInput] returns true when this method is called,
/// the [testTextInput] is configured to simulate the keyboard.
void reset() {
_restorationManager?.dispose();
_restorationManager = null;
resetGestureBinding();
testTextInput.reset();
......
// 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')));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment