Skip to content

Commit

Permalink
Revert "Add missing TimelineMode.off checks (#88)"
Browse files Browse the repository at this point in the history
This reverts commit a4970f7.
  • Loading branch information
passsy committed Dec 20, 2024
1 parent a4970f7 commit d7063b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 46 deletions.
8 changes: 0 additions & 8 deletions lib/src/screenshot/screenshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ extension TimelineSyncScreenshot on Timeline {
List<ScreenshotAnnotator>? 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,
Expand Down
70 changes: 32 additions & 38 deletions lib/src/spot/snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,16 @@ extension MultiWidgetSelectorMatcher<W extends Widget> on WidgetSnapshot<W> {
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');
}
}
Expand All @@ -472,36 +470,32 @@ extension MultiWidgetSelectorMatcher<W extends Widget> on WidgetSnapshot<W> {
});

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;
}
}
Expand Down

0 comments on commit d7063b7

Please sign in to comment.