|
| 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/widgets/implicit_animations/animated_padding.0.dart' |
| 7 | + as example; |
| 8 | +import 'package:flutter_test/flutter_test.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + testWidgets( |
| 12 | + 'AnimatedPadding animates on ElevatedButton tap', |
| 13 | + (WidgetTester tester) async { |
| 14 | + await tester.pumpWidget( |
| 15 | + const example.AnimatedPaddingExampleApp(), |
| 16 | + ); |
| 17 | + |
| 18 | + Padding padding = tester.widget( |
| 19 | + find.descendant( |
| 20 | + of: find.byType(AnimatedPadding), |
| 21 | + matching: find.byType(Padding), |
| 22 | + ), |
| 23 | + ); |
| 24 | + expect(padding.padding, equals(EdgeInsets.zero)); |
| 25 | + |
| 26 | + await tester.tap(find.byType(ElevatedButton)); |
| 27 | + await tester.pump(); |
| 28 | + |
| 29 | + padding = tester.widget( |
| 30 | + find.descendant( |
| 31 | + of: find.byType(AnimatedPadding), |
| 32 | + matching: find.byType(Padding), |
| 33 | + ), |
| 34 | + ); |
| 35 | + expect(padding.padding, equals(EdgeInsets.zero)); |
| 36 | + |
| 37 | + // Advance animation to the end by the 2-second duration specified in |
| 38 | + // the example app. |
| 39 | + await tester.pump(const Duration(seconds: 2)); |
| 40 | + |
| 41 | + padding = tester.widget( |
| 42 | + find.descendant( |
| 43 | + of: find.byType(AnimatedPadding), |
| 44 | + matching: find.byType(Padding), |
| 45 | + ), |
| 46 | + ); |
| 47 | + expect(padding.padding, equals(const EdgeInsets.all(100.0))); |
| 48 | + }, |
| 49 | + ); |
| 50 | +} |
0 commit comments