1 package org.robolectric.shadows; 2 3 import static org.robolectric.Shadows.shadowOf; 4 5 import android.os.Handler; 6 import android.os.Looper; 7 import org.robolectric.annotation.Implements; 8 9 /** 10 * Robolectric places posted {@link Runnable}s into a queue instead of sending them to be handled on a 11 * separate thread. {@link Runnable}s that are scheduled to be executed immediately can be triggered by calling 12 * {@link #idleMainLooper()}. 13 * 14 * todo: add utility method to advance time and trigger execution of Runnables scheduled for a time in the future 15 * 16 * @deprecated There is no special shadow implementation for the {@link android.os.Handler} class. The special 17 * handling is all done by {@link ShadowLooper} and {@link ShadowMessageQueue}. This class has been retained 18 * for backward compatibility with the various static method implementations. 19 */ 20 // <b>Note</b>: If this shadow is ever completely removed it will still probably make sense to keep 21 // the associated tests - if necessary we can copy them into ShadowLooperTest or ShadowMessageQueueTest. 22 @Deprecated 23 // Even though it doesn't implement anything, some parts of the system will fail if we don't have the 24 // @Implements tag (ShadowWrangler). 25 @Implements(Handler.class) 26 public class ShadowHandler { 27 /** 28 * @deprecated use {@link ShadowLooper#idleMainLooper()} instead 29 */ 30 @Deprecated 31 public static void flush() { 32 idleMainLooper(); 33 } 34 35 /** 36 * @deprecated 37 * @see org.robolectric.shadows.ShadowLooper#idleMainLooper() 38 */ 39 @Deprecated 40 public static void idleMainLooper() { 41 ShadowLooper.idleMainLooper(); 42 } 43 44 /** 45 * @deprecated 46 * @see ShadowLooper#runUiThreadTasksIncludingDelayedTasks() 47 */ 48 @Deprecated 49 public static void runMainLooperToEndOfTasks() { 50 ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); 51 } 52 53 /** 54 * @deprecated 55 * @see ShadowLooper#runMainLooperOneTask() () 56 */ 57 @Deprecated 58 public static void runMainLooperOneTask() { 59 shadowOf(Looper.myLooper()).runOneTask(); 60 } 61 62 /** 63 * @deprecated 64 * @see ShadowLooper#runMainLooperToNextTask() () 65 */ 66 @Deprecated 67 public static void runMainLooperToNextTask() { 68 shadowOf(Looper.myLooper()).runToNextTask(); 69 } 70 } 71