@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(); }
@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()); }