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

Commit

Permalink
rename genre btns in scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jiabaow committed May 22, 2022
1 parent aaea119 commit 1edb23f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.sdp.vibester.fragment

import androidx.recyclerview.widget.RecyclerView
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 @@ -46,19 +45,19 @@ class ScoreBoardFragmentTest {
@Test
fun genreShouldDisappearAfterSelected() {
onView(withId(R.id.genrePerScoreboard)).check(matches(isDisplayed()))
onView(withId(R.id.rockButton)).perform(click())
onView(withId(R.id.scoreboard_rockButton)).perform(click())
onView(withId(R.id.genrePerScoreboard)).check(matches(not(isDisplayed())))
}

@Test
fun rockBtnShouldSetUpRecycleView() {
onView(withId(R.id.rockButton)).perform(click())
onView(withId(R.id.scoreboard_rockButton)).perform(click())
onView(withId(R.id.scoreboard_content_scrolling)).check(matches(isDisplayed()))
}

@Test
fun clickOnItemShouldGoesToProfileAndDisplaysScores() {
onView(withId(R.id.rockButton)).perform(click())
onView(withId(R.id.scoreboard_rockButton)).perform(click())

onView((withId(R.id.recycler_view)))
.perform(
Expand All @@ -73,26 +72,26 @@ class ScoreBoardFragmentTest {

@Test
fun topBtnClick() {
onView(withId(R.id.topTracksButton)).perform(click())
onView(withId(R.id.scoreboard_topTracksButton)).perform(click())
}

@Test
fun kpopBtnClick() {
onView(withId(R.id.kpopButton)).perform(click())
onView(withId(R.id.scoreboard_kpopButton)).perform(click())
}

@Test
fun billieEilishButtonClick() {
onView(withId(R.id.billieEilishButton)).perform(click())
onView(withId(R.id.scoreboard_billieEilishButton)).perform(click())
}

@Test
fun imagineDragonsButtonClick() {
onView(withId(R.id.imagDragonsButton)).perform(click())
onView(withId(R.id.scoreboard_imagDragonsButton)).perform(click())
}

@Test
fun btsButtonClick() {
onView(withId(R.id.btsButton)).perform(click())
onView(withId(R.id.scoreboard_btsButton)).perform(click())
}
}
24 changes: 12 additions & 12 deletions app/src/main/java/ch/sdp/vibester/fragment/ScoreBoardFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class ScoreBoardFragment : Fragment(), OnItemClickListener, View.OnClickListener
val view = inflater.inflate(R.layout.fragment_scoreboard, container, false)
val ctx = inflater.context

view.findViewById<Button>(R.id.kpopButton).setOnClickListener(this)
view.findViewById<Button>(R.id.rockButton).setOnClickListener(this)
view.findViewById<Button>(R.id.btsButton).setOnClickListener(this)
view.findViewById<Button>(R.id.topTracksButton).setOnClickListener(this)
view.findViewById<Button>(R.id.imagDragonsButton).setOnClickListener(this)
view.findViewById<Button>(R.id.billieEilishButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_kpopButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_rockButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_btsButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_topTracksButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_imagDragonsButton).setOnClickListener(this)
view.findViewById<Button>(R.id.scoreboard_billieEilishButton).setOnClickListener(this)
setupRecycleView(view, ctx)

return view
Expand Down Expand Up @@ -119,22 +119,22 @@ class ScoreBoardFragment : Fragment(), OnItemClickListener, View.OnClickListener

override fun onClick(v: View?) {
when(v!!.id) {
R.id.btsButton -> {
R.id.scoreboard_btsButton -> {
genre = "BTS"; selectScoreboard()
}
R.id.kpopButton -> {
R.id.scoreboard_kpopButton -> {
genre = "kpop"; selectScoreboard()
}
R.id.imagDragonsButton -> {
R.id.scoreboard_imagDragonsButton -> {
genre = "Imagine Dragons"; selectScoreboard()
}
R.id.billieEilishButton -> {
R.id.scoreboard_billieEilishButton -> {
genre = "Billie Eilish"; selectScoreboard()
}
R.id.rockButton -> {
R.id.scoreboard_rockButton -> {
genre = "rock";selectScoreboard()
}
R.id.topTracksButton -> {
R.id.scoreboard_topTracksButton -> {
genre = "top tracks";selectScoreboard()
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/genre_for_scoreboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/imagDragonsButton"
android:id="@+id/scoreboard_imagDragonsButton"
android:layout_width="170dp"
android:layout_height="130dp"
android:layout_weight="1"
Expand All @@ -45,7 +45,7 @@
android:layout_weight="1" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/billieEilishButton"
android:id="@+id/scoreboard_billieEilishButton"
android:layout_width="170dp"
android:layout_height="130dp"
android:layout_weight="1"
Expand All @@ -69,7 +69,7 @@
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/rockButton"
android:id="@+id/scoreboard_rockButton"
android:layout_width="170sp"
android:layout_height="130sp"
android:layout_weight="1"
Expand All @@ -88,7 +88,7 @@
android:layout_weight="1" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btsButton"
android:id="@+id/scoreboard_btsButton"
android:layout_width="170dp"
android:layout_height="130dp"
android:layout_weight="1"
Expand All @@ -112,7 +112,7 @@
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/topTracksButton"
android:id="@+id/scoreboard_topTracksButton"
android:layout_width="170dp"
android:layout_height="130dp"
android:layout_weight="1"
Expand All @@ -131,7 +131,7 @@
android:layout_weight="1" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/kpopButton"
android:id="@+id/scoreboard_kpopButton"
android:layout_width="170dp"
android:layout_height="130dp"
android:layout_weight="1"
Expand Down

0 comments on commit 1edb23f

Please sign in to comment.