Reverts "Re-land integrate testWidgets with leak tracking." (#140926)
Reverts flutter/flutter#140521 Initiated by: zanderso This change reverts the following previous change: Original Description: Original PR: https://github.com/flutter/flutter/pull/138057 Revert: https://github.com/flutter/flutter/pull/140502 Issue: https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_android%20flutter_test_performance/12787/overview Exception: flutter test rendered unexpected output (1 bad lines) Explanation: leak tracker adds tear down even when there is no leak tracking, because at the moment of adding tear down it is unclear if leak tracking will be used for some tests. Fix: add enabling flag for leak tracker and make creation of tear down conditional. Prerequisites:
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class LeakTrackedClass {
|
||||
LeakTrackedClass() {
|
||||
LeakTracking.dispatchObjectCreated(
|
||||
library: library,
|
||||
className: '$LeakTrackedClass',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
|
||||
static const String library = 'package:my_package/lib/src/my_lib.dart';
|
||||
|
||||
void dispose() {
|
||||
LeakTracking.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
}
|
||||
|
||||
final List<LeakTrackedClass> _notGCedObjects = <LeakTrackedClass>[];
|
||||
|
||||
class LeakingClass {
|
||||
LeakingClass() {
|
||||
_notGCedObjects.add(LeakTrackedClass()..dispose());
|
||||
}
|
||||
}
|
||||
|
||||
class StatelessLeakingWidget extends StatelessWidget {
|
||||
StatelessLeakingWidget({
|
||||
super.key,
|
||||
this.notGCed = true,
|
||||
this.notDisposed = true,
|
||||
}) {
|
||||
if (notGCed) {
|
||||
_notGCedObjects.add(LeakTrackedClass()..dispose());
|
||||
}
|
||||
if (notDisposed) {
|
||||
// ignore: unused_local_variable, it is unused intentionally, to illustrate not disposed object.
|
||||
final LeakTrackedClass notDisposedObject = LeakTrackedClass();
|
||||
}
|
||||
}
|
||||
|
||||
final bool notGCed;
|
||||
final bool notDisposed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user