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

Commit

Permalink
BuzzerScreenActivity: fix buzzer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilababayeva committed Apr 25, 2022
1 parent ee7258c commit 5165ab7
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ch.sdp.vibester.activity

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.click
import androidx.test.espresso.assertion.ViewAssertions.matches
Expand Down Expand Up @@ -49,26 +52,47 @@ class BuzzerScreenActivityTest {
fun answerIsPresentButInvisibleOnStartup() {
onView(withId(R.id.answer)).check(matches(withEffectiveVisibility(Visibility.INVISIBLE)))
}
/*
@Test
fun clickingBuzzerMakesAnswerVisible() {
val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerScreenActivity::class.java)

// Put mock extras inside
val mockPlayersNumber = 2
val mockNameArray = arrayOfNulls<String>(mockPlayersNumber)
mockNameArray[0] = "John"
mockNameArray[1] = "Bob"
intent.putExtra("Number of players", mockPlayersNumber)
intent.putExtra("Player Names", mockNameArray)
val scn: ActivityScenario<BuzzerScreenActivity> = ActivityScenario.launch(intent)

onView(withId(R.id.answer)).check(matches(withEffectiveVisibility(Visibility.INVISIBLE)))
onView(withId(R.id.buzzer_0)).perform(click()) // why does it not find the buzzer???
onView(withId(R.id.buzzer_0)).perform(click())
onView(withId(R.id.answer)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withId(R.id.buttonWrong)).perform(click())
}


@Test
fun clickingAnswerButtonsMakesAnswerInvisible() {
val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerScreenActivity::class.java)

// Put mock extras inside
val mockPlayersNumber = 2
val mockNameArray = arrayOfNulls<String>(mockPlayersNumber)
mockNameArray[0] = "John"
mockNameArray[1] = "Bob"
intent.putExtra("Number of players", mockPlayersNumber)
intent.putExtra("Player Names", mockNameArray)
val scn: ActivityScenario<BuzzerScreenActivity> = ActivityScenario.launch(intent)

val buttonIdArray = arrayOf(R.id.buttonCorrect, R.id.buttonWrong)
for (butId in buttonIdArray) {
onView(withId(R.id.buzzer_0)).perform(click()) // make answer visible first
onView(withId(butId)).perform(click())
onView(withId(R.id.answer)).check(matches(withEffectiveVisibility(Visibility.INVISIBLE)))
}
}
*/

/*
* Currently testing with the *static* values. Change to *dynamic* once the game is correctly
Expand Down

0 comments on commit 5165ab7

Please sign in to comment.