/** * Uses the matcher Visible to know the visibility of a given component using the syntax "is(visible())" or "is(not(visible()))" * * @param component the graphic object * @return True if the component is visible */ @Override public boolean matchesSafely(Component component) { return component.isVisible(); }
/** * To get the string describing the component * * @return the string describing the component */ @Override public String toString() { return this.getClass().toString() + " with state : enabled:" + isEnabled() + ", visible:" + isVisible(); }
@Test public void component_visibility() { when(evaluator.isVisible(any(Component.class))).thenReturn(true, false); Component visibleComponent = new Component(evaluator, id); Component invisibleComponent = new Component(evaluator, id); assertThat(visibleComponent.isVisible(), is(true)); assertThat(invisibleComponent.isVisible(), is(false)); verify(evaluator, times(2)).isVisible(any(Component.class)); }