-
Notifications
You must be signed in to change notification settings - Fork 0
Jwen/set up scoreboard per playlist #203
Changes from 8 commits
7afe79b
9fde3d5
b043fd7
a7b2d86
f2330b8
e3abd42
8a78fe7
73b50d4
11d4d16
5b54240
9db474a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import androidx.test.espresso.matcher.ViewMatchers.* | |
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import ch.sdp.vibester.R | ||
import org.hamcrest.CoreMatchers.not | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
@@ -22,12 +23,22 @@ class ScoreBoardActivityTest { | |
val activityRule = ActivityScenarioRule(ScoreBoardActivity::class.java) | ||
|
||
@Test | ||
fun recycleViewToViewTest() { | ||
fun genreShouldDisappearAfterSelected() { | ||
onView(withId(R.id.genrePerScoreboard)).check(matches(isDisplayed())) | ||
onView(withId(R.id.rockButton)).perform(click()) | ||
onView(withId(R.id.genrePerScoreboard)).check(matches(not(isDisplayed()))) | ||
} | ||
|
||
@Test | ||
fun rockBtnShouldSetUpRecycleVie() { | ||
onView(withId(R.id.rockButton)).perform(click()) | ||
onView(withId(R.id.recycler_view)).check(matches(isDisplayed())) | ||
} | ||
|
||
@Test | ||
fun recycleViewClickTest() { | ||
fun rockBtnShouldEnableRecycleViewClickTest() { | ||
onView(withId(R.id.rockButton)).perform(click()) | ||
|
||
onView((withId(R.id.recycler_view))) | ||
.perform( | ||
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>( | ||
|
@@ -36,6 +47,31 @@ class ScoreBoardActivityTest { | |
) | ||
} | ||
|
||
@Test | ||
fun topBtnClick() { | ||
onView(withId(R.id.topTracksButton)).perform(click()) | ||
} | ||
|
||
@Test | ||
fun kpopBtnClick() { | ||
onView(withId(R.id.kpopButton)).perform(click()) | ||
} | ||
|
||
@Test | ||
fun billieEilishButtonClick() { | ||
onView(withId(R.id.billieEilishButton)).perform(click()) | ||
} | ||
|
||
@Test | ||
fun imagineDragonsButtonClick() { | ||
onView(withId(R.id.imagDragonsButton)).perform(click()) | ||
} | ||
|
||
@Test | ||
fun btsButtonClick() { | ||
onView(withId(R.id.btsButton)).perform(click()) | ||
} | ||
Comment on lines
+50
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it clicks, but does not miss a verification ? What should it test ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, the verification of each should be the same as in rockBtnShouldSetUpRecycleView() and rockBtnShouldEnableRecycleViewClick(), but they are all testing the same lines of code, so to speed up CI and have the coverage rate, I just do click on each of them without the actual verification. |
||
|
||
@Test | ||
fun recycleViewScrollDownTest() { | ||
val recyclerView = RecyclerView(ApplicationProvider.getApplicationContext()) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,11 @@ package ch.sdp.vibester.activity | |||||||||||||||||||||||||
import android.content.ContentValues | ||||||||||||||||||||||||||
import android.os.Bundle | ||||||||||||||||||||||||||
import android.util.Log | ||||||||||||||||||||||||||
import android.view.View | ||||||||||||||||||||||||||
import android.view.View.GONE | ||||||||||||||||||||||||||
import android.view.View.VISIBLE | ||||||||||||||||||||||||||
import androidx.appcompat.app.AppCompatActivity | ||||||||||||||||||||||||||
import androidx.constraintlayout.widget.ConstraintLayout | ||||||||||||||||||||||||||
import androidx.recyclerview.widget.LinearLayoutManager | ||||||||||||||||||||||||||
import androidx.recyclerview.widget.RecyclerView | ||||||||||||||||||||||||||
import ch.sdp.vibester.R | ||||||||||||||||||||||||||
|
@@ -26,7 +30,26 @@ class ScoreBoardActivity : AppCompatActivity() { | |||||||||||||||||||||||||
setSupportActionBar(findViewById(R.id.toolbar)) | ||||||||||||||||||||||||||
setupRecycleView() | ||||||||||||||||||||||||||
players = ArrayList() | ||||||||||||||||||||||||||
loadPlayers() | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* TODO: replace "ranking" by appropriate label | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
fun selectScoreboard(view: View) { | ||||||||||||||||||||||||||
var sortedBy = "" | ||||||||||||||||||||||||||
when (view.id) { | ||||||||||||||||||||||||||
R.id.btsButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
R.id.kpopButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
R.id.imagDragonsButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
R.id.billieEilishButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
R.id.rockButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
R.id.topTracksButton -> sortedBy = "ranking" | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Could store "ranking" into string.xml ? easier to modify after |
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
findViewById<ConstraintLayout>(R.id.genrePerScoreboard).visibility = GONE | ||||||||||||||||||||||||||
findViewById<ConstraintLayout>(R.id.scoreboard).visibility = VISIBLE | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
loadPlayersSortedBy(sortedBy) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
private fun setupRecycleView() { | ||||||||||||||||||||||||||
|
@@ -37,8 +60,8 @@ class ScoreBoardActivity : AppCompatActivity() { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
private fun loadPlayers() { | ||||||||||||||||||||||||||
dbRef.orderByChild("ranking") | ||||||||||||||||||||||||||
private fun loadPlayersSortedBy(order: String) { | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UsersRepo contains all the firebase calls connected with "users", should this function be moved there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean, however, It's more logical for me to put it here because this function is only used locally in scoreboard activity to load the data into the scoreboard. |
||||||||||||||||||||||||||
dbRef.orderByChild(order) | ||||||||||||||||||||||||||
.addValueEventListener(object : ValueEventListener { | ||||||||||||||||||||||||||
override fun onDataChange(snapshots: DataSnapshot) { | ||||||||||||||||||||||||||
for (snapshot in snapshots.children) { | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/chooseGenre" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:visibility="gone"> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/billieEilishButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:onClick="chooseGenre" | ||
android:background="@drawable/rounded_button" | ||
android:text="@string/billie_eilish" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.933" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.687" > | ||
</androidx.appcompat.widget.AppCompatButton> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/imagDragonsButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:onClick="chooseGenre" | ||
android:background="@drawable/rounded_button" | ||
android:text="@string/imagine_dragons" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.066" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.687" > | ||
</androidx.appcompat.widget.AppCompatButton> | ||
|
||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/btsButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:background="@drawable/rounded_button" | ||
android:onClick="chooseGenre" | ||
android:text="@string/bts" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.933" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.402" > | ||
</androidx.appcompat.widget.AppCompatButton> | ||
|
||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/rockButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:onClick="chooseGenre" | ||
android:background="@drawable/rounded_button" | ||
android:text="@string/r_o_c_k" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.065" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.403"> | ||
</androidx.appcompat.widget.AppCompatButton> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/kpopButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:onClick="chooseGenre" | ||
android:background="@drawable/rounded_button" | ||
android:text="@string/k_p_o_p" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.937" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.136"> | ||
</androidx.appcompat.widget.AppCompatButton> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/topTracksButton" | ||
android:layout_width="170dp" | ||
android:layout_height="130dp" | ||
android:background="@drawable/rounded_button" | ||
android:onClick="chooseGenre" | ||
android:text="@string/t_o_p_t_r_a_c_k_s" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.074" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.136"> | ||
</androidx.appcompat.widget.AppCompatButton> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this typo still exist? I remember fixing it in commit 5b54240