Fix how tests count open SemanticsHandles#121571
Fix how tests count open SemanticsHandles#121571auto-submit[bot] merged 8 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
I removed this since SemanticsTester is not actually part of the public API. So, the hint could be a little confusing.
There was a problem hiding this comment.
I assume this would change when there may be multiple pipeline owners?
There was a problem hiding this comment.
I assume this change is to verify the new counting logic work correctly, should we create a new test instead of modifying the existing one?
There was a problem hiding this comment.
Added a test. Turns out, the logic was previously untested and contained a bug. Now some more tests that fail to clean up their semantics handle are failing. I'll have to look into that tomorrow.
There was a problem hiding this comment.
Done. Could you take another look at the new tests and the fixes?
4a2d301 to
d024afc
Compare
d024afc to
39e5314
Compare
chunhtai
left a comment
There was a problem hiding this comment.
LGTM, just some concern about removing the usage of teardown.
| group('Semantics', () { | ||
| testWidgets('day mode', (WidgetTester tester) async { | ||
| final SemanticsHandle semantics = tester.ensureSemantics(); | ||
| addTearDown(semantics.dispose); |
There was a problem hiding this comment.
This is surprising. I always thought this was the better way to dispose resource
There was a problem hiding this comment.
Yeah, but the way our checks currently work they don't play nice with that. We should probably fix that at some point.
Follow-up to #121289.
Part of #121573.
Properly count the open semantics handles in tests. In an ideal world we'd not have the PipelineOwner API for creating semantics handlers and would only be concerned about SemanticsHandlers created via the Binding. However, for backwards compatibility, we will also count the PipelineOwner handles for now (until we eventually deprecate that API).
This change also fixes the leak detection to work properly. Previously, it had an off by one error and was missing leaks. Tests have been added to prevent this in the future.