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/animated_icon/animated_icons_data.0.dart' as example;
7import 'package:flutter_test/flutter_test.dart';
8
9void main() {
10 testWidgets('Show all the animated icons', (WidgetTester tester) async {
11 await tester.pumpWidget(const example.AnimatedIconApp());
12
13 // Check if the total number of AnimatedIcons matches the icons list.
14 expect(find.byType(AnimatedIcon, skipOffstage: false), findsNWidgets(example.iconsList.length));
15
16 // Test the AnimatedIcon size.
17 final Size iconSize = tester.getSize(find.byType(AnimatedIcon).first);
18 expect(iconSize.width, 72.0);
19 expect(iconSize.height, 72.0);
20
21 // Check if AnimatedIcon is animating.
22 await tester.pump(const Duration(milliseconds: 500));
23 AnimatedIcon animatedIcon = tester.widget(find.byType(AnimatedIcon).first);
24 expect(animatedIcon.progress.value, 0.25);
25
26 // Check if animation is completed.
27 await tester.pump(const Duration(milliseconds: 1500));
28 animatedIcon = tester.widget(find.byType(AnimatedIcon).first);
29 expect(animatedIcon.progress.value, 1.0);
30 });
31}
32

Provided by KDAB

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