diff --git a/app/build.gradle b/app/build.gradle index df5a53915..91c16e452 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,6 +52,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'com.google.firebase:firebase-auth-ktx:21.0.1' implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.retrofit2:retrofit:2.0.0' + implementation 'com.squareup.retrofit2:converter-gson:2.0.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.json:json:20180813' testImplementation 'org.robolectric:robolectric:4.6' diff --git a/app/src/androidTest/java/ch/sdp/vibester/LyricTemporaryTest.kt b/app/src/androidTest/java/ch/sdp/vibester/LyricTemporaryTest.kt new file mode 100644 index 000000000..02995771c --- /dev/null +++ b/app/src/androidTest/java/ch/sdp/vibester/LyricTemporaryTest.kt @@ -0,0 +1,70 @@ +package ch.sdp.vibester + +import android.content.Intent +import androidx.test.core.app.ActivityScenario +import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.* +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText +import ch.sdp.vibester.api.LyricsOVHApiInterface +import org.hamcrest.CoreMatchers.containsString +import org.hamcrest.CoreMatchers.equalTo +import org.hamcrest.MatcherAssert.assertThat +import org.junit.Test + +class LyricTemporaryTest { + @Test + fun canGetLyricsFromAPI() { + val service = LyricsOVHApiInterface.create("https://api.lyrics.ovh/") + val lyric = service.getLyrics("Imagine Dragons", "Believer").execute() + assertThat(lyric.body().lyrics, equalTo("First things first\r\n" + + "I'm say all the words inside my head\r\n" + + "I'm fired up and tired of the way that things have been, oh-ooh\r\n" + + "The way that things have been, oh-ooh\r\nSecond thing second\r\n" + + "Don't you tell me what you think that I can be\n\n" + + "I'm the one at the sail, I'm the master of my sea, oh-ooh\n\n" + + "The master of my sea, oh-ooh\n\n\n\nI was broken from a young age\n\n" + + "Taking my sulkin to the masses\n\nWrite down my poems for the few\n\n" + + "That looked at me took to me, shook to me, feeling me\n\n" + + "Singing from heart ache from the pain\n\nTake up my message from the veins\n\n" + + "Speaking my lesson from the brain\n\nSeeing the beauty through the...\n\n\n\n" + + "Pain!\n\nYou made me a, you made me a believer, believer\n\nPain!" + + "\n\nYou break me down, you build me up, believer, believer\n\nPain!\n\n" + + "I let the bullets fly, oh let them rain\n\nMy life, my love, my drive, it came from...\n\n" + + "Pain!\n\nYou made me a, you made me a believer, believer\n\n\n\n" + + "Third things third\n\nSend a prayer to the ones up above\n\n" + + "All the hate that you've heard has turned your spirit to a dove, oh-ooh\n\n" + + "Your spirit up above, oh-ooh\n\n\n\nI was choking in the crowd\n\nLiving my brain up in the cloud\n\n" + + "Falling like ashes to the ground\n\nHoping my feelings, they would drown\n\n" + + "But they never did, ever lived, ebbing and flowing\n\nInhibited, limited\n\n" + + "Till it broke up and it rained down\n\nIt rained down, like...\n\n\n\nPain!\n\n" + + "You made me a, you made me a believer, believer\n\nPain!\n\n" + + "You break me down, you build me up, believer, believer\n\nPain!\n\n" + + "I let the bullets fly, oh let them rain\n\nMy life, my love, my drive, they came from...\n\n" + + "Pain!\n\nYou made me a, you made me a believer, believer\n\n\n\nLast things last\n\n" + + "By the grace of the fire and the flames\n\nYou're the face of the future, you're the blood in my veins, oh-ooh\n\n" + + "The blood in my veins, oh-ooh\n\nBut they never did, ever lived, ebbing and flowing\n\nInhibited, limited\n\n" + + "Till it broke up and it rained down\n\nIt rained down, like...\n\n\n\nPain!" + + "\n\nYou made me a, you made me a believer, believer\n\nPain!\n\n" + + "You break me down, you build me up, believer, believer\n\nPain!\n\n" + + "I let the bullets fly, oh let them rain\n\nMy life, my love, my drive, they came from...\n\n" + + "Pain!\n\nYou made me a, you made me a believer, believer")) + } + + @Test + fun lyricTemporaryTest() { + val inputArtistName = "Imagine Dragons" + val inputTrackName = "Believer" + val intent = Intent( + ApplicationProvider.getApplicationContext(), LyricTemporary::class.java + ) + val scn: ActivityScenario = ActivityScenario.launch(intent) + onView(withId(R.id.artistForLyric)).perform(typeText(inputArtistName), closeSoftKeyboard()) + onView(withId(R.id.trackForLyric)).perform(typeText(inputTrackName), closeSoftKeyboard()) + onView(withId(R.id.validateForLyric)).perform(click()) + Thread.sleep(1500) // wait for API response + onView(withId(R.id.lyricBody)).check(matches(withText(containsString("First things first")))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt index 4c971c21a..e883fcbf8 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt @@ -44,21 +44,15 @@ class MainActivityTest { intended(hasExtra("name", inputName)) } - @Test - fun scoreboardTest() { - onView(withId(R.id.scoreboardButton)).perform(click()) - intended(hasComponent(ScoreBoardActivity::class.qualifiedName)) - } - - @Test - fun profileTest() { - onView(withId(R.id.profileButton)).perform(click()) - intended(hasComponent(ProfileSetup::class.qualifiedName)) - } - @Test fun checkIntentOnWelcome(){ //FILLER TESTING onView(withId(R.id.placeholder_welcome)).perform(click()) intended(hasComponent(WelcomeScreen::class.qualifiedName)) } + + @Test + fun checkIntentOnLyric() { + onView(withId(R.id.lyricButton)).perform(click()) + intended(hasComponent(LyricTemporary::class.qualifiedName)) + } } \ No newline at end of file diff --git a/app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt b/app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt index e17ef6f00..ef861edfd 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt @@ -3,13 +3,9 @@ package ch.sdp.vibester import android.content.Intent import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider -import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.* -import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.assertion.ViewAssertions.matches -import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -28,7 +24,7 @@ class MusicTemporaryTest{ val scn: ActivityScenario = ActivityScenario.launch(intent) onView(withId(R.id.musicName)) .perform(typeText(inputName), closeSoftKeyboard()) - onView(withId(R.id.validate)).perform(click()) + onView(withId(R.id.validateForMusic)).perform(click()) onView(withId(R.id.textViewPlaying)) .check(matches(withText("Imagine Dragons - Believer"))) } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e19b26012..fac2fd3f2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,51 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ch/sdp/vibester/LyricTemporary.kt b/app/src/main/java/ch/sdp/vibester/LyricTemporary.kt new file mode 100644 index 000000000..c81429f76 --- /dev/null +++ b/app/src/main/java/ch/sdp/vibester/LyricTemporary.kt @@ -0,0 +1,47 @@ +package ch.sdp.vibester + +import android.os.Bundle +import android.text.method.ScrollingMovementMethod +import android.widget.Button +import android.widget.EditText +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import ch.sdp.vibester.api.LyricsOVHApiInterface +import ch.sdp.vibester.model.Lyric +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + + +class LyricTemporary: AppCompatActivity() { + private val baseUrl = "https://api.lyrics.ovh/" + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_lyric_temporary) + + val artistName = findViewById(R.id.artistForLyric) + + val trackName = findViewById(R.id.trackForLyric) + + val btnValidate = findViewById