@Implements(value=android.os.Looper.class) public class ShadowLooper extends Object
Looper that enqueues posted Runnables to be run
(on this thread) later. Runnables that are scheduled to run immediately can be
triggered by calling idle().ShadowMessageQueue| Constructor and Description |
|---|
ShadowLooper() |
| Modifier and Type | Method and Description |
|---|---|
void |
__constructor__(boolean quitAllowed) |
static android.os.Looper |
getLooperForThread(Thread thread) |
static android.os.Looper |
getMainLooper() |
org.robolectric.util.Scheduler |
getScheduler()
Returns the
Scheduler that is being used to manage the enqueued tasks. |
static ShadowLooper |
getShadowMainLooper() |
boolean |
hasQuit() |
void |
idle()
Causes
Runnables that have been scheduled to run immediately to actually run. |
void |
idle(long intervalMillis)
Causes
Runnables that have been scheduled to run within the next intervalMillis milliseconds to
run while advancing the scheduler's clock. |
void |
idleConstantly(boolean shouldIdleConstantly) |
static void |
idleMainLooper() |
static void |
idleMainLooper(long interval) |
static void |
idleMainLooperConstantly(boolean shouldIdleConstantly) |
boolean |
isPaused() |
static void |
loop() |
static android.os.Looper |
myLooper() |
void |
pause() |
static void |
pauseLooper(android.os.Looper looper) |
static void |
pauseMainLooper() |
boolean |
post(Runnable runnable,
long delayMillis)
Deprecated.
Use a
Handler instance to post to a looper. |
boolean |
postAtFrontOfQueue(Runnable runnable)
Deprecated.
Use a
Handler instance to post to a looper. |
int |
postSyncBarrier() |
void |
quit() |
void |
quitUnchecked() |
void |
reset()
Causes all enqueued tasks to be discarded, and pause state to be reset
|
void |
resetScheduler() |
static void |
resetThreadLoopers() |
static void |
runMainLooperOneTask() |
static void |
runMainLooperToNextTask() |
void |
runOneTask()
Causes only one of the next
Runnables that have been scheduled to run while advancing the scheduler's
clock to its start time. |
void |
runPaused(Runnable r) |
void |
runToEndOfTasks()
|
void |
runToNextTask()
Causes the next
Runnable(s) that have been scheduled to run while advancing the scheduler's clock to its
start time. |
static void |
runUiThreadTasks()
Runs any immediately runnable tasks previously queued on the UI thread,
e.g.
|
static void |
runUiThreadTasksIncludingDelayedTasks()
Runs all runnable tasks (pending and future) that have been queued on the UI thread.
|
boolean |
setPaused(boolean shouldPause) |
void |
unPause() |
static void |
unPauseLooper(android.os.Looper looper) |
static void |
unPauseMainLooper() |
@Resetter public static void resetThreadLoopers()
@Implementation public void __constructor__(boolean quitAllowed)
@Implementation public static android.os.Looper getMainLooper()
@Implementation public static android.os.Looper myLooper()
@Implementation public static void loop()
@Implementation public void quit()
public void quitUnchecked()
@HiddenApi @Implementation public int postSyncBarrier()
public boolean hasQuit()
public static ShadowLooper getShadowMainLooper()
public static android.os.Looper getLooperForThread(Thread thread)
public static void pauseLooper(android.os.Looper looper)
public static void unPauseLooper(android.os.Looper looper)
public static void pauseMainLooper()
public static void unPauseMainLooper()
public static void idleMainLooper()
public static void idleMainLooper(long interval)
public static void idleMainLooperConstantly(boolean shouldIdleConstantly)
public static void runMainLooperOneTask()
public static void runMainLooperToNextTask()
public static void runUiThreadTasks()
Activity.runOnUiThread(Runnable) or AsyncTask.onPostExecute(Object).
Note: calling this method does not pause or un-pause the scheduler.
runUiThreadTasksIncludingDelayedTasks()public static void runUiThreadTasksIncludingDelayedTasks()
Activity.runOnUiThread(Runnable) or AsyncTask.onPostExecute(Object).
Note: calling this method does not pause or un-pause the scheduler, however the clock is advanced as future tasks are run.
runUiThreadTasks()public void idle()
Runnables that have been scheduled to run immediately to actually run. Does not advance the
scheduler's clock;public void idle(long intervalMillis)
Runnables that have been scheduled to run within the next intervalMillis milliseconds to
run while advancing the scheduler's clock.intervalMillis - milliseconds to advancepublic void idleConstantly(boolean shouldIdleConstantly)
public void runToEndOfTasks()
public void runToNextTask()
public void runOneTask()
@Deprecated public boolean post(Runnable runnable, long delayMillis)
Handler instance to post to a looper.runnable - the task to be rundelayMillis - how many milliseconds into the (virtual) future to run itHandler.postDelayed(Runnable,long)@Deprecated public boolean postAtFrontOfQueue(Runnable runnable)
Handler instance to post to a looper.runnable - the task to be runHandler.postAtFrontOfQueue(Runnable)public void pause()
public void unPause()
public boolean isPaused()
public boolean setPaused(boolean shouldPause)
public void resetScheduler()
public void reset()
public org.robolectric.util.Scheduler getScheduler()
Scheduler that is being used to manage the enqueued tasks.
This scheduler is managed by the Looper's associated queue.Scheduler that is being used to manage the enqueued tasks.public void runPaused(Runnable r)
Copyright © 2016. All rights reserved.