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

Commit

Permalink
Jiabao comments
Browse files Browse the repository at this point in the history
  • Loading branch information
laurislopata committed Mar 13, 2022
2 parents 6ae0e0e + 629ab25 commit 37d3ba4
Show file tree
Hide file tree
Showing 39 changed files with 1,071 additions and 104 deletions.
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

22 changes: 0 additions & 22 deletions .idea/gradle.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The game will also offer a customization where the user can create a game from i
- [x] Create a Github repository
- [x] Setup all Github feature (params, ...)
- [x] Add continuous integration
- [ ]
- [ ]



Expand All @@ -49,8 +49,8 @@ The game will also offer a customization where the user can create a game from i
| Name | GitHub username |
|:--------|---------:|
| Derin Arda Alpay | [Tsathogguaa](https://github.com/Tsathogguaa) |
| Kamila Babayeva | [kamilababayeva14](https://github.com/kamilababayeva14) |
| Kamila Babayeva | [kamilababayeva](https://github.com/kamilababayeva) |
| Laurynas Lopata | [laurislopata](https://github.com/laurislopata) |
| Jiabao Wen | [jiabaow](https://github.com/jiabaow) |
| Maxime Zammit | [MaximeZmt](https://github.com/MaximeZmt) |
| Margaux Zwierski | [zwierski](https://github.com/zwierski) |
| Margaux Zwierski | [zwierski](https://github.com/zwierski) |
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {

defaultConfig {
applicationId "ch.sdp.vibester"
minSdk 23
minSdk 24
targetSdk 31
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -51,7 +51,9 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
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'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20180813'
testImplementation 'org.robolectric:robolectric:4.6'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
Expand Down
10 changes: 5 additions & 5 deletions app/src/androidTest/java/ch/sdp/vibester/GameSetupScreenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GameSetupScreenTest {
@Test
fun checkIntentOnProceedDefault() { //FILLER TEST
onView(withId(R.id.nb_players_selected)).perform(click())
intended(hasComponent(WelcomeScreen::class.java.name))
intended(hasComponent(GamescreenActivity::class.java.name))
intended(hasExtra("Number of players", "One"))
}

Expand All @@ -82,7 +82,7 @@ class GameSetupScreenTest {
onView(withId(R.id.nb_player_spinner)).perform(click())
onData(Matchers.anything()).atPosition(0).perform(click())
onView(withId(R.id.nb_players_selected)).perform(click())
intended(hasComponent(WelcomeScreen::class.java.name))
intended(hasComponent(GamescreenActivity::class.java.name))
intended(hasExtra("Number of players", "One"))
}

Expand All @@ -91,7 +91,7 @@ class GameSetupScreenTest {
onView(withId(R.id.nb_player_spinner)).perform(click())
onData(Matchers.anything()).atPosition(1).perform(click())
onView(withId(R.id.nb_players_selected)).perform(click())
intended(hasComponent(WelcomeScreen::class.java.name))
intended(hasComponent(GamescreenActivity::class.java.name))
intended(hasExtra("Number of players", "Two"))
}

Expand All @@ -100,7 +100,7 @@ class GameSetupScreenTest {
onView(withId(R.id.nb_player_spinner)).perform(click())
onData(Matchers.anything()).atPosition(2).perform(click())
onView(withId(R.id.nb_players_selected)).perform(click())
intended(hasComponent(WelcomeScreen::class.java.name))
intended(hasComponent(GamescreenActivity::class.java.name))
intended(hasExtra("Number of players", "Three"))
}

Expand All @@ -109,7 +109,7 @@ class GameSetupScreenTest {
onView(withId(R.id.nb_player_spinner)).perform(click())
onData(Matchers.anything()).atPosition(3).perform(click())
onView(withId(R.id.nb_players_selected)).perform(click())
intended(hasComponent(WelcomeScreen::class.java.name))
intended(hasComponent(GamescreenActivity::class.java.name))
intended(hasExtra("Number of players", "Four"))
}
}
56 changes: 56 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt
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() {
}
*/
}
8 changes: 7 additions & 1 deletion app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.test.espresso.intent.matcher.IntentMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import ch.sdp.vibester.profile.ProfileSetup
import ch.sdp.vibester.scoreboard.ScoreBoardActivity
import org.junit.After
import org.junit.Before
Expand Down Expand Up @@ -49,10 +50,15 @@ class MainActivityTest {
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))
}

}
37 changes: 37 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/MusicTemporaryTest.kt
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")))
}


}
5 changes: 3 additions & 2 deletions app/src/androidTest/java/ch/sdp/vibester/WelcomeScreenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.intent.Intents
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.espresso.intent.matcher.IntentMatchers.*
import ch.sdp.vibester.profile.ProfileSetup
import ch.sdp.vibester.scoreboard.ScoreBoardActivity
import org.junit.After
import org.junit.Before
Expand Down Expand Up @@ -36,7 +37,7 @@ class WelcomeScreenTest {
@Test
fun checkIntentOnProfile(){ //FILLER TESTING
onView(withId(R.id.welcome_profile)).perform(click())
intended(hasComponent(GameSetupScreen::class.java.name))
intended(hasComponent(ProfileSetup::class.java.name))
}

@Test
Expand All @@ -48,7 +49,7 @@ class WelcomeScreenTest {
@Test
fun checkIntentOnListen(){ //FILLER TESTING
onView(withId(R.id.welcome_listen)).perform(click())
intended(hasComponent(GameSetupScreen::class.java.name))
intended(hasComponent(MusicTemporary::class.java.name))
}

@Test
Expand Down
50 changes: 50 additions & 0 deletions app/src/androidTest/java/ch/sdp/vibester/api/ItunesMusicApiTest.kt
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()
}


}
Loading

0 comments on commit 37d3ba4

Please sign in to comment.