[text_input] introduce TextInputControl (#76072)

Allows the creation of virtual in-app keyboards written in Flutter.  Especially useful for embedded environments.
This commit is contained in:
J-P Nurmi
2022-10-05 00:23:12 +02:00
committed by GitHub
parent 208056f63e
commit 2fdfa29e08
8 changed files with 907 additions and 88 deletions

View File

@@ -0,0 +1,40 @@
// 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/services/text_input/text_input_control.0.dart'
as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Enter text using the VKB', (WidgetTester tester) async {
await tester.pumpWidget(const example.MyApp());
await tester.pumpAndSettle();
await tester.tap(find.descendant(
of: find.byType(example.MyVirtualKeyboard),
matching: find.widgetWithText(ElevatedButton, 'A'),
));
await tester.pumpAndSettle();
expect(find.widgetWithText(TextField, 'A'), findsOneWidget);
await tester.tap(find.descendant(
of: find.byType(example.MyVirtualKeyboard),
matching: find.widgetWithText(ElevatedButton, 'B'),
));
await tester.pumpAndSettle();
expect(find.widgetWithText(TextField, 'AB'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
await tester.pumpAndSettle();
await tester.tap(find.descendant(
of: find.byType(example.MyVirtualKeyboard),
matching: find.widgetWithText(ElevatedButton, 'C'),
));
await tester.pumpAndSettle();
expect(find.widgetWithText(TextField, 'ACB'), findsOneWidget);
});
}