verifyLeaks method
- Leaks leaks,
- LeakTesting settings, {
- required String testDescription,
Verifies leaks
contain expected leaks for the test.
settings
is used to determine:
- if some leaks should be ignored
- which diagnostics should be collected
testDescription
is used in description for the failed expectations.
Implementation
void verifyLeaks(Leaks leaks, LeakTesting settings,
{required String testDescription}) {
final expectedContextKeys = <String>[
if (settings.leakDiagnosticConfig.collectStackTraceOnStart)
ContextKeys.startCallstack,
];
_verifyLeakList(
testDescription,
LeakType.notDisposed,
leaks,
ignore: settings.ignore || settings.ignoredLeaks.notDisposed.ignoreAll,
expectedCount: notDisposedTotal -
(settings.ignoredLeaks.createdByTestHelpers
? notDisposedInHelpers
: 0),
expectedContextKeys: expectedContextKeys,
);
// Add diagnostics that is relevant for notGCed only.
if (settings.leakDiagnosticConfig.collectRetainingPathForNotGCed) {
expectedContextKeys.add(ContextKeys.retainingPath);
}
if (settings.leakDiagnosticConfig.collectStackTraceOnDisposal) {
expectedContextKeys.add(ContextKeys.disposalCallstack);
}
_verifyLeakList(
testDescription,
LeakType.notGCed,
leaks,
ignore: settings.ignore ||
settings.ignoredLeaks.experimentalNotGCed.ignoreAll,
expectedCount: notGCedTotal -
(settings.ignoredLeaks.createdByTestHelpers ? notGCedInHelpers : 0),
expectedContextKeys: expectedContextKeys,
);
}