Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: assert that the UI is updated after sleep creation #441

Merged
merged 1 commit into from
Jan 19, 2024
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
Expand Up @@ -16,6 +16,7 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
import androidx.test.espresso.action.ViewActions.click
// import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intending
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
Expand All @@ -42,7 +43,8 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class MainActivityInstrumentedTest {

@get:Rule
@JvmField
@Rule
var activityScenarioRule = ActivityScenarioRule(MainActivity::class.java)

@get:Rule
Expand All @@ -68,10 +70,18 @@ class MainActivityInstrumentedTest {
}

@Test
fun testCountStat() = runBlocking {
onView(withId(R.id.start_stop)).perform(click())
onView(withId(R.id.start_stop)).perform(click())
fun testCountStat(): Unit = runBlocking {
val startStop = onView(withId(R.id.start_stop_layout))
// Start.
startStop.perform(click())
// Stop.
startStop.perform(click())

// Read number of created sleeps.
assertEquals(1, database.sleepDao().getAll().size)
// FIXME UI is not yet updated, how to wait for this?
// val sleepsCount = onView(withId(R.id.fragment_stats_sleeps))
// sleepsCount.check(matches(withText("1")))
}

@Test
Expand Down
Loading