11import 'dart:io' ;
22import 'dart:ui' ;
3-
43import 'package:flutter_test/flutter_test.dart' ;
54import 'package:lottie/lottie.dart' ;
65import 'package:lottie/src/model/content/content_model.dart' ;
@@ -14,15 +13,21 @@ void main() {
1413 expect (composition.colorSlots['primary' ], const Color (0xFFFF0000 ));
1514 final fills = _collectFills (composition);
1615 expect (fills, hasLength (1 ));
17- expect (fills.single.color? .keyframes.single.startValue, const Color (0xFFFF0000 ));
16+ expect (
17+ fills.single.color? .keyframes.single.startValue,
18+ const Color (0xFFFF0000 ),
19+ );
1820 expect (fills.single.color? .slotId, isNull);
1921 });
2022
2123 test ('empty slot definition does not crash' , () async {
2224 final composition = await _loadComposition ('empty_slot.json' );
2325 expect (composition.colorSlots, isEmpty);
2426 final fills = _collectFills (composition);
25- expect (fills.single.color? .keyframes.single.startValue, const Color (0xFF0000FF ));
27+ expect (
28+ fills.single.color? .keyframes.single.startValue,
29+ const Color (0xFF0000FF ),
30+ );
2631 });
2732
2833 test ('sid without matching slot keeps encoded color' , () async {
@@ -42,8 +47,14 @@ void main() {
4247 expect (composition.colorSlots['secondary' ], const Color (0xFF00FF00 ));
4348 final fills = _collectFills (composition);
4449 expect (fills, hasLength (2 ));
45- expect (fills[0 ].color? .keyframes.single.startValue, const Color (0xFFFF0000 ));
46- expect (fills[1 ].color? .keyframes.single.startValue, const Color (0xFF00FF00 ));
50+ expect (
51+ fills[0 ].color? .keyframes.single.startValue,
52+ const Color (0xFFFF0000 ),
53+ );
54+ expect (
55+ fills[1 ].color? .keyframes.single.startValue,
56+ const Color (0xFF00FF00 ),
57+ );
4758 expect (fills[0 ].color? .slotId, isNull);
4859 expect (fills[1 ].color? .slotId, isNull);
4960 });
@@ -85,7 +96,10 @@ void main() {
8596 for (final layer in precompLayers! ) {
8697 _collectFillsFromShapes (layer.shapes, fills);
8798 }
88- expect (fills.single.color? .keyframes.single.startValue, const Color (0xFFFF0000 ));
99+ expect (
100+ fills.single.color? .keyframes.single.startValue,
101+ const Color (0xFFFF0000 ),
102+ );
89103 expect (fills.single.color? .slotId, isNull);
90104 });
91105
@@ -95,9 +109,43 @@ void main() {
95109 expect (composition.colorSlots.containsKey ('stringSlot' ), isFalse);
96110 expect (composition.colorSlots.containsKey ('badInner' ), isFalse);
97111 final fills = _collectFills (composition);
98- expect (fills.single.color? .keyframes.single.startValue, const Color (0xFFFF0000 ));
112+ expect (
113+ fills.single.color? .keyframes.single.startValue,
114+ const Color (0xFFFF0000 ),
115+ );
99116 expect (fills.single.color? .slotId, isNull);
100117 });
118+
119+ test ('color slot resolves inside font character shapes' , () async {
120+ final composition = await _loadComposition ('font_char_slot.json' );
121+ expect (composition.colorSlots['primary' ], const Color (0xFFFF0000 ));
122+ expect (composition.characters, isNotEmpty);
123+ final fills = < ShapeFill > [];
124+ for (final char in composition.characters.values) {
125+ for (final group in char.shapes) {
126+ _collectFillsFromShapes (group.items, fills);
127+ }
128+ }
129+ expect (fills, hasLength (1 ));
130+ expect (
131+ fills.single.color? .keyframes.single.startValue,
132+ const Color (0xFFFF0000 ),
133+ );
134+ expect (fills.single.color? .slotId, isNull);
135+ });
136+
137+ test ('invalid framerate triggers assertion with message' , () async {
138+ await expectLater (
139+ _loadComposition ('invalid_framerate.json' ),
140+ throwsA (
141+ isA <AssertionError >().having (
142+ (e) => e.message? .toString () ?? '' ,
143+ 'message' ,
144+ contains ('invalid framerate' ),
145+ ),
146+ ),
147+ );
148+ });
101149}
102150
103151Future <LottieComposition > _loadComposition (String fileName) async {
0 commit comments