Fix cloud photo rendering and selection actions
Android / test-and-build (push) Successful in 19m51s
Android / test-and-build (push) Successful in 19m51s
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* qsfera Android client application
|
||||
*
|
||||
* Copyright (C) 2026 QSfera.
|
||||
*/
|
||||
package eu.qsfera.android.presentation.cloud
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class CloudMediaSelectionTest {
|
||||
|
||||
@Test
|
||||
fun `toggle selects and deselects the same media`() {
|
||||
val selection = CloudMediaSelection()
|
||||
val media = media("/Camera/photo.jpg")
|
||||
|
||||
assertTrue(selection.toggle(media))
|
||||
assertTrue(selection.contains(media))
|
||||
assertFalse(selection.toggle(media))
|
||||
assertTrue(selection.isEmpty)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `same path in different spaces remains independently selectable`() {
|
||||
val first = media("/Camera/photo.jpg", spaceId = "personal")
|
||||
val second = media("/Camera/photo.jpg", spaceId = "project")
|
||||
val selection = CloudMediaSelection(listOf(first, second))
|
||||
|
||||
assertEquals(2, selection.size)
|
||||
assertEquals(listOf(first, second), selection.items)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `select all keeps existing order and ignores duplicates`() {
|
||||
val first = media("/Camera/one.jpg")
|
||||
val second = media("/Camera/two.jpg")
|
||||
val selection = CloudMediaSelection(listOf(first))
|
||||
|
||||
selection.selectAll(listOf(first, second, second))
|
||||
|
||||
assertEquals(listOf(first, second), selection.items)
|
||||
}
|
||||
|
||||
private fun media(path: String, spaceId: String? = null) = CloudMediaItem(
|
||||
remotePath = path,
|
||||
mimeType = "image/jpeg",
|
||||
size = 1L,
|
||||
modifiedAt = 1L,
|
||||
spaceId = spaceId,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user