fix(player): 使用根Overlay渲染飘心
This commit is contained in:
1 parent
e7afd316f8
commit
30b43878ab
3 files changed
+122
-31
No files matched your search
@@ -143,6 +143,75 @@ void main() {
|
||||
expect(tester.state(burstFinder), same(burstState));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('heart overlay starts at global tap position and is cleaned up', (
|
||||
tester,
|
||||
) async {
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
final clock = _TestClock();
|
||||
await _pumpHarness(
|
||||
tester,
|
||||
FakeInteractionRepository(),
|
||||
FakeHaptics(),
|
||||
key,
|
||||
clock,
|
||||
);
|
||||
const tapPosition = Offset(120, 220);
|
||||
|
||||
await tester.tapAt(tapPosition);
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(tapPosition);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
|
||||
final firstHeart = find.byKey(const Key('double-tap-heart-0'));
|
||||
expect(firstHeart, findsOneWidget);
|
||||
expect(
|
||||
(tester.getCenter(firstHeart) - tapPosition).distance,
|
||||
lessThanOrEqualTo(1),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
expect(find.byType(PlayerDoubleTapHeartBurst), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('multiple heart overlays run independently', (tester) async {
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
final clock = _TestClock();
|
||||
await _pumpHarness(
|
||||
tester,
|
||||
FakeInteractionRepository(),
|
||||
FakeHaptics(),
|
||||
key,
|
||||
clock,
|
||||
);
|
||||
|
||||
await tester.tapAt(const Offset(100, 180));
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(const Offset(100, 180));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
clock.advance(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.tapAt(const Offset(260, 360));
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(const Offset(260, 360));
|
||||
await tester.pump();
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _pumpHarness(
|
||||
|
||||
Reference in new issue
Block a user