-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add golden test to CircleCropAreaClipper (#140)
* add golden test to CircleCropAreaClipper * add test case to shouldReclip
- Loading branch information
1 parent
a18b1c2
commit e6fab4e
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+2.18 KB
test/widget/circle_crop_area_clipper.viewportSizex200.crop_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
import 'package:crop_your_image/src/widget/circle_crop_area_clipper.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
test('shouldReclip is always true', () { | ||
final oldClipper = CircleCropAreaClipper(Rect.fromLTWH(50, 50, 100, 100)); | ||
final clipper = CircleCropAreaClipper(Rect.fromLTWH(50, 50, 100, 100)); | ||
|
||
expect(clipper.shouldReclip(oldClipper), true); | ||
}); | ||
|
||
group('when viewport is 200 x 200', () { | ||
final viewportSize = 200.0; | ||
testWidgets( | ||
'CircleCropAreaClipper clips center with 100x100 size of circle shape' | ||
'if passing Rect.fromLTWH(50, 50, 100, 100)', | ||
(WidgetTester tester) async { | ||
Widget actual = Center( | ||
child: SizedBox( | ||
width: viewportSize, | ||
height: viewportSize, | ||
child: RepaintBoundary( | ||
child: ClipPath( | ||
clipper: CircleCropAreaClipper(Rect.fromLTWH(50, 50, 100, 100)), | ||
child: ColoredBox( | ||
color: Color(0xFF0000FF), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
await tester.pumpWidget(actual); | ||
await expectLater( | ||
find.byType(RepaintBoundary), | ||
matchesGoldenFile( | ||
'circle_crop_area_clipper.viewportSizex200.crop_center.png'), | ||
); | ||
}, | ||
); | ||
}); | ||
} |