File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
examples/api/test/widgets/focus_traversal Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,6 @@ final Set<String> _knownMissingTests = <String>{
355
355
'examples/api/test/widgets/scroll_position/scroll_metrics_notification.0_test.dart' ,
356
356
'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart' ,
357
357
'examples/api/test/widgets/animated_list/animated_list.0_test.dart' ,
358
- 'examples/api/test/widgets/focus_traversal/focus_traversal_group.0_test.dart' ,
359
358
'examples/api/test/widgets/focus_traversal/ordered_traversal_policy.0_test.dart' ,
360
359
'examples/api/test/widgets/image/image.frame_builder.0_test.dart' ,
361
360
'examples/api/test/widgets/image/image.loading_builder.0_test.dart' ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Flutter Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import 'package:flutter/material.dart' ;
6
+ import 'package:flutter/services.dart' ;
7
+ import 'package:flutter_api_samples/widgets/focus_traversal/focus_traversal_group.0.dart' as example;
8
+ import 'package:flutter_test/flutter_test.dart' ;
9
+
10
+ void main () {
11
+ bool hasFocus (WidgetTester tester, String text) {
12
+ return Focus .of (tester.element (find.text (text))).hasPrimaryFocus;
13
+ }
14
+
15
+ testWidgets ('The focus updates should follow the focus traversal groups policy' , (WidgetTester tester) async {
16
+ await tester.pumpWidget (
17
+ const example.FocusTraversalGroupExampleApp (),
18
+ );
19
+
20
+ // Set the focus to the first button.
21
+ Focus .of (tester.element (find.text ('num: 0' ))).requestFocus ();
22
+ await tester.pump ();
23
+
24
+ expect (hasFocus (tester, 'num: 0' ), isTrue);
25
+
26
+ const List <String > focusOrder = < String > [
27
+ 'num: 1' ,
28
+ 'num: 2' ,
29
+ 'String: A' ,
30
+ 'String: B' ,
31
+ 'String: C' ,
32
+ 'ignored num: 3' ,
33
+ 'ignored num: 2' ,
34
+ 'ignored num: 1' ,
35
+ 'num: 0' ,
36
+ ];
37
+
38
+ for (final String text in focusOrder) {
39
+ await tester.sendKeyEvent (LogicalKeyboardKey .tab);
40
+ await tester.pump ();
41
+
42
+ expect (hasFocus (tester, text), isTrue);
43
+ }
44
+ });
45
+ }
You can’t perform that action at this time.
0 commit comments