Skip to content

Commit 585f860

Browse files
authored
Merge pull request #63 from deepikahr/rating_testing
bottomsheet testing completed
2 parents f7e6026 + 4e7d3ba commit 585f860

File tree

11 files changed

+2960
-451
lines changed

11 files changed

+2960
-451
lines changed

example/lib/main_temp.dart

Lines changed: 2296 additions & 0 deletions
Large diffs are not rendered by default.

lib/components/bottom_sheet/gf_bottom_sheet.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class GFBottomSheet extends StatefulWidget {
1818
this.enableExpandableContent = false,
1919
}) : assert(elevation >= 0.0),
2020
assert(minContentHeight >= 0.0),
21+
assert(contentBody != null),
2122
super(key: key) {
2223
controller.height = minContentHeight;
2324
controller.animationDuration = animationDuration;

lib/components/rating/gf_rating.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ typedef RatingChangeCallback = void Function(double rating);
66
class GFRating extends StatefulWidget {
77
/// [GFRating] to show ratings with many custimazation options.
88
const GFRating({
9+
Key key,
10+
this.onChanged,
911
this.itemCount = 5,
1012
this.spacing = 0.0,
1113
this.value = 0.0,
1214
this.defaultIcon,
13-
this.onChanged,
1415
this.color,
1516
this.borderColor,
1617
this.size = GFSize.MEDIUM,
@@ -23,7 +24,8 @@ class GFRating extends StatefulWidget {
2324
this.inputDecorations,
2425
this.margin = const EdgeInsets.symmetric(vertical: 16),
2526
this.padding = const EdgeInsets.symmetric(horizontal: 16),
26-
}) : assert(value != null);
27+
}) : assert(value != null),
28+
super(key: key);
2729

2830
/// defines total number of rating items
2931
final int itemCount;
@@ -37,7 +39,7 @@ class GFRating extends StatefulWidget {
3739
/// defines the size of items. GFSize can be used for size variations like small. medium. large
3840
final double size;
3941

40-
/// if true, allow half rating of items. Default it will be in true state
42+
/// if true, allow half rating of items on dragging. Default it will be in true state
4143
final bool allowHalfRating;
4244

4345
/// defines the items when filled

test/alert_test.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,66 @@ void main() {
88
width: 100,
99
height: 100,
1010
);
11-
final bgcolor = Colors.teal;
12-
const contentchild = Icon(Icons.umbrella);
11+
final bgColor = Colors.teal;
12+
const contentChild = Icon(Icons.umbrella);
1313
const child = Text('Get Widget');
1414

15-
testWidgets('GF Alert can be created.', (tester) async {
15+
testWidgets('GFAlert can be created.', (tester) async {
1616
final GFAlert alert = GFAlert(
17-
backgroundColor: bgcolor,
18-
contentChild: contentchild,
17+
backgroundColor: bgColor,
18+
contentChild: contentChild,
1919
child: childWidget);
2020

2121
final TestApp app = TestApp(alert);
2222

2323
await tester.pumpWidget(Container(child: childWidget));
2424
expect(find.byWidget(childWidget), findsOneWidget);
25-
expect(app.alert.backgroundColor, bgcolor);
26-
expect(app.alert.contentChild, contentchild);
25+
expect(app.alert.backgroundColor, bgColor);
26+
expect(app.alert.contentChild, contentChild);
2727
expect(app.alert.child, childWidget);
2828
});
2929

30-
testWidgets('Basic GF Alert.', (tester) async {
30+
testWidgets('Basic GFAlert.', (tester) async {
3131
const basicType = GFAlertType.basic;
3232

3333
final GFAlert alert = GFAlert(
34-
backgroundColor: bgcolor,
35-
contentChild: contentchild,
34+
backgroundColor: bgColor,
35+
contentChild: contentChild,
3636
type: basicType,
3737
child: child);
3838

3939
final TestApp app = TestApp(alert);
4040

4141
await tester.pumpWidget(Container(child: childWidget));
4242
expect(find.byWidget(childWidget), findsOneWidget);
43-
expect(app.alert.backgroundColor, bgcolor);
44-
expect(app.alert.contentChild, contentchild);
43+
expect(app.alert.backgroundColor, bgColor);
44+
expect(app.alert.contentChild, contentChild);
4545
expect(app.alert.type, basicType);
4646
expect(app.alert.child, child);
4747
});
4848

49-
testWidgets('Rounded GF Alert.', (tester) async {
49+
testWidgets('Rounded GFAlert.', (tester) async {
5050
const roundedType = GFAlertType.rounded;
5151

5252
const GFAlert alert =
53-
GFAlert(contentChild: contentchild, type: roundedType, child: child);
53+
GFAlert(contentChild: contentChild, type: roundedType, child: child);
5454

5555
const TestApp app = TestApp(alert);
5656

5757
await tester.pumpWidget(Container(child: childWidget));
5858
expect(find.byWidget(childWidget), findsOneWidget);
59-
expect(app.alert.contentChild, contentchild);
59+
expect(app.alert.contentChild, contentChild);
6060
expect(app.alert.type, roundedType);
6161
expect(app.alert.child, child);
6262
});
6363

64-
testWidgets('Fullwidth GF Alert.', (tester) async {
64+
testWidgets('FullWidth GFAlert.', (tester) async {
6565
const basicType = GFAlertType.basic;
6666
const fullWidth = 400.0;
6767

6868
const GFAlert alert = GFAlert(
6969
width: fullWidth,
70-
contentChild: contentchild,
70+
contentChild: contentChild,
7171
type: basicType,
7272
child: child);
7373

@@ -76,12 +76,12 @@ void main() {
7676
await tester.pumpWidget(Container(child: childWidget));
7777
expect(find.byWidget(childWidget), findsOneWidget);
7878
expect(app.alert.width, fullWidth);
79-
expect(app.alert.contentChild, contentchild);
79+
expect(app.alert.contentChild, contentChild);
8080
expect(app.alert.type, basicType);
8181
expect(app.alert.child, child);
8282
});
8383

84-
testWidgets('Customized GF Alert.', (tester) async {
84+
testWidgets('Customized GFAlert.', (tester) async {
8585
const basicType = GFAlertType.basic;
8686
final customBottombar = Row(
8787
mainAxisAlignment: MainAxisAlignment.end,
@@ -112,7 +112,7 @@ void main() {
112112
],
113113
);
114114
final GFAlert alert = GFAlert(
115-
contentChild: contentchild,
115+
contentChild: contentChild,
116116
type: basicType,
117117
bottombar: customBottombar,
118118
child: child);
@@ -121,22 +121,22 @@ void main() {
121121

122122
await tester.pumpWidget(Container(child: childWidget));
123123
expect(find.byWidget(childWidget), findsOneWidget);
124-
expect(app.alert.contentChild, contentchild);
124+
expect(app.alert.contentChild, contentChild);
125125
expect(app.alert.type, basicType);
126126
expect(app.alert.child, child);
127127
});
128128

129-
testWidgets('GF Alert with alignment.', (tester) async {
129+
testWidgets('GFAlert with alignment.', (tester) async {
130130
const alignment = Alignment.bottomRight;
131131

132132
const GFAlert alert =
133-
GFAlert(contentChild: contentchild, alignment: alignment, child: child);
133+
GFAlert(contentChild: contentChild, alignment: alignment, child: child);
134134

135135
const TestApp app = TestApp(alert);
136136

137137
await tester.pumpWidget(Container(child: childWidget));
138138
expect(find.byWidget(childWidget), findsOneWidget);
139-
expect(app.alert.contentChild, contentchild);
139+
expect(app.alert.contentChild, contentChild);
140140
expect(app.alert.alignment, alignment);
141141
expect(app.alert.child, child);
142142
});

test/avatar_test.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,48 @@ void main() {
88
width: 60,
99
height: 60,
1010
);
11-
final bgcolor = Colors.teal;
12-
final fgcolor = Colors.transparent;
11+
const bgColor = Colors.teal;
12+
const fgColor = Colors.transparent;
1313

14-
testWidgets('GF Avatar can be created', (tester) async {
14+
testWidgets('GFAvatar can be created', (tester) async {
1515
final GFAvatar avatar = GFAvatar(
16-
backgroundColor: bgcolor,
17-
foregroundColor: fgcolor,
16+
backgroundColor: bgColor,
17+
foregroundColor: fgColor,
1818
size: GFSize.MEDIUM,
1919
child: childWidget);
2020
final TestApp app = TestApp(avatar);
2121
await tester.pumpWidget(app);
2222
await tester.pumpWidget(Container(child: childWidget));
2323
expect(find.byWidget(childWidget), findsOneWidget);
24-
expect(app.avatar.backgroundColor, bgcolor);
25-
expect(app.avatar.foregroundColor, fgcolor);
24+
expect(app.avatar.backgroundColor, bgColor);
25+
expect(app.avatar.foregroundColor, fgColor);
2626
expect(app.avatar.size, GFSize.MEDIUM);
2727
expect(app.avatar.child, childWidget);
2828
});
2929

30-
testWidgets('GF Avatar with minradius & maxradius', (tester) async {
31-
const minradius = 10.0;
32-
const maxradius = 20.0;
30+
testWidgets('GFAvatar with minRadius & maxRadius', (tester) async {
31+
const minRadius = 10.0;
32+
const maxRadius = 20.0;
3333
final GFAvatar avatar = GFAvatar(
34-
backgroundColor: bgcolor,
35-
foregroundColor: fgcolor,
36-
minRadius: minradius,
37-
maxRadius: maxradius,
34+
backgroundColor: bgColor,
35+
foregroundColor: fgColor,
36+
minRadius: minRadius,
37+
maxRadius: maxRadius,
3838
size: GFSize.MEDIUM,
3939
child: childWidget);
4040
final TestApp app = TestApp(avatar);
4141
await tester.pumpWidget(app);
4242
await tester.pumpWidget(Container(child: childWidget));
4343
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);
44+
expect(app.avatar.backgroundColor, bgColor);
45+
expect(app.avatar.foregroundColor, fgColor);
46+
expect(app.avatar.minRadius, minRadius);
47+
expect(app.avatar.maxRadius, maxRadius);
4848
expect(app.avatar.size, GFSize.MEDIUM);
4949
expect(app.avatar.child, childWidget);
5050
});
5151

52-
testWidgets('Circular GF Avatar with bgImage', (tester) async {
52+
testWidgets('Circular GFAvatar with bgImage', (tester) async {
5353
const bgImage = NetworkImage(
5454
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
5555
);
@@ -65,7 +65,7 @@ void main() {
6565
expect(app.avatar.shape, GFAvatarShape.circle);
6666
});
6767

68-
testWidgets('Square GF Avatar with bgImage', (tester) async {
68+
testWidgets('Square GFAvatar with bgImage', (tester) async {
6969
const bgImage = NetworkImage(
7070
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
7171
);
@@ -81,7 +81,7 @@ void main() {
8181
expect(app.avatar.shape, GFAvatarShape.square);
8282
});
8383

84-
testWidgets('Standard shape GF Avatar with bgImage', (tester) async {
84+
testWidgets('Standard shape GFAvatar with bgImage', (tester) async {
8585
const bgImage = NetworkImage(
8686
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
8787
);

0 commit comments

Comments
 (0)