|
| 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 | +} |
0 commit comments