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
5import 'package:flutter/material.dart';
6import 'package:flutter_api_samples/material/scaffold/scaffold.0.dart' as example;
7import 'package:flutter_test/flutter_test.dart';
8
9void main() {
10 testWidgets('The count should be incremented when the floating action button is tapped', (
11 WidgetTester tester,
12 ) 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
19 for (int i = 1; i <= 5; i++) {
20 await tester.tap(find.byType(FloatingActionButton));
21 await tester.pump();
22 expect(find.text('You have pressed the button $i times.'), findsOne);
23 }
24 });
25}
26

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com