Skip to content

Commit d843863

Browse files
authored
reset state of CustomSemanticsAction before running tests (#137697)
Fixes flutter/flutter#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.
1 parent ba75e7a commit d843863

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/flutter/lib/src/semantics/semantics.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ class CustomSemanticsAction {
274274
static CustomSemanticsAction? getAction(int id) {
275275
return _actions[id];
276276
}
277+
278+
/// Resets internal state between tests. Does nothing if asserts are disabled.
279+
@visibleForTesting
280+
static void resetForTests() {
281+
assert(() {
282+
_actions.clear();
283+
_ids.clear();
284+
_nextId = 0;
285+
return true;
286+
}());
287+
}
277288
}
278289

279290
/// A string that carries a list of [StringAttribute]s.

packages/flutter_test/lib/src/binding.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
251251
if (registerTestTextInput) {
252252
_testTextInput.register();
253253
}
254+
CustomSemanticsAction.resetForTests(); // ignore: invalid_use_of_visible_for_testing_member
254255
}
255256

256257
@override

0 commit comments

Comments
 (0)