fade_transition_test.dart 1.21 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
// 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';
8
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
9 10

void main() {
11
  testWidgetsWithLeakTracking('FadeTransition', (WidgetTester tester) async {
12 13
    final DebugPrintCallback oldPrint = debugPrint;
    final List<String> log = <String>[];
14 15
    debugPrint = (String? message, { int? wrapWidth }) {
      log.add(message!);
16 17
    };
    debugPrintBuildScope = true;
18
    final AnimationController controller = AnimationController(
19 20 21
      vsync: const TestVSync(),
      duration: const Duration(seconds: 2),
    );
22
    await tester.pumpWidget(FadeTransition(
23 24 25 26 27 28 29 30 31 32 33 34 35 36
      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;
  });
}