MainActivityTest.kt 1.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package fr.chenry.android.freshrss.activities

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.DrawerActions
import androidx.test.espresso.contrib.DrawerMatchers.isClosed
import androidx.test.espresso.contrib.DrawerMatchers.isOpen
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import fr.chenry.android.freshrss.R
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@LargeTest
class MainActivityTest {


    @get:Rule
    val activityRule = ActivityTestRule(MainActivity::class.java)

    @Test
    fun `check-drawer-is-closed-when-adding-a-new-subscription`() {
        // Open drawer
        onView(withId(R.id.activity_main_navigation_drawer)).perform(DrawerActions.open())
        onView(withId(R.id.activity_main_navigation_drawer)).check(matches(isOpen()))
        onView(withText(R.string.title_add_subscription)).perform(click())
        onView(withText(android.R.string.ok)).perform(click())
        onView(withId(R.id.activity_main_navigation_drawer)).check(matches(isClosed()))
    }

}