mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fixed leak and removed no-shuffle tag in ticker_test.dart (#88426)
This commit is contained in:
parent
04de2ed3d5
commit
86d7ec4548
@ -2,18 +2,19 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
|
||||
// dependencies have been fixed.
|
||||
// https://github.com/flutter/flutter/issues/85160
|
||||
// Fails with "flutter test --test-randomize-ordering-seed=4281596210"
|
||||
@Tags(<String>['no-shuffle'])
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> setAppLifeCycleState(AppLifecycleState state) async {
|
||||
final ByteData? message =
|
||||
const StringCodec().encodeMessage(state.toString());
|
||||
await ServicesBinding.instance!.defaultBinaryMessenger
|
||||
.handlePlatformMessage('flutter/lifecycle', message, (_) {});
|
||||
}
|
||||
|
||||
testWidgets('Ticker mute control test', (WidgetTester tester) async {
|
||||
int tickCount = 0;
|
||||
void handleTick(Duration duration) {
|
||||
@ -154,17 +155,18 @@ void main() {
|
||||
expect(ticker.isActive, isTrue);
|
||||
expect(tickCount, equals(0));
|
||||
|
||||
final ByteData? message = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
||||
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) { });
|
||||
setAppLifeCycleState(AppLifecycleState.paused);
|
||||
|
||||
expect(ticker.isTicking, isFalse);
|
||||
expect(ticker.isActive, isTrue);
|
||||
|
||||
ticker.stop();
|
||||
|
||||
setAppLifeCycleState(AppLifecycleState.resumed);
|
||||
});
|
||||
|
||||
testWidgets('Ticker can be created before application unpauses', (WidgetTester tester) async {
|
||||
final ByteData? pausedMessage = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
||||
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', pausedMessage, (_) { });
|
||||
setAppLifeCycleState(AppLifecycleState.paused);
|
||||
|
||||
int tickCount = 0;
|
||||
void handleTick(Duration duration) {
|
||||
@ -182,8 +184,7 @@ void main() {
|
||||
expect(tickCount, equals(0));
|
||||
expect(ticker.isTicking, isFalse);
|
||||
|
||||
final ByteData? resumedMessage = const StringCodec().encodeMessage('AppLifecycleState.resumed');
|
||||
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', resumedMessage, (_) { });
|
||||
setAppLifeCycleState(AppLifecycleState.resumed);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 10));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user