mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-27 18:00:40 +00:00
increased timer vibration duration
This commit is contained in:
parent
bd740cc7dc
commit
26752073f6
5 changed files with 26 additions and 26 deletions
|
@ -9,7 +9,7 @@ class HapticsService {
|
|||
|
||||
Future<void> responseVibration() async => _tryVibrate(duration: 50, amplitude: 128);
|
||||
|
||||
Future<void> errorVibration() async => _tryVibrate(duration: 100, amplitude: 128);
|
||||
Future<void> errorVibration() async => _tryVibrate(duration: 500, amplitude: 128);
|
||||
|
||||
Future<void> _tryVibrate({required int duration, required int amplitude}) async {
|
||||
if (await _canVibrate()) {
|
||||
|
|
|
@ -11,13 +11,13 @@ class TimerInteractor {
|
|||
);
|
||||
|
||||
/// Executes vibration if haptics are enabled in settings
|
||||
Future<void> quickVibration() async {
|
||||
Future<void> startVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.quickVibration();
|
||||
}
|
||||
|
||||
/// Executes vibration if haptics are enabled in settings
|
||||
Future<void> responseVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.responseVibration();
|
||||
Future<void> endVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.errorVibration();
|
||||
}
|
||||
|
||||
bool get isAutostartTimerEnabled => _userPreferencesService.autostartTimer;
|
||||
|
|
|
@ -19,19 +19,19 @@ class TimerBloc extends Bloc<TimerEvent, TimerState> {
|
|||
}
|
||||
|
||||
Future<void> _onStartTimer(StartTimerEvent _, Emitter emit) async {
|
||||
_timerInteractor.quickVibration();
|
||||
_timerInteractor.startVibration();
|
||||
emit(const TimerResumedState());
|
||||
}
|
||||
|
||||
Future<void> _onTimerEnded(TimerEndedEvent event, Emitter emit) async {
|
||||
if (state is! TimerResetState) {
|
||||
_timerInteractor.responseVibration();
|
||||
_timerInteractor.endVibration();
|
||||
emit(const TimerStoppedState());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onStopTimer(StopTimerEvent _, Emitter emit) async {
|
||||
_timerInteractor.quickVibration();
|
||||
_timerInteractor.startVibration();
|
||||
emit(const TimerStoppedState());
|
||||
}
|
||||
|
||||
|
|
|
@ -27,36 +27,36 @@ void main() {
|
|||
group(
|
||||
'Haptics',
|
||||
() {
|
||||
test('quickVibration() - true', () async {
|
||||
test('startVibration() - true', () async {
|
||||
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
||||
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
||||
interactor.quickVibration();
|
||||
interactor.startVibration();
|
||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||
verify(() => mockHapticsService.quickVibration()).called(1);
|
||||
});
|
||||
|
||||
test('quickVibration() - false', () async {
|
||||
test('startVibration() - false', () async {
|
||||
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
||||
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
||||
interactor.quickVibration();
|
||||
interactor.startVibration();
|
||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||
verifyNever(() => mockHapticsService.quickVibration());
|
||||
});
|
||||
|
||||
test('responseVibration() - true', () async {
|
||||
test('endVibration() - true', () async {
|
||||
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
||||
when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {});
|
||||
interactor.responseVibration();
|
||||
when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {});
|
||||
interactor.endVibration();
|
||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||
verify(() => mockHapticsService.responseVibration()).called(1);
|
||||
verify(() => mockHapticsService.errorVibration()).called(1);
|
||||
});
|
||||
|
||||
test('responseVibration() - false', () async {
|
||||
test('endVibration() - false', () async {
|
||||
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
||||
when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {});
|
||||
interactor.responseVibration();
|
||||
when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {});
|
||||
interactor.endVibration();
|
||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||
verifyNever(() => mockHapticsService.responseVibration());
|
||||
verifyNever(() => mockHapticsService.errorVibration());
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
|
@ -14,15 +14,15 @@ void main() {
|
|||
setUpAll(() {
|
||||
timerInteractor = _MockTimerInteractor();
|
||||
when(() => timerInteractor.isAutostartTimerEnabled).thenReturn(true);
|
||||
when(timerInteractor.quickVibration).thenAnswer((_) async {});
|
||||
when(timerInteractor.responseVibration).thenAnswer((_) async {});
|
||||
when(timerInteractor.startVibration).thenAnswer((_) async {});
|
||||
when(timerInteractor.endVibration).thenAnswer((_) async {});
|
||||
});
|
||||
|
||||
blocTest<TimerBloc, TimerState>(
|
||||
'Autostart',
|
||||
build: () => TimerBloc(timerInteractor, const Duration(seconds: 1)),
|
||||
verify: (_) {
|
||||
verify(() => timerInteractor.quickVibration()).called(1);
|
||||
verify(() => timerInteractor.startVibration()).called(1);
|
||||
},
|
||||
expect: () => [
|
||||
isA<TimerResumedState>(),
|
||||
|
@ -41,8 +41,8 @@ void main() {
|
|||
bloc.add(const ResetTimerEvent());
|
||||
},
|
||||
verify: (_) {
|
||||
verify(() => timerInteractor.quickVibration()).called(1);
|
||||
verify(() => timerInteractor.responseVibration()).called(1);
|
||||
verify(() => timerInteractor.startVibration()).called(1);
|
||||
verify(() => timerInteractor.endVibration()).called(1);
|
||||
},
|
||||
expect: () => [
|
||||
isA<TimerResumedState>(),
|
||||
|
@ -64,8 +64,8 @@ void main() {
|
|||
bloc.add(const TimerEndedEvent());
|
||||
},
|
||||
verify: (_) {
|
||||
verify(() => timerInteractor.quickVibration()).called(3);
|
||||
verify(() => timerInteractor.responseVibration()).called(1);
|
||||
verify(() => timerInteractor.startVibration()).called(3);
|
||||
verify(() => timerInteractor.endVibration()).called(1);
|
||||
},
|
||||
expect: () => [
|
||||
isA<TimerResumedState>(),
|
||||
|
|
Loading…
Reference in a new issue