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

Unit Test Optimization - adding new test #279

Merged
merged 5 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/VibesterAppTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ch.sdp.vibester

import org.junit.Test

class VibesterAppTest {
@Test
fun testVibester(){
VibesterApp()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DownloadActivityTest {
fun downloadIncorrectSong() {
val intent = Intent(ApplicationProvider.getApplicationContext(), DownloadActivity::class.java)
val scn: ActivityScenario<DownloadActivity> = ActivityScenario.launch(intent)
assertEquals(false, DownloadActivity.downloadStarted)
val songName = "adsfasdgyasdfa"

onView(withId(R.id.download_songName)).perform(typeText(songName), closeSoftKeyboard())
Expand Down
14 changes: 14 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/api/InternetStateTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ch.sdp.vibester.api

import android.content.Context
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert.assertEquals
import org.junit.Test

class InternetStateTest {
@Test
fun internetStatus() {
val ctx = ApplicationProvider.getApplicationContext() as Context
assertEquals(true, InternetState.hasAccessedInternetOnce(ctx))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ch.sdp.vibester.database

import junit.framework.Assert.assertEquals
import org.junit.Test

class PersistanceSetterTest {
@Test
fun testPersistance() {
PersistanceSetter.setPersistance()
assertEquals(true, PersistanceSetter.getPersistance())
}
}
14 changes: 14 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/model/LyricTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ch.sdp.vibester.model

import junit.framework.Assert.assertEquals
import org.junit.Test

class LyricTest {
@Test
fun testLyric() {
val value = "Hello world"
val lyric = Lyric()
lyric.lyrics = value
assertEquals(value, lyric.lyrics)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class SongListTest {
val totalPages = "66649"
val totalSongs = "66649"

assertEquals(songName, mySongsList.getShuffledSongList().get(0).first)


assertEquals(inputSongsList, mySongsList.getSongList())
assertEquals(page, mySongsList.getPage())
Expand Down
14 changes: 14 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/model/SongTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ch.sdp.vibester.model


import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
Expand Down Expand Up @@ -94,11 +96,23 @@ class SongTest {
val previewUrl = "https://none.com"

val mySong = Song.songBuilder(previewUrl, artworkUrl, songName, songArtist)
val mySong2 = Song.songBuilder()

assertEquals(songName, mySong.getTrackName())
assertEquals(songArtist, mySong.getArtistName())
assertEquals(artworkUrl, mySong.getArtworkUrl())
assertEquals(previewUrl, mySong.getPreviewUrl())

assertEquals("", mySong2.getTrackName())
assertEquals("", mySong2.getArtistName())
assertEquals("", mySong2.getArtworkUrl())
assertEquals("", mySong2.getPreviewUrl())
}

@Test
fun testBadArgument() {
assertThrows(IllegalArgumentException::class.java, {Song(JSONObject("{}"))})
assertThrows(IllegalArgumentException::class.java, {Song.listSong("{}")})
}

}