@@ -42,6 +42,37 @@ void main() {
4242 });
4343 });
4444
45+ group ('TextStyle' , () {
46+ final TextStyle ts0 = TextStyle (fontWeight: FontWeight .w700, fontSize: 12.0 , height: 123.0 );
47+ final TextStyle ts1 = TextStyle (color: const Color (0xFF00FF00 ), fontWeight: FontWeight .w800, fontSize: 10.0 , height: 100.0 );
48+ final TextStyle ts2 = TextStyle (fontFamily: 'test' );
49+ final TextStyle ts3 = TextStyle (fontFamily: 'foo' , fontFamilyFallback: < String > ['Roboto' , 'test' ]);
50+ final TextStyle ts4 = TextStyle (leadingDistribution: TextLeadingDistribution .even);
51+
52+ test ('toString works' , () {
53+ expect (
54+ ts0.toString (),
55+ equals ('TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontFamilyFallback: unspecified, fontSize: 12.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 123.0x, leadingDistribution: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)' ),
56+ );
57+ expect (
58+ ts1.toString (),
59+ equals ('TextStyle(color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontFamilyFallback: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x, leadingDistribution: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)' ),
60+ );
61+ expect (
62+ ts2.toString (),
63+ equals ('TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: test, fontFamilyFallback: unspecified, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, leadingDistribution: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)' ),
64+ );
65+ expect (
66+ ts3.toString (),
67+ equals ('TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: foo, fontFamilyFallback: [Roboto, test], fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, leadingDistribution: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)' ),
68+ );
69+ expect (
70+ ts4.toString (),
71+ equals ('TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontFamilyFallback: unspecified, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, leadingDistribution: TextLeadingDistribution.even, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)' ),
72+ );
73+ });
74+ });
75+
4576 group ('TextHeightBehavior' , () {
4677 const TextHeightBehavior behavior0 = TextHeightBehavior ();
4778 const TextHeightBehavior behavior1 = TextHeightBehavior (
@@ -54,6 +85,10 @@ void main() {
5485 const TextHeightBehavior behavior3 = TextHeightBehavior (
5586 applyHeightToLastDescent: false
5687 );
88+ const TextHeightBehavior behavior4 = TextHeightBehavior (
89+ applyHeightToLastDescent: false ,
90+ leadingDistribution: TextLeadingDistribution .even,
91+ );
5792
5893 test ('default constructor works' , () {
5994 expect (behavior0.applyHeightToFirstAscent, equals (true ));
@@ -67,27 +102,33 @@ void main() {
67102
68103 expect (behavior3.applyHeightToFirstAscent, equals (true ));
69104 expect (behavior3.applyHeightToLastDescent, equals (false ));
105+
106+ expect (behavior4.applyHeightToLastDescent, equals (false ));
107+ expect (behavior4.leadingDistribution, equals (TextLeadingDistribution .even));
70108 });
71109
72110 test ('encode works' , () {
73111 expect (behavior0.encode (), equals (0 ));
74112 expect (behavior1.encode (), equals (3 ));
75113 expect (behavior2.encode (), equals (1 ));
76114 expect (behavior3.encode (), equals (2 ));
115+ expect (behavior4.encode (), equals (6 ));
77116 });
78117
79118 test ('decode works' , () {
80- expect (const TextHeightBehavior .fromEncoded (0 ), equals (behavior0));
81- expect (const TextHeightBehavior .fromEncoded (3 ), equals (behavior1));
82- expect (const TextHeightBehavior .fromEncoded (1 ), equals (behavior2));
83- expect (const TextHeightBehavior .fromEncoded (2 ), equals (behavior3));
119+ expect (TextHeightBehavior .fromEncoded (0 ), equals (behavior0));
120+ expect (TextHeightBehavior .fromEncoded (3 ), equals (behavior1));
121+ expect (TextHeightBehavior .fromEncoded (1 ), equals (behavior2));
122+ expect (TextHeightBehavior .fromEncoded (2 ), equals (behavior3));
123+ expect (TextHeightBehavior .fromEncoded (6 ), equals (behavior4));
84124 });
85125
86126 test ('toString works' , () {
87- expect (behavior0.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent: true)' ));
88- expect (behavior1.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: false)' ));
89- expect (behavior2.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: true)' ));
90- expect (behavior3.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent: false)' ));
127+ expect (behavior0.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent: true, leadingDistribution: TextLeadingDistribution.proportional)' ));
128+ expect (behavior1.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: false, leadingDistribution: TextLeadingDistribution.proportional)' ));
129+ expect (behavior2.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: true, leadingDistribution: TextLeadingDistribution.proportional)' ));
130+ expect (behavior3.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent: false, leadingDistribution: TextLeadingDistribution.proportional)' ));
131+ expect (behavior4.toString (), equals ('TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent: false, leadingDistribution: TextLeadingDistribution.even)' ));
91132 });
92133 });
93134
0 commit comments