Skip to content

Commit 0a9e55f

Browse files
authored
Merge pull request #205 from deepikahr/master
loader testing added
2 parents b1e2f59 + fe937bc commit 0a9e55f

File tree

2 files changed

+56
-81
lines changed

2 files changed

+56
-81
lines changed

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ packages:
7373
name: meta
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "1.3.0-nullsafety.3"
76+
version: "1.3.0-nullsafety.4"
7777
path:
7878
dependency: transitive
7979
description:
@@ -99,7 +99,7 @@ packages:
9999
name: stack_trace
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "1.10.0-nullsafety.1"
102+
version: "1.10.0-nullsafety.2"
103103
stream_channel:
104104
dependency: transitive
105105
description:
@@ -143,4 +143,4 @@ packages:
143143
source: hosted
144144
version: "2.1.0-nullsafety.3"
145145
sdks:
146-
dart: ">=2.10.0-110 <2.11.0"
146+
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"

test/loader_test.dart

Lines changed: 53 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ import 'package:flutter_test/flutter_test.dart';
44
import 'package:getwidget/getwidget.dart';
55

66
void main() {
7-
8-
final childWidget = Container(
7+
final Widget childWidget = Container(
98
width: 111,
109
height: 222,
1110
);
1211

13-
final iconOne = Icon(Icons.directions_bike_sharp);
14-
final iconTwo = Icon(Icons.directions_car);
15-
final iconThree = Icon(Icons.directions_bus);
12+
const iconOne = Icon(Icons.directions_bike_sharp);
13+
const iconTwo = Icon(Icons.directions_car);
14+
const iconThree = Icon(Icons.directions_bus);
1615

17-
final duration = Duration(milliseconds: 1000);
16+
const duration = Duration(milliseconds: 1000);
1817

19-
final firstColor = Colors.teal;
20-
final secondColor = Colors.tealAccent;
21-
final thirdColor = Colors.tealAccent.shade400;
18+
const firstColor = Colors.teal;
19+
const secondColor = Colors.tealAccent;
20+
const thirdColor = Colors.tealAccent;
2221

23-
final stroke = 4.0;
22+
const stroke = 4.0;
2423

2524
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
2625

@@ -41,17 +40,16 @@ void main() {
4140
// });
4241

4342
testWidgets('GF Loader can be constructed', (tester) async {
44-
4543
final GFLoader loader = GFLoader(
46-
loaderColorOne: firstColor,
47-
loaderColorTwo: secondColor,
48-
duration: duration,
49-
type: GFLoaderType.ios,
50-
loaderIconOne : iconOne,
51-
// androidLoaderColor : Colors.amber,
52-
loaderstrokeWidth: stroke,
53-
size: GFSize.MEDIUM,
54-
child : childWidget
44+
loaderColorOne: firstColor,
45+
loaderColorTwo: secondColor,
46+
duration: duration,
47+
type: GFLoaderType.ios,
48+
loaderIconOne: iconOne,
49+
// androidLoaderColor : Colors.amber,
50+
loaderstrokeWidth: stroke,
51+
size: GFSize.MEDIUM,
52+
child: childWidget,
5553
);
5654

5755
final TestApp app = TestApp(loader);
@@ -69,35 +67,29 @@ void main() {
6967
expect(app.loader.size, GFSize.MEDIUM);
7068

7169
debugDefaultTargetPlatformOverride = null;
72-
7370
});
7471

7572
testWidgets('Basic GF Loader can be constructed', (tester) async {
73+
const GFLoader loader = GFLoader();
7674

77-
final GFLoader loader = GFLoader(
78-
79-
);
80-
81-
final TestApp app = TestApp(loader);
75+
const TestApp app = TestApp(loader);
8276

8377
await tester.pumpWidget(app);
84-
8578
});
8679

8780
testWidgets('GF Loader with icons can be constructed', (tester) async {
81+
const customType = GFLoaderType.custom;
8882

89-
final customType = GFLoaderType.custom;
90-
91-
final GFLoader loader = GFLoader(
83+
const GFLoader loader = GFLoader(
9284
type: customType,
9385
duration: duration,
94-
loaderIconOne : iconOne,
86+
loaderIconOne: iconOne,
9587
loaderIconTwo: iconTwo,
9688
loaderIconThree: iconThree,
9789
loaderstrokeWidth: stroke,
9890
);
9991

100-
final TestApp app = TestApp(loader);
92+
const TestApp app = TestApp(loader);
10193

10294
await tester.pumpWidget(app);
10395

@@ -108,10 +100,8 @@ void main() {
108100
expect(app.loader.loaderIconTwo, iconTwo);
109101
expect(app.loader.loaderIconThree, iconThree);
110102
expect(app.loader.loaderstrokeWidth, stroke);
111-
112103
});
113104

114-
115105
// testWidgets('Asserts.', (tester) async {
116106
// // when type is null
117107
//
@@ -126,10 +116,9 @@ void main() {
126116
// });
127117

128118
testWidgets('GF Loader with square type can be constructed', (tester) async {
119+
const customType = GFLoaderType.square;
129120

130-
final customType = GFLoaderType.square;
131-
132-
final GFLoader loader = GFLoader(
121+
const GFLoader loader = GFLoader(
133122
type: customType,
134123
duration: duration,
135124
loaderColorOne: firstColor,
@@ -138,7 +127,7 @@ void main() {
138127
loaderstrokeWidth: stroke,
139128
);
140129

141-
final TestApp app = TestApp(loader);
130+
const TestApp app = TestApp(loader);
142131

143132
await tester.pumpWidget(app);
144133

@@ -149,14 +138,12 @@ void main() {
149138
expect(app.loader.loaderColorTwo, secondColor);
150139
expect(app.loader.loaderColorThree, thirdColor);
151140
expect(app.loader.loaderstrokeWidth, stroke);
152-
153141
});
154142

155143
testWidgets('GF Loader with round type can be constructed', (tester) async {
144+
const customType = GFLoaderType.circle;
156145

157-
final customType = GFLoaderType.circle;
158-
159-
final GFLoader loader = GFLoader(
146+
const GFLoader loader = GFLoader(
160147
type: customType,
161148
duration: duration,
162149
loaderColorOne: firstColor,
@@ -165,7 +152,7 @@ void main() {
165152
loaderstrokeWidth: stroke,
166153
);
167154

168-
final TestApp app = TestApp(loader);
155+
const TestApp app = TestApp(loader);
169156

170157
await tester.pumpWidget(app);
171158

@@ -176,29 +163,24 @@ void main() {
176163
expect(app.loader.loaderColorTwo, secondColor);
177164
expect(app.loader.loaderColorThree, thirdColor);
178165
expect(app.loader.loaderstrokeWidth, stroke);
179-
180166
});
181167

182-
testWidgets('GF Loader with android type loader can be constructed', (tester) async {
168+
testWidgets('GF Loader with android type loader can be constructed',
169+
(tester) async {
170+
const customType = GFLoaderType.android;
171+
const color = AlwaysStoppedAnimation<Color>(Colors.green);
183172

184-
final customType = GFLoaderType.android;
185-
final color = AlwaysStoppedAnimation<Color>(Colors.green);
173+
const GFLoader loader =
174+
GFLoader(type: customType, androidLoaderColor: color);
186175

187-
final GFLoader loader = GFLoader(
188-
type: customType,
189-
androidLoaderColor : color
190-
);
191-
192-
final TestApp app = TestApp(loader);
176+
const TestApp app = TestApp(loader);
193177

194178
await tester.pumpWidget(app);
195179

196180
expect(app.loader.type, customType);
197181
expect(app.loader.androidLoaderColor, color);
198-
199182
});
200183

201-
202184
// testWidgets('Asserts.', (tester) async {
203185
// // when type is null
204186
//
@@ -212,14 +194,14 @@ void main() {
212194
// //
213195
// // );
214196
//
215-
// final GFLoader loader = GFLoader(
197+
// const GFLoader loader = GFLoader(
216198
// type: null,
217199
// loaderIconOne : iconOne,
218200
// loaderIconTwo: iconTwo,
219201
// loaderIconThree: iconThree,
220202
// );
221203
//
222-
// final TestApp app = TestApp(loader);
204+
// const TestApp app = TestApp(loader);
223205
//
224206
// await tester.pumpWidget(app);
225207
//
@@ -233,14 +215,11 @@ void main() {
233215
// );
234216
// });
235217

236-
testWidgets('GF Loader with custom loader can be constructed using child', (tester) async {
237-
238-
final customType = GFLoaderType.custom;
218+
testWidgets('GF Loader with custom loader can be constructed using child',
219+
(tester) async {
220+
const customType = GFLoaderType.custom;
239221

240-
final GFLoader loader = GFLoader(
241-
type: customType,
242-
child : childWidget
243-
);
222+
final GFLoader loader = GFLoader(type: customType, child: childWidget);
244223

245224
final TestApp app = TestApp(loader);
246225

@@ -252,31 +231,27 @@ void main() {
252231

253232
expect(app.loader.child, childWidget);
254233
expect(app.loader.type, customType);
255-
256234
});
257-
258235
}
259236

260237
class TestApp extends StatefulWidget {
261-
final GFLoader loader;
238+
const TestApp(this.loader);
262239

263-
TestApp(this.loader);
240+
final GFLoader loader;
264241

265242
@override
266243
_TestAppState createState() => _TestAppState();
267244
}
268245

269246
class _TestAppState extends State<TestApp> {
270247
@override
271-
Widget build(BuildContext context) {
272-
return MaterialApp(
273-
home: Scaffold(
274-
body: Column(
275-
children: [
276-
widget.loader,
277-
],
248+
Widget build(BuildContext context) => MaterialApp(
249+
home: Scaffold(
250+
body: Column(
251+
children: [
252+
widget.loader,
253+
],
254+
),
278255
),
279-
),
280-
);
281-
}
256+
);
282257
}

0 commit comments

Comments
 (0)