How to use DrawerMatchers class of android.support.test.espresso.contrib package

Best Appium-espresso-driver code snippet using android.support.test.espresso.contrib.DrawerMatchers

NavigationDrawerTests.kt

Source:NavigationDrawerTests.kt Github

copy

Full Screen

...16import team16.easytracker.database.DbHelper17import java.time.LocalDate18import java.time.LocalDateTime19import androidx.test.espresso.contrib.DrawerActions20import androidx.test.espresso.contrib.DrawerMatchers21import androidx.test.espresso.contrib.NavigationViewActions22import team16.easytracker.model.Company23import com.google.android.material.internal.NavigationMenuItemView24@RunWith(AndroidJUnit4::class)25class NavigationDrawerTests : TestFramework() {26 private var company : Company? = null27 private fun insertDummyCompany(companyName: String): Int {28 if (company == null)29 {30 val companyId = dbHelper.saveCompany(companyName, 1)31 company = dbHelper.loadCompany(companyId)!!32 }33 return company!!.getId()34 }35 @Before36 override fun setup() {37 super.setup()38 setupLoggedInWorker()39 }40 fun loginwithCompanyWorker()41 {42 val company = insertDummyCompany()43 dbHelper.addWorkerToCompany(MyApplication.loggedInWorker?.getId()!!, company.getId(), "Test")44 dbHelper.setCompanyAdmin(MyApplication.loggedInWorker?.getId()!!, company.getId(), false)45 var activity = getCurrentActivity() as LoginActivity46 onView(withId(R.id.etEmail)).perform(typeText(loggedInWorker.email))47 closeSoftKeyboard()48 onView(withId(R.id.etPassword)).perform(typeText("12345678"))49 closeSoftKeyboard()50 onView(withId(R.id.btnLogin)).perform(click())51 }52 fun loginWithNoCompanyWorker()53 {54 var activity = getCurrentActivity() as LoginActivity55 onView(withId(R.id.etEmail)).perform(typeText(loggedInWorker.email))56 closeSoftKeyboard()57 onView(withId(R.id.etPassword)).perform(typeText("12345678"))58 closeSoftKeyboard()59 onView(withId(R.id.btnLogin)).perform(click())60 }61 fun loginwithCompanyWorkerAdmin()62 {63 val company = insertDummyCompany()64 dbHelper.addWorkerToCompany(MyApplication.loggedInWorker?.getId()!!, company.getId(), "Test")65 dbHelper.setCompanyAdmin(MyApplication.loggedInWorker?.getId()!!, company.getId(), true)66 var activity = getCurrentActivity() as LoginActivity67 onView(withId(R.id.etEmail)).perform(typeText(loggedInWorker.email))68 closeSoftKeyboard()69 onView(withId(R.id.etPassword)).perform(typeText("12345678"))70 closeSoftKeyboard()71 onView(withId(R.id.btnLogin)).perform(click())72 }73 @get:Rule74 val activityRule = ActivityScenarioRule(LoginActivity::class.java)75 fun getCurrentActivity(): Activity {76 var currentActivity: Activity? = null77 getInstrumentation().runOnMainSync { run { currentActivity =78 ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)79 .elementAtOrNull(0)80 }81 }82 return currentActivity!!83 }84 @Test85 fun initialFragmentDashboardTest()86 {87 loginwithCompanyWorker()88 var activity = getCurrentActivity() as HomeActivity89 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_DASHBOARD")90 assert(fragment?.isVisible!!)91 }92 @Test93 fun checkMenuItemVisabilityNoCompany()94 {95 loginWithNoCompanyWorker()96 var activity = getCurrentActivity() as HomeActivity97 var navigationView = activity.findViewById<NavigationView>(R.id.navigationView)98 assert(!navigationView.menu.findItem(R.id.itemAddEmployee).isVisible)99 assert(!navigationView.menu.findItem(R.id.itemOverview).isVisible)100 }101 @Test102 fun checkMenuItemVisabilityCompany()103 {104 loginwithCompanyWorkerAdmin()105 var activity = getCurrentActivity() as HomeActivity106 onView(withId(R.id.drawerLayout))107 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.108 .perform(DrawerActions.open()) // Open Drawer109 var navigationView = activity.findViewById<NavigationView>(R.id.navigationView)110 assert(navigationView.menu.findItem(R.id.itemAddEmployee).isVisible)111 assert(navigationView.menu.findItem(R.id.itemOverview).isVisible)112 assert(!navigationView.menu.findItem(R.id.itemCreateCompany).isVisible)113 }114 @Test115 fun checkMenuItemVisabilityCompanyNoAdmin()116 {117 loginwithCompanyWorker()118 var activity = getCurrentActivity() as HomeActivity119 var navigationView = activity.findViewById<NavigationView>(R.id.navigationView)120 assert(!navigationView.menu.findItem(R.id.itemAddEmployee).isVisible)121 assert(navigationView.menu.findItem(R.id.itemOverview).isVisible)122 assert(!navigationView.menu.findItem(R.id.itemCreateCompany).isVisible)123 }124 @Test125 fun navigateToTrackings()126 {127 loginwithCompanyWorker()128 var activity = getCurrentActivity() as HomeActivity129 onView(withId(R.id.drawerLayout))130 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.131 .perform(DrawerActions.open()) // Open Drawer132 // Start the screen of your activity.133 onView(withId(R.id.navigationView))134 .perform(NavigationViewActions.navigateTo(R.id.itemTrackings))135 Thread.sleep(1000)136 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_TRACKINGS")137 assert(fragment?.isVisible!!)138 }139 @Test140 fun navigateToBluetooth()141 {142 loginwithCompanyWorkerAdmin()143 val companyID = insertDummyCompany("DummyCompany")144 dbHelper.addWorkerToCompany(MyApplication.loggedInWorker?.getId()!!, companyID, "Test")145 dbHelper.setCompanyAdmin(MyApplication.loggedInWorker?.getId()!!, companyID, true)146 var activity = getCurrentActivity() as HomeActivity147 onView(withId(R.id.drawerLayout))148 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.149 .perform(DrawerActions.open()) // Open Drawer150 onView(withId(R.id.navigationView))151 .perform(NavigationViewActions.navigateTo(R.id.itemBluetoothDevices))152 Thread.sleep(1000)153 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_BLUETOOTHDEVICES")154 assert(fragment?.isVisible!!)155 }156 @Test157 fun navigateToAddEmployee()158 {159 loginwithCompanyWorkerAdmin()160 val companyID = insertDummyCompany("DummyCompany")161 dbHelper.addWorkerToCompany(MyApplication.loggedInWorker?.getId()!!, companyID, "Test")162 dbHelper.setCompanyAdmin(MyApplication.loggedInWorker?.getId()!!, companyID, true)163 var activity = getCurrentActivity() as HomeActivity164 onView(withId(R.id.drawerLayout))165 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.166 .perform(DrawerActions.open()) // Open Drawer167 // Start the screen of your activity.168 onView(withId(R.id.navigationView))169 .perform(NavigationViewActions.navigateTo(R.id.itemAddEmployee))170 Thread.sleep(1000)171 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_ADDEMPLOYEE")172 assert(fragment?.isVisible!!)173 }174 @Test175 fun navigateToCompanyOverview()176 {177 loginwithCompanyWorker()178 val companyID = insertDummyCompany("DummyCompany")179 dbHelper.addWorkerToCompany(MyApplication.loggedInWorker?.getId()!!, companyID, "Test")180 var activity = getCurrentActivity() as HomeActivity181 onView(withId(R.id.drawerLayout))182 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.183 .perform(DrawerActions.open()) // Open Drawer184 // Start the screen of your activity.185 onView(withId(R.id.navigationView))186 .perform(NavigationViewActions.navigateTo(R.id.itemOverview))187 Thread.sleep(1000)188 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_OVERVIEW")189 assert(fragment?.isVisible!!)190 }191 @Test192 fun navigateToCreateCompany()193 {194 loginWithNoCompanyWorker()195 var activity = getCurrentActivity() as HomeActivity196 onView(withId(R.id.drawerLayout))197 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.198 .perform(DrawerActions.open()) // Open Drawer199 // Start the screen of your activity.200 onView(withId(R.id.navigationView))201 .perform(NavigationViewActions.navigateTo(R.id.itemCreateCompany))202 Thread.sleep(1000)203 var fragment = activity.supportFragmentManager.findFragmentByTag("TAG_CREATECOMPANY")204 assert(fragment?.isVisible!!)205 }206 @Test207 fun logoutTest()208 {209 loginWithNoCompanyWorker()210 var activity = getCurrentActivity() as HomeActivity211 onView(withId(R.id.drawerLayout))212 .check(matches(DrawerMatchers.isClosed(Gravity.LEFT)))// Left Drawer should be closed.213 .perform(DrawerActions.open()) // Open Drawer214 onView(withId(R.id.navigationView))215 .perform(NavigationViewActions.navigateTo(R.id.itemLogout))216 Thread.sleep(1000)217 assert(MyApplication.loggedInWorker == null)218 }219}...

Full Screen

Full Screen

TeamDetailActivityTest.kt

Source:TeamDetailActivityTest.kt Github

copy

Full Screen

...3import android.support.test.espresso.Espresso4import android.support.test.espresso.action.ViewActions5import android.support.test.espresso.assertion.ViewAssertions6import android.support.test.espresso.contrib.DrawerActions7import android.support.test.espresso.contrib.DrawerMatchers8import android.support.test.espresso.contrib.NavigationViewActions9import android.support.test.espresso.contrib.RecyclerViewActions10import android.support.test.espresso.matcher.ViewMatchers11import android.support.test.rule.ActivityTestRule12import android.support.test.runner.AndroidJUnit413import android.support.v7.widget.RecyclerView14import android.view.Gravity15import com.dscunikom.android.footballmatchschedule.R16import com.dscunikom.android.footballmatchschedule.activity.main.MainActivity17import org.junit.Assert.*18import org.junit.BeforeClass19import org.junit.Rule20import org.junit.Test21import org.junit.runner.RunWith22@RunWith(AndroidJUnit4::class)23class TeamDetailActivityTest {24 @Rule25 @JvmField26 var activityRule = ActivityTestRule(MainActivity::class.java)27 companion object {28 @JvmStatic29 @BeforeClass30 fun beforeClass() {31 InstrumentationRegistry.getTargetContext().deleteDatabase("FavoriteMatch.db")32 }33 }34 @Test35 fun testTeamDetailBehaviour() {36 Thread.sleep(3000)37 Espresso.onView(ViewMatchers.withId(R.id.drawerLayout))38 .check(ViewAssertions.matches(DrawerMatchers.isClosed(Gravity.LEFT))).perform(DrawerActions.open())39 Espresso.onView(ViewMatchers.withId(R.id.navView)).perform(NavigationViewActions.navigateTo(R.id.nav_team))40 Thread.sleep(3000)41 Espresso.onView(ViewMatchers.withId(R.id.list_team)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))42 Espresso.onView(ViewMatchers.withId(R.id.list_team)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(10))43 Espresso.onView(ViewMatchers.withId(R.id.list_team)).perform(44 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(10, ViewActions.click()))45 Thread.sleep(3000)46 Espresso.onView(ViewMatchers.withId(R.id.view_pager)).perform(ViewActions.swipeLeft())47 Thread.sleep(3000)48 Espresso.onView(ViewMatchers.withId(R.id.list_player))49 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))50 Espresso.onView(ViewMatchers.withId(R.id.list_player)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(10))51 Espresso.onView(ViewMatchers.withId(R.id.list_player)).perform(52 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(10, ViewActions.click()))53 Thread.sleep(3000)54 }55 @Test56 fun testFavoriteTeamBehaviour() {57 Thread.sleep(3000)58 Espresso.onView(ViewMatchers.withId(R.id.drawerLayout))59 .check(ViewAssertions.matches(DrawerMatchers.isClosed(Gravity.LEFT))).perform(DrawerActions.open())60 Espresso.onView(ViewMatchers.withId(R.id.navView)).perform(NavigationViewActions.navigateTo(R.id.nav_team))61 Thread.sleep(3000)62 Espresso.onView(ViewMatchers.withId(R.id.list_team)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))63 Espresso.onView(ViewMatchers.withId(R.id.list_team)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(10))64 Espresso.onView(ViewMatchers.withId(R.id.list_team)).perform(65 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(10, ViewActions.click()))66 Thread.sleep(3000)67 Espresso.onView(ViewMatchers.withId(R.id.add_to_favorite)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))68 Espresso.onView(ViewMatchers.withId(R.id.add_to_favorite)).perform(ViewActions.click())69 Espresso.pressBack()70 Espresso.onView(ViewMatchers.withId(R.id.drawerLayout))71 .check(ViewAssertions.matches(DrawerMatchers.isClosed(Gravity.LEFT))).perform(DrawerActions.open())72 Espresso.onView(ViewMatchers.withId(R.id.navView)).perform(NavigationViewActions.navigateTo(R.id.nav_favorite))73 Thread.sleep(3000)74 Espresso.onView(ViewMatchers.withId(R.id.viewpager)).perform(ViewActions.swipeLeft())75 Espresso.onView(ViewMatchers.withId(R.id.list_team_favorite))76 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))77 }78}

