forked from comigor/showcase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test component with a golden test
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MyComponent extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text('This is my text'), | ||
Text('This is another text'), | ||
RaisedButton( | ||
onPressed: () {}, | ||
child: Text('This should be a button'), | ||
color: Colors.amber, | ||
), | ||
Switch( | ||
onChanged: (_) {}, | ||
value: true, | ||
), | ||
Slider( | ||
value: 2.0, | ||
max: 7.0, | ||
onChanged: (_) {}, | ||
), | ||
], | ||
); | ||
} | ||
} |
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,18 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:showcase/components/my_component.dart'; | ||
import '../helpers/golden_boundary.dart'; | ||
|
||
void main() { | ||
testWidgets('MyComponent golden', (WidgetTester tester) async { | ||
await tester.pumpWidget(GoldenBoundary( | ||
child: MyComponent(), | ||
)); | ||
|
||
await expectLater( | ||
find.byType(Container).first, | ||
matchesGoldenFile('golden.png'), | ||
); | ||
}); | ||
} |
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,23 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class GoldenBoundary extends StatelessWidget { | ||
final Widget child; | ||
|
||
GoldenBoundary({@required this.child}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: RepaintBoundary( | ||
child: Container( | ||
padding: EdgeInsets.all(10.0), | ||
width: 640.0, | ||
height: 480.0, | ||
child: child, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |