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_icon.0.dart' as example;
7import 'package:flutter_test/flutter_test.dart';
8
9void main() {
10 testWidgets('AnimatedIcon animates', (WidgetTester tester) async {
11 await tester.pumpWidget(const example.AnimatedIconApp());
12
13 // Test the AnimatedIcon size.
14 final Size iconSize = tester.getSize(find.byType(AnimatedIcon));
15 expect(iconSize.width, 72.0);
16 expect(iconSize.height, 72.0);
17
18 // Check if AnimatedIcon is animating.
19 await tester.pump(const Duration(milliseconds: 500));
20 AnimatedIcon animatedIcon = tester.widget(find.byType(AnimatedIcon));
21 expect(animatedIcon.progress.value, 0.25);
22
23 // Check if animation is completed.
24 await tester.pump(const Duration(milliseconds: 1500));
25 animatedIcon = tester.widget(find.byType(AnimatedIcon));
26 expect(animatedIcon.progress.value, 1.0);
27 });
28}
29

Provided by KDAB

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