From 8818e60a653b1c1780bad23b3ece91cfdba6f3c0 Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Fri, 2 Aug 2024 22:40:09 +0800 Subject: [PATCH] Add test for scaffold_state.show_bottom_sheet.0.dart (#152731) Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/material/scaffold/scaffold_state.show_bottom_sheet.0.dart` --- dev/bots/check_code_samples.dart | 1 - ...affold_state.show_bottom_sheet.0_test.dart | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index 599e2a9a86..82a5ca876c 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -320,7 +320,6 @@ final Set _knownMissingTests = { 'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart', 'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart', 'examples/api/test/material/selection_area/selection_area.0_test.dart', - 'examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger_state.show_material_banner.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.0_test.dart', 'examples/api/test/material/app_bar/sliver_app_bar.2_test.dart', diff --git a/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart b/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart new file mode 100644 index 0000000000..c538a7942f --- /dev/null +++ b/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart @@ -0,0 +1,26 @@ +// 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/scaffold/scaffold_state.show_bottom_sheet.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The button should show a bottom sheet when pressed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShowBottomSheetExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'ScaffoldState Sample'), findsOne); + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(BottomSheet, 'BottomSheet'), findsOne); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Close BottomSheet')); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(BottomSheet, 'BottomSheet'), findsNothing); + }); +}