51 lines
1.5 KiB
Dart
51 lines
1.5 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/pages/player/widgets/player_double_tap_hearts.dart';
|
|
|
|
void main() {
|
|
testWidgets('should_show_three_medium_hearts_when_double_tap_burst_starts', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(body: PlayerDoubleTapHeartBurst(onCompleted: _noop)),
|
|
),
|
|
);
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
|
|
expect(find.byIcon(Icons.favorite_rounded), findsNWidgets(3));
|
|
expect(_size(tester, 0), 44);
|
|
expect(_size(tester, 1), 34);
|
|
expect(_size(tester, 2), 38);
|
|
expect(
|
|
tester
|
|
.widgetList<Stack>(
|
|
find.descendant(
|
|
of: find.byType(PlayerDoubleTapHeartBurst),
|
|
matching: find.byType(Stack),
|
|
),
|
|
)
|
|
.every((stack) => stack.clipBehavior == Clip.none),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('heart burst stays long and sparse', () {
|
|
expect(PlayerDoubleTapHeartBurst.singleHeartDurationMs, 1300);
|
|
expect(
|
|
PlayerDoubleTapHeartBurst.animationDuration,
|
|
greaterThanOrEqualTo(const Duration(milliseconds: 1200)),
|
|
);
|
|
expect(PlayerDoubleTapHeartBurst.particleCount, lessThanOrEqualTo(4));
|
|
expect(PlayerDoubleTapHeartBurst.particleCount, 3);
|
|
});
|
|
}
|
|
|
|
double _size(WidgetTester tester, int index) {
|
|
return tester.widget<Icon>(find.byKey(Key('double-tap-heart-$index'))).size!;
|
|
}
|
|
|
|
void _noop() {}
|