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

Commit

Permalink
test to scoreboard button
Browse files Browse the repository at this point in the history
  • Loading branch information
jiabaow committed Mar 9, 2022
1 parent a145ce2 commit 2049cd0
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions app/src/androidTest/java/ch/sdp/vibester/MainActivityTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra
import androidx.test.espresso.intent.matcher.IntentMatchers.toPackage
import androidx.test.espresso.intent.matcher.IntentMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import ch.sdp.vibester.scoreboard.ScoreBoardActivity
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -22,15 +24,29 @@ class MainActivityTest {
MainActivity::class.java
)

@Before
fun setUp() {
Intents.init()
}

@After
fun clean() {
Intents.release()
}

@Test
fun mainTest(){
val inputName = "SDPUser"
Intents.init()
onView(withId(R.id.mainNameInput)).perform(typeText(inputName))
onView(withId(R.id.mainButton)).perform(click())
intended(toPackage("ch.sdp.vibester"))
intended(hasExtra("name", inputName))
Intents.release()
}

@Test
fun scoreboardTest() {
onView(withId(R.id.scoreboardButton)).perform(click())
intended(hasComponent(ScoreBoardActivity::class.qualifiedName))
}


Expand Down

0 comments on commit 2049cd0

Please sign in to comment.