@@ -9,20 +9,17 @@ import 'package:flutter_test/flutter_test.dart';
9
9
import '../rendering/mock_canvas.dart' ;
10
10
11
11
void main () {
12
- testWidgets ('The Ink widget renders a SizedBox by default ' , (WidgetTester tester) async {
12
+ testWidgets ('The Ink widget expands when no dimensions are set ' , (WidgetTester tester) async {
13
13
await tester.pumpWidget (
14
14
Material (
15
15
child: Ink (),
16
16
),
17
17
);
18
- Finder sizedBox = find.descendant (
19
- of: find.byType (Ink ),
20
- matching: find.byType (SizedBox ),
21
- );
22
- expect (sizedBox, findsOneWidget);
23
- expect (tester.getSize (sizedBox).height, 600.0 );
24
- expect (tester.getSize (sizedBox).width, 800.0 );
18
+ expect (find.byType (Ink ), findsOneWidget);
19
+ expect (tester.getSize (find.byType (Ink )), const Size (800.0 , 600.0 ));
20
+ });
25
21
22
+ testWidgets ('The Ink widget fits the specified size' , (WidgetTester tester) async {
26
23
const double height = 150.0 ;
27
24
const double width = 200.0 ;
28
25
await tester.pumpWidget (
@@ -36,13 +33,24 @@ void main() {
36
33
),
37
34
);
38
35
await tester.pumpAndSettle ();
39
- sizedBox = find.descendant (
40
- of: find.byType (Ink ),
41
- matching: find.byType (SizedBox ),
36
+ expect (find.byType (Ink ), findsOneWidget);
37
+ expect (tester.getSize (find.byType (Ink )), const Size (width, height));
38
+ });
39
+
40
+ testWidgets ('The Ink widget expands on a unspecified dimension' , (WidgetTester tester) async {
41
+ const double height = 150.0 ;
42
+ await tester.pumpWidget (
43
+ Material (
44
+ child: Center ( // used to constrain to child's size
45
+ child: Ink (
46
+ height: height,
47
+ ),
48
+ ),
49
+ ),
42
50
);
43
- expect (sizedBox, findsNWidgets ( 2 ) );
44
- expect (tester. getSize (sizedBox. at ( 0 )).height, height );
45
- expect (tester.getSize (sizedBox. at ( 0 )).width, width );
51
+ await tester. pumpAndSettle ( );
52
+ expect (find. byType ( Ink ), findsOneWidget );
53
+ expect (tester.getSize (find. byType ( Ink )), const Size ( 800 , height) );
46
54
});
47
55
48
56
testWidgets ('The InkWell widget renders an ink splash' , (WidgetTester tester) async {
0 commit comments