-
-
Notifications
You must be signed in to change notification settings - Fork 646
Expand file tree
/
Copy pathimage_test.dart
More file actions
142 lines (117 loc) · 3.79 KB
/
image_test.dart
File metadata and controls
142 lines (117 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/getwidget.dart';
void main() {
final childWidget = Container(
width: 100,
height: 100,
);
const color = Colors.teal;
const padding = EdgeInsets.all(5);
const margin = EdgeInsets.all(5);
const boxFit = BoxFit.cover;
const bgImage = NetworkImage(
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
);
testWidgets('GF Image can be created.', (tester) async {
final GFImageOverlay image = GFImageOverlay(
image: bgImage,
color: color,
padding: padding,
boxFit: boxFit,
margin: margin,
child: childWidget);
final TestApp app = TestApp(image);
await tester.pumpWidget(Container(child: childWidget));
expect(find.byWidget(childWidget), findsOneWidget);
expect(app.image.image, bgImage);
expect(app.image.color, color);
expect(app.image.padding, padding);
expect(app.image.boxFit, boxFit);
expect(app.image.margin, margin);
expect(app.image.child, childWidget);
});
testWidgets('GF Image with border & border radius.', (tester) async {
final borderRadius = BorderRadius.circular(10);
final border = Border.all(color: Colors.red);
final GFImageOverlay image = GFImageOverlay(
image: bgImage,
color: color,
border: border,
borderRadius: borderRadius,
padding: padding,
margin: margin,
);
final TestApp app = TestApp(image);
await tester.pumpWidget(Container(child: childWidget));
expect(find.byWidget(childWidget), findsOneWidget);
expect(app.image.image, bgImage);
expect(app.image.color, color);
expect(app.image.border, border);
expect(app.image.borderRadius, borderRadius);
expect(app.image.padding, padding);
expect(app.image.margin, margin);
});
testWidgets('GF Image with child icon.', (tester) async {
const content = Icon(Icons.car_rental);
const GFImageOverlay image = GFImageOverlay(
image: bgImage,
color: color,
child: content,
);
const TestApp app = TestApp(image);
await tester.pumpWidget(Container(child: childWidget));
expect(find.byWidget(childWidget), findsOneWidget);
expect(app.image.image, bgImage);
expect(app.image.color, color);
expect(app.image.child, content);
});
testWidgets('GF Image with circular shape', (tester) async {
const shape = BoxShape.circle;
const GFImageOverlay image = GFImageOverlay(
image: bgImage,
shape: shape,
);
const TestApp app = TestApp(image);
expect(app.image.image, bgImage);
expect(app.image.shape, shape);
});
testWidgets('GF Image with image overlay', (tester) async {
const colorFilter = ColorFilter.mode(Colors.black26, BlendMode.colorBurn);
const GFImageOverlay image = GFImageOverlay(
image: bgImage,
colorFilter: colorFilter,
);
const TestApp app = TestApp(image);
expect(app.image.image, bgImage);
expect(app.image.colorFilter, colorFilter);
});
testWidgets('GF Image with alignment of child widget', (tester) async {
const alignment = Alignment.bottomCenter;
const GFImageOverlay image = GFImageOverlay(
image: bgImage,
alignment: alignment,
);
const TestApp app = TestApp(image);
expect(app.image.image, bgImage);
expect(app.image.alignment, alignment);
});
}
class TestApp extends StatefulWidget {
const TestApp(this.image);
final GFImageOverlay image;
@override
_TestAppState createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: Column(
children: [
widget.image,
],
),
),
);
}