-
Notifications
You must be signed in to change notification settings - Fork 0
feat(serveur): lancer un album distant en entier ou au hasard #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
app/src/test/java/app/waveflow/ui/server/catalog/RemoteAlbumDetailScreenTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| package app.waveflow.ui.server.catalog | ||
|
|
||
| import androidx.compose.ui.test.assertIsDisplayed | ||
| import androidx.compose.ui.test.assertIsEnabled | ||
| import androidx.compose.ui.test.assertIsNotEnabled | ||
| import androidx.compose.ui.test.junit4.v2.createComposeRule | ||
| import androidx.compose.ui.test.hasText | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import androidx.compose.ui.test.performClick | ||
| import app.waveflow.model.RemoteAlbum | ||
| import app.waveflow.model.RemoteAlbumDetail | ||
| import app.waveflow.model.RemoteSong | ||
| import app.waveflow.testing.remoteSong | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.robolectric.RobolectricTestRunner | ||
| import org.robolectric.annotation.Config | ||
|
|
||
| /** L'écran d'un album distant : ce qu'il affiche et ce qu'il déclenche. */ | ||
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(qualifiers = "w411dp-h2000dp-xhdpi") | ||
| class RemoteAlbumDetailScreenTest { | ||
|
|
||
| @get:Rule | ||
| val compose = createComposeRule() | ||
|
|
||
| private val songs = listOf( | ||
| remoteSong(id = "a", title = "Première Lueur", trackNumber = 1), | ||
| remoteSong(id = "b", title = "Ciel Bas", trackNumber = 2), | ||
| ) | ||
|
|
||
| private val detail = RemoteAlbumDetail( | ||
| album = RemoteAlbum( | ||
| id = "album-1", | ||
| title = "Nuit Blanche", | ||
| artist = "Aurore", | ||
| artistId = "artiste-1", | ||
| year = 2024, | ||
| artworkUri = null, | ||
| ), | ||
| songs = songs, | ||
| ) | ||
|
|
||
| private val joues = mutableListOf<RemoteSong>() | ||
| private var lectures = 0 | ||
| private var aleatoires = 0 | ||
|
|
||
| private fun afficher( | ||
| state: AlbumDetailState, | ||
| nowPlayingMediaId: String? = null, | ||
| ) { | ||
| compose.setContent { | ||
| RemoteAlbumDetailScreen( | ||
| state = state, | ||
| nowPlayingMediaId = nowPlayingMediaId, | ||
| onSongClick = { joues += it }, | ||
| onPlay = { lectures++ }, | ||
| onShuffle = { aleatoires++ }, | ||
| onRetry = {}, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `l'album affiche ses commandes et ses morceaux`() { | ||
| afficher(AlbumDetailState(value = detail)) | ||
|
|
||
| compose.onNodeWithText("Nuit Blanche").assertIsDisplayed() | ||
| compose.onNodeWithText("Lecture").assertIsEnabled() | ||
| compose.onNodeWithText("Aléatoire").assertIsEnabled() | ||
| compose.onNodeWithText("Première Lueur").assertIsDisplayed() | ||
| } | ||
|
|
||
| @Test | ||
| fun `Lecture et Aleatoire sont deux commandes distinctes`() { | ||
| // Le piège déjà rencontré sur les albums locaux : les deux boutons | ||
| // avaient fini par faire la même chose. | ||
| afficher(AlbumDetailState(value = detail)) | ||
|
|
||
| compose.onNodeWithText("Lecture").performClick() | ||
| compose.onNodeWithText("Aléatoire").performClick() | ||
|
|
||
| assertEquals(1, lectures) | ||
| assertEquals(1, aleatoires) | ||
| } | ||
|
|
||
| @Test | ||
| fun `un album vide n'offre pas de lecture`() { | ||
| afficher(AlbumDetailState(value = detail.copy(songs = emptyList()))) | ||
|
|
||
| compose.onNodeWithText("Lecture").assertIsNotEnabled() | ||
| } | ||
|
|
||
| @Test | ||
| fun `toucher un morceau le demande a l'appelant`() { | ||
| afficher(AlbumDetailState(value = detail)) | ||
|
|
||
| compose.onNodeWithText("Ciel Bas").performClick() | ||
|
|
||
| assertEquals(listOf(songs[1]), joues) | ||
| } | ||
|
|
||
| @Test | ||
| fun `un chargement en cours n'affiche ni commande ni morceau`() { | ||
| afficher(AlbumDetailState(isLoading = true)) | ||
|
|
||
| assertTrue(compose.onAllNodes(hasText("Lecture")).fetchSemanticsNodes().isEmpty()) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.