Skip to content

Commit

Permalink
Update test body tests
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Nov 3, 2024
1 parent 1fbd1ed commit f17181b
Showing 1 changed file with 84 additions and 32 deletions.
116 changes: 84 additions & 32 deletions test/timeline/tap/act_tap_timeline_test_bodies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ActTapTimelineTestBodies {
output,
isNot(contains('Tap ${_subtractButtonSelector.toStringBreadcrumb()}')),
);
_testTimeLineContent(output: output, eventCount: 0);
_testTimeLineContent(output: output, tapCount: 0, assertionCount: 0);
}

static Future<void> throwOnGlobalTimelineChange({
Expand Down Expand Up @@ -83,27 +83,31 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
shared.timelineHeader,
);
expect(
timeline[2],
'Event: Tap Icon Widget with icon: "IconData(U+0E047)"',
timeline[14],
'Event Type: Tap Event',
);
expect(
timeline[3].startsWith('Caller: at main file:///'),
timeline[15],
'Details: Tap Icon Widget with icon: "IconData(U+0E047)"',
);
expect(
timeline[16].startsWith('Caller: at main file:///'),
isTrue,
);
expect(
timeline[4].startsWith(
timeline[17].startsWith(
'Screenshot: file:///',
),
isTrue,
);
expect(
timeline[5].startsWith(
timeline[18].startsWith(
'Timestamp:',
),
isTrue,
);
expect(
timeline[6],
timeline[19],
shared.timelineSeparator,
);
final prefix = isGlobalMode ? 'global' : 'local';
Expand Down Expand Up @@ -131,27 +135,31 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
// Does not start with 'Timeline', this only happens on error
expect(timeline.first, shared.timelineHeader);
expect(
timeline.second,
'Event: Tap Icon Widget with icon: "IconData(U+0E047)"',
timeline[13],
'Event Type: Tap Event',
);
expect(
timeline[14],
'Details: Tap Icon Widget with icon: "IconData(U+0E047)"',
);
expect(
timeline[2].startsWith('Caller: at'),
timeline[15].startsWith('Caller: at'),
isTrue,
);
expect(
timeline[3].startsWith(
timeline[16].startsWith(
'Screenshot: file:///',
),
isTrue,
);
expect(
timeline[4].startsWith(
timeline[17].startsWith(
'Timestamp:',
),
isTrue,
);
expect(
timeline[5],
timeline[18],
shared.timelineSeparator,
);
final htmlLine =
Expand Down Expand Up @@ -179,27 +187,31 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
// Does not start with 'Timeline', this only happens on error
expect(timeline.first, shared.timelineHeader);
expect(
timeline.second,
'Event: Tap Icon Widget with icon: "IconData(U+0E047)"',
timeline[26],
'Event Type: Tap Event',
);
expect(
timeline[2].startsWith('Caller: at main file:///'),
timeline[27],
'Details: Tap Icon Widget with icon: "IconData(U+0E516)"',
);
expect(
timeline[28].startsWith('Caller: at main file:///'),
isTrue,
);
expect(
timeline[3].startsWith(
timeline[29].startsWith(
'Screenshot: file:///',
),
isTrue,
);
expect(
timeline[4].startsWith(
timeline[30].startsWith(
'Timestamp:',
),
isTrue,
);
expect(
timeline[5],
timeline[31],
shared.timelineSeparator,
);
final prefix = isGlobalMode ? 'global' : 'local';
Expand Down Expand Up @@ -239,7 +251,7 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
output,
isNot(contains('Tap ${_subtractButtonSelector.toStringBreadcrumb()}')),
);
_testTimeLineContent(output: output, eventCount: 0);
_testTimeLineContent(output: output, tapCount: 0, assertionCount: 0);
}

static Future<void> liveTurnOffDuringTest({
Expand Down Expand Up @@ -282,7 +294,7 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
output,
isNot(contains('Tap ${_clearButtonSelector.toStringBreadcrumb()}')),
);
_testTimeLineContent(output: output, eventCount: 2);
_testTimeLineContent(output: output, tapCount: 2, assertionCount: 4);
expect(output, contains('⏸︎ - Timeline recording is off'));
}

Expand All @@ -306,43 +318,83 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
// Changes in local test since it's `record` by default. Globally it does not
// change since the global mode is already `live`.
expect(containsMessage, isGlobalMode ? isFalse : isTrue);

expect(
output,
contains('Event: Tap ${_addButtonSelector.toStringBreadcrumb()}'),
contains(
'Event Type: Assertion\n'
'Details: ${_addButtonSelector.toStringBreadcrumb()} exists once',
),
);
expect(
output,
contains('Event: Tap ${_subtractButtonSelector.toStringBreadcrumb()}'),
contains(
'Event Type: Assertion\n'
'Details: ${spotText('Counter: 3')} exists once',
),
);
_testTimeLineContent(output: output, eventCount: 2);
expect(
output,
contains(
'Event Type: Tap Event\n'
'Details: Tap ${_addButtonSelector.toStringBreadcrumb()}',
),
);
expect(
output,
contains(
'Event Type: Assertion\n'
'Details: ${spotText('Counter: 4')} exists once',
),
);
expect(
output,
contains(
'Event Type: Tap Event\n'
'Details: Tap ${_subtractButtonSelector.toStringBreadcrumb()}',
),
);
expect(
output,
contains(
'Event Type: Assertion\n'
'Details: ${spotText('Counter: 3')} exists once',
),
);
_testTimeLineContent(output: output, tapCount: 2, assertionCount: 4);
}

static void _testTimeLineContent({
required String output,
required int eventCount,
required int tapCount,
required int assertionCount,
}) {
expect(
RegExp(shared.timelineHeader).allMatches(output).length,
eventCount,
RegExp('Event Type: Tap Event').allMatches(output).length,
tapCount,
);
expect(
RegExp('Event: Tap Icon Widget with icon:').allMatches(output).length,
eventCount,
RegExp('Event Type: Assertion').allMatches(output).length,
assertionCount,
);
expect(
RegExp(shared.timelineHeader).allMatches(output).length,
tapCount + assertionCount,
);
final callerParts = output.split('\n').where((line) {
return line.startsWith('Caller: at') && line.contains('file://');
}).toList();
expect(
callerParts.length,
eventCount,
tapCount + assertionCount,
);
final screenshots = output.split('\n').where((line) {
return line.startsWith('Screenshot: file:');
}).toList();
if (WidgetsBinding.instance is! LiveTestWidgetsFlutterBinding) {
expect(
screenshots.length,
eventCount,
tapCount,
);
} else {
expect(
Expand All @@ -352,7 +404,7 @@ Example: timeline.mode = $globalTimelineModeToSwitch;
}
expect(
RegExp('Timestamp: ').allMatches(output).length,
eventCount,
tapCount + assertionCount,
);
}

Expand Down

0 comments on commit f17181b

Please sign in to comment.