Skip to content

Commit f7e6026

Browse files
authored
Merge pull request #62 from sipra-acharya/master
sipra's testing pull
2 parents e07916c + f13de53 commit f7e6026

File tree

7 files changed

+1400
-0
lines changed

7 files changed

+1400
-0
lines changed

test/alert_test.dart

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:getwidget/getwidget.dart';
4+
import 'package:flutter/cupertino.dart';
5+
6+
void main() {
7+
final childWidget = Container(
8+
width: 100,
9+
height: 100,
10+
);
11+
final bgcolor = Colors.teal;
12+
const contentchild = Icon(Icons.umbrella);
13+
const child = Text('Get Widget');
14+
15+
testWidgets('GF Alert can be created.', (tester) async {
16+
final GFAlert alert = GFAlert(
17+
backgroundColor: bgcolor,
18+
contentChild: contentchild,
19+
child: childWidget);
20+
21+
final TestApp app = TestApp(alert);
22+
23+
await tester.pumpWidget(Container(child: childWidget));
24+
expect(find.byWidget(childWidget), findsOneWidget);
25+
expect(app.alert.backgroundColor, bgcolor);
26+
expect(app.alert.contentChild, contentchild);
27+
expect(app.alert.child, childWidget);
28+
});
29+
30+
testWidgets('Basic GF Alert.', (tester) async {
31+
const basicType = GFAlertType.basic;
32+
33+
final GFAlert alert = GFAlert(
34+
backgroundColor: bgcolor,
35+
contentChild: contentchild,
36+
type: basicType,
37+
child: child);
38+
39+
final TestApp app = TestApp(alert);
40+
41+
await tester.pumpWidget(Container(child: childWidget));
42+
expect(find.byWidget(childWidget), findsOneWidget);
43+
expect(app.alert.backgroundColor, bgcolor);
44+
expect(app.alert.contentChild, contentchild);
45+
expect(app.alert.type, basicType);
46+
expect(app.alert.child, child);
47+
});
48+
49+
testWidgets('Rounded GF Alert.', (tester) async {
50+
const roundedType = GFAlertType.rounded;
51+
52+
const GFAlert alert =
53+
GFAlert(contentChild: contentchild, type: roundedType, child: child);
54+
55+
const TestApp app = TestApp(alert);
56+
57+
await tester.pumpWidget(Container(child: childWidget));
58+
expect(find.byWidget(childWidget), findsOneWidget);
59+
expect(app.alert.contentChild, contentchild);
60+
expect(app.alert.type, roundedType);
61+
expect(app.alert.child, child);
62+
});
63+
64+
testWidgets('Fullwidth GF Alert.', (tester) async {
65+
const basicType = GFAlertType.basic;
66+
const fullWidth = 400.0;
67+
68+
const GFAlert alert = GFAlert(
69+
width: fullWidth,
70+
contentChild: contentchild,
71+
type: basicType,
72+
child: child);
73+
74+
const TestApp app = TestApp(alert);
75+
76+
await tester.pumpWidget(Container(child: childWidget));
77+
expect(find.byWidget(childWidget), findsOneWidget);
78+
expect(app.alert.width, fullWidth);
79+
expect(app.alert.contentChild, contentchild);
80+
expect(app.alert.type, basicType);
81+
expect(app.alert.child, child);
82+
});
83+
84+
testWidgets('Customized GF Alert.', (tester) async {
85+
const basicType = GFAlertType.basic;
86+
final customBottombar = Row(
87+
mainAxisAlignment: MainAxisAlignment.end,
88+
children: <Widget>[
89+
GFButton(
90+
shape: GFButtonShape.square,
91+
color: GFColors.LIGHT,
92+
onPressed: () {},
93+
child: const Text(
94+
'Skip',
95+
style: TextStyle(color: Colors.black),
96+
),
97+
),
98+
const SizedBox(
99+
width: 5,
100+
),
101+
GFButton(
102+
shape: GFButtonShape.square,
103+
type: GFButtonType.outline2x,
104+
icon: const Icon(
105+
Icons.keyboard_arrow_right,
106+
color: GFColors.PRIMARY,
107+
),
108+
position: GFPosition.end,
109+
text: 'Learn More',
110+
onPressed: () {},
111+
)
112+
],
113+
);
114+
final GFAlert alert = GFAlert(
115+
contentChild: contentchild,
116+
type: basicType,
117+
bottombar: customBottombar,
118+
child: child);
119+
120+
final TestApp app = TestApp(alert);
121+
122+
await tester.pumpWidget(Container(child: childWidget));
123+
expect(find.byWidget(childWidget), findsOneWidget);
124+
expect(app.alert.contentChild, contentchild);
125+
expect(app.alert.type, basicType);
126+
expect(app.alert.child, child);
127+
});
128+
129+
testWidgets('GF Alert with alignment.', (tester) async {
130+
const alignment = Alignment.bottomRight;
131+
132+
const GFAlert alert =
133+
GFAlert(contentChild: contentchild, alignment: alignment, child: child);
134+
135+
const TestApp app = TestApp(alert);
136+
137+
await tester.pumpWidget(Container(child: childWidget));
138+
expect(find.byWidget(childWidget), findsOneWidget);
139+
expect(app.alert.contentChild, contentchild);
140+
expect(app.alert.alignment, alignment);
141+
expect(app.alert.child, child);
142+
});
143+
}
144+
145+
class TestApp extends StatefulWidget {
146+
const TestApp(this.alert);
147+
final GFAlert alert;
148+
@override
149+
_TestAppState createState() => _TestAppState();
150+
}
151+
152+
class _TestAppState extends State<TestApp> {
153+
@override
154+
Widget build(BuildContext context) => MaterialApp(
155+
home: Scaffold(
156+
body: Column(
157+
children: [
158+
widget.alert,
159+
],
160+
),
161+
),
162+
);
163+
}

