This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,071 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ch.sdp.vibester | ||
|
||
import android.app.AlertDialog | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.intent.Intents | ||
import androidx.test.espresso.intent.matcher.IntentMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.hamcrest.CoreMatchers.allOf | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
|
||
class GamescreenActivityTest { | ||
|
||
@get:Rule | ||
val testRule = ActivityScenarioRule( | ||
GamescreenActivity::class.java | ||
) | ||
|
||
@Before | ||
fun setUp() { | ||
Intents.init() | ||
} | ||
|
||
@After | ||
fun clean() { | ||
Intents.release() | ||
} | ||
|
||
@Test | ||
fun buzzerLayoutIsDisplayed() { | ||
onView(withId(R.id.buzzersLayout)).check(matches(isDisplayed())) | ||
} | ||
|
||
@Test | ||
fun scoresLayoutIsDisplayed() { | ||
onView(withId(R.id.scoresTable)).check(matches(isDisplayed())) | ||
} | ||
|
||
// FIXME: Find a way to test the popup showing despite not being a component / make robolectric work | ||
/* | ||
@Test | ||
fun clickingButtonLaunchesPopup() { | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class MusicTemporaryTest{ | ||
|
||
// Temporary test | ||
@Test | ||
fun musicTemporaryTest() { | ||
val inputName = "Imagine Dragons Believer" | ||
val intent = | ||
Intent(ApplicationProvider.getApplicationContext(), MusicTemporary::class.java) | ||
val scn: ActivityScenario<GreetingActivity> = ActivityScenario.launch(intent) | ||
onView(withId(R.id.musicName)) | ||
.perform(typeText(inputName), closeSoftKeyboard()) | ||
onView(withId(R.id.validate)).perform(click()) | ||
onView(withId(R.id.textViewPlaying)) | ||
.check(matches(withText("Imagine Dragons - Believer"))) | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/androidTest/java/ch/sdp/vibester/api/ItunesMusicApiTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ch.sdp.vibester.api | ||
|
||
|
||
|
||
import ch.sdp.vibester.model.Song | ||
import okhttp3.OkHttpClient | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import java.lang.Exception | ||
|
||
|
||
class ItunesMusicApiTest{ | ||
|
||
@Test | ||
fun itunesAPIQueryWorks() { | ||
var songFut = ItunesMusicApi.querySong("imagine dragons believer", OkHttpClient()) | ||
val song = Song(songFut.get()) | ||
assertEquals("Imagine Dragons", song.getArtistName()) | ||
} | ||
|
||
@get:Rule | ||
var exception = ExpectedException.none() | ||
|
||
@Test | ||
fun itunesAPIQueryError() { | ||
exception.expect(Exception::class.java) | ||
var songFut = ItunesMusicApi.querySong("imagine dragons believer", OkHttpClient(), "https://ThisIsNotAnURL666.notADomain") | ||
songFut.get() | ||
} | ||
|
||
@Test | ||
fun itunesAPIQueryWorksComplete() { | ||
var songFut = ItunesMusicApi.querySong("imagine dragons believer", OkHttpClient()) | ||
val song = Song(songFut.get()) | ||
val mediaFut = ItunesMusicApi.playAudio(song.getPreviewUrl()) | ||
val player = mediaFut.get() | ||
assertEquals(true, player.isPlaying) | ||
} | ||
|
||
@Test | ||
fun itunesAPIQueryCompleteError() { | ||
exception.expect(Exception::class.java) | ||
val mediaFut = ItunesMusicApi.playAudio("https://ThisIsNotAnURL666.notADomain") | ||
mediaFut.get() | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.