34 lines
1.1 KiB
Dart
34 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshport_lab/features/detail_pages.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'iOS detail polling pauses when hidden and resumes on return',
|
|
(tester) async {
|
|
final binding = tester.binding;
|
|
binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
|
var builds = 0;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: LiveDetailPage(title: '详情', builder: () => Text('${++builds}')),
|
|
),
|
|
);
|
|
final initial = builds;
|
|
await tester.pump(const Duration(seconds: 2));
|
|
expect(builds, initial + 1);
|
|
|
|
binding.handleAppLifecycleStateChanged(AppLifecycleState.hidden);
|
|
final beforeHidden = builds;
|
|
await tester.pump(const Duration(seconds: 10));
|
|
expect(builds, beforeHidden);
|
|
|
|
binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
|
await tester.pump(const Duration(seconds: 2));
|
|
expect(builds, beforeHidden + 1);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
},
|
|
variant: const TargetPlatformVariant({TargetPlatform.iOS}),
|
|
);
|
|
}
|