• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.os.Binder;
4 import android.os.IBinder;
5 import android.os.IInterface;
6 import android.os.RemoteCallbackList;
7 import org.junit.Test;
8 import org.junit.runner.RunWith;
9 
10 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
11 
12 import static org.hamcrest.CoreMatchers.sameInstance;
13 import static org.hamcrest.MatcherAssert.assertThat;
14 
15 @RunWith(WithTestDefaultsRunner.class)
16 public class RemoteCallbackListTest {
17     @Test
testBasicWiring()18     public void testBasicWiring() throws Exception {
19         RemoteCallbackList<Foo> fooRemoteCallbackList = new RemoteCallbackList<Foo>();
20         Foo callback = new Foo();
21         fooRemoteCallbackList.register(callback);
22 
23         fooRemoteCallbackList.beginBroadcast();
24 
25         assertThat(fooRemoteCallbackList.getBroadcastItem(0), sameInstance(callback));
26     }
27 
28     public static class Foo implements IInterface {
29 
30         @Override
asBinder()31         public IBinder asBinder() {
32             return new Binder();
33         }
34     }
35 }