Merge branch 'feature/animation-speed'
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_animation_section.dart';
|
||||
import 'package:pipelines_app/ui/motion/animation_speed.dart';
|
||||
|
||||
class _Store implements AnimationSpeedStore {
|
||||
double? saved;
|
||||
@override
|
||||
Future<double?> load() async => saved;
|
||||
@override
|
||||
Future<bool> save(double speed) async {
|
||||
saved = speed;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
tearDown(() => timeDilation = 1);
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'native slider updates global speed and Reset restores normal ($cupertino)',
|
||||
(tester) async {
|
||||
final store = _Store();
|
||||
final controller = AnimationSpeedController(store: store);
|
||||
final section = SettingsAnimationSection(controller: controller);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: section))
|
||||
: MaterialApp(home: Scaffold(body: section)),
|
||||
);
|
||||
if (cupertino) {
|
||||
final slider = tester.widget<CupertinoSlider>(
|
||||
find.byType(CupertinoSlider),
|
||||
);
|
||||
slider.onChanged!(1.8);
|
||||
slider.onChangeEnd!(1.8);
|
||||
} else {
|
||||
final slider = tester.widget<Slider>(find.byType(Slider));
|
||||
slider.onChanged!(1.8);
|
||||
slider.onChangeEnd!(1.8);
|
||||
}
|
||||
await tester.pump();
|
||||
expect(find.text('1.8×'), findsWidgets);
|
||||
expect(timeDilation, closeTo(1 / 1.8, 0.001));
|
||||
expect(store.saved, 1.8);
|
||||
await tester.tap(find.text('Reset'));
|
||||
await tester.pump();
|
||||
expect(controller.speed, 1);
|
||||
expect(timeDilation, 1);
|
||||
expect(store.saved, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
controller.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user