I create unit-test from Espresso in Android. My project has NavigationDrawer. I create test which must slide NavigationDrawer and click on button. In understand, how create slide action in my test.
My current solution:
try
{
runTestOnUiThread(new Runnable()
{
@Override
public void run()
{
DrawerLayout drawer = (DrawerLayout)getActivity().findViewById(R.id.drawer_layout);
drawer.openDrawer(Gravity.LEFT);
}
});
}
catch (Throwable e)
{
e.printStackTrace();
}
But I think it's bad code.
Add a navigation drawerThe drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen. Figure 3. An open drawer displaying a navigation menu. The drawer icon is displayed on all top-level destinations that use a DrawerLayout .
Android Navigation Drawer is a sliding left menu that is used to display the important links in the application. Navigation drawer makes it easy to navigate to and fro between those links. It's not visible by default and it needs to opened either by sliding from left or clicking its icon in the ActionBar.
There is a description how to do this in android-test-kit group, explained by ValeraZakharov - link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With