Unverified Commit 10e4f268 authored by Tirth's avatar Tirth Committed by GitHub

Write Tests for API Example of `form.0.dart` (#142635)

Write Tests for API Example of `form.0.dart`.

Part of #130459
parent 05cd4fd0
...@@ -406,7 +406,6 @@ final Set<String> _knownMissingTests = <String>{ ...@@ -406,7 +406,6 @@ final Set<String> _knownMissingTests = <String>{
'examples/api/test/widgets/drag_target/draggable.0_test.dart', '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.1_test.dart',
'examples/api/test/widgets/shared_app_data/shared_app_data.0_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_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.2_test.dart',
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart', 'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart',
......
// 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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment