Skip to content

Instantly share code, notes, and snippets.

@quentin7b
Last active August 29, 2015 14:21
Show Gist options
  • Save quentin7b/9b51a3827c842417636b to your computer and use it in GitHub Desktop.
Save quentin7b/9b51a3827c842417636b to your computer and use it in GitHub Desktop.
Robotium 5.3.1 (App compat API 21+) / Open navigation drawer
/**
* As we use app compat it seems Solo#setNavigationDrawer is not doing well (drawer does not open, but the button is clicked)
* Same result for clickOnView(getView(android.R.id.home))
*
* This code opens the navigation drawer on the main thread
* Be aware : you need to provide your DrawerLayout id (you can do it in params)
*/
public void openCompatNavigationDrawer() {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
// You need to replace with your DrawerLayout id, or set it in params
((DrawerLayout) mSolo.getView(R.id.drawer_layout)).openDrawer(Gravity.LEFT);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment