fade_transition_test.dart 1.11 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('FadeTransition', (WidgetTester tester) async {
    final DebugPrintCallback oldPrint = debugPrint;
    final List<String> log = <String>[];
13 14
    debugPrint = (String? message, { int? wrapWidth }) {
      log.add(message!);
15 16
    };
    debugPrintBuildScope = true;
17
    final AnimationController controller = AnimationController(
18 19 20
      vsync: const TestVSync(),
      duration: const Duration(seconds: 2),
    );
21
    await tester.pumpWidget(FadeTransition(
22 23 24 25 26 27 28 29 30 31 32 33 34 35
      opacity: controller,
      child: const Placeholder(),
    ));
    expect(log, hasLength(2));
    expect(log.last, 'buildScope finished');
    await tester.pump();
    expect(log, hasLength(2));
    controller.forward();
    await tester.pumpAndSettle();
    expect(log, hasLength(2));
    debugPrint = oldPrint;
    debugPrintBuildScope = false;
  });
}