mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add tests for ordered_traversal_group.0.dart (#152849)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart`
This commit is contained in:
parent
0397e890be
commit
ff3ad8290e
@ -343,7 +343,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/scroll_position/scroll_metrics_notification.0_test.dart',
|
||||
'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart',
|
||||
'examples/api/test/widgets/animated_list/animated_list.0_test.dart',
|
||||
'examples/api/test/widgets/focus_traversal/ordered_traversal_policy.0_test.dart',
|
||||
'examples/api/test/widgets/image/image.frame_builder.0_test.dart',
|
||||
'examples/api/test/widgets/image/image.loading_builder.0_test.dart',
|
||||
'examples/api/test/widgets/page_storage/page_storage.0_test.dart',
|
||||
|
@ -8,9 +8,9 @@ import 'package:flutter_api_samples/widgets/focus_traversal/focus_traversal_grou
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
bool hasFocus(WidgetTester tester, String text) {
|
||||
return Focus.of(tester.element(find.text(text))).hasPrimaryFocus;
|
||||
}
|
||||
bool hasFocus(WidgetTester tester, String text) {
|
||||
return Focus.of(tester.element(find.text(text))).hasPrimaryFocus;
|
||||
}
|
||||
|
||||
testWidgets('The focus updates should follow the focus traversal groups policy', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
|
@ -0,0 +1,38 @@
|
||||
// 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 'package:flutter/services.dart';
|
||||
import 'package:flutter_api_samples/widgets/focus_traversal/ordered_traversal_policy.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
bool hasFocus(WidgetTester tester, String text) {
|
||||
return Focus.of(tester.element(find.text(text))).hasPrimaryFocus;
|
||||
}
|
||||
|
||||
testWidgets('The focus updates should follow the focus traversal groups policy', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OrderedTraversalPolicyExampleApp(),
|
||||
);
|
||||
|
||||
expect(hasFocus(tester, 'One'), isTrue);
|
||||
|
||||
const List<String> focusOrder = <String>[
|
||||
'Two',
|
||||
'Three',
|
||||
'Four',
|
||||
'Five',
|
||||
'Six',
|
||||
'One',
|
||||
];
|
||||
|
||||
for (final String text in focusOrder) {
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.pump();
|
||||
|
||||
expect(hasFocus(tester, text), isTrue);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user