reset state of CustomSemanticsAction before running tests (#137697)

Fixes https://github.com/flutter/flutter/issues/137696

This will get the tree green again.

The problem is that `CustomSemanticsAction` has static state in it, and todays test seed order makes things unhappy.
This commit is contained in:
Dan Field 2023-11-01 13:09:41 -07:00 committed by GitHub
parent ba75e7a019
commit d843863c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -274,6 +274,17 @@ class CustomSemanticsAction {
static CustomSemanticsAction? getAction(int id) {
return _actions[id];
}
/// Resets internal state between tests. Does nothing if asserts are disabled.
@visibleForTesting
static void resetForTests() {
assert(() {
_actions.clear();
_ids.clear();
_nextId = 0;
return true;
}());
}
}
/// A string that carries a list of [StringAttribute]s.

View File

@ -251,6 +251,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
if (registerTestTextInput) {
_testTextInput.register();
}
CustomSemanticsAction.resetForTests(); // ignore: invalid_use_of_visible_for_testing_member
}
@override