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

BuzzerScreenActivity: fix buzzer tests #198

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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