fix: close the alarm screen when a restore replaces the ringing alarm
A backup restore stops the ring while its row still exists and deletes the row afterwards, so the screen's one check came too early and left a silent ring screen up for good. It now closes once the coordinator and storage both say nothing rings, which still keeps it up if the import fails and the ring resumes.
This commit is contained in:
1 parent
c83c12cf64
commit
405374de7e
3 files changed
+38
-5
No files matched your search
@@ -227,6 +227,27 @@ class AlarmRingViewModelTest {
|
||||
.isEqualTo(null to RingUiState.Finished)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a backup restore that replaces the ringing alarm finishes the screen`(@TempDir tempDir: Path) =
|
||||
runTest(main.dispatcher) {
|
||||
val engine = engine(tempDir)
|
||||
givenRinging(engine)
|
||||
val viewModel = viewModel(engine)
|
||||
advanceUntilIdle()
|
||||
|
||||
// The restore's order: the ring is stopped while its row still exists,
|
||||
// so the screen must stay up in case the import fails and it resumes.
|
||||
engine.suspendRingForImport()
|
||||
advanceUntilIdle()
|
||||
val whileSuspended = viewModel.state.value
|
||||
// Replacing the rows cascades to the ring state.
|
||||
stateDao.deleteAll()
|
||||
advanceUntilIdle()
|
||||
|
||||
assertThat(whileSuspended).isInstanceOf(RingUiState.Ringing::class.java)
|
||||
assertThat(viewModel.state.value).isEqualTo(RingUiState.Finished)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `dismiss does nothing while the maths gate is closed`(@TempDir tempDir: Path) =
|
||||
runTest(main.dispatcher) {
|
||||
|
||||
Reference in new issue
Block a user