-
-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support vertical-align in inline styles (#1266)
- Loading branch information
1 parent
d7247cb
commit fe896de
Showing
7 changed files
with
201 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import 'package:flutter_html/flutter_html.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../test_utils.dart'; | ||
|
||
void main() { | ||
testWidgets( | ||
'Tag with vertical align set inline should receive that style', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<span style="vertical-align: super;">Text</span> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.sup)); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'Tag with vertical align set in style tag should receive that style', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<style>span {vertical-align: sub;}</style> | ||
<span>Text</span> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.sub)); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'Tag with no vertical align set should have default', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<span>Text</span> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.baseline)); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'Tag with vertical align bottom set should have that value', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<div style="vertical-align: bottom;">Text</div> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.bottom)); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'Tag with vertical align middle set should have that value', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<div style="vertical-align: middle;">Text</div> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.middle)); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'Tag with vertical align top set should have that value', | ||
(tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """ | ||
<div style="vertical-align: top;">Text</div> | ||
""", | ||
), | ||
), | ||
); | ||
expect(find.text("Text", findRichText: true), findsOneWidget); | ||
expect( | ||
findCssBox(find.text("Text", findRichText: true))! | ||
.style | ||
.verticalAlign, | ||
equals(VerticalAlign.top)); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters