From 8522b0e6c4ab4aae2bf83cdeae91610b5e075e3c Mon Sep 17 00:00:00 2001 From: zwierski Date: Wed, 16 Mar 2022 01:54:54 +0100 Subject: [PATCH 1/8] Changed popup to Linear Layout and tested view display --- .../ch/sdp/vibester/GamescreenActivityTest.kt | 9 +++- .../ch/sdp/vibester/GamescreenActivity.kt | 43 +++++++++------- .../main/res/layout/activity_gamescreen.xml | 51 +++++++++++++++++-- 3 files changed, 79 insertions(+), 24 deletions(-) diff --git a/app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt index 503c405bb..fea958f1f 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/GamescreenActivityTest.kt @@ -45,10 +45,15 @@ class GamescreenActivityTest { 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 answerIsPresentButInvisibleOnStartup() { + onView(withId(R.id.answer)).check(matches(withEffectiveVisibility(Visibility.INVISIBLE))) + } + + // FIXME: Find a way to make buttons fetchable (give them an ID)? /* @Test - fun clickingButtonLaunchesPopup() { + fun clickingButtonMakesAnswerVisible() { } diff --git a/app/src/main/java/ch/sdp/vibester/GamescreenActivity.kt b/app/src/main/java/ch/sdp/vibester/GamescreenActivity.kt index 9b472833d..d178cc23f 100644 --- a/app/src/main/java/ch/sdp/vibester/GamescreenActivity.kt +++ b/app/src/main/java/ch/sdp/vibester/GamescreenActivity.kt @@ -1,6 +1,7 @@ package ch.sdp.vibester import android.content.Intent +import android.opengl.Visibility import android.os.Bundle import android.view.Gravity import android.widget.* @@ -21,30 +22,21 @@ class GamescreenActivity: AppCompatActivity() { */ val players = arrayOf("Kamila", "Jiabao", "Arda", "Laurynas") + val answer = findViewById(R.id.answer) + val answerText = findViewById(R.id.answerText) + val gamescreenIntent = Intent(this, GamescreenActivity::class.java) // hardcoded test values val song = "Demo" val artist = "The Placeholders" - val buildPopup = AlertDialog.Builder(this) - buildPopup.setTitle("Solution") - buildPopup.setMessage("The song was " + song + " by " + artist) - - buildPopup.setPositiveButton("Correct") { dialog, which -> - Toast.makeText(applicationContext, - "Congrats!", Toast.LENGTH_SHORT).show() - } - - buildPopup.setNegativeButton("Wrong") { dialog, which -> - Toast.makeText(applicationContext, - "Too bad!", Toast.LENGTH_SHORT).show() - } + answerText.text= "The song was $song by $artist" val allPoints = arrayOf(1, 2, 3, 4) buildScores(players, allPoints) - buildBuzzers(players, buildPopup) + buildBuzzers(players, answer) } @@ -87,7 +79,7 @@ class GamescreenActivity: AppCompatActivity() { /* Programmatically builds the buzzers according to the number and names of players. */ - private fun buildBuzzers(players: Array, popup: AlertDialog.Builder) { + private fun buildBuzzers(players: Array, answer: LinearLayout) { val buzzers = findViewById(R.id.buzzersLayout) val buttons = arrayOfNulls