test/avatar_test.dart

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:getwidget/getwidget.dart';
4+
import 'package:flutter/cupertino.dart';
5+
6+
void main() {
7+
final childWidget = Container(
8+
width: 60,
9+
height: 60,
10+
);
11+
final bgcolor = Colors.teal;
12+
final fgcolor = Colors.transparent;
13+
14+
testWidgets('GF Avatar can be created', (tester) async {
15+
final GFAvatar avatar = GFAvatar(
16+
backgroundColor: bgcolor,
17+
foregroundColor: fgcolor,
18+
size: GFSize.MEDIUM,
19+
child: childWidget);
20+
final TestApp app = TestApp(avatar);
21+
await tester.pumpWidget(app);
22+
await tester.pumpWidget(Container(child: childWidget));
23+
expect(find.byWidget(childWidget), findsOneWidget);
24+
expect(app.avatar.backgroundColor, bgcolor);
25+
expect(app.avatar.foregroundColor, fgcolor);
26+
expect(app.avatar.size, GFSize.MEDIUM);
27+
expect(app.avatar.child, childWidget);
28+
});
29+
30+
testWidgets('GF Avatar with minradius & maxradius', (tester) async {
31+
const minradius = 10.0;
32+
const maxradius = 20.0;
33+
final GFAvatar avatar = GFAvatar(
34+
backgroundColor: bgcolor,
35+
foregroundColor: fgcolor,
36+
minRadius: minradius,
37+
maxRadius: maxradius,
38+
size: GFSize.MEDIUM,
39+
child: childWidget);
40+
final TestApp app = TestApp(avatar);
41+
await tester.pumpWidget(app);
42+
await tester.pumpWidget(Container(child: childWidget));
43+
expect(find.byWidget(childWidget), findsOneWidget);
44+
expect(app.avatar.backgroundColor, bgcolor);
45+
expect(app.avatar.foregroundColor, fgcolor);
46+
expect(app.avatar.minRadius, minradius);
47+
expect(app.avatar.maxRadius, maxradius);
48+
expect(app.avatar.size, GFSize.MEDIUM);
49+
expect(app.avatar.child, childWidget);
50+
});
51+
52+
testWidgets('Circular GF Avatar with bgImage', (tester) async {
53+
const bgImage = NetworkImage(
54+
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
55+
);
56+
57+
const GFAvatar avatar = GFAvatar(
58+
backgroundImage: bgImage,
59+
shape: GFAvatarShape.circle,
60+
);
61+
62+
const TestApp app = TestApp(avatar);
63+
64+
expect(app.avatar.backgroundImage, bgImage);
65+
expect(app.avatar.shape, GFAvatarShape.circle);
66+
});
67+
68+
testWidgets('Square GF Avatar with bgImage', (tester) async {
69+
const bgImage = NetworkImage(
70+
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
71+
);
72+
73+
const GFAvatar avatar = GFAvatar(
74+
backgroundImage: bgImage,
75+
shape: GFAvatarShape.square,
76+
);
77+
78+
const TestApp app = TestApp(avatar);
79+
80+
expect(app.avatar.backgroundImage, bgImage);
81+
expect(app.avatar.shape, GFAvatarShape.square);
82+
});
83+
84+
testWidgets('Standard shape GF Avatar with bgImage', (tester) async {
85+
const bgImage = NetworkImage(
86+
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
87+
);
88+
89+
const GFAvatar avatar = GFAvatar(
90+
backgroundImage: bgImage,
91+
shape: GFAvatarShape.standard,
92+
);
93+
94+
const TestApp app = TestApp(avatar);
95+
96+
expect(app.avatar.backgroundImage, bgImage);
97+
expect(app.avatar.shape, GFAvatarShape.standard);
98+
});
99+
}
100+
101+
class TestApp extends StatefulWidget {
102+
const TestApp(this.avatar);
103+
final GFAvatar avatar;
104+
@override
105+
_TestAppState createState() => _TestAppState();
106+
}
107+
108+
class _TestAppState extends State<TestApp> {
109+
@override
110+
Widget build(BuildContext context) => MaterialApp(
111+
home: Scaffold(
112+
body: Column(
113+
children: [
114+
widget.avatar,
115+
],
116+
),
117+
),
118+
);
119+
}

0 commit comments

Comments
 (0)