| 1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import 'package:flutter/material.dart'; |
| 6 | import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.0.dart' |
| 7 | as example; |
| 8 | import 'package:flutter_test/flutter_test.dart'; |
| 9 | |
| 10 | void main() { |
| 11 | testWidgets('BottomSheet can be opened and closed' , (WidgetTester tester) async { |
| 12 | const String titleText = 'Modal BottomSheet' ; |
| 13 | const String closeText = 'Close BottomSheet' ; |
| 14 | |
| 15 | await tester.pumpWidget(const example.BottomSheetApp()); |
| 16 | |
| 17 | expect(find.text(titleText), findsNothing); |
| 18 | expect(find.text(closeText), findsNothing); |
| 19 | |
| 20 | // Open the bottom sheet. |
| 21 | await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet' )); |
| 22 | await tester.pumpAndSettle(); |
| 23 | |
| 24 | // Verify that the bottom sheet is open. |
| 25 | expect(find.text(titleText), findsOneWidget); |
| 26 | expect(find.text(closeText), findsOneWidget); |
| 27 | }); |
| 28 | } |
| 29 | |