Skip to content

Commit

Permalink
Add test "Global: record, without error" and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmolnar committed Jun 26, 2024
1 parent ee9f640 commit f9ff5df
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
20 changes: 12 additions & 8 deletions test/timeline/tap/global/global_live_timeline_tap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ import '../../../util/timeline_test_helpers.dart';

void main() {
globalTimelineMode = TimelineMode.live;
test('Global: Live timeline - without error, prints HTML', () async {
await TimelineTestHelpers.liveTimelineWithoutErrorPrintsHtml(
testWidgets('Global: record, without error', (tester) async {
await TimelineTestHelpers.liveWithoutError(
tester: tester,
isGlobalMode: true,
);
});
test('Global: live - without error, prints HTML', () async {
await TimelineTestHelpers.liveWithoutErrorPrintsHtml(
isGlobalMode: true,
);
});
test(
'Global: Live timeline - Live timeline - with error, no duplicates, prints HTML',
() async {
await TimelineTestHelpers.liveTimelineWithErrorNoDuplicatesPrintsHtml(
test('Global: live - with error, no duplicates, prints HTML', () async {
await TimelineTestHelpers.liveWithErrorNoDuplicatesPrintsHtml(
isGlobalMode: true,
);
});
testWidgets('Global: Turn live timeline off during test', (tester) async {
await TimelineTestHelpers.liveTimelineTurnOffDuringTest(
testWidgets('Global: live, turn off during test', (tester) async {
await TimelineTestHelpers.liveTurnOffDuringTest(
isGlobalMode: true,
tester: tester,
);
Expand Down
4 changes: 2 additions & 2 deletions test/timeline/tap/global/global_off_timeline_tap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import '../../../util/timeline_test_helpers.dart';

void main() {
globalTimelineMode = TimelineMode.off;
testWidgets('Global timeline - Timeline off', (tester) async {
await TimelineTestHelpers.offTimelineTest(
testWidgets('Global: off, without error', (tester) async {
await TimelineTestHelpers.offWithoutError(
tester: tester,
isGlobalMode: true,
);
Expand Down
8 changes: 4 additions & 4 deletions test/timeline/tap/global/global_record_timeline_tap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import '../../../util/timeline_test_helpers.dart';

void main() {
globalTimelineMode = TimelineMode.record;
testWidgets('Global timeline - record, without error', (tester) async {
await TimelineTestHelpers.recordTimelineTestWithoutError(
testWidgets('Global: record, without error', (tester) async {
await TimelineTestHelpers.recordWithoutError(
tester: tester,
isGlobalMode: true,
);
});
test('Global timeline - record, with error', () async {
await TimelineTestHelpers.recordTimelineTestWithError(isGlobalMode: true);
test('Global: record, with error', () async {
await TimelineTestHelpers.recordWithError(isGlobalMode: true);
});
}
28 changes: 15 additions & 13 deletions test/timeline/tap/local/local_timeline_tap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@ void main() {
});

group('Override global timeline', () {
testWidgets('Local: Start with Timeline Mode off', (tester) async {
await TimelineTestHelpers.offTimelineTest(tester: tester);
testWidgets('Local: live, without error', (tester) async {
await TimelineTestHelpers.liveWithoutError(tester: tester);
});
testWidgets('Local: Turn live timeline off during test', (tester) async {
await TimelineTestHelpers.liveTimelineTurnOffDuringTest(tester: tester);
testWidgets('Local: off, without error', (tester) async {
await TimelineTestHelpers.offWithoutError(tester: tester);
});
testWidgets('Local: live, turn off during test', (tester) async {
await TimelineTestHelpers.liveTurnOffDuringTest(tester: tester);
});
});

group('Print on teardown', () {
testWidgets('Local: OnError timeline - without error', (tester) async {
await TimelineTestHelpers.recordTimelineTestWithoutError(tester: tester);
testWidgets('Local: record, without error', (tester) async {
await TimelineTestHelpers.recordWithoutError(tester: tester);
});

test('Local: OnError timeline - with error, prints timeline', () async {
await TimelineTestHelpers.recordTimelineTestWithError();
test('Local: record, with error', () async {
await TimelineTestHelpers.recordWithError();
});
test('Local: Live timeline - without error, prints HTML', () async {
await TimelineTestHelpers.liveTimelineWithoutErrorPrintsHtml();
test('Local: live - without error, prints HTML', () async {
await TimelineTestHelpers.liveWithoutErrorPrintsHtml();
});
test('Local: Live timeline - with error, no duplicates, prints HTML',
() async {
await TimelineTestHelpers.liveTimelineWithErrorNoDuplicatesPrintsHtml();
test('Local: live - with error, no duplicates, prints HTML', () async {
await TimelineTestHelpers.liveWithErrorNoDuplicatesPrintsHtml();
});
});
}
30 changes: 13 additions & 17 deletions test/util/timeline_test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TimelineTestHelpers {
};
}

static Future<void> recordTimelineTestWithoutError({
static Future<void> recordWithoutError({
required WidgetTester tester,
bool isGlobalMode = false,
}) async {
Expand Down Expand Up @@ -66,16 +66,14 @@ class TimelineTestHelpers {
_testTimeLineContent(output: output, eventCount: 0);
}

static Future<void> recordTimelineTestWithError({
static Future<void> recordWithError({
bool isGlobalMode = false,
}) async {
final tempDir = Directory.systemTemp.createTempSync();
final tempTestFile = File('${tempDir.path}/temp_test.dart');
final testTitle =
'${isGlobalMode ? 'Global: ' : 'Local: '}OnError timeline - with error, prints timeline';
await tempTestFile.writeAsString(
_tapTestAsString(
title: testTitle,
title: 'OnError timeline - with error, prints timeline',
timelineMode: TimelineMode.record,
shouldFail: true,
isGlobalMode: isGlobalMode,
Expand Down Expand Up @@ -148,16 +146,14 @@ class TimelineTestHelpers {
);
}

static Future<void> liveTimelineWithoutErrorPrintsHtml({
static Future<void> liveWithoutErrorPrintsHtml({
bool isGlobalMode = false,
}) async {
final tempDir = Directory.systemTemp.createTempSync();
final tempTestFile = File('${tempDir.path}/temp_test.dart');
final testTitle =
'${isGlobalMode ? 'Global: ' : 'Local: '}Live timeline without error prints html';
await tempTestFile.writeAsString(
_tapTestAsString(
title: testTitle,
title: 'Live timeline without error prints html',
timelineMode: TimelineMode.live,
isGlobalMode: isGlobalMode,
),
Expand Down Expand Up @@ -229,16 +225,14 @@ class TimelineTestHelpers {
);
}

static Future<void> liveTimelineWithErrorNoDuplicatesPrintsHtml({
static Future<void> liveWithErrorNoDuplicatesPrintsHtml({
bool isGlobalMode = false,
}) async {
final tempDir = Directory.systemTemp.createTempSync();
final tempTestFile = File('${tempDir.path}/temp_test.dart');
final testTitle =
'${isGlobalMode ? 'Global: ' : 'Local: '}Live timeline - with error, no duplicates, prints HTML';
await tempTestFile.writeAsString(
_tapTestAsString(
title: testTitle,
title: 'Live timeline - with error, no duplicates, prints HTML',
timelineMode: TimelineMode.live,
shouldFail: true,
isGlobalMode: isGlobalMode,
Expand Down Expand Up @@ -311,7 +305,7 @@ class TimelineTestHelpers {
);
}

static Future<void> offTimelineTest({
static Future<void> offWithoutError({
required WidgetTester tester,
bool isGlobalMode = false,
}) async {
Expand Down Expand Up @@ -340,7 +334,7 @@ class TimelineTestHelpers {
_testTimeLineContent(output: output, eventCount: 0);
}

static Future<void> liveTimelineTurnOffDuringTest({
static Future<void> liveTurnOffDuringTest({
required WidgetTester tester,
bool isGlobalMode = false,
}) async {
Expand Down Expand Up @@ -391,7 +385,7 @@ class TimelineTestHelpers {
expect(output, contains('Timeline mode is already set to "off"'));
}

static Future<void> liveTimelineTest({
static Future<void> liveWithoutError({
required WidgetTester tester,
bool isGlobalMode = false,
}) async {
Expand Down Expand Up @@ -457,6 +451,8 @@ class TimelineTestHelpers {
bool shouldFail = false,
bool isGlobalMode = false,
}) {
final testTitle = '${isGlobalMode ? 'Global: ' : 'Local: '}$title';

final globalInitiator =
isGlobalMode ? '${_globalTimelineInitiator(timelineMode)};' : '';

Expand All @@ -475,7 +471,7 @@ void main() async {
$globalInitiator
final addButtonSelector = spotIcon(Icons.add);
final subtractButtonSelector = spotIcon(Icons.remove);
testWidgets("$title", (WidgetTester tester) async {
testWidgets("$testTitle", (WidgetTester tester) async {
$localInitiator
await tester.pumpWidget(const TimelineTestWidget());
addButtonSelector.existsOnce();
Expand Down

0 comments on commit f9ff5df

Please sign in to comment.