mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Rework on the text button use case to pass [b/347102786](https://b.corp.google.com/347102786), After talking with the tester, it seems like there isn't an issue with the A11y of the text button, rather just how the test case is set up. In order for the text case to pass, there needs to be real time feedback of an action that is done by pressing the text button (think of a dialog popup, or form submission notification). So I rewrote the test case to mimic a simple form with a submit button that once submitted, will let the user know it is submitted with a snack bar notification. https://screencast.googleplex.com/cast/NTM0ODc1NDIxMDE2MDY0MHwzYWI4MTZhMS1hMA
38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
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:a11y_assessments/use_cases/text_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'test_utils.dart';
|
|
|
|
void main() {
|
|
testWidgets('text button can run', (WidgetTester tester) async {
|
|
await pumpsUseCase(tester, TextButtonUseCase());
|
|
expect(find.text('Submit'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('submit causes snackbar to show', (WidgetTester tester) async {
|
|
await pumpsUseCase(tester, TextButtonUseCase());
|
|
final Finder textFormField = find.byType(TextFormField);
|
|
final Finder submitButton = find.text('Submit');
|
|
|
|
// Enter text in field and submit.
|
|
await tester.enterText(textFormField, 'test text');
|
|
await tester.tap(submitButton);
|
|
await tester.pump();
|
|
|
|
// Verify that the snackbar is visible.
|
|
expect(find.text('Form submitted'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('text button demo page has one h1 tag', (WidgetTester tester) async {
|
|
await pumpsUseCase(tester, TextButtonUseCase());
|
|
final Finder findHeadingLevelOnes = find.bySemanticsLabel('TextButton Demo');
|
|
await tester.pumpAndSettle();
|
|
expect(findHeadingLevelOnes, findsOne);
|
|
});
|
|
}
|