本文整理匯總了Java中android.support.test.espresso.UiController.loopMainThreadForAtLeast方法的典型用法代碼示例。如果您正苦於以下問題:Java UiController.loopMainThreadForAtLeast方法的具體用法?Java UiController.loopMainThreadForAtLeast怎麽用?Java UiController.loopMainThreadForAtLeast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.test.espresso.UiController
的用法示例。
在下文中一共展示了UiController.loopMainThreadForAtLeast方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeSoftKeyboard
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
public static ViewAction closeSoftKeyboard() {
return new ViewAction() {
/**
* The real {@link CloseKeyboardAction} instance.
*/
private final ViewAction mCloseSoftKeyboard = new CloseKeyboardAction();
@Override
public Matcher<View> getConstraints() {
return mCloseSoftKeyboard.getConstraints();
}
@Override
public String getDescription() {
return mCloseSoftKeyboard.getDescription();
}
@Override
public void perform(final UiController uiController, final View view) {
mCloseSoftKeyboard.perform(uiController, view);
uiController.loopMainThreadForAtLeast(KEYBOARD_DISMISSAL_DELAY_MILLIS);
}
};
}
示例2: loopMainThreadFor
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
public static ViewAction loopMainThreadFor(final long millis) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isEnabled();
}
@Override
public String getDescription() {
return "Rturns an action that loops the main thread for at least " + millis +"ms.";
}
@Override
public void perform(final UiController uiController, final View view) {
uiController.loopMainThreadForAtLeast(millis);
}
};
}
示例3: waitFor
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
public static ViewAction waitFor(final long millis) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "Wait for " + millis + " milliseconds.";
}
@Override
public void perform(UiController uiController, final View view) {
uiController.loopMainThreadForAtLeast(millis);
}
};
}
示例4: performWaitLoop
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
public static void performWaitLoop(UiController controller, long waitTime) {
controller.loopMainThreadForAtLeast(waitTime);
}
示例5: closeSoftKeyboardWithDelay
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
/**
* Give keyboard time to close, to avoid java.lang.SecurityException
* if hidden button is clicked next.
*/
static ViewAction closeSoftKeyboardWithDelay() {
return new ViewAction() {
/**
* The delay time to allow the soft keyboard to dismiss.
*/
private static final long KEYBOARD_DISMISSAL_DELAY_MILLIS = 1000L;
/**
* The real {@link CloseKeyboardAction} instance.
*/
private final ViewAction mCloseSoftKeyboard = new CloseKeyboardAction();
@Override
public Matcher<View> getConstraints() {
return mCloseSoftKeyboard.getConstraints();
}
@Override
public String getDescription() {
return mCloseSoftKeyboard.getDescription();
}
@Override
public void perform(final UiController uiController, final View view) {
mCloseSoftKeyboard.perform(uiController, view);
uiController.loopMainThreadForAtLeast(KEYBOARD_DISMISSAL_DELAY_MILLIS);
}
};
}
示例6: waitForMatch
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
public static ViewAction waitForMatch(final Matcher<View> aViewMatcher, final long timeout) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "Waiting for view matching " + aViewMatcher;
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final long startTime = System.currentTimeMillis();
final long endTime = startTime + timeout;
do {
for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
if (aViewMatcher.matches(child)) {
// found
return;
}
}
uiController.loopMainThreadForAtLeast(50);
} while (System.currentTimeMillis() < endTime);
//The action has timed out.
throw new PerformException.Builder()
.withActionDescription(getDescription())
.withViewDescription("")
.withCause(new TimeoutException())
.build();
}
};
}
示例7: waitId
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
/**
* Perform action of waiting for a specific view id.
*/
public static ViewAction waitId(final int viewId, final long millis) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
}
@Override
public void perform(final UiController uiController, final View view) {
uiController.loopMainThreadUntilIdle();
final long startTime = System.currentTimeMillis();
final long endTime = startTime + millis;
final Matcher<View> viewMatcher = withId(viewId);
do {
for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
// found view with required ID
if (viewMatcher.matches(child)) {
return;
}
}
uiController.loopMainThreadForAtLeast(50);
}
while (System.currentTimeMillis() < endTime);
// timeout happens
throw new PerformException.Builder()
.withActionDescription(this.getDescription())
.withViewDescription(HumanReadables.describe(view))
.withCause(new TimeoutException())
.build();
}
};
}
示例8: perform
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadForAtLeast(loopTime);
}
示例9: waitId
import android.support.test.espresso.UiController; //導入方法依賴的package包/類
/** Perform action of waiting for a specific view id. */
public static ViewAction waitId(final int viewId, final long millis) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
}
@Override
public void perform(final UiController uiController, final View view) {
uiController.loopMainThreadUntilIdle();
final long startTime = System.currentTimeMillis();
final long endTime = startTime + millis;
final Matcher<View> viewMatcher = withId(viewId);
do {
for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
// found view with required ID
if (viewMatcher.matches(child)) {
return;
}
}
uiController.loopMainThreadForAtLeast(50);
}
while (System.currentTimeMillis() < endTime);
// timeout happens
throw new PerformException.Builder()
.withActionDescription(this.getDescription())
.withViewDescription(HumanReadables.describe(view))
.withCause(new TimeoutException())
.build();
}
};
}