Do not paint a description label when rendering an integration test (#153875)

Fixes https://github.com/flutter/flutter/issues/153624
This commit is contained in:
Jason Simmons 2024-08-29 10:08:38 -07:00 committed by GitHub
parent 05c454c28c
commit 9bf7d7bb35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -1832,7 +1832,13 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
fontSize: 10.0, fontSize: 10.0,
); );
void _setDescription(String value) { /// Label describing the test.
@visibleForTesting
TextPainter? get label => _label;
/// Set a description label that is drawn into the test output.
@protected
void setLabel(String value) {
if (value.isEmpty) { if (value.isEmpty) {
_label = null; _label = null;
return; return;
@ -2033,7 +2039,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
}) { }) {
assert(!inTest); assert(!inTest);
_inTest = true; _inTest = true;
_setDescription(description); setLabel(description);
return _runTest(testBody, invariantTester, description); return _runTest(testBody, invariantTester, description);
} }

View File

@ -244,6 +244,11 @@ https://docs.flutter.dev/testing/integration-tests
results[description] ??= _success; results[description] ??= _success;
} }
// Do not paint a description label because it could show up in screenshots
// of the integration test.
@override
void setLabel(String value) {}
vm.VmService? _vmService; vm.VmService? _vmService;
/// Initialize the [vm.VmService] settings for the timeline. /// Initialize the [vm.VmService] settings for the timeline.

View File

@ -130,6 +130,10 @@ Future<void> main() async {
expect(find.byType(RepaintBoundary), findsOneWidget); expect(find.byType(RepaintBoundary), findsOneWidget);
}); });
testWidgets('integration test has no label', (WidgetTester tester) async {
expect(binding.label, null);
});
}); });
tearDownAll(() async { tearDownAll(() async {