title: Android Testing Splash Screen
body: <p>So I have this Splash screen which is working well, but I would like to test "is the handler has lunched the next activity".
  class:</p>
  
  <pre><code>public class SplashActivity extends Activity {
  private final int SPLASH_DISPLAY_LENGTH = 3000;
  private TextView quote_text;
  
  private int[] quote_id = {R.string.quote_1, R.string.quote_2, R.string.quote_3, R.string.quote_4, R.string.quote_5};
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.splashscreen);
  
      quote_text = (TextView) findViewById(R.id.quote_text);
  
      int idx = new Random().nextInt(quote_id.length);
      int selectedID = (quote_id[idx]);
      quote_text.setText(getResources().getText(selectedID));
  
      new Handler().postDelayed(new Runnable() {
           @Override
           public void run() {
               Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
               SplashActivity.this.startActivity(mainIntent);
               SplashActivity.this.finish();
           }
       }, SPLASH_DISPLAY_LENGTH);
  }  }
  </code></pre>
  
  <p>Robolectric: 
  Test, which is fail at the<br>
  <strong>assertEquals(expectedIntent, shadowOf(activity).getNextStartedActivity());</strong></p>
  
  <pre><code>  @Test
      public void testNextActivityWasLaunchedWithIntent() {
          SplashActivity activity =        Robolectric.buildActivity(SplashActivity.class).create().start().resume().get();
        assertNotNull("MainActivity is not instantiated", activity);
  
      synchronized (this)
      {
          try {
              this.wait(3200);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  
      Intent expectedIntent = new Intent(activity, MainActivity.class);
      assertNotNull(expectedIntent);
  
      assertEquals(expectedIntent,shadowOf(activity).getNextStartedActivity());
  }
  </code></pre>
  
  <p>Can anyone tell me please, how can I test, is the handler fired my next activity ? 
  Thank you very much!</p>