Revert "Integrate testWidgets with leak tracking. (#138057)" (#140502)

The PR is breaking the `flutter_test_performance` test and making the
tree red.
This commit is contained in:
Jim Graham
2023-12-21 03:44:58 -08:00
committed by GitHub
parent d746007fcd
commit 8407dd2d0e
4 changed files with 0 additions and 298 deletions

View File

@@ -4,7 +4,6 @@
import 'dart:async';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:meta/meta.dart';
import 'package:test_api/scaffolding.dart' show Timeout;
import 'package:test_api/src/backend/declarer.dart'; // ignore: implementation_imports
@@ -164,7 +163,6 @@ void test(
Map<String, dynamic>? onPlatform,
int? retry,
}) {
_configureTearDownForTestFile();
_declarer.test(
description.toString(),
body,
@@ -188,7 +186,6 @@ void test(
/// of running the group's tests.
@isTestGroup
void group(Object description, void Function() body, { dynamic skip, int? retry }) {
_configureTearDownForTestFile();
_declarer.group(description.toString(), body, skip: skip, retry: retry);
}
@@ -204,7 +201,6 @@ void group(Object description, void Function() body, { dynamic skip, int? retry
/// Each callback at the top level or in a given group will be run in the order
/// they were declared.
void setUp(dynamic Function() body) {
_configureTearDownForTestFile();
_declarer.setUp(body);
}
@@ -222,7 +218,6 @@ void setUp(dynamic Function() body) {
///
/// See also [addTearDown], which adds tear-downs to a running test.
void tearDown(dynamic Function() body) {
_configureTearDownForTestFile();
_declarer.tearDown(body);
}
@@ -240,7 +235,6 @@ void tearDown(dynamic Function() body) {
/// prefer [setUp], and only use [setUpAll] if the callback is prohibitively
/// slow.
void setUpAll(dynamic Function() body) {
_configureTearDownForTestFile();
_declarer.setUpAll(body);
}
@@ -256,27 +250,9 @@ void setUpAll(dynamic Function() body) {
/// prefer [tearDown], and only use [tearDownAll] if the callback is
/// prohibitively slow.
void tearDownAll(dynamic Function() body) {
_configureTearDownForTestFile();
_declarer.tearDownAll(body);
}
bool _isTearDownForTestFileConfigured = false;
/// Configures `tearDownAll` after all user defined `tearDownAll` in the test file.
///
/// This function should be invoked in all functions, that may be invoked by user in the test file,
/// to be invoked before any other `tearDownAll`.
void _configureTearDownForTestFile() {
if (_isTearDownForTestFileConfigured) {
return;
}
_declarer.tearDownAll(_tearDownForTestFile);
_isTearDownForTestFileConfigured = true;
}
/// Tear down that should happen after all user defined tear down.
Future<void> _tearDownForTestFile() async {
await maybeTearDownLeakTrackingForAll();
}
/// A reporter that prints each test on its own line.
///

View File

@@ -9,7 +9,6 @@ import 'package:flutter/material.dart' show Tooltip;
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:matcher/expect.dart' as matcher_expect;
import 'package:meta/meta.dart';
import 'package:test_api/scaffolding.dart' as test_package;
@@ -117,18 +116,6 @@ E? _lastWhereOrNull<E>(Iterable<E> list, bool Function(E) test) {
/// If the [tags] are passed, they declare user-defined tags that are implemented by
/// the `test` package.
///
/// The argument [experimentalLeakTesting] is experimental and is not recommended
/// for use outside of the Flutter framework.
/// When [experimentalLeakTesting] is set, it is used to leak track objects created
/// during test execution.
/// Otherwise [LeakTesting.settings] is used.
/// Adjust [LeakTesting.settings] in flutter_test_config.dart
/// (see https://github.com/flutter/flutter/blob/master/packages/flutter_test/lib/flutter_test.dart)
/// for the entire package or folder, or in the test's main for a test file
/// (don't use [setUp] or [setUpAll]).
/// To turn off leak tracking just for one test, set [experimentalLeakTesting] to
/// `LeakTrackingForTests.ignore()`.
///
/// ## Sample code
///
/// ```dart
@@ -148,7 +135,6 @@ void testWidgets(
TestVariant<Object?> variant = const DefaultTestVariant(),
dynamic tags,
int? retry,
LeakTesting? experimentalLeakTesting,
}) {
assert(variant.values.isNotEmpty, 'There must be at least one value to test in the testing variant.');
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
@@ -179,11 +165,9 @@ void testWidgets(
Object? memento;
try {
memento = await variant.setUp(value);
maybeSetupLeakTrackingForTest(experimentalLeakTesting, combinedDescription);
await callback(tester);
} finally {
await variant.tearDown(value, memento);
maybeTearDownLeakTrackingForTest();
}
semanticsHandle?.dispose();
},