@Test
 public void testPhotoListManagerDidFinish_withNoPhotos_ShowsToast() {
   List emptyFlickrPhotoList = new ArrayList<FlickrPhoto>();
   subject.photoListManagerDidFinish(emptyFlickrPhotoList);
   Toast actualToast = ShadowToast.getLatestToast();
   Assertions.assertThat(actualToast).isNotNull();
   String actualToastText = ShadowToast.getTextOfLatestToast();
   Assertions.assertThat(actualToastText).isEqualTo("Flickr api response malformed");
 }
  @Test
  public void testRefreshBluetooth() {
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);

    activity.findViewById(R.id.refresh_bluetooth).performClick();
    assertEquals(
        "Unexpected toast text",
        shadowActivity.getString(R.string.scan_for_devices),
        ShadowToast.getTextOfLatestToast());
  }
  @Test
  public void shouldValidateMovementDateOnSelectionAndShowToastIfInvalid()
      throws ParseException, LMISException {
    viewHolder.populate(viewModel, stockCard);

    StockMovementViewHolder.MovementDateListener movementDateListener =
        viewHolder.new MovementDateListener(viewModel, new Date());
    movementDateListener.onDateSet(mock(DatePicker.class), 2015, 11, 10);
    assertNotNull(ShadowToast.getLatestToast());
  }
  @Test
  public void testComposeEmailOnNoMailer() {
    String[] addresses = new String[] {"dummyEmail"};
    String subject = "subject";
    String text = "text";
    sut.composeEmail(addresses, subject, text);

    Toast expectedToast = ShadowToast.getLatestToast();
    Assert.assertNotNull(expectedToast);
  }
  @Test
  public void testBluetoothSelected_nochange() {
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    activity.selectedItemTV.setText("No Device Selected!");

    activity.findViewById(R.id.done_selecting).performClick();
    assertEquals(
        "Unexpected toast text",
        shadowActivity.getString(R.string.no_change_to_device),
        ShadowToast.getTextOfLatestToast());
    assertTrue("finish() was not called", shadowActivity.isFinishing());
  }
  @Test
  public void shouldValidateMovementDateOnSelectionAnd() throws ParseException, LMISException {
    viewHolder.populate(viewModel, stockCard);

    StockMovementViewHolder.MovementDateListener movementDateListener =
        viewHolder
        .new MovementDateListener(viewModel, DateUtil.parseString("11-11-2015", "MM-dd-YYYY"));
    movementDateListener.onDateSet(mock(DatePicker.class), 2015, 10, 15);
    assertEquals("15 Nov 2015", viewHolder.txMovementDate.getText().toString());
    assertEquals("15 Nov 2015", viewModel.getMovementDate());
    assertNull(ShadowToast.getLatestToast());
  }
  // Should pass
  @Test
  public void testButtonOneClick_shouldShowToast() {
    MainActivity activity = Robolectric.setupActivity(MainActivity.class);
    activity.findViewById(R.id.button_1).performClick();

    ShadowLooper.idleMainLooper();
    // Check toast correctness
    Assert.assertTrue(ShadowToast.getTextOfLatestToast().equals("Button #1 Clicked"));

    // Check textView text
    TextView textView = (TextView) activity.findViewById(R.id.test_text);
    Assert.assertTrue("Button 1 Clicked".equals(textView.getText()));
  }
 @Test
 public void testPhotoListManagerDidFinish_withPhotos_DoesNotShowToast() {
   subject.photoListManagerDidFinish(flickrPhotoList);
   Toast actualToast = ShadowToast.getLatestToast();
   Assertions.assertThat(actualToast).isNull();
 }