Enables setting of semantics focused and focusable attributes within Focus widgets. (#41814)
This adds a Semantics node to the Focus and FocusScope widgets, setting the focused and focusable attributes so that the accessibility subsystem can be told when a control has the input focus. Includes an engine roll to flutter/engine@77252d2, and the following 8 engine changes: flutter/engine@77252d2 Greg Spencer Add missing focusable testing info (flutter/engine#13013) flutter/engine@0e42a29 skia-flutter-.. Roll src/third_party/skia 54548626a977..e27a503a0a21 (1 commits) (flutter/engine#13024) flutter/engine@6b56ed7 gaaclarke Refactor: FlutterDartProject (flutter/engine#13006) flutter/engine@393480c skia-flutter-.. Roll src/third_party/skia 77dde599c98a..54548626a977 (1 commits) (flutter/engine#13023) flutter/engine@080b89d skia-flutter-.. Roll src/third_party/skia 2b1a25a4d324..77dde599c98a (1 commits) (flutter/engine#13021) flutter/engine@90b0f30 Ben Konyi Roll src/third_party/dart f4a72bfc64..bb04f145b2 (18 commits) (flutter/engine#13020) flutter/engine@049fb89 skia-flutter-.. Roll fuchsia/sdk/core/linux-amd64 from q_uYX... to cknsi... (flutter/engine#13019) flutter/engine@6925b2a skia-flutter-.. Roll fuchsia/sdk/core/mac-amd64 from wuAtw... to u0JpE... (flutter/engine#13018) Related Issues Addresses #40101 Landing on red in order to fix the build: it's red because of the needed engine roll.
This commit is contained in:
@@ -24,6 +24,9 @@ class AndroidClassName {
|
||||
|
||||
/// The class name used for toggle switches.
|
||||
static const String toggleSwitch = 'android.widget.Switch';
|
||||
|
||||
/// The default className for buttons.
|
||||
static const String button = 'android.widget.Button';
|
||||
}
|
||||
|
||||
/// Action constants which correspond to `AccessibilityAction` in Android.
|
||||
|
||||
@@ -135,8 +135,13 @@ class _AndroidSemanticsMatcher extends Matcher {
|
||||
return _failWithMessage('Expected size: $size', matchState);
|
||||
if (actions != null) {
|
||||
final List<AndroidSemanticsAction> itemActions = item.getActions();
|
||||
if (!unorderedEquals(actions).matches(itemActions, matchState))
|
||||
return _failWithMessage('Expected actions: $actions', matchState);
|
||||
if (!unorderedEquals(actions).matches(itemActions, matchState)) {
|
||||
final List<String> actionsString = actions.map<String>((AndroidSemanticsAction action) => action.toString()).toList()..sort();
|
||||
final List<String> itemActionsString = itemActions.map<String>((AndroidSemanticsAction action) => action.toString()).toList()..sort();
|
||||
final Set<String> unexpected = itemActionsString.toSet().difference(actionsString.toSet());
|
||||
final Set<String> missing = actionsString.toSet().difference(itemActionsString.toSet());
|
||||
return _failWithMessage('Expected actions: $actionsString\nActual actions: $itemActionsString\nUnexpected: $unexpected\nMissing: $missing', matchState);
|
||||
}
|
||||
}
|
||||
if (isChecked != null && isChecked != item.isChecked)
|
||||
return _failWithMessage('Expected isChecked: $isChecked', matchState);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/// The name of the route containing the test suite.
|
||||
const String popupControlsRoute = 'popups';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the popup menu button.
|
||||
const String popupButtonKeyValue = 'PopupControls#PopupButton1';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the popup menu.
|
||||
const String popupKeyValue = 'PopupControls#Popup1';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the dropdown button.
|
||||
const String dropdownButtonKeyValue = 'PopupControls#DropdownButton1';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the dropdown button menu.
|
||||
const String dropdownKeyValue = 'PopupControls#Dropdown1';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the alert button.
|
||||
const String alertButtonKeyValue = 'PopupControls#AlertButton1';
|
||||
|
||||
/// The string supplied to the [ValueKey] for the alert dialog.
|
||||
const String alertKeyValue = 'PopupControls#Alert1';
|
||||
|
||||
const List<String> popupItems = <String>['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5'];
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'popup_constants.dart';
|
||||
|
||||
export 'popup_constants.dart';
|
||||
|
||||
/// A page with a popup menu, a dropdown menu, and a modal alert.
|
||||
class PopupControlsPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _PopupControlsPageState();
|
||||
}
|
||||
|
||||
class _PopupControlsPageState extends State<PopupControlsPage> {
|
||||
final Key popupKey = const ValueKey<String>(popupKeyValue);
|
||||
final Key dropdownKey = const ValueKey<String>(dropdownKeyValue);
|
||||
final Key alertKey = const ValueKey<String>(alertKeyValue);
|
||||
|
||||
String popupValue = popupItems.first;
|
||||
String dropdownValue = popupItems.first;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
PopupMenuButton<String>(
|
||||
key: const ValueKey<String>(popupButtonKeyValue),
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return popupItems.map<PopupMenuItem<String>>((String item) {
|
||||
return PopupMenuItem<String>(
|
||||
key: ValueKey<String>('$popupKeyValue.$item'),
|
||||
value: item,
|
||||
child: Text(item),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
onSelected: (String value) {
|
||||
popupValue = value;
|
||||
},
|
||||
),
|
||||
DropdownButton<String>(
|
||||
key: const ValueKey<String>(dropdownButtonKeyValue),
|
||||
value: dropdownValue,
|
||||
items: popupItems.map<DropdownMenuItem<String>>((String item) {
|
||||
return DropdownMenuItem<String>(
|
||||
key: ValueKey<String>('$dropdownKeyValue.$item'),
|
||||
value: item,
|
||||
child: Text(item),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String value) {
|
||||
setState(() {
|
||||
dropdownValue = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
MaterialButton(
|
||||
key: const ValueKey<String>(alertButtonKeyValue),
|
||||
child: const Text('Alert'),
|
||||
onPressed: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
key: const ValueKey<String>(alertKeyValue),
|
||||
title: const Text('Title text', key: ValueKey<String>('$alertKeyValue.Title')),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: const <Widget>[
|
||||
Text('Body text line 1.', key: ValueKey<String>('$alertKeyValue.Body1')),
|
||||
Text('Body text line 2.', key: ValueKey<String>('$alertKeyValue.Body2')),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: const Text('OK', key: ValueKey<String>('$alertKeyValue.OK')),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user