Skip to content

Commit

Permalink
YaruBackButton: add golden test (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnurmi committed Oct 23, 2022
1 parent 3ffcbad commit e44cc98
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions test/controls/yaru_back_button_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

import '../yaru_golden_tester.dart';

void main() {
testWidgets(
'golden images',
(tester) async {
final variant = goldenVariant.currentValue!;

await tester.pumpScaffold(
const YaruBackButton(),
themeMode: variant.themeMode,
size: const Size(40, 40),
);
await tester.pumpAndSettle();

if (variant.hasState(MaterialState.pressed)) {
await tester.down(find.byType(YaruBackButton));
await tester.pumpAndSettle();
} else if (variant.hasState(MaterialState.hovered)) {
await tester.hover(find.byType(YaruBackButton));
await tester.pumpAndSettle();
}

await expectLater(
find.byType(YaruBackButton),
matchesGoldenFile('goldens/yaru_back_button-${variant.label}.png'),
);
},
variant: goldenVariant,
tags: 'golden',
);
}

final goldenVariant = ValueVariant({
...goldenThemeVariants('normal'),
...goldenThemeVariants('hovered', {MaterialState.hovered: true}),
...goldenThemeVariants('pressed', {MaterialState.pressed: true}),
});

0 comments on commit e44cc98

Please sign in to comment.