mirror of
https://github.com/flutter/flutter
synced 2024-09-28 20:44:26 +00:00
This reverts commit 70e9b4185e
.
Relands https://github.com/flutter/flutter/pull/150481
Contributes to https://github.com/flutter/flutter/issues/130459
It adds a test for
- `examples/api/lib/material/text_form_field/text_form_field.1.dart`
This commit is contained in:
parent
47689616a9
commit
93c14565f0
|
@ -325,7 +325,6 @@ final Set<String> _knownMissingTests = <String>{
|
|||
'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart',
|
||||
'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart',
|
||||
'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart',
|
||||
'examples/api/test/material/text_form_field/text_form_field.1_test.dart',
|
||||
'examples/api/test/material/scrollbar/scrollbar.1_test.dart',
|
||||
'examples/api/test/material/search_anchor/search_anchor.0_test.dart',
|
||||
'examples/api/test/material/search_anchor/search_anchor.1_test.dart',
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
// 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/material/text_form_field/text_form_field.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing space should focus the next field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.TextFormFieldExampleApp());
|
||||
final Finder textFormField = find.byType(TextFormField);
|
||||
|
||||
expect(textFormField, findsExactly(5));
|
||||
|
||||
final Finder editableText = find.byType(EditableText);
|
||||
expect(editableText, findsExactly(5));
|
||||
|
||||
List<bool> getFocuses() {
|
||||
return editableText.evaluate()
|
||||
.map((Element finderResult) => (finderResult.widget as EditableText).focusNode.hasFocus)
|
||||
.toList();
|
||||
}
|
||||
|
||||
expect(getFocuses(), const <bool>[false, false, false, false, false]);
|
||||
|
||||
await tester.tap(textFormField.first);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[true, false, false, false, false]);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[false, true, false, false, false]);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[false, false, true, false, false]);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[false, false, false, true, false]);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[false, false, false, false, true]);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pump();
|
||||
|
||||
expect(getFocuses(), const <bool>[true, false, false, false, false]);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue