Add drawer and navigation drawer in a11y assessment app, also run dart format under a11y_assessments/ (#153034)

This commit is contained in:
hangyu 2024-08-07 17:19:12 -07:00 committed by GitHub
parent 12aafe30d6
commit 9b281bec20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 631 additions and 112 deletions

View File

@ -21,28 +21,27 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData lightTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
));
final ThemeData darkTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
));
final Map<String, WidgetBuilder> routes = Map<String, WidgetBuilder>.fromEntries(
useCases.map((UseCase useCase) => MapEntry<String, WidgetBuilder>(useCase.route, useCase.build)),
final Map<String, WidgetBuilder> routes =
Map<String, WidgetBuilder>.fromEntries(
useCases.map((UseCase useCase) =>
MapEntry<String, WidgetBuilder>(useCase.route, useCase.build)),
);
return MaterialApp(
title: 'Accessibility Assessments',
theme: lightTheme,
darkTheme: darkTheme,
routes: <String, WidgetBuilder>{
'/': (_) => const HomePage(),
...routes
},
routes: <String, WidgetBuilder>{'/': (_) => const HomePage(), ...routes},
);
}
}
@ -65,17 +64,14 @@ class HomePageState extends State<HomePage> {
Widget _buildUseCaseItem(int index, UseCase useCase) {
return Padding(
padding: const EdgeInsets.all(10),
child: Builder(
builder: (BuildContext context) {
return TextButton(
key: Key(useCase.name),
onPressed: () => Navigator.of(context).pushNamed(useCase.route),
child: Text(useCase.name),
);
}
)
);
padding: const EdgeInsets.all(10),
child: Builder(builder: (BuildContext context) {
return TextButton(
key: Key(useCase.name),
onPressed: () => Navigator.of(context).pushNamed(useCase.route),
child: Text(useCase.name),
);
}));
}
@override

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class AutoCompleteUseCase extends UseCase {
@override
String get name => 'AutoComplete';
@ -32,7 +31,11 @@ class _MainWidgetState extends State<_MainWidget> {
'lemon',
];
static Widget _fieldViewBuilder(BuildContext context, TextEditingController textEditingController, FocusNode focusNode, VoidCallback onFieldSubmitted) {
static Widget _fieldViewBuilder(
BuildContext context,
TextEditingController textEditingController,
FocusNode focusNode,
VoidCallback onFieldSubmitted) {
return TextFormField(
focusNode: focusNode,
controller: textEditingController,

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class BadgeUseCase extends UseCase {
@override
String get name => 'Badge';

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class CheckBoxListTile extends UseCase {
@override
String get name => 'CheckBoxListTile';

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class DatePickerUseCase extends UseCase {
@override
String get name => 'DatePicker';
@ -26,7 +25,6 @@ class _MainWidget extends StatefulWidget {
}
class _MainWidgetState extends State<_MainWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class DialogUseCase extends UseCase {
@override
String get name => 'Dialog';

View File

@ -0,0 +1,88 @@
// Copyright 2014 The Flutter 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 'use_cases.dart';
class DrawerUseCase extends UseCase {
@override
String get name => 'drawer';
@override
String get route => '/drawer';
@override
Widget build(BuildContext context) => const DrawerExample();
}
class DrawerExample extends StatefulWidget {
const DrawerExample({super.key});
@override
State<DrawerExample> createState() => _DrawerExampleState();
}
class _DrawerExampleState extends State<DrawerExample> {
String selectedPage = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Drawer Example'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text(
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
),
ListTile(
leading: const Icon(Icons.message),
title: const Text('Messages'),
onTap: () {
setState(() {
selectedPage = 'Messages';
});
},
),
ListTile(
leading: const Icon(Icons.account_circle),
title: const Text('Profile'),
onTap: () {
setState(() {
selectedPage = 'Profile';
});
},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: () {
setState(() {
selectedPage = 'Settings';
});
},
),
],
),
),
body: Center(
child: Text('Page: $selectedPage'),
),
);
}
}

View File

@ -17,7 +17,6 @@ class ExpansionTileUseCase extends UseCase {
Widget build(BuildContext context) => const ExpansionTileExample();
}
class ExpansionTileExample extends StatefulWidget {
const ExpansionTileExample({super.key});
@ -48,7 +47,9 @@ class _ExpansionTileExampleState extends State<ExpansionTileExample> {
title: const Text('ExpansionTile 2'),
subtitle: const Text('Custom expansion arrow icon'),
trailing: Icon(
_customTileExpanded ? Icons.arrow_drop_down_circle : Icons.arrow_drop_down,
_customTileExpanded
? Icons.arrow_drop_down_circle
: Icons.arrow_drop_down,
),
children: const <Widget>[
ListTile(title: Text('This is tile number 2')),

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class MaterialBannerUseCase extends UseCase {
@override
String get name => 'MaterialBanner';
@ -27,7 +26,8 @@ class MainWidget extends StatefulWidget {
class MainWidgetState extends State<MainWidget> {
double currentSliderValue = 20;
ScaffoldFeatureController<MaterialBanner, MaterialBannerClosedReason>? controller;
ScaffoldFeatureController<MaterialBanner, MaterialBannerClosedReason>?
controller;
@override
Widget build(BuildContext context) {

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class NavigationBarUseCase extends UseCase {
@override
String get name => 'NavigationBar';

View File

@ -0,0 +1,117 @@
// Copyright 2014 The Flutter 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 'use_cases.dart';
class ExampleDestination {
const ExampleDestination(this.label, this.icon, this.selectedIcon);
final String label;
final Widget icon;
final Widget selectedIcon;
}
const List<ExampleDestination> destinations = <ExampleDestination>[
ExampleDestination(
'Messages', Icon(Icons.widgets_outlined), Icon(Icons.widgets)),
ExampleDestination(
'Profile', Icon(Icons.format_paint_outlined), Icon(Icons.format_paint)),
ExampleDestination(
'Settings', Icon(Icons.settings_outlined), Icon(Icons.settings)),
];
class NavigationDrawerUseCase extends UseCase {
@override
String get name => 'NavigationDrawer';
@override
String get route => '/navigation-drawer';
@override
Widget build(BuildContext context) => const NavigationDrawerExample();
}
class NavigationDrawerExample extends StatefulWidget {
const NavigationDrawerExample({super.key});
@override
State<NavigationDrawerExample> createState() =>
_NavigationDrawerExampleState();
}
class _NavigationDrawerExampleState extends State<NavigationDrawerExample> {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
int screenIndex = 0;
late bool showNavigationDrawer;
void handleScreenChanged(int selectedScreen) {
setState(() {
screenIndex = selectedScreen;
});
}
void openDrawer() {
scaffoldKey.currentState!.openEndDrawer();
}
Widget buildDrawerScaffold(BuildContext context) {
return Scaffold(
key: scaffoldKey,
appBar: AppBar(
title: const Text('Navigation Drawer Example'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SafeArea(
bottom: false,
top: false,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Page Index = $screenIndex'),
ElevatedButton(
onPressed: openDrawer,
child: const Text('Open Drawer'),
),
],
),
),
),
endDrawer: NavigationDrawer(
onDestinationSelected: handleScreenChanged,
selectedIndex: screenIndex,
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(28, 16, 16, 10),
child: Text(
'Header',
style: Theme.of(context).textTheme.titleSmall,
),
),
...destinations.map(
(ExampleDestination destination) {
return NavigationDrawerDestination(
label: Text(destination.label),
icon: destination.icon,
selectedIcon: destination.selectedIcon,
);
},
),
const Padding(
padding: EdgeInsets.fromLTRB(28, 16, 28, 10),
child: Divider(),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return buildDrawerScaffold(context);
}
}

View File

@ -0,0 +1,183 @@
// Copyright 2014 The Flutter 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 'use_cases.dart';
class NavigationRailUseCase extends UseCase {
@override
String get name => 'NavigationRail';
@override
String get route => '/navigation-rail';
@override
Widget build(BuildContext context) => const NavRailExample();
}
class NavRailExample extends StatefulWidget {
const NavRailExample({super.key});
@override
State<NavRailExample> createState() => _NavRailExampleState();
}
class _NavRailExampleState extends State<NavRailExample> {
int _selectedIndex = 0;
NavigationRailLabelType labelType = NavigationRailLabelType.all;
bool showLeading = false;
bool showTrailing = false;
double groupAlignment = -1.0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: <Widget>[
NavigationRail(
selectedIndex: _selectedIndex,
groupAlignment: groupAlignment,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
labelType: labelType,
leading: showLeading
? FloatingActionButton(
elevation: 0,
onPressed: () {
// Add your onPressed code here!
},
child: const Icon(Icons.add),
)
: const SizedBox(),
trailing: showTrailing
? IconButton(
onPressed: () {
// Add your onPressed code here!
},
icon: const Icon(Icons.more_horiz_rounded),
)
: const SizedBox(),
destinations: const <NavigationRailDestination>[
NavigationRailDestination(
icon: Icon(Icons.favorite_border),
selectedIcon: Icon(Icons.favorite),
label: Text('First'),
),
NavigationRailDestination(
icon: Icon(Icons.bookmark_border),
selectedIcon: Icon(Icons.book),
label: Text('Second'),
),
NavigationRailDestination(
icon: Icon(Icons.star_border),
selectedIcon: Icon(Icons.star),
label: Text('Third'),
),
],
),
const VerticalDivider(thickness: 1, width: 1),
// This is the main content.
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('selectedIndex: $_selectedIndex'),
const SizedBox(height: 20),
Text('Label type: ${labelType.name}'),
const SizedBox(height: 10),
OverflowBar(
spacing: 10.0,
children: <Widget>[
ElevatedButton(
onPressed: () {
setState(() {
labelType = NavigationRailLabelType.none;
});
},
child: const Text('None'),
),
ElevatedButton(
onPressed: () {
setState(() {
labelType = NavigationRailLabelType.selected;
});
},
child: const Text('Selected'),
),
ElevatedButton(
onPressed: () {
setState(() {
labelType = NavigationRailLabelType.all;
});
},
child: const Text('All'),
),
],
),
const SizedBox(height: 20),
Text('Group alignment: $groupAlignment'),
const SizedBox(height: 10),
OverflowBar(
spacing: 10.0,
children: <Widget>[
ElevatedButton(
onPressed: () {
setState(() {
groupAlignment = -1.0;
});
},
child: const Text('Top'),
),
ElevatedButton(
onPressed: () {
setState(() {
groupAlignment = 0.0;
});
},
child: const Text('Center'),
),
ElevatedButton(
onPressed: () {
setState(() {
groupAlignment = 1.0;
});
},
child: const Text('Bottom'),
),
],
),
const SizedBox(height: 20),
OverflowBar(
spacing: 10.0,
children: <Widget>[
ElevatedButton(
onPressed: () {
setState(() {
showLeading = !showLeading;
});
},
child: Text(showLeading ? 'Hide Leading' : 'Show Leading'),
),
ElevatedButton(
onPressed: () {
setState(() {
showTrailing = !showTrailing;
});
},
child: Text(showTrailing ? 'Hide Trailing' : 'Show Trailing'),
),
],
),
],
),
),
],
),
);
}
}

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class RadioListTileUseCase extends UseCase {
@override
String get name => 'RadioListTile';

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class SliderUseCase extends UseCase {
@override
String get name => 'Slider';

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class TextButtonUseCase extends UseCase {
@override
String get name => 'TextButton';
@ -46,7 +45,9 @@ class MainWidgetState extends State<MainWidget> {
const Text('This is a TextButton:'),
TextButton(
onPressed: () {
setState(() { _count++; });
setState(() {
_count++;
});
},
child: const Text('Action'),
),

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class TextFieldUseCase extends UseCase {
@override
String get name => 'TextField';

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class TextFieldPasswordUseCase extends UseCase {
@override
String get name => 'TextField password';

View File

@ -11,9 +11,12 @@ import 'card.dart';
import 'check_box_list_tile.dart';
import 'date_picker.dart';
import 'dialog.dart';
import 'drawer.dart';
import 'expansion_tile.dart';
import 'material_banner.dart';
import 'navigation_bar.dart';
import 'navigation_drawer.dart';
import 'navigation_rail.dart';
import 'radio_list_tile.dart';
import 'slider.dart';
import 'snack_bar.dart';
@ -46,4 +49,7 @@ final List<UseCase> useCases = <UseCase>[
SwitchListTileUseCase(),
ExpansionTileUseCase(),
CardUseCase(),
DrawerUseCase(),
NavigationDrawerUseCase(),
NavigationRailUseCase(),
];

View File

@ -9,9 +9,11 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
for (final UseCase useCase in useCases) {
testWidgets('testing accessibility guideline for ${useCase.name}', (WidgetTester tester) async {
testWidgets('testing accessibility guideline for ${useCase.name}',
(WidgetTester tester) async {
await tester.pumpWidget(const App());
final ScrollController controller = tester.state<HomePageState>(find.byType(HomePage)).scrollController;
final ScrollController controller =
tester.state<HomePageState>(find.byType(HomePage)).scrollController;
while (find.byKey(Key(useCase.name)).evaluate().isEmpty) {
controller.jumpTo(controller.offset + 600);
await tester.pumpAndSettle();

View File

@ -8,7 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
void main() {
testWidgets('check box list tile use-case renders check boxes', (WidgetTester tester) async {
testWidgets('check box list tile use-case renders check boxes',
(WidgetTester tester) async {
await pumpsUseCase(tester, CheckBoxListTile());
expect(find.text('a check box list title'), findsOneWidget);
expect(find.text('a disabled check box list title'), findsOneWidget);

View File

@ -0,0 +1,23 @@
// Copyright 2014 The Flutter 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:a11y_assessments/use_cases/drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
void main() {
testWidgets('drawer can run', (WidgetTester tester) async {
await pumpsUseCase(tester, DrawerUseCase());
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openEndDrawer();
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(find.byType(Drawer), findsExactly(1));
});
}

View File

@ -7,75 +7,137 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
void main() {
testWidgets('Has light and dark theme', (WidgetTester tester) async {
await tester.pumpWidget(const App());
final MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final MaterialApp app =
find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme!.brightness, equals(Brightness.light));
expect(app.darkTheme!.brightness, equals(Brightness.dark));
});
testWidgets('App can generate high-contrast color scheme', (WidgetTester tester) async {
testWidgets('App can generate high-contrast color scheme',
(WidgetTester tester) async {
await tester.pumpWidget(const MediaQuery(
data: MediaQueryData(
highContrast: true,
),
child: App()
));
data: MediaQueryData(
highContrast: true,
),
child: App()));
final MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final MaterialApp app =
find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final DynamicScheme highContrastScheme = SchemeTonalSpot(sourceColorHct: Hct.fromInt(const Color(0xff6750a4).value), isDark: false, contrastLevel: 1.0);
final DynamicScheme highContrastScheme = SchemeTonalSpot(
sourceColorHct: Hct.fromInt(const Color(0xff6750a4).value),
isDark: false,
contrastLevel: 1.0);
final ColorScheme appScheme = app.theme!.colorScheme;
expect(appScheme.primary.value, MaterialDynamicColors.primary.getArgb(highContrastScheme));
expect(appScheme.onPrimary.value, MaterialDynamicColors.onPrimary.getArgb(highContrastScheme));
expect(appScheme.primaryContainer.value, MaterialDynamicColors.primaryContainer.getArgb(highContrastScheme));
expect(appScheme.onPrimaryContainer.value, MaterialDynamicColors.onPrimaryContainer.getArgb(highContrastScheme));
expect(appScheme.primaryFixed.value, MaterialDynamicColors.primaryFixed.getArgb(highContrastScheme));
expect(appScheme.primaryFixedDim.value, MaterialDynamicColors.primaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onPrimaryFixed.value, MaterialDynamicColors.onPrimaryFixed.getArgb(highContrastScheme));
expect(appScheme.onPrimaryFixedVariant.value, MaterialDynamicColors.onPrimaryFixedVariant.getArgb(highContrastScheme));
expect(appScheme.secondary.value, MaterialDynamicColors.secondary.getArgb(highContrastScheme));
expect(appScheme.onSecondary.value, MaterialDynamicColors.onSecondary.getArgb(highContrastScheme));
expect(appScheme.secondaryContainer.value, MaterialDynamicColors.secondaryContainer.getArgb(highContrastScheme));
expect(appScheme.onSecondaryContainer.value, MaterialDynamicColors.onSecondaryContainer.getArgb(highContrastScheme));
expect(appScheme.secondaryFixed.value, MaterialDynamicColors.secondaryFixed.getArgb(highContrastScheme));
expect(appScheme.secondaryFixedDim.value, MaterialDynamicColors.secondaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onSecondaryFixed.value, MaterialDynamicColors.onSecondaryFixed.getArgb(highContrastScheme));
expect(appScheme.onSecondaryFixedVariant.value, MaterialDynamicColors.onSecondaryFixedVariant.getArgb(highContrastScheme));
expect(appScheme.tertiary.value, MaterialDynamicColors.tertiary.getArgb(highContrastScheme));
expect(appScheme.onTertiary.value, MaterialDynamicColors.onTertiary.getArgb(highContrastScheme));
expect(appScheme.tertiaryContainer.value, MaterialDynamicColors.tertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.onTertiaryContainer.value, MaterialDynamicColors.onTertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixed.value, MaterialDynamicColors.tertiaryFixed.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixedDim.value, MaterialDynamicColors.tertiaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onTertiaryFixed.value, MaterialDynamicColors.onTertiaryFixed.getArgb(highContrastScheme));
expect(appScheme.onTertiaryFixedVariant.value, MaterialDynamicColors.onTertiaryFixedVariant.getArgb(highContrastScheme));
expect(appScheme.error.value, MaterialDynamicColors.error.getArgb(highContrastScheme));
expect(appScheme.onError.value, MaterialDynamicColors.onError.getArgb(highContrastScheme));
expect(appScheme.errorContainer.value, MaterialDynamicColors.errorContainer.getArgb(highContrastScheme));
expect(appScheme.onErrorContainer.value, MaterialDynamicColors.onErrorContainer.getArgb(highContrastScheme));
expect(appScheme.background.value, MaterialDynamicColors.background.getArgb(highContrastScheme));
expect(appScheme.onBackground.value, MaterialDynamicColors.onBackground.getArgb(highContrastScheme));
expect(appScheme.surface.value, MaterialDynamicColors.surface.getArgb(highContrastScheme));
expect(appScheme.surfaceDim.value, MaterialDynamicColors.surfaceDim.getArgb(highContrastScheme));
expect(appScheme.surfaceBright.value, MaterialDynamicColors.surfaceBright.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerLowest.value, MaterialDynamicColors.surfaceContainerLowest.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerLow.value, MaterialDynamicColors.surfaceContainerLow.getArgb(highContrastScheme));
expect(appScheme.surfaceContainer.value, MaterialDynamicColors.surfaceContainer.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerHigh.value, MaterialDynamicColors.surfaceContainerHigh.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerHighest.value, MaterialDynamicColors.surfaceContainerHighest.getArgb(highContrastScheme));
expect(appScheme.onSurface.value, MaterialDynamicColors.onSurface.getArgb(highContrastScheme));
expect(appScheme.surfaceVariant.value, MaterialDynamicColors.surfaceVariant.getArgb(highContrastScheme));
expect(appScheme.onSurfaceVariant.value, MaterialDynamicColors.onSurfaceVariant.getArgb(highContrastScheme));
expect(appScheme.outline.value, MaterialDynamicColors.outline.getArgb(highContrastScheme));
expect(appScheme.outlineVariant.value, MaterialDynamicColors.outlineVariant.getArgb(highContrastScheme));
expect(appScheme.shadow.value, MaterialDynamicColors.shadow.getArgb(highContrastScheme));
expect(appScheme.scrim.value, MaterialDynamicColors.scrim.getArgb(highContrastScheme));
expect(appScheme.inverseSurface.value, MaterialDynamicColors.inverseSurface.getArgb(highContrastScheme));
expect(appScheme.onInverseSurface.value, MaterialDynamicColors.inverseOnSurface.getArgb(highContrastScheme));
expect(appScheme.inversePrimary.value, MaterialDynamicColors.inversePrimary.getArgb(highContrastScheme));
expect(appScheme.primary.value,
MaterialDynamicColors.primary.getArgb(highContrastScheme));
expect(appScheme.onPrimary.value,
MaterialDynamicColors.onPrimary.getArgb(highContrastScheme));
expect(appScheme.primaryContainer.value,
MaterialDynamicColors.primaryContainer.getArgb(highContrastScheme));
expect(appScheme.onPrimaryContainer.value,
MaterialDynamicColors.onPrimaryContainer.getArgb(highContrastScheme));
expect(appScheme.primaryFixed.value,
MaterialDynamicColors.primaryFixed.getArgb(highContrastScheme));
expect(appScheme.primaryFixedDim.value,
MaterialDynamicColors.primaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onPrimaryFixed.value,
MaterialDynamicColors.onPrimaryFixed.getArgb(highContrastScheme));
expect(
appScheme.onPrimaryFixedVariant.value,
MaterialDynamicColors.onPrimaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.secondary.value,
MaterialDynamicColors.secondary.getArgb(highContrastScheme));
expect(appScheme.onSecondary.value,
MaterialDynamicColors.onSecondary.getArgb(highContrastScheme));
expect(appScheme.secondaryContainer.value,
MaterialDynamicColors.secondaryContainer.getArgb(highContrastScheme));
expect(appScheme.onSecondaryContainer.value,
MaterialDynamicColors.onSecondaryContainer.getArgb(highContrastScheme));
expect(appScheme.secondaryFixed.value,
MaterialDynamicColors.secondaryFixed.getArgb(highContrastScheme));
expect(appScheme.secondaryFixedDim.value,
MaterialDynamicColors.secondaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onSecondaryFixed.value,
MaterialDynamicColors.onSecondaryFixed.getArgb(highContrastScheme));
expect(
appScheme.onSecondaryFixedVariant.value,
MaterialDynamicColors.onSecondaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.tertiary.value,
MaterialDynamicColors.tertiary.getArgb(highContrastScheme));
expect(appScheme.onTertiary.value,
MaterialDynamicColors.onTertiary.getArgb(highContrastScheme));
expect(appScheme.tertiaryContainer.value,
MaterialDynamicColors.tertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.onTertiaryContainer.value,
MaterialDynamicColors.onTertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixed.value,
MaterialDynamicColors.tertiaryFixed.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixedDim.value,
MaterialDynamicColors.tertiaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onTertiaryFixed.value,
MaterialDynamicColors.onTertiaryFixed.getArgb(highContrastScheme));
expect(
appScheme.onTertiaryFixedVariant.value,
MaterialDynamicColors.onTertiaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.error.value,
MaterialDynamicColors.error.getArgb(highContrastScheme));
expect(appScheme.onError.value,
MaterialDynamicColors.onError.getArgb(highContrastScheme));
expect(appScheme.errorContainer.value,
MaterialDynamicColors.errorContainer.getArgb(highContrastScheme));
expect(appScheme.onErrorContainer.value,
MaterialDynamicColors.onErrorContainer.getArgb(highContrastScheme));
expect(appScheme.background.value,
MaterialDynamicColors.background.getArgb(highContrastScheme));
expect(appScheme.onBackground.value,
MaterialDynamicColors.onBackground.getArgb(highContrastScheme));
expect(appScheme.surface.value,
MaterialDynamicColors.surface.getArgb(highContrastScheme));
expect(appScheme.surfaceDim.value,
MaterialDynamicColors.surfaceDim.getArgb(highContrastScheme));
expect(appScheme.surfaceBright.value,
MaterialDynamicColors.surfaceBright.getArgb(highContrastScheme));
expect(
appScheme.surfaceContainerLowest.value,
MaterialDynamicColors.surfaceContainerLowest
.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerLow.value,
MaterialDynamicColors.surfaceContainerLow.getArgb(highContrastScheme));
expect(appScheme.surfaceContainer.value,
MaterialDynamicColors.surfaceContainer.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerHigh.value,
MaterialDynamicColors.surfaceContainerHigh.getArgb(highContrastScheme));
expect(
appScheme.surfaceContainerHighest.value,
MaterialDynamicColors.surfaceContainerHighest
.getArgb(highContrastScheme));
expect(appScheme.onSurface.value,
MaterialDynamicColors.onSurface.getArgb(highContrastScheme));
expect(appScheme.surfaceVariant.value,
MaterialDynamicColors.surfaceVariant.getArgb(highContrastScheme));
expect(appScheme.onSurfaceVariant.value,
MaterialDynamicColors.onSurfaceVariant.getArgb(highContrastScheme));
expect(appScheme.outline.value,
MaterialDynamicColors.outline.getArgb(highContrastScheme));
expect(appScheme.outlineVariant.value,
MaterialDynamicColors.outlineVariant.getArgb(highContrastScheme));
expect(appScheme.shadow.value,
MaterialDynamicColors.shadow.getArgb(highContrastScheme));
expect(appScheme.scrim.value,
MaterialDynamicColors.scrim.getArgb(highContrastScheme));
expect(appScheme.inverseSurface.value,
MaterialDynamicColors.inverseSurface.getArgb(highContrastScheme));
expect(appScheme.onInverseSurface.value,
MaterialDynamicColors.inverseOnSurface.getArgb(highContrastScheme));
expect(appScheme.inversePrimary.value,
MaterialDynamicColors.inversePrimary.getArgb(highContrastScheme));
});
}

View File

@ -0,0 +1,23 @@
// Copyright 2014 The Flutter 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:a11y_assessments/use_cases/navigation_drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
void main() {
testWidgets('navigation drawer can run', (WidgetTester tester) async {
await pumpsUseCase(tester, NavigationDrawerUseCase());
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openEndDrawer();
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(find.byType(NavigationDrawer), findsExactly(1));
});
}

View File

@ -0,0 +1,17 @@
// Copyright 2014 The Flutter 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:a11y_assessments/use_cases/navigation_rail.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
void main() {
testWidgets('navigation rail can run', (WidgetTester tester) async {
await pumpsUseCase(tester, NavigationRailUseCase());
expect(find.byType(NavigationRail), findsExactly(1));
});
}

View File

@ -8,7 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
void main() {
testWidgets('radio list tile use-case renders radio buttons', (WidgetTester tester) async {
testWidgets('radio list tile use-case renders radio buttons',
(WidgetTester tester) async {
await pumpsUseCase(tester, RadioListTileUseCase());
expect(find.text('Lafayette'), findsOneWidget);
expect(find.text('Jefferson'), findsOneWidget);

View File

@ -16,12 +16,14 @@ void main() {
await tester.tapAt(tester.getCenter(find.byType(Slider)));
await tester.pumpAndSettle();
final MainWidgetState state = tester.state<MainWidgetState>(find.byType(MainWidget));
final MainWidgetState state =
tester.state<MainWidgetState>(find.byType(MainWidget));
expect(state.currentSliderValue, 60);
});
testWidgets('slider semantics wrapper exists', (WidgetTester tester) async {
await pumpsUseCase(tester, SliderUseCase());
final Finder semanticsWidget = find.bySemanticsLabel('Accessibility Test Slider');
final Finder semanticsWidget =
find.bySemanticsLabel('Accessibility Test Slider');
expect(semanticsWidget, findsOneWidget);
});
}

View File

@ -9,7 +9,7 @@ import 'test_utils.dart';
void main() {
testWidgets('snack bar can run', (WidgetTester tester) async {
await pumpsUseCase(tester, SnackBarUseCase());
await pumpsUseCase(tester, SnackBarUseCase());
const String snackBarText = 'Awesome Snackbar!';
expect(find.text(snackBarText), findsNothing);
await tester.tap(find.text('Show Snackbar'));

View File

@ -14,7 +14,8 @@ void main() {
expect(find.text('Action Disabled'), findsOneWidget);
});
testWidgets('text button increments correctly when clicked', (WidgetTester tester) async {
testWidgets('text button increments correctly when clicked',
(WidgetTester tester) async {
await pumpsUseCase(tester, TextButtonUseCase());
expect(find.text('Action'), findsOneWidget);

View File

@ -31,7 +31,8 @@ void main() {
}
});
testWidgets('text field passwords do not have hint text', (WidgetTester tester) async {
testWidgets('text field passwords do not have hint text',
(WidgetTester tester) async {
await pumpsUseCase(tester, TextFieldPasswordUseCase());
expect(find.byType(TextField), findsExactly(2));
@ -40,7 +41,6 @@ void main() {
final Finder finder = find.byKey(const Key('enabled password'));
final TextField textField = tester.widget<TextField>(finder);
expect(textField.decoration?.hintText, isNull);
}
// Test the disabled password

View File

@ -31,7 +31,8 @@ void main() {
}
});
testWidgets('font size increase does not ellipsize hint text', (WidgetTester tester) async {
testWidgets('font size increase does not ellipsize hint text',
(WidgetTester tester) async {
await pumpsUseCase(tester, TextFieldUseCase());
await tester.pumpWidget(MaterialApp(
home: MediaQuery.withClampedTextScaling(
@ -59,7 +60,8 @@ void main() {
await pumpsUseCase(tester, TextFieldUseCase());
const String textFieldLabel = 'Input field with suffix @gmail.com';
final Finder semanticsWidgets = find.bySemanticsLabel(RegExp(textFieldLabel));
final Finder semanticsWidgets =
find.bySemanticsLabel(RegExp(textFieldLabel));
expect(semanticsWidgets, findsExactly(2));
});
}