flutter_test_config.dart 1.51 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
import 'dart:async';

import 'package:flutter/rendering.dart';
8
import 'package:flutter_test/flutter_test.dart';
9
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
10

11 12 13
import '_goldens_io.dart'
  if (dart.library.html) '_goldens_web.dart' as flutter_goldens;

14 15 16
/// Test configuration for each test library in this directory.
///
/// See https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html.
17
Future<void> testExecutable(FutureOr<void> Function() testMain) {
18 19 20 21
  // Enable checks because there are many implementations of [RenderBox] in this
  // package can benefit from the additional validations.
  debugCheckIntrinsicSizes = true;

22 23 24 25
  // Make tap() et al fail if the given finder specifies a widget that would not
  // receive the event.
  WidgetController.hitTestWarningShouldBeFatal = true;

26
  LeakTracking.warnForUnsupportedPlatforms = false;
27 28 29

  // TODO(polina-c): clean up leaks and stop ignoring them.
  // https://github.com/flutter/flutter/issues/137311
30
  // Leak tracking is off by default. To temporary enable it add `.withTrackedAll()` after `settings`.
31 32 33 34
  LeakTesting.settings = LeakTesting
    .settings
    .withIgnored(
      allNotGCed: true,
35 36 37
      notDisposed: <String, int?>{
        'OverlayEntry': null,
      },
38
    );
39

40
  // Enable golden file testing using Skia Gold.
41 42
  return flutter_goldens.testExecutable(testMain);
}