Write Tests for API Example of form.0.dart
(#142635)
Write Tests for API Example of `form.0.dart`. Part of #130459
This commit is contained in:
parent
05cd4fd042
commit
10e4f26868
@ -406,7 +406,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/drag_target/draggable.0_test.dart',
|
||||
'examples/api/test/widgets/shared_app_data/shared_app_data.1_test.dart',
|
||||
'examples/api/test/widgets/shared_app_data/shared_app_data.0_test.dart',
|
||||
'examples/api/test/widgets/form/form.0_test.dart',
|
||||
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view_state.0_test.dart',
|
||||
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.2_test.dart',
|
||||
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart',
|
||||
|
34
examples/api/test/widgets/form/form.0_test.dart
Normal file
34
examples/api/test/widgets/form/form.0_test.dart
Normal file
@ -0,0 +1,34 @@
|
||||
// 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_api_samples/widgets/form/form.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Form Smoke Test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.FormExampleApp(),
|
||||
);
|
||||
expect(find.widgetWithText(AppBar, 'Form Sample'), findsOneWidget);
|
||||
|
||||
final Finder textField = find.byType(TextField);
|
||||
final Finder button = find.byType(ElevatedButton);
|
||||
final TextField textFieldWidget = tester.widget<TextField>(textField);
|
||||
|
||||
expect(textField, findsOneWidget);
|
||||
expect(button, findsOneWidget);
|
||||
|
||||
expect(textFieldWidget.controller?.text, '');
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Please enter some text'), findsOneWidget);
|
||||
|
||||
await tester.enterText(textField, 'Hello World');
|
||||
expect(textFieldWidget.controller?.text, 'Hello World');
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Please enter some text'), findsNothing);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user