From 45dedfbda4796b89c8328d6c56f600785c4ed357 Mon Sep 17 00:00:00 2001 From: MaximeZmt Date: Thu, 12 May 2022 23:11:26 +0200 Subject: [PATCH 1/4] test adding new test --- .../java/ch/sdp/vibester/VibesterAppTest.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/src/androidTest/java/ch/sdp/vibester/VibesterAppTest.kt 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 From b9774cdb80173f72943720901367939e943a9476 Mon Sep 17 00:00:00 2001 From: MaximeZmt Date: Thu, 12 May 2022 23:25:10 +0200 Subject: [PATCH 2/4] adding InternetState Test --- .../sdp/vibester/activity/DownloadActivityTest.kt | 1 + .../java/ch/sdp/vibester/api/InternetStateTest.kt | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 app/src/androidTest/java/ch/sdp/vibester/api/InternetStateTest.kt 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 From 98f65fa73ab6e8c23c5283c2ce4ed885e0c59b51 Mon Sep 17 00:00:00 2001 From: MaximeZmt Date: Thu, 12 May 2022 23:44:36 +0200 Subject: [PATCH 3/4] testing optimization --- .../sdp/vibester/database/PersistanceSetterTest.kt | 13 +++++++++++++ .../java/ch/sdp/vibester/model/LyricTest.kt | 14 ++++++++++++++ .../java/ch/sdp/vibester/model/SongListTest.kt | 2 ++ .../java/ch/sdp/vibester/model/SongTest.kt | 14 ++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt create mode 100644 app/src/androidTest/java/ch/sdp/vibester/model/LyricTest.kt 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..2497fdd85 --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt @@ -0,0 +1,13 @@ +package ch.sdp.vibester.database + +import junit.framework.Assert.assertEquals +import org.junit.Test + +class PersistanceSetterTest { + @Test + fun testPersistance() { + assertEquals(false, PersistanceSetter.getPersistance()) + 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 From 12d0d3ac72091d4c806b5bc86dc7a418b5132bcb Mon Sep 17 00:00:00 2001 From: MaximeZmt Date: Fri, 13 May 2022 00:08:13 +0200 Subject: [PATCH 4/4] update persistance test --- .../java/ch/sdp/vibester/database/PersistanceSetterTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt b/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt index 2497fdd85..344634dbc 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/database/PersistanceSetterTest.kt @@ -6,7 +6,6 @@ import org.junit.Test class PersistanceSetterTest { @Test fun testPersistance() { - assertEquals(false, PersistanceSetter.getPersistance()) PersistanceSetter.setPersistance() assertEquals(true, PersistanceSetter.getPersistance()) }