Skip to content

Commit

Permalink
cover more tests with leak tracking (#134837)
Browse files Browse the repository at this point in the history
  • Loading branch information
derdilla authored Sep 20, 2023
1 parent 52ef9d8 commit 14b832a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/flutter/test/scheduler/ticker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
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() {
Future<void> setAppLifeCycleState(AppLifecycleState state) async {
Expand All @@ -15,7 +16,7 @@ void main() {
.handlePlatformMessage('flutter/lifecycle', message, (_) {});
}

testWidgets('Ticker mute control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker mute control test', (WidgetTester tester) async {
int tickCount = 0;
void handleTick(Duration duration) {
tickCount += 1;
Expand Down Expand Up @@ -97,7 +98,7 @@ void main() {
expect(ticker.isActive, isFalse);
});

testWidgets('Ticker control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker control test', (WidgetTester tester) async {
late Ticker ticker;

void testFunction() {
Expand All @@ -110,7 +111,7 @@ void main() {
expect(ticker.toString(debugIncludeStack: true), contains('testFunction'));
});

testWidgets('Ticker can be sped up with time dilation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker can be sped up with time dilation', (WidgetTester tester) async {
timeDilation = 0.5; // Move twice as fast.
late Duration lastDuration;
void handleTick(Duration duration) {
Expand All @@ -128,7 +129,7 @@ void main() {
timeDilation = 1.0; // restore time dilation, or it will affect other tests
});

testWidgets('Ticker can be slowed down with time dilation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker can be slowed down with time dilation', (WidgetTester tester) async {
timeDilation = 2.0; // Move half as fast.
late Duration lastDuration;
void handleTick(Duration duration) {
Expand All @@ -146,7 +147,7 @@ void main() {
timeDilation = 1.0; // restore time dilation, or it will affect other tests
});

testWidgets('Ticker stops ticking when application is paused', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker stops ticking when application is paused', (WidgetTester tester) async {
int tickCount = 0;
void handleTick(Duration duration) {
tickCount += 1;
Expand All @@ -169,7 +170,7 @@ void main() {
setAppLifeCycleState(AppLifecycleState.resumed);
});

testWidgets('Ticker can be created before application unpauses', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticker can be created before application unpauses', (WidgetTester tester) async {
setAppLifeCycleState(AppLifecycleState.paused);

int tickCount = 0;
Expand Down

0 comments on commit 14b832a

Please sign in to comment.