-
Notifications
You must be signed in to change notification settings - Fork 191
/
golden_text_test.dart
64 lines (56 loc) · 1.92 KB
/
golden_text_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import 'package:flutter_test/flutter_test.dart';
import 'package:rive/math.dart';
import 'package:rive/rive.dart';
import '../../src/utils.dart';
import '../golden_comparator.dart';
void main() {
group('Golden - Text tests', () {
testWidgets('Text runs update with bone constraints',
(WidgetTester tester) async {
final riveBytes = loadFile('assets/electrified_button_simple.riv');
final file = RiveFile.import(riveBytes);
late Artboard artboard;
late StateMachineController controller;
late TextValueRun textRun;
final widget = RiveAnimation.direct(
file,
useArtboardSize: true,
onInit: (a) {
artboard = a;
controller = artboard.stateMachineByName('button')!;
artboard.addController(controller);
textRun = artboard.component<TextValueRun>('name')!;
},
);
await tester.pumpWidget(widget);
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'text_bones_constraint_01.png',
reason: 'First frame should match golden',
);
controller.pointerMove(Vec2D.fromValues(250, 250));
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'text_bones_constraint_02.png',
reason:
'Hovering should trigger a different animation for text and button',
);
textRun.text = 'short';
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'text_bones_constraint_03.png',
reason: 'Short text runs should update with bone constraints',
);
textRun.text = 'Extremely long text. The longest.';
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'text_bones_constraint_04.png',
reason: 'Long text runs should update with bone constraints',
);
});
});
}