@@ -10,7 +10,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
10
10
import '../widgets/semantics_tester.dart' ;
11
11
12
12
void main () {
13
- testWidgetsWithLeakTracking ('Drawer control test' , (WidgetTester tester) async {
13
+ testWidgetsWithLeakTracking ('Material2 - Drawer control test' , (WidgetTester tester) async {
14
14
const Key containerKey = Key ('container' );
15
15
16
16
await tester.pumpWidget (
@@ -58,6 +58,54 @@ void main() {
58
58
expect (find.text ('header' ), findsOneWidget);
59
59
});
60
60
61
+ testWidgetsWithLeakTracking ('Material3 - Drawer control test' , (WidgetTester tester) async {
62
+ const Key containerKey = Key ('container' );
63
+
64
+ await tester.pumpWidget (
65
+ MaterialApp (
66
+ theme: ThemeData (useMaterial3: true ),
67
+ home: Scaffold (
68
+ drawer: Drawer (
69
+ child: ListView (
70
+ children: < Widget > [
71
+ DrawerHeader (
72
+ child: Container (
73
+ key: containerKey,
74
+ child: const Text ('header' ),
75
+ ),
76
+ ),
77
+ const ListTile (
78
+ leading: Icon (Icons .archive),
79
+ title: Text ('Archive' ),
80
+ ),
81
+ ],
82
+ ),
83
+ ),
84
+ ),
85
+ ),
86
+ );
87
+
88
+ expect (find.text ('Archive' ), findsNothing);
89
+ final ScaffoldState state = tester.firstState (find.byType (Scaffold ));
90
+ state.openDrawer ();
91
+
92
+ await tester.pump ();
93
+ await tester.pump (const Duration (seconds: 1 ));
94
+ expect (find.text ('Archive' ), findsOneWidget);
95
+
96
+ RenderBox box = tester.renderObject (find.byType (DrawerHeader ));
97
+ expect (box.size.height, equals (160.0 + 8.0 + 1.0 )); // height + bottom margin + bottom edge
98
+
99
+ final double drawerWidth = box.size.width;
100
+ final double drawerHeight = box.size.height;
101
+
102
+ box = tester.renderObject (find.byKey (containerKey));
103
+ expect (box.size.width, equals (drawerWidth - 2 * 16.0 ));
104
+ expect (box.size.height, equals (drawerHeight - 2 * 16.0 - 1.0 )); // Header divider thickness is 1.0 in Material 3.
105
+
106
+ expect (find.text ('header' ), findsOneWidget);
107
+ });
108
+
61
109
testWidgetsWithLeakTracking ('Drawer dismiss barrier has label' , (WidgetTester tester) async {
62
110
final SemanticsTester semantics = SemanticsTester (tester);
63
111
await tester.pumpWidget (
@@ -570,7 +618,7 @@ void main() {
570
618
expect (box.size.width, equals (smallWidth));
571
619
});
572
620
573
- testWidgetsWithLeakTracking ('Drawer default shape (ltr)' , (WidgetTester tester) async {
621
+ testWidgetsWithLeakTracking ('Material3 - Drawer default shape (ltr)' , (WidgetTester tester) async {
574
622
await tester.pumpWidget (
575
623
MaterialApp (
576
624
theme: ThemeData (useMaterial3: true ),
@@ -630,7 +678,7 @@ void main() {
630
678
);
631
679
});
632
680
633
- testWidgetsWithLeakTracking ('Drawer default shape (rtl)' , (WidgetTester tester) async {
681
+ testWidgetsWithLeakTracking ('Material3 - Drawer default shape (rtl)' , (WidgetTester tester) async {
634
682
await tester.pumpWidget (
635
683
MaterialApp (
636
684
theme: ThemeData (useMaterial3: true ),
@@ -690,7 +738,7 @@ void main() {
690
738
);
691
739
});
692
740
693
- testWidgetsWithLeakTracking ('Drawer clip behavior' , (WidgetTester tester) async {
741
+ testWidgetsWithLeakTracking ('Material3 - Drawer clip behavior' , (WidgetTester tester) async {
694
742
await tester.pumpWidget (
695
743
MaterialApp (
696
744
theme: ThemeData (useMaterial3: true ),
@@ -746,7 +794,7 @@ void main() {
746
794
// support is deprecated and the APIs are removed, these tests
747
795
// can be deleted.
748
796
749
- testWidgetsWithLeakTracking ('Drawer default shape' , (WidgetTester tester) async {
797
+ testWidgetsWithLeakTracking ('Material2 - Drawer default shape' , (WidgetTester tester) async {
750
798
await tester.pumpWidget (
751
799
MaterialApp (
752
800
theme: ThemeData (useMaterial3: false ),
@@ -787,7 +835,7 @@ void main() {
787
835
expect (material.shape, null );
788
836
});
789
837
790
- testWidgetsWithLeakTracking ('Drawer clip behavior' , (WidgetTester tester) async {
838
+ testWidgetsWithLeakTracking ('Material2 - Drawer clip behavior' , (WidgetTester tester) async {
791
839
await tester.pumpWidget (
792
840
MaterialApp (
793
841
theme: ThemeData (useMaterial3: false ),
0 commit comments