Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ffc04232
Unverified
Commit
ffc04232
authored
Oct 20, 2023
by
chunhtai
Committed by
GitHub
Oct 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds more a11y use cases (#136761)
parent
464e751a
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
459 additions
and
1 deletion
+459
-1
main.dart
dev/a11y_assessments/lib/main.dart
+15
-1
auto_complete.dart
dev/a11y_assessments/lib/use_cases/auto_complete.dart
+75
-0
badge.dart
dev/a11y_assessments/lib/use_cases/badge.dart
+49
-0
material_banner.dart
dev/a11y_assessments/lib/use_cases/material_banner.dart
+74
-0
navigation_bar.dart
dev/a11y_assessments/lib/use_cases/navigation_bar.dart
+79
-0
text_button.dart
dev/a11y_assessments/lib/use_cases/text_button.dart
+55
-0
use_cases.dart
dev/a11y_assessments/lib/use_cases/use_cases.dart
+10
-0
accessibility_guideline_test.dart
dev/a11y_assessments/test/accessibility_guideline_test.dart
+5
-0
auto_complete_test.dart
dev/a11y_assessments/test/auto_complete_test.dart
+19
-0
badge_test.dart
dev/a11y_assessments/test/badge_test.dart
+16
-0
material_banner_test.dart
dev/a11y_assessments/test/material_banner_test.dart
+23
-0
navigation_bar_test.dart
dev/a11y_assessments/test/navigation_bar_test.dart
+23
-0
text_button_test.dart
dev/a11y_assessments/test/text_button_test.dart
+16
-0
No files found.
dev/a11y_assessments/lib/main.dart
View file @
ffc04232
...
@@ -44,9 +44,22 @@ class App extends StatelessWidget {
...
@@ -44,9 +44,22 @@ class App extends StatelessWidget {
}
}
}
}
class
HomePage
extends
State
less
Widget
{
class
HomePage
extends
State
ful
Widget
{
const
HomePage
({
super
.
key
});
const
HomePage
({
super
.
key
});
@override
State
<
HomePage
>
createState
()
=>
HomePageState
();
}
class
HomePageState
extends
State
<
HomePage
>
{
final
ScrollController
scrollController
=
ScrollController
();
@override
void
dispose
()
{
scrollController
.
dispose
();
super
.
dispose
();
}
Widget
_buildUseCaseItem
(
int
index
,
UseCase
useCase
)
{
Widget
_buildUseCaseItem
(
int
index
,
UseCase
useCase
)
{
return
Padding
(
return
Padding
(
padding:
const
EdgeInsets
.
all
(
10
),
padding:
const
EdgeInsets
.
all
(
10
),
...
@@ -69,6 +82,7 @@ class HomePage extends StatelessWidget {
...
@@ -69,6 +82,7 @@ class HomePage extends StatelessWidget {
appBar:
AppBar
(
title:
const
Text
(
'Accessibility Assessments'
)),
appBar:
AppBar
(
title:
const
Text
(
'Accessibility Assessments'
)),
body:
Center
(
body:
Center
(
child:
ListView
(
child:
ListView
(
controller:
scrollController
,
children:
List
<
Widget
>.
generate
(
children:
List
<
Widget
>.
generate
(
useCases
.
length
,
useCases
.
length
,
(
int
index
)
=>
_buildUseCaseItem
(
index
,
useCases
[
index
]),
(
int
index
)
=>
_buildUseCaseItem
(
index
,
useCases
[
index
]),
...
...
dev/a11y_assessments/lib/use_cases/auto_complete.dart
0 → 100644
View file @
ffc04232
// 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
AutoCompleteUseCase
extends
UseCase
{
@override
String
get
name
=>
'AutoComplete'
;
@override
String
get
route
=>
'/auto-complete'
;
@override
Widget
build
(
BuildContext
context
)
=>
const
_MainWidget
();
}
class
_MainWidget
extends
StatefulWidget
{
const
_MainWidget
();
@override
State
<
_MainWidget
>
createState
()
=>
_MainWidgetState
();
}
class
_MainWidgetState
extends
State
<
_MainWidget
>
{
static
const
List
<
String
>
_kOptions
=
<
String
>[
'apple'
,
'banana'
,
'lemon'
,
];
static
Widget
_fieldViewBuilder
(
BuildContext
context
,
TextEditingController
textEditingController
,
FocusNode
focusNode
,
VoidCallback
onFieldSubmitted
)
{
return
TextFormField
(
focusNode:
focusNode
,
autofocus:
true
,
controller:
textEditingController
,
onFieldSubmitted:
(
String
value
)
{
onFieldSubmitted
();
},
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Theme
.
of
(
context
).
colorScheme
.
inversePrimary
,
title:
const
Text
(
'AutoComplete'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
'Type below to autocomplete the following possible results:
$_kOptions
.'
),
Autocomplete
<
String
>(
optionsBuilder:
(
TextEditingValue
textEditingValue
)
{
if
(
textEditingValue
.
text
==
''
)
{
return
const
Iterable
<
String
>.
empty
();
}
return
_kOptions
.
where
((
String
option
)
{
return
option
.
contains
(
textEditingValue
.
text
.
toLowerCase
());
});
},
fieldViewBuilder:
_fieldViewBuilder
,
),
],
),
),
);
}
}
dev/a11y_assessments/lib/use_cases/badge.dart
0 → 100644
View file @
ffc04232
// 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
BadgeUseCase
extends
UseCase
{
@override
String
get
name
=>
'Badge'
;
@override
String
get
route
=>
'/badge'
;
@override
Widget
build
(
BuildContext
context
)
=>
const
MainWidget
();
}
class
MainWidget
extends
StatefulWidget
{
const
MainWidget
({
super
.
key
});
@override
State
<
MainWidget
>
createState
()
=>
MainWidgetState
();
}
class
MainWidgetState
extends
State
<
MainWidget
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Theme
.
of
(
context
).
colorScheme
.
inversePrimary
,
title:
const
Text
(
'Badge'
),
),
body:
const
Center
(
child:
Badge
(
label:
Text
(
'5'
,
semanticsLabel:
'5 new messages'
,
style:
TextStyle
(
color:
Colors
.
white
),
),
backgroundColor:
Colors
.
green
,
child:
Icon
(
Icons
.
mail
,
semanticLabel:
'Messages'
),
),
),
);
}
}
dev/a11y_assessments/lib/use_cases/material_banner.dart
0 → 100644
View file @
ffc04232
// 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
MaterialBannerUseCase
extends
UseCase
{
@override
String
get
name
=>
'MaterialBanner'
;
@override
String
get
route
=>
'/material_banner'
;
@override
Widget
build
(
BuildContext
context
)
=>
const
MainWidget
();
}
class
MainWidget
extends
StatefulWidget
{
const
MainWidget
({
super
.
key
});
@override
State
<
MainWidget
>
createState
()
=>
MainWidgetState
();
}
class
MainWidgetState
extends
State
<
MainWidget
>
{
double
currentSliderValue
=
20
;
ScaffoldFeatureController
<
MaterialBanner
,
MaterialBannerClosedReason
>?
controller
;
@override
Widget
build
(
BuildContext
context
)
{
VoidCallback
?
onPress
;
if
(
controller
==
null
)
{
onPress
=
()
{
setState
(()
{
controller
=
ScaffoldMessenger
.
of
(
context
).
showMaterialBanner
(
MaterialBanner
(
padding:
const
EdgeInsets
.
all
(
20
),
content:
const
Text
(
'Hello, I am a Material Banner'
),
leading:
const
Icon
(
Icons
.
agriculture_outlined
),
backgroundColor:
Colors
.
green
,
actions:
<
Widget
>[
TextButton
(
onPressed:
()
{
controller
!.
close
();
setState
(()
{
controller
=
null
;
});
},
child:
const
Text
(
'DISMISS'
),
),
],
),
);
});
};
}
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Theme
.
of
(
context
).
colorScheme
.
inversePrimary
,
title:
const
Text
(
'MaterialBanner'
),
),
body:
Center
(
child:
ElevatedButton
(
autofocus:
true
,
onPressed:
onPress
,
child:
const
Text
(
'Show a MaterialBanner'
),
),
),
);
}
}
dev/a11y_assessments/lib/use_cases/navigation_bar.dart
0 → 100644
View file @
ffc04232
// 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
NavigationBarUseCase
extends
UseCase
{
@override
String
get
name
=>
'NavigationBar'
;
@override
String
get
route
=>
'/navigation-bar'
;
@override
Widget
build
(
BuildContext
context
)
=>
const
MainWidget
();
}
class
MainWidget
extends
StatefulWidget
{
const
MainWidget
({
super
.
key
});
@override
State
<
MainWidget
>
createState
()
=>
MainWidgetState
();
}
class
MainWidgetState
extends
State
<
MainWidget
>
{
int
currentPageIndex
=
0
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Theme
.
of
(
context
).
colorScheme
.
inversePrimary
,
title:
const
Text
(
'NavigationBar'
),
),
bottomNavigationBar:
NavigationBar
(
onDestinationSelected:
(
int
index
)
{
setState
(()
{
currentPageIndex
=
index
;
});
},
indicatorColor:
Colors
.
amber
[
800
],
selectedIndex:
currentPageIndex
,
destinations:
const
<
Widget
>[
NavigationDestination
(
selectedIcon:
Icon
(
Icons
.
home
),
icon:
Icon
(
Icons
.
home_outlined
),
label:
'Home'
,
),
NavigationDestination
(
icon:
Icon
(
Icons
.
business
),
label:
'Business'
,
),
NavigationDestination
(
selectedIcon:
Icon
(
Icons
.
school
),
icon:
Icon
(
Icons
.
school_outlined
),
label:
'School'
,
),
],
),
body:
<
Widget
>[
Container
(
alignment:
Alignment
.
center
,
child:
const
Text
(
'Page 1'
),
),
Container
(
alignment:
Alignment
.
center
,
child:
const
Text
(
'Page 2'
),
),
Container
(
alignment:
Alignment
.
center
,
child:
const
Text
(
'Page 3'
),
),
][
currentPageIndex
],
);
}
}
dev/a11y_assessments/lib/use_cases/text_button.dart
0 → 100644
View file @
ffc04232
// 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
TextButtonUseCase
extends
UseCase
{
@override
String
get
name
=>
'TextButton'
;
@override
String
get
route
=>
'/text-button'
;
@override
Widget
build
(
BuildContext
context
)
=>
const
MainWidget
();
}
class
MainWidget
extends
StatefulWidget
{
const
MainWidget
({
super
.
key
});
@override
State
<
MainWidget
>
createState
()
=>
MainWidgetState
();
}
class
MainWidgetState
extends
State
<
MainWidget
>
{
double
currentSliderValue
=
20
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Theme
.
of
(
context
).
colorScheme
.
inversePrimary
,
title:
const
Text
(
'TextButton'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
TextButton
(
onPressed:
()
{
},
child:
const
Text
(
'Text button'
),
),
const
TextButton
(
onPressed:
null
,
child:
Text
(
'Text button disabled'
),
),
],
),
),
);
}
}
dev/a11y_assessments/lib/use_cases/use_cases.dart
View file @
ffc04232
...
@@ -4,10 +4,15 @@
...
@@ -4,10 +4,15 @@
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'auto_complete.dart'
;
import
'badge.dart'
;
import
'check_box_list_tile.dart'
;
import
'check_box_list_tile.dart'
;
import
'date_picker.dart'
;
import
'date_picker.dart'
;
import
'dialog.dart'
;
import
'dialog.dart'
;
import
'material_banner.dart'
;
import
'navigation_bar.dart'
;
import
'slider.dart'
;
import
'slider.dart'
;
import
'text_button.dart'
;
import
'text_field.dart'
;
import
'text_field.dart'
;
import
'text_field_password.dart'
;
import
'text_field_password.dart'
;
...
@@ -24,4 +29,9 @@ final List<UseCase> useCases = <UseCase>[
...
@@ -24,4 +29,9 @@ final List<UseCase> useCases = <UseCase>[
TextFieldUseCase
(),
TextFieldUseCase
(),
TextFieldPasswordUseCase
(),
TextFieldPasswordUseCase
(),
DatePickerUseCase
(),
DatePickerUseCase
(),
AutoCompleteUseCase
(),
BadgeUseCase
(),
MaterialBannerUseCase
(),
NavigationBarUseCase
(),
TextButtonUseCase
(),
];
];
dev/a11y_assessments/test/accessibility_guideline_test.dart
View file @
ffc04232
...
@@ -11,6 +11,11 @@ void main() {
...
@@ -11,6 +11,11 @@ void main() {
for
(
final
UseCase
useCase
in
useCases
)
{
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
());
await
tester
.
pumpWidget
(
const
App
());
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
();
}
await
tester
.
tap
(
find
.
byKey
(
Key
(
useCase
.
name
)));
await
tester
.
tap
(
find
.
byKey
(
Key
(
useCase
.
name
)));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
...
dev/a11y_assessments/test/auto_complete_test.dart
0 → 100644
View file @
ffc04232
// 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/auto_complete.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
testWidgets
(
'auto complete can run'
,
(
WidgetTester
tester
)
async
{
await
pumpsUseCase
(
tester
,
AutoCompleteUseCase
());
await
tester
.
enterText
(
find
.
byType
(
TextFormField
),
'a'
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'apple'
),
findsOneWidget
);
});
}
dev/a11y_assessments/test/badge_test.dart
0 → 100644
View file @
ffc04232
// 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/badge.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
testWidgets
(
'badge can run'
,
(
WidgetTester
tester
)
async
{
await
pumpsUseCase
(
tester
,
BadgeUseCase
());
expect
(
find
.
semantics
.
byLabel
(
'5 new messages'
),
findsOne
);
expect
(
find
.
semantics
.
byLabel
(
'Messages'
),
findsOne
);
});
}
dev/a11y_assessments/test/material_banner_test.dart
0 → 100644
View file @
ffc04232
// 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/material_banner.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
testWidgets
(
'material banner can run'
,
(
WidgetTester
tester
)
async
{
await
pumpsUseCase
(
tester
,
MaterialBannerUseCase
());
expect
(
find
.
text
(
'Show a MaterialBanner'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Show a MaterialBanner'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Hello, I am a Material Banner'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'DISMISS'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Hello, I am a Material Banner'
),
findsNothing
);
});
}
dev/a11y_assessments/test/navigation_bar_test.dart
0 → 100644
View file @
ffc04232
// 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_bar.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
testWidgets
(
'navigation bar can run'
,
(
WidgetTester
tester
)
async
{
await
pumpsUseCase
(
tester
,
NavigationBarUseCase
());
expect
(
find
.
text
(
'Page 1'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Business'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Page 2'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'School'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Page 3'
),
findsOneWidget
);
});
}
dev/a11y_assessments/test/text_button_test.dart
0 → 100644
View file @
ffc04232
// 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/text_button.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
testWidgets
(
'text button can run'
,
(
WidgetTester
tester
)
async
{
await
pumpsUseCase
(
tester
,
TextButtonUseCase
());
expect
(
find
.
text
(
'Text button'
),
findsOneWidget
);
expect
(
find
.
text
(
'Text button disabled'
),
findsOneWidget
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment