Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #121 from MaximeZmt/kamila/change_songlist_structure
Browse files Browse the repository at this point in the history
Kamila/change songlist structure
  • Loading branch information
kamilababayeva authored Mar 28, 2022
2 parents 83265b7 + a99a7b8 commit 6ecc7e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ class GenreTemporaryTest {
fun songListIsEmpty(){
exception.expect(PerformException::class.java)
onView(withId(R.id.songsListView)).check(matches(isDisplayed()))
onData(allOf(`is`(instanceOf(String::class.java)))).atPosition(2).perform(click())
onData(allOf(`is`(instanceOf(Pair::class.java)))).atPosition(2).perform(click())
}

@Test
fun rockButtonClick() {
onView(withId(R.id.rockButton)).perform(click())
onView(withId(R.id.songsListView)).check(matches(isDisplayed()))
Thread.sleep(1000) // wait for data to fetch
onData(allOf(`is`(instanceOf(String::class.java)))).atPosition(2).perform(click())
onData(allOf(`is`(instanceOf(Pair::class.java)))).atPosition(2).perform(click())
}
@Test
fun topButtonClick() {
onView(withId(R.id.topTracksButton)).perform(click())
onView(withId(R.id.songsListView)).check(matches(isDisplayed()))
Thread.sleep(1000) // wait for data to fetch
onData(allOf(`is`(instanceOf(String::class.java)))).atPosition(2).perform(click())
onData(allOf(`is`(instanceOf(Pair::class.java)))).atPosition(2).perform(click())
}

@Test
fun kpopButtonClick() {
onView(withId(R.id.kpopButton)).perform(click())
onView(withId(R.id.songsListView)).check(matches(isDisplayed()))
Thread.sleep(1000) // wait for data to fetch
onData(allOf(`is`(instanceOf(String::class.java)))).atPosition(2).perform(click())
onData(allOf(`is`(instanceOf(Pair::class.java)))).atPosition(2).perform(click())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SongListTest {

val songName = "Wonderwall"
val artistName = "Oasis"
val inputSongsList = mutableListOf<String>("$songName $artistName")
val inputSongsList = mutableListOf<Pair<String,String>>(Pair("$songName","$artistName"))
val page = "1"
val songsPerPage = "1"
val totalPages = "66649"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ch/sdp/vibester/api/LastfmHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LastfmHelper {
* @param tag: tag to retrieve songs. If method BY_CHART is used, tag is empty.
* @return list of songs in a format ("$songName $artistName")
*/
fun getRandomSongList(method: String, tag: String = ""): List<String> {
fun getRandomSongList(method: String, tag: String = ""): List<Pair<String, String>> {
val firstQuery = SongList(
LastfmApi.querySongList(
OkHttpClient(),
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/ch/sdp/vibester/model/SongList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.json.JSONObject

/**
* Process the fetched data from Lastfm query.
* Mainly, it creates a list of songs in the form ["$songName $artistName"]
* Mainly, it creates a list of songs in the form Pair("$songName", "$artistName")
* @param jsonMeta: Lastfm fetched data
*/
class SongList(jsonMeta: String) {

private var songList = mutableListOf<String>()
private var songList = mutableListOf<Pair<String, String>>()
private var page = ""
private var songsPerPage = ""
private var totalPages = ""
Expand Down Expand Up @@ -47,16 +47,16 @@ class SongList(jsonMeta: String) {
val songName = songObj.getString("name")
val artistDetails = songObj.getJSONObject("artist")
val artistName = artistDetails.getString("name")
songList.add("$songName $artistName")
songList.add(Pair("$songName", "$artistName"))
++i
}
}

/**
* Getter that return songs for the given tag
* @return MutableList<String> of type "$artistName $songName"
* @return MutableList<Pair<String,String>> of type Pair("$songName", "$artistName")
*/
fun getSongList():MutableList<String>{
fun getSongList():MutableList<Pair<String,String>>{
return songList
}

Expand Down

0 comments on commit 6ecc7e9

Please sign in to comment.