Skip to content

Commit f13de53

Browse files
Merge pull request #6 from sipra-acharya/widget_testing
gfbottomsheet test cases
2 parents 5cd17c4 + 8917974 commit f13de53

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

test/bottomsheet_test.dart

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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 GFBottomSheetController _controller = GFBottomSheetController();
8+
const contentbody = Text('GetWidget');
9+
const header = Text('Header');
10+
const footer = Text('Footer');
11+
const minheight = 100.0;
12+
const maxheight = 400.0;
13+
const elevation = 0.0;
14+
const headerHeight = 50.0;
15+
const footerHeight = 50.0;
16+
const animationduration = 1300;
17+
const enableexpandablecontent = true;
18+
19+
testWidgets('GF Bottomsheet can be created.', (tester) async {
20+
final GFBottomSheet bottomsheet = GFBottomSheet(
21+
controller: _controller,
22+
contentBody: contentbody,
23+
stickyHeaderHeight: headerHeight,
24+
stickyHeader: header,
25+
minContentHeight: minheight,
26+
maxContentHeight: maxheight,
27+
);
28+
29+
final TestApp app = TestApp(bottomsheet);
30+
31+
await tester.pumpWidget(app);
32+
expect(app.bottomsheet.contentBody, contentbody);
33+
expect(app.bottomsheet.stickyHeaderHeight, headerHeight);
34+
expect(app.bottomsheet.stickyHeader, header);
35+
expect(app.bottomsheet.minContentHeight, minheight);
36+
expect(app.bottomsheet.maxContentHeight, maxheight);
37+
});
38+
39+
testWidgets('GF Bottomsheet with header & footer.', (tester) async {
40+
final GFBottomSheet bottomsheet = GFBottomSheet(
41+
controller: _controller,
42+
contentBody: contentbody,
43+
stickyHeaderHeight: headerHeight,
44+
stickyHeader: header,
45+
elevation: elevation,
46+
stickyFooterHeight: footerHeight,
47+
stickyFooter: footer,
48+
minContentHeight: minheight,
49+
maxContentHeight: maxheight,
50+
);
51+
52+
final TestApp app = TestApp(bottomsheet);
53+
54+
await tester.pumpWidget(app);
55+
expect(app.bottomsheet.contentBody, contentbody);
56+
expect(app.bottomsheet.stickyHeaderHeight, headerHeight);
57+
expect(app.bottomsheet.stickyHeader, header);
58+
expect(app.bottomsheet.elevation, elevation);
59+
expect(app.bottomsheet.stickyFooterHeight, footerHeight);
60+
expect(app.bottomsheet.stickyFooter, footer);
61+
expect(app.bottomsheet.minContentHeight, minheight);
62+
expect(app.bottomsheet.maxContentHeight, maxheight);
63+
});
64+
65+
testWidgets('GF Bottomsheet with expandable content property.',
66+
(tester) async {
67+
final GFBottomSheet bottomsheet = GFBottomSheet(
68+
controller: _controller,
69+
contentBody: contentbody,
70+
stickyHeaderHeight: headerHeight,
71+
stickyHeader: header,
72+
elevation: elevation,
73+
minContentHeight: minheight,
74+
maxContentHeight: maxheight,
75+
enableExpandableContent: enableexpandablecontent,
76+
);
77+
78+
final TestApp app = TestApp(bottomsheet);
79+
80+
await tester.pumpWidget(app);
81+
expect(app.bottomsheet.contentBody, contentbody);
82+
expect(app.bottomsheet.stickyHeaderHeight, headerHeight);
83+
expect(app.bottomsheet.stickyHeader, header);
84+
expect(app.bottomsheet.elevation, elevation);
85+
expect(app.bottomsheet.minContentHeight, minheight);
86+
expect(app.bottomsheet.maxContentHeight, maxheight);
87+
expect(app.bottomsheet.enableExpandableContent, enableexpandablecontent);
88+
});
89+
90+
testWidgets('GF Bottomsheet with animation duration.', (tester) async {
91+
final GFBottomSheet bottomsheet = GFBottomSheet(
92+
controller: _controller,
93+
contentBody: contentbody,
94+
stickyHeaderHeight: headerHeight,
95+
stickyHeader: header,
96+
elevation: elevation,
97+
minContentHeight: minheight,
98+
maxContentHeight: maxheight,
99+
animationDuration: animationduration,
100+
);
101+
102+
final TestApp app = TestApp(bottomsheet);
103+
104+
await tester.pumpWidget(app);
105+
expect(app.bottomsheet.contentBody, contentbody);
106+
expect(app.bottomsheet.stickyHeaderHeight, headerHeight);
107+
expect(app.bottomsheet.stickyHeader, header);
108+
expect(app.bottomsheet.elevation, elevation);
109+
expect(app.bottomsheet.minContentHeight, minheight);
110+
expect(app.bottomsheet.maxContentHeight, maxheight);
111+
expect(app.bottomsheet.animationDuration, animationduration);
112+
});
113+
}
114+
115+
class TestApp extends StatefulWidget {
116+
const TestApp(this.bottomsheet);
117+
final GFBottomSheet bottomsheet;
118+
@override
119+
_TestAppState createState() => _TestAppState();
120+
}
121+
122+
class _TestAppState extends State<TestApp> {
123+
@override
124+
Widget build(BuildContext context) => MaterialApp(
125+
home: Scaffold(
126+
bottomSheet: widget.bottomsheet,
127+
),
128+
);
129+
}

0 commit comments

Comments
 (0)