From d7063b740b18b129c2e8177fafc3f4254fd4e6ec Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Fri, 20 Dec 2024 14:55:45 +0100 Subject: [PATCH] Revert "Add missing TimelineMode.off checks (#88)" This reverts commit a4970f739af52e41a2bad51683eb3767a77e38e5. --- lib/src/screenshot/screenshot.dart | 8 ---- lib/src/spot/snapshot.dart | 70 ++++++++++++++---------------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/lib/src/screenshot/screenshot.dart b/lib/src/screenshot/screenshot.dart index 2da02065..e581f1fc 100644 --- a/lib/src/screenshot/screenshot.dart +++ b/lib/src/screenshot/screenshot.dart @@ -137,14 +137,6 @@ extension TimelineSyncScreenshot on Timeline { List? annotators, }) { final Frame? frame = _caller(); - - if (timeline.mode == TimelineMode.off) { - // ignore: avoid_print - print( - 'Warning: The timeline is off, do not take screenshots for the timeline\n' - ' at ${frame?.member} ${frame?.uri}:${frame?.line}:${frame?.column}', - ); - } final liveElement = _findSingleElement( element: element, snapshot: snapshot, diff --git a/lib/src/spot/snapshot.dart b/lib/src/spot/snapshot.dart index 756b13c5..4598e220 100644 --- a/lib/src/spot/snapshot.dart +++ b/lib/src/spot/snapshot.dart @@ -442,18 +442,16 @@ extension MultiWidgetSelectorMatcher on WidgetSnapshot { final errorBuilder = StringBuffer(); errorBuilder.writeln('Could not find $selector in widget tree'); _dumpWidgetTree(errorBuilder); - if (timeline.mode != TimelineMode.off) { - timeline.addEvent( - eventType: 'Assertion Failed', - details: errorBuilder.toString(), - color: Colors.red, - screenshot: timeline.takeScreenshotSync( - annotators: [ - HighlightAnnotator.elements(discoveredElements), - ], - ), - ); - } + timeline.addEvent( + eventType: 'Assertion Failed', + details: errorBuilder.toString(), + color: Colors.red, + screenshot: timeline.takeScreenshotSync( + annotators: [ + HighlightAnnotator.elements(discoveredElements), + ], + ), + ); fail('Could not find $selector in widget tree'); } } @@ -472,36 +470,32 @@ extension MultiWidgetSelectorMatcher on WidgetSnapshot { }); final tree = findCommonAncestor(discoveredElements).toStringDeep(); - if (timeline.mode != TimelineMode.off) { - timeline.addEvent( - eventType: 'Assertion Failed', - details: '$errorBuilder\n' - '$tree', - color: Colors.red, - screenshot: timeline.takeScreenshotSync( - annotators: [ - HighlightAnnotator.elements(discoveredElements), - ], - ), - ); - } + timeline.addEvent( + eventType: 'Assertion Failed', + details: '$errorBuilder\n' + '$tree', + color: Colors.red, + screenshot: timeline.takeScreenshotSync( + annotators: [ + HighlightAnnotator.elements(discoveredElements), + ], + ), + ); fail(errorBuilder.toString()); } } - if (timeline.mode != TimelineMode.off) { - timeline.addEvent( - eventType: 'Assertion', - details: - 'Found ${discovered.length} widgets matching $selector.\nExpected: ${min != null ? "min:$min," : ''}${max != null ? "max:$max," : ''}', - color: Colors.grey, - screenshot: timeline.takeScreenshotSync( - annotators: [ - HighlightAnnotator.elements(discoveredElements), - ], - ), - ); - } + timeline.addEvent( + eventType: 'Assertion', + details: + 'Found ${discovered.length} widgets matching $selector.\nExpected: ${min != null ? "min:$min," : ''}${max != null ? "max:$max," : ''}', + color: Colors.grey, + screenshot: timeline.takeScreenshotSync( + annotators: [ + HighlightAnnotator.elements(discoveredElements), + ], + ), + ); return this; } }