Search in sources :

Example 1 with PerformException

use of com.google.android.apps.common.testing.ui.espresso.PerformException in project double-espresso by JakeWharton.

the class TypeTextActionTest method testTypeTextActionPerformInjectEventSecurityException.

public void testTypeTextActionPerformInjectEventSecurityException() throws InjectEventSecurityException {
    String stringToBeTyped = "Hello!";
    typeTextAction = new TypeTextAction(stringToBeTyped);
    when(mockUiController.injectMotionEvent(isA(MotionEvent.class))).thenReturn(true);
    when(mockUiController.injectString(stringToBeTyped)).thenThrow(new InjectEventSecurityException(""));
    try {
        typeTextAction.perform(mockUiController, mockView);
        fail("Should have thrown PerformException");
    } catch (PerformException e) {
        if (!(e.getCause() instanceof InjectEventSecurityException)) {
            fail("Exception cause should be of type InjectEventSecurityException");
        }
    }
}
Also used : PerformException(com.google.android.apps.common.testing.ui.espresso.PerformException) InjectEventSecurityException(com.google.android.apps.common.testing.ui.espresso.InjectEventSecurityException) MotionEvent(android.view.MotionEvent)

Aggregations

MotionEvent (android.view.MotionEvent)1 InjectEventSecurityException (com.google.android.apps.common.testing.ui.espresso.InjectEventSecurityException)1 PerformException (com.google.android.apps.common.testing.ui.espresso.PerformException)1