-
-
Notifications
You must be signed in to change notification settings - Fork 646
Expand file tree
/
Copy pathtabbarview_test.dart
More file actions
101 lines (85 loc) · 2.59 KB
/
tabbarview_test.dart
File metadata and controls
101 lines (85 loc) · 2.59 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
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/getwidget.dart';
void main() {
final Key tabBarViewKey = UniqueKey();
final List<String> tabs = <String>[
'AAAAAA',
'BBBBBB',
'CCCCCC',
'DDDDDD',
'EEEEEE'
];
final List<Widget> tabList = [
Text(tabs[0]),
Text(tabs[1]),
Text(tabs[2]),
Text(tabs[3]),
Text(tabs[4])
];
testWidgets('GFTabBarView can be constructed', (tester) async {
final TabController tabController =
TabController(length: 3, initialIndex: 0, vsync: tester);
final GFTabBarView tabBarView =
GFTabBarView(controller: tabController, children: [
Container(
child: const Text('aaa'),
),
Container(
child: const Text('bbb'),
),
Container(
child: const Text('ccc'),
),
]);
final TestApp app = TestApp(tabBarView);
await tester.pumpWidget(app);
expect(find.text('aaa'), findsOneWidget);
expect(find.text('bbb'), findsNothing);
Offset point = tester.getCenter(find.text('aaa'));
await tester.dragFrom(point, const Offset(-600, 0));
await tester.pump();
expect(find.text('bbb'), findsOneWidget);
point = tester.getCenter(find.text('bbb'));
await tester.dragFrom(point, const Offset(-600, 0));
await tester.pump();
expect(find.text('ccc'), findsOneWidget);
point = tester.getCenter(find.text('ccc'));
await tester.dragFrom(point, const Offset(600, 0));
await tester.pump();
expect(find.text('bbb'), findsOneWidget);
});
testWidgets('GFTabBarView can be constructed with properties',
(tester) async {
final TabController tabController =
TabController(length: tabList.length, initialIndex: 0, vsync: tester);
final GFTabBarView tabBarView = GFTabBarView(
key: tabBarViewKey,
controller: tabController,
children: tabList,
height: 345,
);
final TestApp app = TestApp(tabBarView);
await tester.pumpWidget(app);
expect(app.tabBarView.controller, tabController);
expect(app.tabBarView.children, tabList);
expect(app.tabBarView.height, 345);
});
}
class TestApp extends StatefulWidget {
const TestApp(this.tabBarView);
final GFTabBarView tabBarView;
@override
_TestAppState createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('TabBarView'),
),
body: widget.tabBarView,
),
);
}