Skip to content

Commit

Permalink
Cover some Services tests with leak tracing (#134381)
Browse files Browse the repository at this point in the history
  • Loading branch information
derdilla authored Sep 14, 2023
1 parent d2ff241 commit 5467363
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/flutter/test/services/asset_bundle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

class TestAssetBundle extends CachingAssetBundle {
Map<String, int> loadCallCount = <String, int>{};
Expand Down Expand Up @@ -135,7 +136,7 @@ void main() {
expect(await data, 1);
});

testWidgets('loadStructuredData handles exceptions correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('loadStructuredData handles exceptions correctly', (WidgetTester tester) async {
final TestAssetBundle bundle = TestAssetBundle();
try {
await bundle.loadStructuredData('AssetManifest.json', (String value) => Future<String>.error('what do they say?'));
Expand All @@ -145,7 +146,7 @@ void main() {
}
});

testWidgets('loadStructuredBinaryData handles exceptions correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('loadStructuredBinaryData handles exceptions correctly', (WidgetTester tester) async {
final TestAssetBundle bundle = TestAssetBundle();
try {
await bundle.loadStructuredBinaryData('AssetManifest.bin', (ByteData value) => Future<String>.error('buy more crystals'));
Expand Down
5 changes: 3 additions & 2 deletions packages/flutter/test/services/lifecycle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import 'dart:ui';

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

void main() {
testWidgets('initialLifecycleState is used to init state paused', (WidgetTester tester) async {
testWidgetsWithLeakTracking('initialLifecycleState is used to init state paused', (WidgetTester tester) async {
expect(ServicesBinding.instance.lifecycleState, isNull);
final TestWidgetsFlutterBinding binding = tester.binding;
binding.resetLifecycleState();
Expand All @@ -20,7 +21,7 @@ void main() {
// even though no lifecycle event was fired from the platform.
expect(binding.lifecycleState.toString(), equals('AppLifecycleState.paused'));
});
testWidgets('Handles all of the allowed states of AppLifecycleState', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Handles all of the allowed states of AppLifecycleState', (WidgetTester tester) async {
final TestWidgetsFlutterBinding binding = tester.binding;
for (final AppLifecycleState state in AppLifecycleState.values) {
binding.resetLifecycleState();
Expand Down

0 comments on commit 5467363

Please sign in to comment.