コード例 #1
0
  @Test(expected = RuntimeException.class)
  public void checkedClick_shouldThrowIfViewIsNotVisible() throws Exception {
    ViewGroup grandParent = new LinearLayout(null);
    ViewGroup parent = new LinearLayout(null);
    grandParent.addView(parent);
    parent.addView(view);
    grandParent.setVisibility(View.GONE);

    shadowOf(view).checkedPerformClick();
  }
コード例 #2
0
  @Test
  public void shouldKnowIfThisOrAncestorsAreVisible() throws Exception {
    assertTrue(shadowOf(view).derivedIsVisible());

    ViewGroup grandParent = new LinearLayout(null);
    ViewGroup parent = new LinearLayout(null);
    grandParent.addView(parent);
    parent.addView(view);

    grandParent.setVisibility(View.GONE);

    assertFalse(shadowOf(view).derivedIsVisible());
  }