flutter/examples/api/test/material/snack_bar/snack_bar.0_test.dart
derdilla aaa4d336f6
Test snack bar examples (#147774)
Adds tests to the last two Snack Bar examples as part of #130459. Makes the [last example](https://api.flutter.dev/flutter/material/SnackBar-class.html#material.SnackBar.3) more usable through the use of standard widgets and visual hierarchy. Constraints on options that are not required by the SnackBar contract have been removed (Overflow threshold works on fixed SnackBars).
2024-05-23 18:54:11 +00:00

23 lines
892 B
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/material/snack_bar/snack_bar.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Clicking on Button shows a SnackBar', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SnackBarExampleApp(),
);
expect(find.widgetWithText(AppBar, 'SnackBar Sample'), findsOneWidget);
expect(find.widgetWithText(ElevatedButton, 'Show Snackbar'), findsOneWidget);
await tester.tap(find.widgetWithText(ElevatedButton, 'Show Snackbar'));
await tester.pump();
expect(find.text('Awesome Snackbar!'), findsOneWidget);
expect(find.text('Action'), findsOneWidget);
});
}