Unverified Commit 4b6cc473 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add label to drawer and regression test cases (#20537)

parent 7bdd31f7
......@@ -401,8 +401,11 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
// On Android, the back button is used to dismiss a modal.
excludeFromSemantics: defaultTargetPlatform == TargetPlatform.android,
onTap: close,
child: new Semantics(
label: MaterialLocalizations.of(context)?.modalBarrierDismissLabel,
child: new Container(
color: _color.evaluate(_controller)
color: _color.evaluate(_controller),
),
),
),
),
......
......@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';
void main() {
testWidgets('Drawer control test', (WidgetTester tester) async {
const Key containerKey = Key('container');
......@@ -52,4 +56,54 @@ void main() {
expect(find.text('header'), findsOneWidget);
});
testWidgets('Drawer dismiss barrier has label on iOS', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
drawer: Drawer()
),
),
);
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openDrawer();
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(semantics, includesNodeWith(
label: const DefaultMaterialLocalizations().modalBarrierDismissLabel,
actions: <SemanticsAction>[SemanticsAction.tap],
));
semantics.dispose();
debugDefaultTargetPlatformOverride = null;
});
testWidgets('Drawer dismiss barrier has no label on Android', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
drawer: Drawer()
),
),
);
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openDrawer();
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(semantics, isNot(includesNodeWith(
label: const DefaultMaterialLocalizations().modalBarrierDismissLabel,
actions: <SemanticsAction>[SemanticsAction.tap],
)));
semantics.dispose();
});
}
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