title: Test toast with robolectric
body: <p><code>onReceive</code> in my BroadcastReceiver is never call when execute tests with Robolectric.</p>
  
  <h2>Test</h2>
  
  <pre><code>@Test
  public void WhenSentNewMessageInAirplaneMode_ToastShouldBeDisplayed() {
      // Arrange
      ShadowSettings.setAirplaneMode(true);
      ImageButton sendBtn = (ImageButton)activity.findViewById(R.id.sendBtn);
      EditText messageEditText = (EditText)activity.findViewById(R.id.messageEditText);
      EditText recipientsEditText = (EditText)activity.findViewById(R.id.recipientsEditText);
  
      messageEditText.setText("&lt;a message&gt;");
      recipientsEditText.setText("&lt;a address&gt;");
  
      // Act
      sendBtn.performClick();
  
      // Assert
      assertEquals(Robolectric.application.getString(R.string.message_not_sent), ShadowToast.getTextOfLatestToast());  // --&gt; ShadowToast.getTextOfLatestToast() is always null
  }
  </code></pre>
  
  <h2>My activity</h2>
  
  <p><strong>OnCreate</strong>  </p>
  
  <pre><code>PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SmsMessageSender.SENT), PendingIntent.FLAG_UPDATE_CURRENT);
  </code></pre>
  
  <p><strong>Overrides</strong></p>
  
  <pre><code>@Override
  protected void onPause() {
      super.onPause();
      unregisterReceiver(smsSentReceiver);
  }
  
  @Override
  protected void onResume() {
      super.onResume(); // This call always
      smsSentReceiver = new BroadcastReceiver(){
          @Override
          public void onReceive(Context arg0, Intent arg1) {
              if (getResultCode() != Activity.RESULT_OK) {
                  Toast.makeText(getBaseContext(), getString(R.string.message_not_sent), Toast.LENGTH_LONG).show(); // On test this never call
              }
          }
      };
  
      registerReceiver(smsSentReceiver, new IntentFilter(SmsMessageSender.SENT));
  }
  </code></pre>
  
  <p><strong>On click send btn</strong></p>
  
  <pre><code>smsManager.sendMultipartTextMessage(recipient, null, messageParts,
                  new ArrayList&lt;&gt;(Arrays.asList(sentPI))
                  , null)
          );
  </code></pre>