com.xtremelabs.robolectric.shadows
Class ShadowHandler

java.lang.Object
  extended by com.xtremelabs.robolectric.shadows.ShadowHandler

@Implements(value=android.os.Handler.class)
public class ShadowHandler
extends java.lang.Object

Shadow for Handler that puts posted Runnables into a queue instead of sending them to be handled on a separate thread.Runnables that are scheduled to be executed immediately can be triggered by calling flush(). todo: add utility method to advance time and trigger execution of Runnables scheduled for a time in the future


Constructor Summary
ShadowHandler()
           
 
Method Summary
 void __constructor__()
           
 void __constructor__(android.os.Looper looper)
           
static void flush()
          Causes any posted Runnables that are scheduled to run immediately to actually be run.
 android.os.Message obtainMessage(int what, java.lang.Object obj)
           
 boolean post(java.lang.Runnable r)
           
 boolean postDelayed(java.lang.Runnable r, long delayMillis)
           
 boolean sendEmptyMessage(int what)
           
 boolean sendMessage(android.os.Message msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShadowHandler

public ShadowHandler()
Method Detail

__constructor__

public void __constructor__()

__constructor__

public void __constructor__(android.os.Looper looper)

post

@Implementation
public boolean post(java.lang.Runnable r)

postDelayed

@Implementation
public boolean postDelayed(java.lang.Runnable r,
                                          long delayMillis)

obtainMessage

@Implementation
public android.os.Message obtainMessage(int what,
                                                       java.lang.Object obj)

sendMessage

@Implementation
public final boolean sendMessage(android.os.Message msg)

sendEmptyMessage

@Implementation
public final boolean sendEmptyMessage(int what)

flush

public static void flush()
Causes any posted Runnables that are scheduled to run immediately to actually be run. This gives visibility into the order in which things will happen. An event can be triggered and its immediate effects examined, and then flush() can be called and the side-effects of the original event can be examined.