/** * To get the string describing the TBody element. * * @return string describing the TBody element */ public String toString() { return super.toString() + ", title:" + title(); } }
/** * @see org.testatoo.core.Evaluator */ @Override public void mouseOver(Component component) { evaljQuery("$('#" + component.id() + "').simulate('mouseover')"); }
/** * Uses the matcher Disabled to know if a given component is disabled using the syntax "is(disabled())" or "is(not(disabled()))" * * @param component the graphic object * @return True if the component is disabled */ @Override public boolean matchesSafely(Component component) { return component.isDisabled(); }
@Test public void equality_is_on_the_id() { when(evaluator.existComponent("myId2")).thenReturn(true); Component component_1 = new Component(evaluator, id); Component component_2 = new Component(evaluator, "myId2"); Component component_3 = new Component(evaluator, id); assertThat(component_1, is(not(equalTo(component_2)))); assertThat(component_1, is(equalTo(component_3))); }
@Test public void component_enability() { when(evaluator.isEnabled(any(Component.class))).thenReturn(true, true, false, false); Component enabledComponent = new Component(evaluator, id); Component disabledComponent = new Component(evaluator, id); assertThat(enabledComponent.isEnabled(), is(true)); assertThat(enabledComponent.isDisabled(), is(false)); assertThat(disabledComponent.isDisabled(), is(true)); assertThat(disabledComponent.isEnabled(), is(false)); verify(evaluator, times(4)).isEnabled(any(Component.class)); }
/** * @see org.testatoo.core.Evaluator */ @Override public String label(LabelSupport labelSupport) { try { Component label = new Component(this, $("label[for=" + ((Component) labelSupport).id() + "]").id(this)); return nodeTextContent(label); } catch (ComponentException e) { try { Component label = new Component(this, $("$('#" + ((Component) labelSupport).id() + "').prev('label')").id(this)); return nodeTextContent(label); } catch (ComponentException ex) { try { Component label = new Component(this, $("$('#" + ((Component) labelSupport).id() + "').parent()").id(this)); return nodeTextContent(label); } catch (ComponentException exp) { return ""; } } } }
@Test public void test_toString() { when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.isVisible(any(Component.class))).thenReturn(false); Component component = new Component(evaluator, id); assertThat(component.toString(), is("class org.testatoo.core.component.Component with state : enabled:true, visible:false")); } }
@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)); }
/** * To know if the component is disabled * * @return True if the component is disabled */ public Boolean isDisabled() { return !isEnabled(); }
/** * 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(); }
/** * @see org.testatoo.core.Evaluator */ @Override public Boolean hasFocus(Component component) { return currentFocusedComponent != null && currentFocusedComponent.equals(component); }
public static Component disabledComponent() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(false); return new Component(evaluator, id); }
/** * Uses the matcher Enabled to know if a given component is enabled using the syntax "is(enabled())" or "is(not(enabled())" * * @param component the graphic object * @return True if the component is enabled */ @Override public boolean matchesSafely(Component component) { return component.isEnabled(); }
/** * To get the string describing the column group. * * @return string describing the column group */ public String toString() { return super.toString() + ", title:" + title(); } }
/** * @see org.testatoo.cartridge.html4.HtmlEvaluator */ @Override public String nodename(Component component) { return evaljQuery("$('#" + component.id() + "').prop('nodeName')"); }
public static Component visibleComponent() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); return new Component(evaluator, id); }
/** * To get the string describing the table header cell. * * @return string describing the table header cell */ public String toString() { return super.toString() + ", title:" + title(); } }