fix(player): 延长飘心并显示毫秒计时
This commit is contained in:
1 parent
84b24775d6
commit
810ca5bf9d
4 files changed
+165
-40
No files matched your search
@@ -110,7 +110,7 @@ void main() {
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('parent rebuild keeps the heart burst state alive', (
|
||||
testWidgets('parent rebuild 30 times keeps the heart burst alive', (
|
||||
tester,
|
||||
) async {
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
@@ -135,13 +135,24 @@ void main() {
|
||||
final burstFinder = find.byType(PlayerDoubleTapHeartBurst);
|
||||
final gestureState = tester.state(gestureFinder);
|
||||
final burstState = tester.state(burstFinder);
|
||||
var elapsedMs = 100;
|
||||
|
||||
key.currentState!.rebuild();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
for (var index = 0; index < 30; index++) {
|
||||
key.currentState!.rebuild();
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
elapsedMs += 16;
|
||||
}
|
||||
|
||||
expect(tester.state(gestureFinder), same(gestureState));
|
||||
expect(tester.state(burstFinder), same(burstState));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
|
||||
while (burstFinder.evaluate().isNotEmpty && elapsedMs < 2000) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
elapsedMs += 16;
|
||||
}
|
||||
expect(burstFinder, findsNothing);
|
||||
expect(elapsedMs, greaterThanOrEqualTo(1500));
|
||||
});
|
||||
|
||||
testWidgets('heart burst is cleaned up when gesture region is disposed', (
|
||||
@@ -166,6 +177,12 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
|
||||
expect(find.byType(PlayerDoubleTapHeartBurst), findsOneWidget);
|
||||
expect(
|
||||
(tester.getCenter(find.byKey(const Key('double-tap-heart-0'))) -
|
||||
tapPosition)
|
||||
.distance,
|
||||
lessThanOrEqualTo(1),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
@@ -200,6 +217,8 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
|
||||
expect(find.byType(PlayerDoubleTapHeartBurst), findsNWidgets(2));
|
||||
expect(find.byKey(const ValueKey('heart-overlay-0')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('heart-overlay-1')), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
expect(find.byType(PlayerDoubleTapHeartBurst), findsNothing);
|
||||
|
||||
Reference in new issue
Block a user