コード例 #1
0
 @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");
 }
コード例 #2
0
  @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());
  }
コード例 #4
0
  @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);
  }
コード例 #5
0
  @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());
  }
コード例 #7
0
  // 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()));
  }
コード例 #8
0
 @Test
 public void testPhotoListManagerDidFinish_withPhotos_DoesNotShowToast() {
   subject.photoListManagerDidFinish(flickrPhotoList);
   Toast actualToast = ShadowToast.getLatestToast();
   Assertions.assertThat(actualToast).isNull();
 }