Add tests for scaffold messenger state (#152735)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/material/scaffold/scaffold_messenger_state.show_snack_bar.0.dart` - `examples/api/lib/material/scaffold/scaffold_messenger_state.show_material_banner.0.dart`
This commit is contained in:
parent
5c5b3c5796
commit
b7997cba54
@ -320,8 +320,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'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_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',
|
||||
'examples/api/test/material/app_bar/sliver_app_bar.3_test.dart',
|
||||
'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart',
|
||||
|
@ -0,0 +1,25 @@
|
||||
// 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_messenger_state.show_material_banner.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing the button should show a material banner', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowMaterialBannerExampleApp(),
|
||||
);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessengerState Sample'), findsOne);
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Show MaterialBanner'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.widgetWithText(MaterialBanner, 'This is a MaterialBanner'), findsOne);
|
||||
expect(
|
||||
find.descendant(of: find.byType(MaterialBanner), matching: find.widgetWithText(TextButton, 'DISMISS')),
|
||||
findsOne,
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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_messenger_state.show_snack_bar.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing the button should display a snack bar', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowSnackBarExampleApp(),
|
||||
);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessengerState Sample'), findsOne);
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Show SnackBar'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.widgetWithText(SnackBar, 'A SnackBar has been shown.'), findsOne);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user