mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-11 14:07:41 +01:00
Pre-existing coverage gaps, unrelated to the manual-workout feature, blocking the 100% pre-push gate: - widget_test: exercise WorkoutApp's app-lifecycle handler (paused/detached/ resumed/inactive/hidden) via handleAppLifecycleStateChanged. - http_server_service: add a resetForTesting seam and test the bind-in-use SocketException swallow plus the /workout HTTP endpoint (no-data 404, data 200, unknown-path 404). coverage:ignore the /sdcard-file-read branch (only reachable on a real device). - backup_service: coverage:ignore the Android permission wrappers and the defensive readSyncToken catch. - main(): coverage:ignore the platform-channel app bootstrap. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PM3auNTifaVgcXWDizZrjH
48 lines
1.5 KiB
Dart
48 lines
1.5 KiB
Dart
import 'package:flutter/material.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/http_server_service.dart';
|
|
import 'package:workout_app/services/storage_service.dart';
|
|
|
|
void main() {
|
|
setUpAll(() {
|
|
sqfliteFfiInit();
|
|
databaseFactory = databaseFactoryFfi;
|
|
});
|
|
|
|
setUp(() async {
|
|
StorageService.resetForTesting();
|
|
await StorageService.init();
|
|
});
|
|
|
|
testWidgets('WorkoutApp renders HomeScreen', (tester) async {
|
|
await tester.runAsync(() async {
|
|
await tester.pumpWidget(const WorkoutApp());
|
|
await Future<void>.delayed(const Duration(milliseconds: 300));
|
|
});
|
|
await tester.pump();
|
|
expect(find.text('Workout Tracker'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('app-lifecycle changes drive the HTTP server', (tester) async {
|
|
await tester.runAsync(() async {
|
|
await tester.pumpWidget(const WorkoutApp());
|
|
await Future<void>.delayed(const Duration(milliseconds: 100));
|
|
// A valid forward transition path that visits every handled state.
|
|
for (final state in const [
|
|
AppLifecycleState.resumed,
|
|
AppLifecycleState.inactive,
|
|
AppLifecycleState.hidden,
|
|
AppLifecycleState.paused,
|
|
AppLifecycleState.detached,
|
|
]) {
|
|
tester.binding.handleAppLifecycleStateChanged(state);
|
|
await Future<void>.delayed(const Duration(milliseconds: 5));
|
|
}
|
|
await HttpServerService.instance.stop();
|
|
});
|
|
await tester.pump();
|
|
});
|
|
}
|