1package com.xtremelabs.robolectric.shadows; 2 3import android.os.Bundle; 4import android.os.Handler; 5import android.os.ResultReceiver; 6import com.xtremelabs.robolectric.WithTestDefaultsRunner; 7import org.junit.Test; 8import org.junit.runner.RunWith; 9 10import static org.junit.Assert.assertEquals; 11 12@RunWith(WithTestDefaultsRunner.class) 13public class ResultReceiverTest { 14 @Test 15 public void callingSend_shouldCallOverridenOnReceiveResultWithTheSameArguments() throws Exception { 16 TestResultReceiver testResultReceiver = new TestResultReceiver(null); 17 Bundle bundle = new Bundle(); 18 19 testResultReceiver.send(5, bundle); 20 assertEquals(5, testResultReceiver.resultCode); 21 assertEquals(bundle, testResultReceiver.resultData); 22 } 23 24 static class TestResultReceiver extends ResultReceiver { 25 int resultCode; 26 Bundle resultData; 27 28 public TestResultReceiver(Handler handler) { 29 super(handler); 30 } 31 32 @Override 33 protected void onReceiveResult(int resultCode, Bundle resultData) { 34 this.resultCode = resultCode; 35 this.resultData = resultData; 36 } 37 } 38} 39