Skip to content

Commit a9e7207

Browse files
committed
[FTD #6] add golden tests for box painters
Signed-off-by: Jonas Klock <jonas.klock@exxeta.com>
1 parent 78a2506 commit a9e7207

7 files changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/basic_dart_check.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515

1616
- name: 🛠️ Set up Flutter
1717
uses: subosito/flutter-action@v2
18+
with:
19+
channel: stable
20+
flutter-version: 3.27.1
21+
- run: flutter --version
1822

1923
- name: ⚙️ Install dependencies
2024
run: flutter pub get

dart_test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tags:
2+
golden:
5.55 KB
Loading
9.36 KB
Loading
4.09 KB
Loading
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:flutter_text_decorator/flutter_text_decorator.dart';
4+
5+
import '../../test_utils/test_util.dart';
6+
7+
const _text = Text(
8+
testText,
9+
style: TextStyle(fontSize: 16),
10+
);
11+
const _stokeWidth = 2.0;
12+
13+
Widget _createCenter(Widget child) => Center(child: Padding(padding: const EdgeInsets.all(32), child: child));
14+
15+
void main() {
16+
group('TextDecorator tests', () {
17+
group('Testing TextDecorator.boxed styles', () {
18+
testWidgets(
19+
'BoxStyle.bubble renders',
20+
(tester) async {
21+
// arrange
22+
final widget = TextDecorator.boxed(
23+
text: _text,
24+
strokeWidth: _stokeWidth,
25+
);
26+
27+
// act
28+
await tester.pumpWidget(createTestApp(_createCenter(widget)));
29+
await tester.pumpAndSettle();
30+
31+
// assert
32+
await expectLater(
33+
find.byType(Text),
34+
matchesGoldenFile('text_decorator/box/bubble.default.png'),
35+
);
36+
},
37+
tags: ['golden'],
38+
);
39+
testWidgets(
40+
'BoxStyle.rounded renders',
41+
(tester) async {
42+
// arrange
43+
final widget = TextDecorator.boxed(
44+
style: BoxStyle.rounded,
45+
text: _text,
46+
strokeWidth: _stokeWidth,
47+
borderRadius: 2,
48+
);
49+
50+
// act
51+
await tester.pumpWidget(createTestApp(_createCenter(widget)));
52+
await tester.pumpAndSettle();
53+
54+
// assert
55+
await expectLater(
56+
find.byType(Text),
57+
matchesGoldenFile('text_decorator/box/rounded.default.png'),
58+
);
59+
},
60+
tags: ['golden'],
61+
);
62+
63+
testWidgets(
64+
'BoxStyle.curled renders',
65+
(tester) async {
66+
// arrange
67+
final widget = TextDecorator.boxed(
68+
style: BoxStyle.curled,
69+
text: _text,
70+
strokeWidth: _stokeWidth,
71+
);
72+
73+
// act
74+
await tester.pumpWidget(createTestApp(_createCenter(widget)));
75+
await tester.pumpAndSettle();
76+
77+
// assert
78+
await expectLater(
79+
find.byType(Text),
80+
matchesGoldenFile('text_decorator/box/curled.default.png'),
81+
);
82+
},
83+
tags: ['golden'],
84+
);
85+
});
86+
});
87+
}

test/test_utils/test_util.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'package:flutter/material.dart';
2+
3+
const testText = 'Franz jagt im komplett verwahrlosten Taxi quer durch Berlin';
4+
5+
Widget createTestApp(Widget child) => MaterialApp(
6+
debugShowCheckedModeBanner: false,
7+
home: Scaffold(body: child),
8+
);

0 commit comments

Comments
 (0)