Render startup immediately and defer native work with a smooth home transition
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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(
|
||||
'slow initialization paints branded frames instead of waiting without a Flutter UI',
|
||||
(tester) async {
|
||||
final ready = Completer<void>();
|
||||
final startup = launchApplication(
|
||||
ready: ready.future,
|
||||
child: const MaterialApp(home: Text('已读取课表')),
|
||||
);
|
||||
try {
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
expect(find.byType(TpLaunchPage), findsOneWidget);
|
||||
expect(find.text('已读取课表'), findsNothing);
|
||||
expect(tester.binding.sendFramesToEngine, isTrue);
|
||||
} finally {
|
||||
ready.complete();
|
||||
await startup;
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user