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

Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/material/scaffold/scaffold_messenger.0.dart` - `examples/api/lib/material/scaffold/scaffold_messenger.of.0.dart` - `examples/api/lib/material/scaffold/scaffold_messenger.of.1.dart`
32 lines
1.1 KiB
Dart
32 lines
1.1 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:flutter/material.dart';
|
|
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger.of.1.dart' as example;
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('A snack bar is displayed after 10 taps', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const example.OfExampleApp(),
|
|
);
|
|
|
|
expect(find.widgetWithText(AppBar, 'ScaffoldMessenger Demo'), findsOne);
|
|
expect(find.text('You have pushed the button this many times:'), findsOne);
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
await tester.tap(find.byType(FloatingActionButton));
|
|
await tester.pump();
|
|
expect(find.text('${i + 1}'), findsOne);
|
|
}
|
|
expect(find.byType(SnackBar), findsNothing);
|
|
|
|
await tester.tap(find.byType(FloatingActionButton));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('10'), findsOne);
|
|
|
|
expect(find.widgetWithText(SnackBar, 'A multiple of ten!'), findsOne);
|
|
});
|
|
}
|