Created
July 11, 2014 20:14
-
-
Save DavidRyan/51e3afb517d79a1b3046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Perform action of waiting for a specific view id. */ | |
public static ViewAction waitForId(final int viewId, final long millis) { | |
return new ViewAction() { | |
@Override | |
public Matcher<View> getConstraints() { | |
return isDisplayed(); | |
} | |
@Override | |
public String getDescription() { | |
return "waited for a specific view with id <" + viewId + "> for " + millis + " millis."; | |
} | |
@Override | |
public void perform(final UiController uiController, final View view) { | |
uiController.loopMainThreadUntilIdle(); | |
final long startTime = System.currentTimeMillis(); | |
final long endTime = startTime + millis; | |
do { | |
uiController.loopMainThreadForAtLeast(100); | |
} | |
while (System.currentTimeMillis() < endTime); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment