87 lines
3.5 KiB
Dart
87 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fancake/core/ui/planet_25d.dart';
|
|
|
|
void main() {
|
|
testWidgets('HERO 종료는 잔여 입자 회수 후 사라지고 재조회에 반복하지 않는다', (tester) async {
|
|
Future<void> show(Set<String> ids, {int stage = 2, bool reduced = false}) =>
|
|
tester.pumpWidget(
|
|
MaterialApp(
|
|
home: MediaQuery(
|
|
data: MediaQueryData(disableAnimations: reduced),
|
|
child: Center(
|
|
child: Planet25D(
|
|
image: 'assets/figma/planet-home.png',
|
|
size: 200,
|
|
stage: stage,
|
|
heroEventIds: ids,
|
|
isHeroTime: ids.isNotEmpty,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await show({'one'});
|
|
await show({});
|
|
expect(find.text('HERO TIME 종료'), findsOneWidget);
|
|
await tester.pump(const Duration(seconds: 2));
|
|
expect(find.text('HERO TIME 종료'), findsNothing);
|
|
await show({});
|
|
expect(find.text('HERO TIME 종료'), findsNothing);
|
|
await show({'two'});
|
|
await show({}, stage: 3);
|
|
expect(find.text('이상 반응'), findsOneWidget);
|
|
expect(find.text('HERO TIME 종료'), findsNothing);
|
|
await tester.pump(const Duration(milliseconds: 3300));
|
|
expect(find.text('HERO TIME 종료'), findsOneWidget);
|
|
await tester.pump(const Duration(seconds: 2));
|
|
await show({'three'}, stage: 3, reduced: true);
|
|
await show({}, stage: 3, reduced: true);
|
|
expect(find.text('HERO TIME 종료'), findsOneWidget);
|
|
await tester.pump(const Duration(seconds: 2));
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
testWidgets('HERO 최초 상태는 기준점이며 새 ID만 발동하고 진화 뒤에 이어진다', (tester) async {
|
|
Future<void> show(int stage, Set<String>? ids) => tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Center(
|
|
child: Planet25D(
|
|
image: 'assets/figma/planet-home.png',
|
|
size: 200,
|
|
stage: stage,
|
|
isHeroTime: ids?.isNotEmpty ?? false,
|
|
heroEventIds: ids,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await show(1, null);
|
|
await show(1, {'old'});
|
|
expect(find.text('행성이 깨어납니다'), findsNothing);
|
|
await show(1, {'old', 'new'});
|
|
expect(find.text('행성이 깨어납니다'), findsOneWidget);
|
|
await tester.pump(const Duration(milliseconds: 1500));
|
|
expect(find.text('HERO TIME'), findsOneWidget);
|
|
await tester.pump(const Duration(seconds: 2));
|
|
await show(1, {'old', 'new'});
|
|
expect(find.text('HERO TIME'), findsNothing);
|
|
await show(2, {'old', 'new', 'next'});
|
|
expect(find.text('이상 반응'), findsOneWidget);
|
|
expect(find.text('행성이 깨어납니다'), findsNothing);
|
|
await tester.pump(const Duration(milliseconds: 3300));
|
|
expect(find.text('행성이 깨어납니다'), findsOneWidget);
|
|
await show(2, {});
|
|
expect(find.text('행성이 깨어납니다'), findsNothing);
|
|
await show(2, {'next'});
|
|
expect(find.text('행성이 깨어납니다'), findsNothing, reason: '재수신은 재발동하지 않는다');
|
|
await show(3, {'next', 'expires'});
|
|
await show(3, {'next'});
|
|
await tester.pump(const Duration(milliseconds: 3300));
|
|
expect(
|
|
find.text('행성이 깨어납니다'),
|
|
findsNothing,
|
|
reason: '대기하던 신규 이벤트가 끝났으면 다른 진행 중 이벤트가 있어도 재생하지 않는다',
|
|
);
|
|
});
|
|
}
|