private static int selectViewPagerItem(
      Instrumentation instr, final HowItWorksActivity activity, final int position) {
    TestUtilities.runOnMainSyncWithTimeout(
        new Callable<Void>() {
          @Override
          public Void call() {
            activity.setViewPagerCurrentItem(position);
            return null;
          }
        });
    instr.waitForIdleSync();
    return activity.getViewPagerCurrentItem();
  }
Set the current item of the view pager to the requested position.

@return the current item index after the action.
javatests/com/google/android/apps/authenticator/howitworks/HowItWorksActivityTest.java