1package com.xtremelabs.robolectric.shadows; 2 3import static org.junit.Assert.*; 4 5import com.xtremelabs.robolectric.WithTestDefaultsRunner; 6import org.junit.Before; 7import org.junit.Test; 8import org.junit.runner.RunWith; 9 10import android.os.Bundle; 11import android.os.Handler; 12import android.os.Message; 13import android.os.Messenger; 14 15import static com.xtremelabs.robolectric.Robolectric.shadowOf; 16 17@RunWith(WithTestDefaultsRunner.class) 18public class MessengerTest { 19 20 @Test 21 public void testMessengerSend() throws Exception { 22 Handler handler = new Handler(); 23 Messenger messenger = new Messenger(handler); 24 25 ShadowLooper.pauseMainLooper(); 26 Message msg = Message.obtain(null, 123); 27 messenger.send(msg); 28 29 assertTrue(handler.hasMessages(123)); 30 ShadowHandler.runMainLooperOneTask(); 31 assertFalse(handler.hasMessages(123)); 32 } 33} 34