mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
long press the hero to delete a partially downloaded list
The hero's control now carries the whole rule: a tap does what the state offers (Download, Cancel, Delete) and a long press asks to delete when there is anything downloaded to delete, so a partially downloaded album can be emptied without starting the rest first. Nothing downloaded means the long press does nothing. The rule itself returns the actions rather than one of them, so a partially downloaded list offers both Download and Delete; the tap takes the first. That list is what the library tabs' context menus will read.
This commit is contained in:
@@ -26,4 +26,26 @@ class BulkDownloadActionTest {
|
||||
fun aFullyDownloadedListOffersDelete() {
|
||||
assertEquals(BulkDownloadAction.Delete, ListDownloadStatus(total = 3, downloaded = 3).action())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aPartiallyDownloadedListOffersBoth() {
|
||||
assertEquals(
|
||||
listOf(BulkDownloadAction.Download, BulkDownloadAction.Delete),
|
||||
ListDownloadStatus(total = 3, downloaded = 1).actions(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anInFlightListOffersOnlyCancel() {
|
||||
assertEquals(
|
||||
listOf(BulkDownloadAction.Cancel),
|
||||
ListDownloadStatus(total = 3, downloaded = 1, downloading = 1).actions(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anUndownloadedListOffersOnlyDownload() {
|
||||
assertEquals(listOf(BulkDownloadAction.Download), ListDownloadStatus(total = 3).actions())
|
||||
assertEquals(listOf(BulkDownloadAction.Download), ListDownloadStatus().actions())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,17 @@ package com.subtracks.ui.components
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
|
||||
import androidx.compose.ui.test.longClick
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performTouchInput
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.subtracks.data.model.BulkDownloadAction
|
||||
import com.subtracks.data.model.ListDownloadStatus
|
||||
import com.subtracks.ui.theme.SubtracksTheme
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -42,6 +45,26 @@ class HeroDownloadTest {
|
||||
assertEquals(listOf(BulkDownloadAction.Delete), actions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun longPressingAPartiallyDownloadedListAsksToDelete() {
|
||||
val actions = mutableListOf<BulkDownloadAction>()
|
||||
render(ListDownloadStatus(total = 3, downloaded = 1)) { actions += it }
|
||||
|
||||
composeRule.onNodeWithContentDescription("Download").performTouchInput { longClick() }
|
||||
|
||||
assertEquals(listOf(BulkDownloadAction.Delete), actions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun longPressingAnUndownloadedListDoesNothing() {
|
||||
val actions = mutableListOf<BulkDownloadAction>()
|
||||
render(ListDownloadStatus(total = 3)) { actions += it }
|
||||
|
||||
composeRule.onNodeWithContentDescription("Download").performTouchInput { longClick() }
|
||||
|
||||
assertTrue(actions.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theButtonIsDisabledWithoutSongs() {
|
||||
render(ListDownloadStatus(), hasSongs = false) {}
|
||||
|
||||
Reference in New Issue
Block a user