66 lines
2.1 KiB
Dart
66 lines
2.1 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fancake/core/ui/adaptive_planet_effects.dart';
|
|
import 'package:fancake/core/ui/planet_25d.dart';
|
|
import 'package:fancake/core/ui/planet_evolution.dart';
|
|
|
|
FrameTiming frame(int cost) => FrameTiming(
|
|
vsyncStart: 0,
|
|
buildStart: 0,
|
|
buildFinish: cost,
|
|
rasterStart: cost,
|
|
rasterFinish: cost * 2,
|
|
rasterFinishWallTime: cost * 2,
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('일시 지연은 무시하고 지속 지연에서 단계적으로 축소하며 진화 결과는 유지한다', (tester) async {
|
|
Future<void> show(int stage) => tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptivePlanetEffects(
|
|
child: Center(
|
|
child: Planet25D(
|
|
image: 'assets/figma/planet-home.png',
|
|
size: 200,
|
|
stage: stage,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
int level() => tester
|
|
.widget<PlanetEffectsQuality>(find.byType(PlanetEffectsQuality))
|
|
.level;
|
|
Future<void> timings(int count, int cost) async {
|
|
tester.binding.platformDispatcher.onReportTimings!(
|
|
List.generate(count, (_) => frame(cost)),
|
|
);
|
|
await tester.pump();
|
|
}
|
|
|
|
await show(3);
|
|
await timings(60, 40000); // 시작 시 리소스 로딩은 판정 제외.
|
|
expect(level(), 0);
|
|
await timings(20, 40000);
|
|
await timings(100, 2000);
|
|
expect(level(), 0, reason: '짧은 지연만으로 품질을 떨어뜨리지 않는다');
|
|
await timings(120, 40000);
|
|
expect(level(), 1);
|
|
await timings(120, 40000);
|
|
expect(level(), 2);
|
|
expect(
|
|
tester.widget<PlanetEvolution>(find.byType(PlanetEvolution)).lowEffects,
|
|
true,
|
|
);
|
|
await show(4);
|
|
expect(find.text('이상 반응'), findsOneWidget);
|
|
await tester.pump(const Duration(milliseconds: 1800));
|
|
expect(find.text('Stage 4 · 동행'), findsOneWidget);
|
|
await timings(240, 2000);
|
|
expect(level(), 2, reason: '세션 중 품질이 반복 왕복하지 않는다');
|
|
await tester.pumpWidget(const SizedBox());
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|