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/scaffold/scaffold.2.dart' as example; |
7 | import 'package:flutter_test/flutter_test.dart'; |
8 | |
9 | void main() { |
10 | testWidgets( |
11 | 'The count should be incremented when the centered floating action button is tapped', |
12 | (WidgetTester tester) async { |
13 | await tester.pumpWidget(const example.ScaffoldExampleApp()); |
14 | |
15 | expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne); |
16 | expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); |
17 | expect(find.text('You have pressed the button 0 times.'), findsOne); |
18 | expect(find.byType(BottomAppBar), findsOne); |
19 | expect(tester.getCenter(find.byType(FloatingActionButton)).dx, 400); |
20 | |
21 | for (int i = 1; i <= 5; i++) { |
22 | await tester.tap(find.byType(FloatingActionButton)); |
23 | await tester.pump(); |
24 | expect(find.text('You have pressed the button$i times.'), findsOne); |
25 | } |
26 | }, |
27 | ); |
28 | } |
29 |