Render startup immediately and defer native work with a smooth home transition

This commit is contained in:
Codex
2026-10-14 17:26:24 +08:00
parent bb7a7a2e58
commit ce21cdc10c
17 changed files with 641 additions and 144 deletions
+7 -5
View File
@@ -3,9 +3,10 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hepan_everyday/app/tp_startup.dart';
import 'package:hepan_everyday/app/tp_launch_page.dart';
void main() {
testWidgets('waiting initialization does not replace the native launch', (
testWidgets('waiting initialization keeps painted brand frames', (
tester,
) async {
await tester.pumpWidget(const SizedBox());
@@ -16,13 +17,14 @@ void main() {
child: const MaterialApp(home: Text('已准备好课表')),
).then((_) => startupFinished = true);
await tester.pump();
expect(startupFinished, isFalse);
expect(startupFinished, isTrue);
expect(find.byType(TpLaunchPage), findsOneWidget);
expect(tester.binding.sendFramesToEngine, isTrue);
expect(find.text('TPSchedule'), findsNothing);
expect(find.text('已准备好课表'), findsNothing);
ready.complete();
await startup;
await tester.pump();
await tester.pumpAndSettle();
expect(find.text('已准备好课表'), findsOneWidget);
expect(find.text('TPSchedule'), findsNothing);
expect(tester.binding.sendFramesToEngine, isTrue);
@@ -37,7 +39,7 @@ void main() {
ready: ready,
child: const MaterialApp(home: Text('保存的课表')),
);
await tester.pump();
await tester.pumpAndSettle();
expect(find.text('保存的课表'), findsOneWidget);
expect(find.text('TPSchedule'), findsNothing);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.paused);
@@ -57,7 +59,7 @@ void main() {
);
ready.completeError(StateError('storage failed'));
await startup;
await tester.pump();
await tester.pumpAndSettle();
expect(find.text('恢复保存文件'), findsOneWidget);
expect(tester.binding.sendFramesToEngine, isTrue);
expect(tester.takeException(), isNull);