/** * To simulate a uncheck of the component * * @param <T> type of the component * @param component testatoo component * @return the unchecked component */ public static <T extends CheckBox> T unCheck(T component) { component.unCheck(); return component; }
/** * Class constructor specifying the evaluator to use and the id of the checkBox we want to test. * The checkBox allows the user to make multiple selections. * The constructor checks if the given id does correspond to a checkBox. * * @param evaluator a technology specific evaluator * @param id the id (unique) of the checkBox */ public CheckBox(Evaluator evaluator, String id) { super(evaluator, id); checkIsExpectedComponent(CheckBox); }
@Test public void can_check_and_modifiy_checkbox_state() { CheckBox checkBox = new CheckBox(evaluator, id); when(evaluator.isChecked(checkBox)).thenReturn(false, true, false); assertThat(checkBox.isChecked(), is(false)); checkBox.check(); assertThat(checkBox.isChecked(), is(true)); checkBox.unCheck(); assertThat(checkBox.isChecked(), is(false)); verify(evaluator, times(3)).isChecked(checkBox); verify(evaluator, times(1)).check(checkBox); verify(evaluator, times(1)).unCheck(checkBox); }
/** * @see org.testatoo.core.Evaluator */ @Override public void unCheck(org.testatoo.core.component.CheckBox checkbox) { if (checkbox.isChecked()) click(checkbox, Click.left); }
public static CheckBox checkBoxWithLabel(final String label) { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(CheckBox); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.isChecked(any(CheckBox.class))).thenReturn(true); when(evaluator.label(any(CheckBox.class))).thenReturn(label); return new CheckBox(evaluator, id); }
@Test public void test_toString() { CheckBox checkBox = new CheckBox(evaluator, id); when(evaluator.isChecked(checkBox)).thenReturn(false); when(evaluator.label(checkBox)).thenReturn("label"); assertThat(checkBox.toString(), is("class org.testatoo.core.component.CheckBox with state : enabled:true, visible:true, label:label, checked:false")); } }
public static CheckBox checkedCheckBox() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(CheckBox); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.label(any(CheckBox.class))).thenReturn("label"); when(evaluator.isChecked(any(CheckBox.class))).thenReturn(true); return new CheckBox(evaluator, id); }
public static CheckBox unCheckedCheckBox() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(CheckBox); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.label(any(CheckBox.class))).thenReturn("label"); when(evaluator.isChecked(any(CheckBox.class))).thenReturn(false); return new CheckBox(evaluator, id); }
public static CheckBox checkBoxWithoutLabel() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(CheckBox); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.isChecked(any(CheckBox.class))).thenReturn(true); when(evaluator.label(any(CheckBox.class))).thenReturn(""); return new CheckBox(evaluator, id); }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new CheckBox(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a CheckBox but a Radio")); } }
@Test public void checkbox_usage_through_language() { when(evaluator.componentType(id)).thenReturn(CheckBox); CheckBox checkBox = new CheckBox(evaluator, id); when(evaluator.isChecked(checkBox)).thenReturn(false, true, false); when(evaluator.label(checkBox)).thenReturn("myLabel"); assertThat(checkBox, is(not(checked()))); check(checkBox); assertThat(checkBox, is(checked())); unCheck(checkBox); assertThat(checkBox, is(not(checked()))); assertThat(checkBox, has(label("myLabel"))); verify(evaluator, times(1)).check(checkBox); verify(evaluator, times(1)).unCheck(checkBox); verify(evaluator, times(3)).isChecked(checkBox); }