diff --git a/app/src/androidTest/java/ch/sdp/vibester/VibesterAppTest.kt b/app/src/androidTest/java/ch/sdp/vibester/VibesterAppTest.kt new file mode 100644 index 000000000..64d102a80 --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/VibesterAppTest.kt @@ -0,0 +1,10 @@ +package ch.sdp.vibester + +import org.junit.Test + +class VibesterAppTest { + @Test + fun testVibester(){ + VibesterApp() + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/activity/DownloadActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/activity/DownloadActivityTest.kt index 2871f90db..6bc71fe84 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/activity/DownloadActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/activity/DownloadActivityTest.kt @@ -49,6 +49,7 @@ class DownloadActivityTest { fun downloadIncorrectSong() { val intent = Intent(ApplicationProvider.getApplicationContext(), DownloadActivity::class.java) val scn: ActivityScenario = ActivityScenario.launch(intent) + assertEquals(false, DownloadActivity.downloadStarted) val songName = "adsfasdgyasdfa" onView(withId(R.id.download_songName)).perform(typeText(songName), closeSoftKeyboard()) diff --git a/app/src/androidTest/java/ch/sdp/vibester/api/InternetStateTest.kt b/app/src/androidTest/java/ch/sdp/vibester/api/InternetStateTest.kt new file mode 100644 index 000000000..77f540527 --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/api/InternetStateTest.kt @@ -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)) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt b/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt new file mode 100644 index 000000000..344634dbc --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt @@ -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()) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/model/LyricTest.kt b/app/src/androidTest/java/ch/sdp/vibester/model/LyricTest.kt new file mode 100644 index 000000000..0ac2ca565 --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/model/LyricTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/model/SongListTest.kt b/app/src/androidTest/java/ch/sdp/vibester/model/SongListTest.kt index 7b7f6073c..4f2e8e8a1 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/model/SongListTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/model/SongListTest.kt @@ -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()) diff --git a/app/src/androidTest/java/ch/sdp/vibester/model/SongTest.kt b/app/src/androidTest/java/ch/sdp/vibester/model/SongTest.kt index a0b0399d2..43373a74c 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/model/SongTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/model/SongTest.kt @@ -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 @@ -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("{}")}) } } \ No newline at end of file