Full Screen

Full Screen

GardenActivityTest.kt

Source:GardenActivityTest.kt Github

copy

Full Screen

...19import android.support.test.espresso.Espresso.onView20import android.support.test.espresso.action.ViewActions21import android.support.test.espresso.action.ViewActions.click22import android.support.test.espresso.assertion.ViewAssertions.matches23import android.support.test.espresso.contrib.DrawerMatchers.isClosed24import android.support.test.espresso.contrib.DrawerMatchers.isOpen25import android.support.test.espresso.contrib.NavigationViewActions.navigateTo26import android.support.test.espresso.matcher.ViewMatchers.isDisplayed27import android.support.test.espresso.matcher.ViewMatchers.isRoot28import android.support.test.espresso.matcher.ViewMatchers.withContentDescription29import android.support.test.espresso.matcher.ViewMatchers.withId30import android.support.test.rule.ActivityTestRule31import android.view.Gravity32import com.google.samples.apps.sunflower.utilities.getToolbarNavigationContentDescription33import org.junit.Assert.assertEquals34import org.junit.Rule35import org.junit.Test36class GardenActivityTest {37 @Rule @JvmField38 var activityTestRule = ActivityTestRule(GardenActivity::class.java)...

Full Screen

Full Screen

ContainerActivityInstrumentedTest.kt

Source:ContainerActivityInstrumentedTest.kt Github

copy

Full Screen

...6import android.support.test.espresso.matcher.ViewMatchers.withId7import android.support.test.espresso.matcher.ViewMatchers.isDisplayed8import android.support.test.espresso.assertion.ViewAssertions.matches9import android.support.test.espresso.contrib.DrawerActions10import android.support.test.espresso.contrib.DrawerMatchers11import android.support.test.espresso.contrib.NavigationViewActions12import android.support.test.rule.ActivityTestRule13import org.junit.Test14import org.junit.runner.RunWith15import org.junit.Assert.*16import org.junit.Rule17@RunWith(AndroidJUnit4::class)18class ContainerActivityInstrumentedTest {19 @Rule20 @JvmField21 val mActivityRule: ActivityTestRule<ContainerActivity> = ActivityTestRule(ContainerActivity::class.java)22 @Test23 fun useAppContext() {24 // Context of the app under test.25 val appContext = InstrumentationRegistry.getTargetContext()26 assertEquals("alison.fivethingskotlin", appContext.packageName)27 }28 //TODO how to mock AccountManager in the fragment?29 @Test30 fun userCanOpenAppDrawer() {31 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())32 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen()))33 }34 @Test35 fun userCanCloseAppDrawerWithBackButton() {36 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())37 pressBack()38 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isClosed()))39 }40 @Test41 fun userCanClickFiveThingsNavButton() {42 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())43 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen()))44 onView(withId(R.id.navigation_view)).perform(NavigationViewActions.navigateTo(R.id.five_things_item))45 onView(withId(R.id.five_things_container)).check(matches(isDisplayed()))46 }47 @Test48 fun userCanClickDesignsNavButton() {49 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())50 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen()))51 onView(withId(R.id.navigation_view)).perform(NavigationViewActions.navigateTo(R.id.templates_item))52 onView(withId(R.id.designs_container)).check(matches(isDisplayed()))53 }54 @Test55 fun userCanClickSettingsNavButton() {56 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())57 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen()))58 onView(withId(R.id.navigation_view)).perform(NavigationViewActions.navigateTo(R.id.settings_item))59 onView(withId(R.id.settings_container)).check(matches(isDisplayed()))60 }61 @Test62 fun userCanClickAnalyticsNavButton() {63 onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())64 onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen()))65 onView(withId(R.id.navigation_view)).perform(NavigationViewActions.navigateTo(R.id.analytics_item))66 onView(withId(R.id.analytics_container)).check(matches(isDisplayed()))67 }68}...

Full Screen

Full Screen

AppNavigationTest.kt

Source:AppNavigationTest.kt Github

copy

Full Screen

...12import android.support.test.espresso.Espresso.onView13import android.support.test.espresso.action.ViewActions.click14import android.support.test.espresso.assertion.ViewAssertions.matches15import android.support.test.espresso.contrib.DrawerActions.open16import android.support.test.espresso.contrib.DrawerMatchers.isClosed17import android.support.test.espresso.contrib.DrawerMatchers.isOpen18import android.support.test.espresso.contrib.NavigationViewActions.navigateTo19import android.support.test.espresso.matcher.ViewMatchers.withContentDescription20import android.support.test.espresso.matcher.ViewMatchers.withId21import android.support.test.espresso.matcher.ViewMatchers.withText22/**23 * Tests for the [DrawerLayout] layout component in [RoomsActivity] which manages24 * navigation within the app.25 */26@RunWith(AndroidJUnit4::class)27@LargeTest28class AppNavigationTest {29 /**30 * [ActivityTestRule] is a JUnit [@Rule][Rule] to launch your activity under test.31 *...

Full Screen

Full Screen

TestFilters.kt

Source:TestFilters.kt Github

copy

Full Screen

...4import android.support.test.espresso.action.ViewActions.click5import android.support.test.espresso.assertion.ViewAssertions6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.contrib.DrawerActions8import android.support.test.espresso.contrib.DrawerMatchers9import android.support.test.espresso.contrib.NavigationViewActions10import android.support.test.espresso.matcher.ViewMatchers11import android.support.test.espresso.matcher.ViewMatchers.*12import android.support.test.rule.ActivityTestRule13import android.support.test.runner.AndroidJUnit414import android.view.Gravity15import org.hamcrest.Matchers.*16import org.junit.Before17import org.junit.Rule18import org.junit.Test19import org.junit.runner.RunWith20import ru.a1024bits.bytheway.R21import ru.a1024bits.bytheway.ui.activity.MenuActivity22@RunWith(AndroidJUnit4::class)23class TestFilters {24 @Rule25 @JvmField26 val mActivityRule = ActivityTestRule<MenuActivity>(MenuActivity::class.java)27 @Before28 fun init() {29 onView(ViewMatchers.withId(R.id.drawer_layout))30 .check(ViewAssertions.matches(DrawerMatchers.isClosed(Gravity.LEFT)))31 .perform(DrawerActions.open())32 onView(ViewMatchers.withId(R.id.nav_view))33 .perform(NavigationViewActions.navigateTo(R.id.all_users_item))34 onView(ViewMatchers.withId(R.id.displayAllUsers)).check(ViewAssertions.matches(ViewMatchers.isEnabled()))35 onView(withId(R.id.searchParametersText)).check(matches(isDisplayed())).perform(click())36 onView(withId(R.id.block_search_parameters)).check(matches(isDisplayed()))37 }38 @Test39 fun testBubgets() {40 onView(withId(R.id.startBudget)).check(matches(isDisplayed()))41 onView(withId(R.id.endBudget)).check(matches(isDisplayed()))42 }43 @Test44 fun testAges() {...

Full Screen

Full Screen

MainActivityTest.kt

Source:MainActivityTest.kt Github

copy

Full Screen

...6import android.support.test.espresso.action.Press7import android.support.test.espresso.action.Tap8import android.support.test.espresso.assertion.ViewAssertions.matches9import android.support.test.espresso.contrib.DrawerActions10import android.support.test.espresso.contrib.DrawerMatchers11import android.support.test.espresso.contrib.DrawerMatchers.isClosed12import android.support.test.filters.SmallTest13import android.support.test.rule.ActivityTestRule14import android.support.test.runner.AndroidJUnit415import android.support.v4.widget.DrawerLayout16import android.view.InputDevice17import android.view.MotionEvent18import org.hamcrest.Matchers.instanceOf19import org.junit.Rule20import org.junit.Test21import org.junit.runner.RunWith22@RunWith(AndroidJUnit4::class)23@SmallTest24class MainActivityTest {25 @get:Rule26 var rule = ActivityTestRule(MainActivity::class.java)27 @Test28 fun openDrawer() {29 Espresso.onView(instanceOf(DrawerLayout::class.java))30 .check(matches(isClosed()))31 .perform(DrawerActions.open())32 Thread.sleep(1000)33 matches(DrawerMatchers.isOpen())34 }35/*36 @Test37 fun scheduleOpenActivityTest() {38 onView(withId(R.id.material_drawer_slider_layout))39 //.check(ViewAssertions.matches(DrawerMatchers.isOpen(Gravity.START)))40 .perform(DrawerActions.open())41 .perform(NavigationViewActions.navigateTo(R.id.schedule))42 Thread.sleep(1000)43 onView(Matchers.instanceOf(TimetableLayout::class.java))44 .perform(clickXY(20, 20))45 .perform(clickXY(20, 20))46 }*/47 private fun clickXY(x: Int, y: Int): ViewAction {48 return GeneralClickAction(49 Tap.SINGLE,50 CoordinatesProvider { view ->51 val screenPos = IntArray(2)52 view.getLocationOnScreen(screenPos)53 val screenX = (screenPos[0] + x).toFloat()...

Full Screen

Full Screen

NavigatorTest.kt

Source:NavigatorTest.kt Github

copy

Full Screen

2import android.support.test.InstrumentationRegistry3import android.support.test.espresso.Espresso.onView4import android.support.test.espresso.action.ViewActions.click5import android.support.test.espresso.assertion.ViewAssertions.matches6import android.support.test.espresso.contrib.DrawerMatchers.isClosed7import android.support.test.espresso.contrib.DrawerMatchers.isOpen8import android.support.test.espresso.matcher.ViewMatchers.*9import android.support.test.filters.LargeTest10import android.support.test.rule.ActivityTestRule11import android.support.test.runner.AndroidJUnit412import android.view.Gravity13import org.junit.Test14import org.junit.runner.RunWith15import org.junit.Assert.*16import org.junit.Before17import org.junit.ClassRule18import org.junit.Rule19/**20 * Instrumented test, which will execute on an Android device.21 *...

Full Screen

Full Screen

DrawerMatchers

Using AI Code Generation

copy

Full Screen

1import org.junit.Rule;2import org.junit.Test;3import org.junit.runner.RunWith;4import android.support.test.espresso.contrib.DrawerMatchers;5import android.support.test.espresso.contrib.NavigationViewActions;6import android.support.test.rule.ActivityTestRule;7import android.support.test.runner.AndroidJUnit4;8import android.support.v4.widget.DrawerLayout;9import android.support.v7.widget.Toolbar;10import android.view.Gravity;11import android.widget.TextView;12import static android.support.test.espresso.Espresso.onView;13import static android.support.test.espresso.action.ViewActions.click;14import static android.support.test.espresso.assertion.ViewAssertions.matches;15import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;16import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;17import static android.support.test.espresso.matcher.ViewMatchers.withId;18import static android.support.test.espresso.matcher.ViewMatchers.withText;19import static android.support.test.espresso.matcher.ViewMatchers.withParent;20import static org.hamcrest.Matchers.allOf;21import static org.hamcrest.Matchers.instanceOf;22@RunWith(AndroidJUnit4.class)23public class DrawerLayoutActivityTest {24public ActivityTestRule<DrawerLayoutActivity> mActivityRule = new ActivityTestRule<>(DrawerLayoutActivity.class);25public void drawerLayoutTest() {26onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isClosed(Gravity.LEFT)));27onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());28onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isOpen(Gravity.LEFT)));29onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());30onView(withId(R.id.drawer_layout)).check(matches(DrawerMatchers.isClosed(Gravity.LEFT)));31}32}

Full Screen

Full Screen

DrawerMatchers

Using AI Code Generation

copy

Full Screen

1@RunWith(AndroidJUnit4.class)2public class MainActivityTest {3 public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);4 public void clickOnDrawerItem() {5 onView(withId(R.id.drawer_layout))6 .perform(DrawerActions.open());7 onView(withId(R.id.nav_view))8 .perform(NavigationViewActions.navigateTo(R.id.nav_gallery));9 onView(withId(R.id.text_gallery))10 .check(matches(isDisplayed()));11 }12}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium-espresso-driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in DrawerMatchers

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful