screen-locker/stronglift_replacement/workout_app/test/main_lifecycle_test.dart
Krzysztof kuhy Rudnicki 5f2925a550 Move workout_app to Flutter 3.50 material_ui
Flutter 3.50 deprecates package:flutter/material.dart, which made
flutter-analyze report 27 deprecated_member_use infos and blocked the
gate. workout_app now imports material_ui 1.11.0, with crdt_sync_dart
0.14.1 and sync_settings_ui 0.8.2 (both on material_ui).

material_ui's MaterialApp ships its own MaterialLocalizations, so a
package that still calls the framework showDialog threw a null check.
WorkoutApp now adds the framework delegate, and a widget test opens a
material_ui and a framework dialog through the real app root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:54:33 +01:00

44 lines
1.3 KiB
Dart

// The lifecycle observer that starts and stops the phone's HTTP socket.
//
// Linux returns early because main() never starts the socket there, so a
// resume must not start one behind the lock screen's back.
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:workout_app/main.dart';
import 'package:workout_app/services/storage_service.dart';
import 'fake_secure_storage.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
setUpAll(() {
// The widget-test host has no Android sqflite plugin; the FFI factory
// drives the same schema, as everywhere else in this suite.
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
});
setUp(() async {
StorageService.resetForTesting();
await StorageService.init();
installFakeSecureStorage();
});
testWidgets('every lifecycle transition is handled without throwing', (
tester,
) async {
await tester.pumpWidget(const WorkoutApp());
await tester.pump();
// Drives didChangeAppLifecycleState for each state the switch names.
for (final state in AppLifecycleState.values) {
tester.binding.handleAppLifecycleStateChanged(state);
await tester.pump();
}
expect(tester.takeException(), isNull);
});
}