Unverified Commit ebaf1603 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Update `Drawer` tests for M2/M3 (#135752)

Updated unit tests for `Drawer` to have M2 and M3 versions.

More info in #127064
parent 7c9feea8
......@@ -10,7 +10,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart';
void main() {
testWidgetsWithLeakTracking('Drawer control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Drawer control test', (WidgetTester tester) async {
const Key containerKey = Key('container');
await tester.pumpWidget(
......@@ -58,6 +58,54 @@ void main() {
expect(find.text('header'), findsOneWidget);
});
testWidgetsWithLeakTracking('Material3 - Drawer control test', (WidgetTester tester) async {
const Key containerKey = Key('container');
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
home: Scaffold(
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
child: Container(
key: containerKey,
child: const Text('header'),
),
),
const ListTile(
leading: Icon(Icons.archive),
title: Text('Archive'),
),
],
),
),
),
),
);
expect(find.text('Archive'), findsNothing);
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openDrawer();
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(find.text('Archive'), findsOneWidget);
RenderBox box = tester.renderObject(find.byType(DrawerHeader));
expect(box.size.height, equals(160.0 + 8.0 + 1.0)); // height + bottom margin + bottom edge
final double drawerWidth = box.size.width;
final double drawerHeight = box.size.height;
box = tester.renderObject(find.byKey(containerKey));
expect(box.size.width, equals(drawerWidth - 2 * 16.0));
expect(box.size.height, equals(drawerHeight - 2 * 16.0 - 1.0)); // Header divider thickness is 1.0 in Material 3.
expect(find.text('header'), findsOneWidget);
});
testWidgetsWithLeakTracking('Drawer dismiss barrier has label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......@@ -570,7 +618,7 @@ void main() {
expect(box.size.width, equals(smallWidth));
});
testWidgetsWithLeakTracking('Drawer default shape (ltr)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Drawer default shape (ltr)', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -630,7 +678,7 @@ void main() {
);
});
testWidgetsWithLeakTracking('Drawer default shape (rtl)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Drawer default shape (rtl)', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -690,7 +738,7 @@ void main() {
);
});
testWidgetsWithLeakTracking('Drawer clip behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Drawer clip behavior', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -746,7 +794,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgetsWithLeakTracking('Drawer default shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Drawer default shape', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -787,7 +835,7 @@ void main() {
expect(material.shape, null);
});
testWidgetsWithLeakTracking('Drawer clip behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Drawer clip behavior', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment