title: Android Espresso: Make assertion while button is kept pressed
body: <p>I'm quite new to Espresso on Android and I am running into the following problem:
  I want Espresso to perform a longclick(or something..) on a button, and while the button is kept pressed down, I want to check the state of a different View.</p>
  
  <p>In (more or less) pseudocode:</p>
  
  <pre><code>onView(withId(button_id)).perform(pressButtonDown());
  onView(withId(textBox_id)).check(matches(withText("Button is pressed")));
  onView(withId(button_id)).perform(releaseButton());
  </code></pre>
  
  <p>I tried writing 2 custom Taps, PRESS and RELEASE, with MotionEvents.sendDown() and .sendUp(), but did not get it to work.
  If this is the right path, I can post the code I've got so far.</p>
  
  <p><strong>Edit:</strong></p>
  
  <pre><code>public class PressViewActions
  {
      public static ViewAction pressDown(){
          return new GeneralClickAction(HoldTap.DOWN, GeneralLocation.CENTER, Press.THUMB);
      }
  
      public static ViewAction release() {
          return new GeneralClickAction(HoldTap.UP, GeneralLocation.CENTER, Press.THUMB);
      }
  }
  </code></pre>
  
  <p>And the code for the Tappers:</p>
  
  <pre><code>public enum HoldTap implements Tapper {
  
      DOWN {
          @Override
          public Tapper.Status sendTap(UiController uiController, float[] coordinates, float[] precision)
          {
              checkNotNull(uiController);
              checkNotNull(coordinates);
              checkNotNull(precision);
  
              DownResultHolder res = MotionEvents.sendDown(uiController, coordinates, precision);
  
              ResultHolder.setController(uiController);
              ResultHolder.setResult(res);
  
              return Status.SUCCESS;
          }
      },
  
      UP{
          @Override
          public Tapper.Status sendTap(UiController uiController, float[] coordinates, float[] precision)
          {
              DownResultHolder res = ResultHolder.getResult();
              UiController controller = ResultHolder.getController();
  
              try {
                  if(!MotionEvents.sendUp(controller, res.down))
                  {
                      MotionEvents.sendCancel(controller, res.down);
                      return Status.FAILURE;
                  }
  
              }
              finally {
                  //res.down.recycle();
              }
  
              return Status.SUCCESS;
          }
      }
  }
  </code></pre>
  
  <p>The error I get is the following:</p>
  
  <pre><code>android.support.test.espresso.PerformException: Error performing 'up click' on view 'with id: de.test.app:id/key_ptt'.
  ...
  ...
  Caused by: java.lang.RuntimeException: Couldn't click at: 281.5,1117.5 precision: 25.0, 25.0 . Tapper: UP coordinate provider: CENTER precision describer: THUMB. Tried 3 times. With Rollback? false
  </code></pre>
  
  <p>I hope, this helps.</p>
  
  <p>Any help and ideas will be appreciated!</p>
  
  <p>Tanks a lot in advance!</p>